Re: Passing data from a data collection window back to a main

2006-11-26 Thread [EMAIL PROTECTED]
This is my global variable version:

   #include gtk/gtk.h

   #include callbacks.h
   #include interface.h
   #include support.h

   GtkWidget *window2, *window1, *label1, *entry1;

   void
   on_button1_clicked (GtkButton   *button,
gpointer user_data)
   {
window1 = lookup_widget(button,window1);
window2=create_window2();
gtk_widget_show(window2);
gtk_grab_add(window2);
   }


   void
   on_button2_clicked (GtkButton   *button,
   gpointer user_data)
   {
label1 = lookup_widget(window1,label1);
entry1 = lookup_widget(window2,entry1); 
gtk_label_set_text(label1,gtk_entry_get_text(entry1));
gtk_grab_remove(window1);
gtk_widget_destroy(window2);
   }

Thanks,
Kim
 [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: 
 Hi,
 
 I am about to start a new app, and would like to improve my programming 
 style. I have been using global variables to pass data from popup windows 
 back to a main window. I have seen discussion about using g_object_set_data, 
 but have not progressed to being able to use it confidently. 
 
 Does anyone know of a simple example using g_object_set_data. The sort of 
 thing I am thinking about is a main window with a label and button, that pops 
 up a child window with an entry and a button. Clicking the child windows 
 button returns the string in the entry back to the main windows label.
 
 This sort of example would be very useful in the tutorial.
 
 Thanks,
 Kim
 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Passing data from a data collection window back to a main

2006-11-26 Thread Zeeshan Ali
Hi!
   The best and simplest way to get rid of global varriables would be
to define a structure that would contain all the data you need and
then you can keep passing it's pointer around in the callbacks using
the 'user_data' argument. If you want to use g_object_set/get_data()
instead, thats also possible and very easy (you don't even have to
define a new structure, since you can assign different string keys for
different kinds of data). IMHO, the g_object_set/get_data() API
reference (1) is good enough and there doesn't need to be an example
code for all possible scenerios in the tutorials/docs.

1. 
http://developer.gnome.org/doc/API/2.0/gobject/gobject-The-Base-Object-Type.html#g-object-set-data

On 11/26/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 This is my global variable version:

#include gtk/gtk.h

#include callbacks.h
#include interface.h
#include support.h

GtkWidget *window2, *window1, *label1, *entry1;

void
on_button1_clicked (GtkButton   *button,
 gpointer user_data)
{
 window1 = lookup_widget(button,window1);
 window2=create_window2();
 gtk_widget_show(window2);
 gtk_grab_add(window2);
}


void
on_button2_clicked (GtkButton   *button,
gpointer user_data)
{
 label1 = lookup_widget(window1,label1);
 entry1 = lookup_widget(window2,entry1);
 gtk_label_set_text(label1,gtk_entry_get_text(entry1));
 gtk_grab_remove(window1);
 gtk_widget_destroy(window2);
}

 Thanks,
 Kim
  [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
  Hi,
 
  I am about to start a new app, and would like to improve my programming 
  style. I have been using global variables to pass data from popup windows 
  back to a main window. I have seen discussion about using 
  g_object_set_data, but have not progressed to being able to use it 
  confidently.
 
  Does anyone know of a simple example using g_object_set_data. The sort of 
  thing I am thinking about is a main window with a label and button, that 
  pops up a child window with an entry and a button. Clicking the child 
  windows button returns the string in the entry back to the main windows 
  label.
 
  This sort of example would be very useful in the tutorial.
 
  Thanks,
  Kim
  ___
  gtk-app-devel-list mailing list
  gtk-app-devel-list@gnome.org
  http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



-- 
Regards,

Zeeshan Ali,
Software Design Engineer,
Open Source Software Operations,
Nokia,
Helsinki, Finland.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


sendfile through GIOChannel

2006-11-26 Thread Ruben Fonseca
Hi there!

I'm building a application which makes extensive use of GLib. Since it
is a network application, it uses sockets, so I decided to use the
GIOChannel to have a nice higher level on top of sockets. It is working
flawlessly. 

But I have a problem: my application requires the send of files through
the socket. The way I'm doing this right now is, read a fixed buffer
data from the file and write it to the GIOChannel. I know this to be
very inefficient. I'm copying data from the kernel space to the user
space, only to send it through kernel space again.

With raw sockets I could use the sendfile system call that allows me to
pass this job of transferring streams to the kernel. So my question is:
is it possible to use sendfile with GIOChannel? Is there any other
efficient alternative? Am I forced to use the read to buffer - write
to socket approach?

Thank you for your support.

Ruben

-- 
Ruben Fonseca [EMAIL PROTECTED]
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

g_signal_connect_swapped

2006-11-26 Thread Richard

Could someone explain the reason for this function

g_signal_connect_swapped

I have read the manual here:

http://www.gtk.org/tutorial/x159.html

where it says:

,
| g_signal_connect_swapped() is the same as g_signal_connect() except that
| the instance on which the signal is emitted and data will be swapped
| when calling the handler. So when using this function to connect
| signals, the callback should be of the form
| 
| 
| void callback_func( gpointer   callback_data,
| ... /* other signal arguments */
| GtkWidget *widget);
| 
| where the object is usually a widget.
`

Could anyone express this a little clearer? I (as a gtk beginner) can
see no reason for it.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: g_signal_connect_swapped

2006-11-26 Thread Paul Pogonyshev
Richard wrote:
 
 Could someone explain the reason for this function
 
 g_signal_connect_swapped

For instance, you can do

  g_signal_connect (widget, destroy, G_CALLBACK (null_pointer), pointer);

  ...

  void
  null_pointer (GtkObject* object, gpointer pointer)
  {
 *pointer = NULL;
  }

Or

  g_signal_connect_swapped (widget, destroy, G_CALLBACK (null_pointer), 
pointer);

  ...

  void
  null_pointer (gpointer pointer)
  {
 *pointer = NULL;
  }

Note the absence of unneeded argument in the second case.  This is not
very important when you write a function yourself, but can save you
from writing an adaptor in case of ready functions.  For instance,
imagine this:

  g_signal_connect_swapped (widget, destroy,
G_CALLBACK (gtk_widget_destroy), another_widget);

if you want `another_widget' leave no longer than `widget'.  Without
g_signal_connect_swapped(), you'd have to write a dummy function which
just rearranges its arguments and invokes gtk_widget_destroy().

Paul
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Drag_Drop to before the first row of Tree View (List Store)

2006-11-26 Thread Daniel Yek
Resending...Still hoping for a nice solution.

At 01:39 AM 11/22/2006, Daniel Yek wrote:
Hi,

I'm trying to handle Drag_Drop to before the first row and after the last 
row of a Tree View with a List Store.

In the drag_drop handler, I got a y-coordinate of between 0 and 25, 
corresponding to the column headers. The drop destination highlight was 
still turned on. When I called gtk_tree_view_get_dest_row_at_pos(), I got 
path == NULL.

Because path was NULL, I couldn't tell if this is before the first, or 
after the last -- both of them yield path == NULL.

I would like to find out the y-coordinates of where the column headers end 
and the first row starts. How do I do that?

I tried several approaches...still looking for a good solution.

If I can translate between the tree coordinates and the coordinates of the 
window containing column headers, my problem would be solved. How can I do 
that? Is there another easier way to do this?

Thanks.

--
Daniel Yek

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: g_signal_connect_swapped

2006-11-26 Thread Matt Hoosier
On 11/25/06, Richard [EMAIL PROTECTED] wrote:

 Could someone explain the reason for this function

 g_signal_connect_swapped

 I have read the manual here:

 http://www.gtk.org/tutorial/x159.html

 where it says:

 ,
 | g_signal_connect_swapped() is the same as g_signal_connect() except that
 | the instance on which the signal is emitted and data will be swapped
 | when calling the handler. So when using this function to connect
 | signals, the callback should be of the form
 |
 |
 | void callback_func( gpointer   callback_data,
 | ... /* other signal arguments */
 | GtkWidget *widget);
 |
 | where the object is usually a widget.
 `

 Could anyone express this a little clearer? I (as a gtk beginner) can
 see no reason for it.

This just means that the widget and callback_data pointers will be
pushed onto the call stack in the opposite order from their ordering
if hooked up with g_signal_connect(). If you're designing your own
callback function, this probably isn't useful; just use
g_signal_connnect() with a callback that has GObject* and gpointer
parameters [in that order].

 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: g_signal_connect_swapped

2006-11-26 Thread Lance Dillon


- Original Message 
From: Matt Hoosier [EMAIL PROTECTED]
To: Richard [EMAIL PROTECTED]
Cc: gtk-app-devel-list@gnome.org
Sent: Sunday, November 26, 2006 6:44:13 PM
Subject: Re: g_signal_connect_swapped

On 11/25/06, Richard [EMAIL PROTECTED] wrote:

 Could someone explain the reason for this function

 g_signal_connect_swapped

 I have read the manual here:

 http://www.gtk.org/tutorial/x159.html

 where it says:

 ,
 | g_signal_connect_swapped() is the same as g_signal_connect() except that
 | the instance on which the signal is emitted and data will be swapped
 | when calling the handler. So when using this function to connect
 | signals, the callback should be of the form
 |
 |
 | void callback_func( gpointer   callback_data,
 | ... /* other signal arguments */
 | GtkWidget *widget);
 |
 | where the object is usually a widget.
 `

 Could anyone express this a little clearer? I (as a gtk beginner) can
 see no reason for it.

This just means that the widget and callback_data pointers will be
pushed onto the call stack in the opposite order from their ordering
if hooked up with g_signal_connect(). If you're designing your own
callback function, this probably isn't useful; just use
g_signal_connnect() with a callback that has GObject* and gpointer
parameters [in that order].


-

I've used it for a couple of different things.  One, if you aren't concerned 
with the widget that it is concerning, then you can used _swapped() and have 
your user_data first, and not worry about where the widget is, somewhere at the 
end of the argument list.  Or another thing is with language bindings.  I'm 
writing the language binding for pike, and in the signal marshaller I'm taking 
the arguments and actually rearranging them kind of different, so that the pike 
funciton gets the widget, the user_data, then an array of the rest of the 
arguments.  This way the user can get the user_data at arg2, regardless of the 
number of other args there are.








___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Libglade application distribution how-to?

2006-11-26 Thread Fabricio Rocha
Dearest ones,

   I have a working set of .C and .H source files for my 
application, a bunch of Glade files and their icons in a subdirectory 
called pixmaps, and I can get all this stuff compiled and functional 
through Anjuta. Ok.

   But could you please point out a good tutorial of how to put all 
this stuff in a source tarball, so the application can be downloaded and 
tested by other people? I could not find anything like that with Google. 
I am sure I am NOT doing it right:

- There is all that EXTREMELY complicated stuff of autoconf, 
automake, makefiles, etc., first of all. Can I presume that just putting 
my Anjuta-generated Makefiles along with the sources in the tarball will 
work? Or what exactly must be done?

- Although Glade can see and draw the pixmaps in ./pixmaps 
when I edit the interface files, I found out (after a project directory 
change) that the pixmaps are not found in runtime. Maybe this is the 
reason I get those Failed to read a valid object file image from 
memory when running the app from GDB. How can one force libglade to 
find these pixmaps?

   - I have been using the config.h macro PACKAGE_SRC_DIR in the 
sources for loading the Glade files, but what will happen if someone 
wants to build a, for example, Debian binary package with the software? 
I suppose there will be no source directory in this case, so what 
would be the correct way of coding this libglade stuff?


Thank you all and best regards!

Fabricio Rocha
Brasilia, Brasil
The RADiola Project - http://radiola.sourceforge.net


___ 
Novidade no Yahoo! Mail: receba alertas de novas mensagens no seu celular. 
Registre seu aparelho agora! 
http://br.mobile.yahoo.com/mailalertas/ 
 

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


GtkTreeview

2006-11-26 Thread sunzysjzri
hi, 
a simple question, that which signal of GtkTreeView could i use to catch a 
mouse clicked event?

sun zhiyong
2006-11-27
[EMAIL PROTECTED]
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list