Re: is there a memory leak problem with gtk_widget_queue_draw()?
Does the profiler report the problem is inside gtk_widget_queue_draw code? Actually, Glib's memory profiling does not show the exact place where memory leak occurs, it just shows how much memory allocated. it is not as comprehensive as Valgrind. May be it is better to check with Valgrind, with a simple test application whether gtk_widget_queue_draw() causes such a problem or not as Jim suggested. I will check and inform. thanks, Onur Fernando Apesteguía wrote: On 9/6/07, okty [EMAIL PROTECTED] wrote: Hi, I am using GLib's memory profiling to check memory usage of my program. I noticed that for each refresh in my screen with gtk_widget_queue_draw(), I am checking my allocated memory and each refresh increases the size of allocated memory. Do you know any memory leak problem in gtk_widget_queue_draw()? I've never used Glib's memory profiling, but sometimes other programs like Valgrind (you could use this as well) report false positives in memory leaks. It has something to do with the way the memory is allocated (GAllocator is specially confusing for profilers) Does the profiler report the problem is inside gtk_widget_queue_draw code? Cheers Regards, -- View this message in context: http://www.nabble.com/is-there-a-memory-leak-problem-with-gtk_widget_queue_draw%28%29--tf4392383.html#a12523308 Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com. ___ 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 -- View this message in context: http://www.nabble.com/is-there-a-memory-leak-problem-with-gtk_widget_queue_draw%28%29--tf4392383.html#a12563182 Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: How to convert a jpg image to a GtkImage ?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 David Nečas (Yeti) wrote: On Fri, Aug 31, 2007 at 02:11:15PM -0700, Mike Melanson wrote: I have an application, that amoung other things, is receiving a jpg file from a network connection. Once that file is in memory (it's relatively small), I wish to load it into a GtkImage (so that I can display it, e.g. by adding the GtkImage to a vbox, or something like that). ... My first impulse is that you will need to drag libjpeg into this (pretty standard everywhere) and delegate image decoding over to that module. Then create a new image in memory with gdk_image_new() and copy the decoded RGB data over. No, explicit use of libjpeg is not necessary. Create a GdkPixbufLoader, feed the in-memory image date to it with gdk_pixbuf_loader_write() and if everything is all right fetch the GdkPixbuf from it. Then construct the GtkImage with gtk_image_new_from_pixbuf(). This works fine, but now I have a concern as regards to memory leak. Here is the scenerio I have. I have a gtk application that, amoung other things is receiving packets from a server. Sometimes those packets will contain a url to a jpg, which I them fetch, and then need to display. Essentially, once the jpg image is fetched, I do: my_loader = gdk_pixbuf_loader_new(); rv = gdk_pixbuf_loader_write(my_loader, jpg_image, jpg_image_size, 0); if (!rv) { /* loading jpg image failed */ return NULL; } rv = gdk_pixbuf_loader_close(my_loader, 0); if (!rv) { /* closing jpg image loader failed */ return NULL; } jpg_pixbuf = gdk_pixbuf_loader_get_pixbuf(my_loader); image = gtk_image_new_from_pixbuf(jpg_pixbuf); And then I add the image to a display widget via: gtk_box_pack_start(GTK_BOX(vbox), image, TRUE, TRUE, 4); I have run the application under valgrind, and valgrind is detecting a number of leaks relating specifically to the gdk_pixbuf_loader_write's allocation of various memory structures. I should hasten to add that when I run valgrind, I pass the flags: G_DEBUG=gc-friendly G_SLICE=always-malloc to lessen false positives. The reason for new'ing a new loader each time is that, from the documentation, it appears that once I loader_close(), I can no longer write to the loader, and it is not clear that I can do sequential loader writes's followed by loader_get_pixbuf's, thereby reusing the same (original) loader. I also am not seeing a convenient way to destroy the loader. (it does happen to have a finalize routine, but I'm not sure how to invoke it :) I'm looking for thoughts as to: destroying the loader, so that it will free up all of it's internal memory (the close doesn't free up all of the interally allocated memory!) or reusing the loader (if possible). many thanks in advance, - -Greg Hosler Yeti -- http://gwyddion.net/ ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list - -- +-+ Please also check the log file at /dev/null for additional information. (from /var/log/Xorg.setup.log) | Greg Hosler [EMAIL PROTECTED]| +-+ -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFG48so404fl/0CV/QRAkwuAJ47exv2lic1LHSWi85jxXOxU+ycJACglTxm 2elUbrCyGumYFV55QKPw8Jc= =MgFV -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: How to convert a jpg image to a GtkImage ?
On Sun, Sep 09, 2007 at 06:30:02PM +0800, Gregory Hosler wrote: This works fine, but now I have a concern as regards to memory leak. ... The reason for new'ing a new loader each time is that, from the documentation, it appears that once I loader_close(), I can no longer write to the loader, and it is not clear that I can do sequential loader writes's followed by loader_get_pixbuf's, thereby reusing the same (original) loader. I also am not seeing a convenient way to destroy the loader. (it does happen to have a finalize routine, but I'm not sure how to invoke it :) GdkPixbufLoader is a GObject, you get rid of it as of anything else: by releasing the last reference with g_object_unref(). reusing the loader (if possible). This is not possible (the loader is tied to its pixbuf). Yeti -- http://gwyddion.net/ ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Building menus with UIManager
Hi, I'm trying to port a hard coded gtk menu to the new UIManager and GTK_Actions approach. The code is written in ada but I'm using the c docs to get the ideas and than I try to write the ada code. After googleing around I found enough docs to get the basic menu up and running. But there are two questions remaining. 1) Is there a possibility to determine where an action was triggered? Simple example: I want to provide an openfile action and I have two different kind of windows (A and B). Each window type is able to open a file but the file types are different (a and b). The easy way is to add an openfilea and openfileb action but this allows the user to add the wrong action (openfileb) to the Window of type A. Therefor I would like to determine the path of the widget (eg. /menubarA or /menubarB). 2.) How to realize a recent file submenu? What is the best and easiest way to realize a recent file submenu? I've added an empty menu in the xml and unset the hide_if_empty property of the action. I've noticed that the activate action is triggered while the submenu opens. Do I have to merge new menu items in the callback routine? But then I've to determine where the action was triggered since the position of the recent file menu can change. Thanks in advance Bernhard ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Panel Applets and PANEL_APPLET_HAS_HANDLE
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello In my panel applet, I have an option to toggle PANEL_APPLET_HAS_HANDLE flag on the fly (in preferences window). Unfortunately, if handle is visible and user wants co hide it, it does not hide. It is still visible, but does not work (ie. I can't move panel with it). The only way I found is to toggle PANEL_APPLET_EXPAND_MAJOR flag at the same time. Is it a bug in panels, or am I doing something wrong? - -- Semper Fidelis Adam Klobukowski [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFG49yUVVIYOc5drI0RAm9GAJ4+38ZScK8eU3G064CRGfAsYCL7LwCfU8Sy 1CMsqg/ykYpXb1WYq13sqLw= =Utnu -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: Building menus with UIManager
On Sun, 2007-09-09 at 13:05 +0200, Bernhard Berger wrote: 2.) How to realize a recent file submenu? What is the best and easiest way to realize a recent file submenu? I've added an empty menu in the xml and unset the hide_if_empty property of the action. I've noticed that the activate action is triggered while the submenu opens. Do I have to merge new menu items in the callback routine? But then I've to determine where the action was triggered since the position of the recent file menu can change. there's a C example of that here: http://www.gnome.org/~ebassi/recent-uimanager-inline.c for both sub-menu and inline recent files list, using GtkUIManager and a custom action. with the next stable release of GTK+ there'll be a GtkRecentAction available which will make the code far easier to write. ciao, Emmanuele. -- Emmanuele Bassi, W: http://www.emmanuelebassi.net B: http://log.emmanuelebassi.net ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Custom cel renderer
Hi, On Fri, Sep 07, 2007 at 05:33:37PM +0530, amol wrote: What i am trying is to implement 'cell_class-render' and in it try to draw this widget on parent GdkWindow through gdk_draw_drawable() but i am not able to get GdkDrawable (GdkWindow) of widget(i.e of button) to draw it on destination GdkWindow. GtkButton is a no-window widget (together with a lot of other widgets), which means that it draws directly on the parent widget's window. It does not create a window itself to draw on. Is there any way to draw this widget on parent GdkWindow or is there any other way to display widgets with cellrenderer? Are there any guidelines to write custom cellrenderer which will display any GtkWidget? There isn't any cell renderer that displays GtkWidgets. If at all possible, it will be hard to get right -- keep in mind that widgets and cell renderers are very different. For example: the same cell renderer is used to render content for every row, how would your cell renderer deal with this? Even if you get the cell renderer to draw the widget, it won't be able to do much because cell renderers do not receive GdkEvents. You are probably much better off to mimic a widget in a cell renderer by drawing it yourself. For example GtkCellRendererProgress is drawing the progress bars in exactly the same style as the GtkProgressBar widget by using the gtk_paint_*() calls. You can draw a button by using the same set of gtk_paint_*() calls as GtkButton does. regards, -kris. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Using GtkFileChooserWidget
Hi, I'll just reply to my own post with an example on how to reproduce the error-dump. This is no pretty program which simply either inserts or removes the same widget every other time the window close widget is clicked - just to keep it brief. Who might I contact regarding this issue?? GtkWidget *window; GtkWidget *file_widget; gboolean delete_event(GtkWidget *widget, GdkEvent *event, WindowThread *_this) { if(GtkWidget *sub = gtk_bin_get_child(GTK_BIN(window))) gtk_container_remove(GTK_CONTAINER(window), sub); else gtk_container_add(GTK_CONTAINER(window), file_widget); return TRUE; } int main() { window = gtk_window_new(GTK_WINDOW_TOPLEVEL); file_widget = gtk_file_chooser_widget_new(GTK_FILE_CHOOSER_ACTION_SAVE); g_object_ref(file_widget); g_signal_connect(G_OBJECT(window), delete_event, G_CALLBACK(delete_event), 0); gtk_container_add(GTK_CONTAINER(window), file_widget); gtk_widget_show_all(window); gtk_main(); return 0; } br - N :o) Nikolaj Thygesen wrote: Hi list, I wonder if anyone here has ever used the GtkFileChooserWidget directly?? When I create the widget and add it to a window everything goes ok - but if I close the window (I did add an extra g_object_ref(widget); to the widget keeping it alive) and open a new window adding the same widget to it - or - alternatively remove the GtkFileChooserWidget from the window and re-adds the very same widget then I get errors like: (DiamondBOX:18575): Gtk-CRITICAL **: gtk_tree_model_get_iter: assertion `path != NULL' failed (DiamondBOX:18575): Gtk-CRITICAL **: gtk_list_store_set_valist: assertion `VALID_ITER (iter, list_store)' failed (DiamondBOX:18575): Gtk-CRITICAL **: gtk_tree_model_get_iter: assertion `path != NULL' failed (DiamondBOX:18575): Gtk-CRITICAL **: gtk_list_store_set_valist: assertion `VALID_ITER (iter, list_store)' failed (DiamondBOX:18575): Gtk-CRITICAL **: gtk_tree_model_get_iter: assertion `path != NULL' failed (DiamondBOX:18575): Gtk-CRITICAL **: gtk_list_store_set_valist: assertion `VALID_ITER (iter, list_store)' failed when displaying the window. Is this expected behaviour or a bug??? Perhaps I could do something to prepare the widget for the later re-appearance?? best regards - Nikolaj Thygesen ___ 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
gtk pango draw rotated text
Hi, I want to draw some rotated text on a Window. I've tried every code I found on the net but still no solution :( I would like to draw some rotated text on a window, the rotation point should X,Y and not to the center of the rectangle where the text is draw. Can anyone please help me? This is my current code (in pascal): WidgetCont := pango_layout_get_context(UseFont); rotated_matrix.xx := 1.0; rotated_matrix.xy := 0.0; rotated_matrix.yx := 0.0; rotated_matrix.yy := 1.0; rotated_matrix.x0 := 0.0; rotated_matrix.y0 := 0.0; pango_matrix_rotate (@rotated_matrix, 45); pango_context_set_matrix (WidgetCont, @rotated_matrix); pango_layout_context_changed (UseFont); gdk_draw_layout_with_colors(DevCtx.drawable, DevCtx.GC, X, Y, UseFont, Foreground, nil); Thanks in advance. Luis ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: gtk pango draw rotated text
Take a look at the excellent example in the program 'gtk-demo', which should be installed on your system already. Try '# gtk-demo', then choose the 'rotated text' example. Note: double-clinking the choice launches the example, also notice the two tabs - one show description, one show the actual code. James, On Mon, 2007-09-10 at 00:33 +0100, Luis Rodrigues wrote: Hi, I want to draw some rotated text on a Window. I've tried every code I found on the net but still no solution :( I would like to draw some rotated text on a window, the rotation point should X,Y and not to the center of the rectangle where the text is draw. Can anyone please help me? This is my current code (in pascal): WidgetCont := pango_layout_get_context(UseFont); rotated_matrix.xx := 1.0; rotated_matrix.xy := 0.0; rotated_matrix.yx := 0.0; rotated_matrix.yy := 1.0; rotated_matrix.x0 := 0.0; rotated_matrix.y0 := 0.0; pango_matrix_rotate (@rotated_matrix, 45); pango_context_set_matrix (WidgetCont, @rotated_matrix); pango_layout_context_changed (UseFont); gdk_draw_layout_with_colors(DevCtx.drawable, DevCtx.GC, X, Y, UseFont, Foreground, nil); Thanks in advance. Luis ___ 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: GTK drawing area cannot get keyboard events
On Sat, Sep 08, 2007 at 02:21:11PM -0700, Tom Trebisky wrote: I have spent a couple of half-days trying to get keyboard events from a GTK drawing area with no luck, gtk_widget_add_events ( GTK_WIDGET(da), GDK_FOCUS_CHANGE ); On Sat, Sep 08, 2007 at 11:51:38PM +0200, David Ne?as (Yeti) wrote: And this is the bug. GDK_FOCUS_CHANGE is not an event mask (i.e. GdkEventMask value), it's an event type (i.e. GdkEventType valye). It should be GDK_FOCUS_CHANGE_MASK. Thank you Yeti, for your help. Perhaps apart from commenting on the problem and code that follows, you might direct me to the best resources on understanding GTK in its current form. In an attempt to get up to date with GTK, I am busy reading various documents at http://library.gnome.org/devel/gtk/unstable/index.html but perhaps you have better suggestions. In fact, perhaps there is a better approach than using a GTK Drawing Area to do what I do. I really just need a canvas within which to tile a bunch of JPG images (that comprise a topographic map). Here is what I am doing: 1) I use GdkPixbufLoader to read files and put the images into pixbufs. 2) The pixbufs are then tiled into pixmaps. 3) A selected pixmap gets copied into the drawing area on an expose event. All this works really well, but now I am frustrated adding new functionality to the application. All that aside, here is where I am with regard to getting keyboard events from a drawing area in my application; I get: GLib-GObject-WARNING **: gsignal.c:1669: signal `focus_event' is invalid for instance `0x684110' The relevant code now looks like: mw = gtk_window_new ( GTK_WINDOW_TOPLEVEL ); g_signal_connect ( mw, delete_event, G_CALLBACK(destroy_handler), NULL ); da = gtk_drawing_area_new (); g_signal_connect ( da, expose_event, G_CALLBACK(expose_handler), NULL ); g_signal_connect ( da, configure_event, G_CALLBACK(configure_handler), NULL ); g_signal_connect ( da, button_release_event, G_CALLBACK(mouse_handler), NULL ); gtk_widget_add_events ( GTK_WIDGET(da), GDK_BUTTON_RELEASE_MASK ); gtk_widget_add_events ( GTK_WIDGET(da), GDK_BUTTON_PRESS_MASK ); /* Now, try to work the magic to get keyboard events */ GTK_WIDGET_SET_FLAGS ( da, GTK_CAN_FOCUS ); gtk_widget_add_events ( GTK_WIDGET(da), GDK_FOCUS_CHANGE_MASK ); g_signal_connect ( da, focus_event, G_CALLBACK(focus_handler), NULL ); gtk_widget_add_events ( GTK_WIDGET(da), GDK_KEY_PRESS_MASK ); g_signal_connect ( da, key_press_event, G _CALLBACK(keyboard_handler), NULL ); ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GTK drawing area cannot get keyboard events
g_signal_connect ( da, focus_event, I change this to a pair of connects to focus_in_event and focus_out_event and Voila! I am getting keyboard events (not focus events mind you, but I am OK with not getting those at this point). My previous high level questions about overall strategy in using the gtk drawing area for this project, as well as where to find the best documentation still stand. It would seem that the best resource is the GTK+ website at www.gtk.org . Thanks to you all for your help and patience. Tom -- Tom Trebisky MMT Observatory University of Arizona -- Tucson [EMAIL PROTECTED] ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Start editing a GtkCellRendererText using F2
Hi I have a GtkTreeView and one of the columns is an editable GtkCellRendererText. I would like to have the F2 key edit the cell, just as clicking on it does, but I can't figure out how. I can do gtk_accelerator_parse()/g_cclosure_new()/gtk_accel_group_connect() to have a callback called when F2 is pressed but I've no idea how to tell the callback to edit the selected cell. Is this doable? Thanks in advance, Andrew ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list