Problem grabbing motion-notify events.
Hello, I'm having a problem with grabbing motion-notify events when reparenting widgets. Reparenting appears to stop you from receiving all of the events. I have written the test application below to highlight the problem. The application reparents a handle box to a window and then reparents it back to the main application window. Heres how to use it... 1) Hold the left mouse button down over the handle box and move the cursor outside of the application boundary. You'll notice you'll receive motion-notify events, even if your not over the main application window. This is what I'm expecting. 2) Whilst still holding the left mouse button, click the right mouse button. This reparents the handle box to a newly created GTK_WINDOW_POPUP window. The newly created window should follow the mouse around. 3) Clicking the right mouse button again reparents the handle box back to the main application window. Move the cursor over the application window and you'll get motion-notify events, move it outside the application boundary like before and you'll not get any events? Can someone please give me a pointer as to why its not receiving events outside the main application boundary after its been reparented? Is it a bug? Its had me stumped all weekend. I need it to still pick up events even if its outside the windows (like step 1) Its worth noting that if you change the window style to a GTK_WINDOW_TOPLEVEL then you get similar problems for the newly created window (step 2). Many thanks #include gtk/gtk.h static gboolean reparented = FALSE; static GtkWidget* old_window = NULL; static GtkWidget* new_window; static GtkWidget* button = NULL; int events(GtkWidget* widget, GdkEvent* event, gpointer object) { switch(event-type) { case GDK_BUTTON_PRESS: { break; } case GDK_BUTTON_RELEASE: { GdkEventButton* eventbutton; eventbutton = (GdkEventButton*)event; if (eventbutton-button == 1 /* Left button. */) { GdkGrabStatus grabstatus; grabstatus = gdk_pointer_grab(widget-window, FALSE, GDK_BUTTON_RELEASE_MASK|GDK_POINTER_MOTION_MASK|GDK_POINTER_MOTION_HINT_MASK, NULL, NULL, GDK_CURRENT_TIME); gtk_grab_add(widget); } else if (eventbutton-button == 3 /* Right button. */) { if (!reparented) { /* Reparent the handle box to a floating window. */ /* If you now Right click it will be reparented back to the main window. */ gdk_pointer_ungrab(GDK_CURRENT_TIME); gtk_grab_remove(widget); new_window = gtk_window_new(GTK_WINDOW_POPUP); // GTK_WINDOW_TOPLEVEL gtk_container_remove(GTK_CONTAINER(old_window), button); gtk_container_add(GTK_CONTAINER(new_window), button); gtk_widget_show_all(new_window); /* Reaquire the grab as the widget-window will have changed. */ gdk_pointer_grab(widget-window, FALSE, GDK_BUTTON_RELEASE_MASK|GDK_POINTER_MOTION_MASK|GDK_POINTER_MOTION_HINT_MASK, 0, NULL, GDK_CURRENT_TIME); gtk_grab_add(widget); reparented = TRUE; /* Move the reparented window */ gtk_widget_set_uposition(new_window, (gint)eventbutton-x_root, (gint)eventbutton-y_root); while (gtk_events_pending()) gtk_main_iteration(); /* Process all events currently in the queue. */ } else { /* Reparent the handle box back to the maiun window. */ /* You only receive mouse events if over the main window */ gdk_pointer_ungrab(GDK_CURRENT_TIME); gtk_grab_remove(widget); widget-allocation.width = 50; widget-allocation.height = 50; gtk_container_remove(GTK_CONTAINER(new_window), button); gtk_container_add(GTK_CONTAINER(old_window), button); gtk_widget_show_all(button); gdk_pointer_grab(widget-window, FALSE, GDK_BUTTON_RELEASE_MASK|GDK_POINTER_MOTION_MASK|GDK_POINTER_MOTION_HINT_MASK, 0, NULL, GDK_CURRENT_TIME); gtk_grab_add(widget); gtk_widget_destroy(GTK_WIDGET(new_window)); new_window = NULL; reparented = FALSE; while (gtk_events_pending()) gtk_main_iteration(); /* Process all events currently in the queue. */ } } break; } case GDK_MOTION_NOTIFY: {
fill color in text entry box
Hi, Is there a way to fill/set background color in a gtk+ text entry box. Thanks ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
where to find a specific part of the gnome code?
Im at a point with my application where i exactly need the code for the function that runs when you have encrypted disks and start gnome. I mean the password request for the LUKS devices that pops up when gnome is starting on my ubuntu/dapper machine. i looked though the gnome cvs but thats way to much to handle. My goal: In my code i want to execute a cryptsetup shellcommand which gives you an password request after starting, i found the gnome_password_dialog, but this doesnt seem the right, because there is no user needed in my request. Just for testing I started coding a small gtk_dialog, but at the point where i have to pass the password to the cryptsetup command I am stuck, so I would like to take a look at the code from the gnome tree. thx for help ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: help me catch up on GTK gui tools
Brett Stottlemyer wrote: Tristan- Thanks for the heads up, glad to hear it. Will there be an announcement on this mailing list? Not that I've planned, we've been announcing snapshot releases on gnome-announce-list and [EMAIL PROTECTED] we will have an article in this month's journal for those interested though ;-) Cheers, -Tristan ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
GtkPrint PangoLayout extents
Hi, I am trying to use the new GtkPrint from GTK 2.10. I am creating a pango layout from the cairo reference, setting the font and text and calling pango_layout_get_pixel_extents. This seems to work well, except that the returned width seems to be about twice of what it is printed either on preview or in the output page in the printer. Is this correct or is there a better way to figure out the text extents when using Pango? Here's the exact code I am using: PangoLayout *layout = gtk_print_context_create_pango_layout (job-pc); PangoRectangle ink; PangoRectangle log; pango_layout_set_font_description (layout, current_font); pango_layout_set_text (layout, text, -1); pango_layout_context_changed (layout); pango_layout_get_pixel_extents (layout, ink, log); g_object_unref (layout); return ink.width; Francisco ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
resource sizes with gdk-pixbuf-csource
Hi, I'd like to use gdk-pixbuf-csource for the usual reasons (to eliminate runtime file access in an application). I've noticed that the C arrays created by this, even when compiled to object code, are much larger (at least for the PNG's I'm trying) than the original graphic file. For example, gdk-pixbuf-csource foo.png foo_png.c gcc `pkg-config --cflags gtk+-2.0` -c foo_png_harness.c The C file which actually gets compiled above does nothing more than add the right #include statements so that the right datatypes are declared, then directly include foo_png.c. The resulting file sizes are: foo.png: 7856 bytes foo_png_harness.o: 12993 I've fiddled around with different switches to gdk-pixbuf-csource, but nothing seem to crack this blowup ratio of about 5:3. Presumably the inlined resource is a little bigger because some preprocessing has been done to make the bytewise content of the array more palatable for use as a GdkPixbuf. Is this just the best I can get, or is there some more tricky way to make the tool just insert a bytewise copy of the image file, and let the pixbuf do all decoding at runtime? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: where to find a specific part of the gnome code?
rupert wrote: Im at a point with my application where i exactly need the code for the function that runs when you have encrypted disks and start gnome. I mean the password request for the LUKS devices that pops up when gnome is starting on my ubuntu/dapper machine. i looked though the gnome cvs but thats way to much to handle. My goal: In my code i want to execute a cryptsetup shellcommand which gives you an password request after starting, i found the gnome_password_dialog, but this doesnt seem the right, because there is no user needed in my request. Just for testing I started coding a small gtk_dialog, but at the point where i have to pass the password to the cryptsetup command I am stuck, so I would like to take a look at the code from the gnome tree. I dont think the component you speak of is really in gnome software... You can feed the password to cryptsetup using stdin, and you can also use a gtk/gnome dialog to do so, maybe the ubuntu folks wrote up something that does this ? Cheers, -Tristan ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: resource sizes with gdk-pixbuf-csource
On Mon, Aug 07, 2006 at 09:21:26AM -0500, Matt Hoosier wrote: Hi, I'd like to use gdk-pixbuf-csource for the usual reasons (to eliminate runtime file access in an application). [...] Is this just the best I can get, or is there some more tricky way to make the tool just insert a bytewise copy of the image file, and let the pixbuf do all decoding at runtime? Well, the PNG has quiote a few compression tricks which have to be undone when reading it (unless you can send it down to the X server as-is). So I'd guess that the bytewise copy of the image file, like what is in the program image is more like what csource does. When you read in the image, it will get expanded anyway. Regards -- tomás ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: resource sizes with gdk-pixbuf-csource
On 8/7/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On Mon, Aug 07, 2006 at 09:21:26AM -0500, Matt Hoosier wrote: Hi, I'd like to use gdk-pixbuf-csource for the usual reasons (to eliminate runtime file access in an application). [...] Is this just the best I can get, or is there some more tricky way to make the tool just insert a bytewise copy of the image file, and let the pixbuf do all decoding at runtime? Well, the PNG has quiote a few compression tricks which have to be undone when reading it (unless you can send it down to the X server as-is). So I'd guess that the bytewise copy of the image file, like what is in the program image is more like what csource does. When you read in the image, it will get expanded anyway. Yes, understood. It would be nice to avoid the expansion until actual use, so that the process's address space isn't inflated for images that are only occassionally used. There's also the consideration the the binary's disk footprint grows, which is significant when dealing with embedded apps. Regards -- tomás -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFE11AlBcgs9XrR2kYRAkW4AJ9KdaFWq4erHynGtLWSPOzEcXrOnwCeIVUF J1uyYJ1fXfBkfJ9hORT84nM= =qTjB -END PGP SIGNATURE- ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: resource sizes with gdk-pixbuf-csource
On Mon, Aug 07, 2006 at 09:46:43AM -0500, Matt Hoosier wrote: On 8/7/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On Mon, Aug 07, 2006 at 09:21:26AM -0500, Matt Hoosier wrote: [...] Yes, understood. It would be nice to avoid the expansion until actual use, so that the process's address space isn't inflated for images that are only occassionally used. Hmm. But when expanding, you'd end up with double (well 1 + 5/8) the inflation of address space, since you get to keep the compressed image around (of course, if it is cleverly done, the MM would know that the compressed part is read-only and thus discardable from physical memory). There's also the consideration the the binary's disk footprint grows, which is significant when dealing with embedded apps. Seems you'll have to do the png decoding yourself :-( regards -- tomás ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GTK for win32 cannot use stdio???
On Wed, 2006-08-02 at 10:48 +0800, u821417 wrote: I just download GTK for win32 , developing win32 GTK applications using VC++ GUI. But what i am wondering is ... many stdio functions cannot work??? (It's ok to compile , but no reaction for running!) Such like ... printf、file read/write doesn't work! Could someone give me a guide? I develop very little on the Windows platform, but I think I remember this one: Visual Studio sets up your app's build configoration tailored to the kind of app you tell it you want to make, and if you don't specify a console app, it doesn't link in the stdio lib. Now throw a pinch of salt on this advice because I haven't thought about it for a couple of years. // Wally -- Your eyes are weary from staring at the CRT. You feel sleepy. Notice how restful it is to watch the cursor blink. Close your eyes. The opinions stated above are yours. You cannot imagine why you ever felt otherwise. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: resource sizes with gdk-pixbuf-csource
On 8/7/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On Mon, Aug 07, 2006 at 09:46:43AM -0500, Matt Hoosier wrote: On 8/7/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On Mon, Aug 07, 2006 at 09:21:26AM -0500, Matt Hoosier wrote: [...] Yes, understood. It would be nice to avoid the expansion until actual use, so that the process's address space isn't inflated for images that are only occassionally used. Hmm. But when expanding, you'd end up with double (well 1 + 5/8) the inflation of address space, since you get to keep the compressed image around (of course, if it is cleverly done, the MM would know that the compressed part is read-only and thus discardable from physical memory). There's also the consideration the the binary's disk footprint grows, which is significant when dealing with embedded apps. Seems you'll have to do the png decoding yourself :-( Yes, I suspected this from the outset too. Thanks for the comments. regards -- tomás -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFE11jqBcgs9XrR2kYRAvmBAJ4jzNI9X4CDwAA0+nhisZXlJX9kCACdEuUk hlrcJtRwYKaBrioljJhUCn0= =uk8Q -END PGP SIGNATURE- ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GTK for win32 cannot use stdio???
I think I remember this one: Visual Studio sets up your app's build configoration tailored to the kind of app you tell it you want to make, and if you don't specify a console app, it doesn't link in the stdio lib. Now throw a pinch of salt on this advice because I haven't thought about it for a couple of years. A quite large pinch of salt indeed ;) Firstly, there is no separate stdio library. What you probably refer to is that if one marks an application as a GUI application in the linking phase, as opposed to console application, then its stdout and stderr by default don't go anywhere, not even if you start it from the command line. (It's just a flag in the .exe header, can be toggled even afterwards. It's not implemented by linking or not linking to some stdio lib.) You have to redirect stdout (and stderr) to a file or pipe if you want to see them. Yes, there is I/O redirection, quite like in Bourne-type shells, also in the Windows command interpreter. But unless the original poster can tell us what he actually means, I don't think just guessing here will help much. Anyway, in case somebody still wonders: There is absolutely no way I can think of that using GTK would affect an application's ability to use stdio. --tml ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Problem grabbing motion-notify events.
On Mon, 2006-08-07 at 08:06 +, [EMAIL PROTECTED] wrote: Hello, I'm having a problem with grabbing motion-notify events when reparenting widgets. Reparenting appears to stop you from receiving all of the events. I have written the test application below to highlight the problem. The application reparents a handle box to a window and then reparents it back to the main application window. I didn't reviewed the full source code but something that hit my eyes is your re-parenting code. You should not take a GtkWidget out of its container without holding a reference to it, as it can be destroyed when you do that. The steps for re-parenting a widget should be: g_object_ref() gtk_container_remove gtk_container_add g_object_unref() But better to try gtk_widget_reparent (). -- Iago Rubio ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: resource sizes with gdk-pixbuf-csource
On Mon, Aug 07, 2006 at 11:24:19AM -0500, Matt Hoosier wrote: On 8/7/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On Mon, Aug 07, 2006 at 09:46:43AM -0500, Matt Hoosier wrote: On 8/7/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: [...] Seems you'll have to do the png decoding yourself :-( Yes, I suspected this from the outset too. Thanks for the comments. Luckily, libpng seems to help you with that: http://www.libpng.org/pub/png/libpng-1.2.5-manual.html#section-5 HTH -- tomás ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: resource sizes with gdk-pixbuf-csource
On Mon, 7 Aug 2006, Matt Hoosier wrote: On 8/7/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Seems you'll have to do the png decoding yourself :-( Yes, I suspected this from the outset too. Thanks for the comments. You can try to store the png file in an array of chars, then feed the data in that array to a GdkPixbufLoader. Something like this: GdkPixbuf * get_my_pixbuf (void) { static const gchar data[] = { 0x89, 0x50, 0x4e, 0x47, /* ... the rest of the png file ... */ }; GdkPixbufLoader *loader; GdkPixbuf *pixbuf; loader = gdk_pixbuf_loader_new (); gdk_pixbuf_loader_write (loader, data, sizeof data, NULL); pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); g_object_unref (G_OBJECT (loader)); return pixbuf; } HTH JV ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: resource sizes with gdk-pixbuf-csource
On Mon, Aug 07, 2006 at 03:57:28PM -0400, John Vetterli wrote: On Mon, 7 Aug 2006, Matt Hoosier wrote: On 8/7/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Seems you'll have to do the png decoding yourself :-( Yes, I suspected this from the outset too. Thanks for the comments. You can try to store the png file in an array of chars, then feed the data in that array to a GdkPixbufLoader. Something like this: Thanks, that's even better than my half-baked attempts Regards -- tomas ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[no subject]
Hi all, I build firefox 1.5.0.3 over gtk+-2.10 with Directfb Backend. But getting crashed while running.. I found that its because of the function g_signal_emit. can anyone tell me what this does and where it is defined..? Thanks, Karunakaran A. _ Is your PC infected? Get a FREE online computer virus scan from McAfee® Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
definition of g_signal_emit
Hi all, I build firefox 1.5.0.3 over gtk+-2.10 with Directfb Backend. But getting crashed while running.. I found that it's because of the function g_signal_emit. can anyone tell me what this does and where it is defined..? Thanks, Karunakaran A. _ Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: Gtk2::ComboBox - setting value by string?
Matthew Braid wrote: Hi all, Running into a minor problem with Gtk2::ComboBox. I can set the current selected option by using an iter (or a string representation of the iter like 0) but I can't just set it to a string I know is in the list directly. As a workaround I've had to create a little helper function like: sub find_index { my ($model, $find) = @_; my $i = 0; while (1) { my $iter = $model-get_iter_from_string($i); last if not defined $iter; return $i if $find eq $model-get($iter, 0); ++$i; } return undef; } (where $model is the combobox's model from $cb-get_model). Is this sort of thing necessary or is there a way to set a combobox's value by string rather than by index? Yes it's required: http://bugzilla.gnome.org/show_bug.cgi?id=149248 While you're at it, write yourself another little function to call your other little function ( above ) when the focus leaves the Combo's entry, because Combo's don't automatically detect if someone types a string into their entry that matches an item in their model ( ie the correct iter is only set as 'active' if you use the *mouse* to select an item ... any keyboard input is ignored ! ): http://bugzilla.gnome.org/show_bug.cgi?id=156017 And look out if you try to get a value out of a CellRendererCombo in a TreeView: http://bugzilla.gnome.org/show_bug.cgi?id=317387 IMHO there are *far* too many combo-related bugs in gtk+ :( Don't the developers use combos? -- Daniel Kasak IT Developer NUS Consulting Group Level 5, 77 Pacific Highway North Sydney, NSW, Australia 2060 T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989 email: [EMAIL PROTECTED] website: http://www.nusconsulting.com.au ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list