Re: multithreaded gtk app
On Wed, 2010-01-20 at 17:05 +0100, Manu TM wrote: gdk_threads_leave; Just in case you posted actual code snippets, not mangled code: the quoted line (repeated in the else branch) is not a function call, and you'll probably get some problems from keeping the lock. ___ 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 catch window manager close
On Fri, 2010-01-08 at 10:43 -0500, Chris Bare wrote: Can anyone point me to a tutorial or something on how to catch the window manager close in GTK? I'm creating an app with glade, and I've got a GtkAboutDialog. my About menu item's activate singal calls gtk_widget_show which works as expected. I've attached gtk_widget hide to the about dialog's close, response and destroy signal. The close button works fine, but if you close it with the window manager, there's apparently some default callback that actually destroys the window, so the next time I select About from the menu I get the following error: (spiral:9162): GLib-GObject-WARNING **: invalid unclassed pointer in cast to `GtkAboutDialog' I want to be able to catch the close even and just hide the window. In general, you should connect to the delete-event signal to catch the user closing a window via the window manager. However, for dialogs, this should be unnecessary. The dialog should be handling things itself, if you run it. An example from my own project, in Python, but should be easy to understand for other bindings: def on_about_menuitem_activate(self, *args): w = self.widgets['aboutdialog'] w.set_version(dimbola.version) w.show() w.run() w.hide() While the run() method is being called, the program processes events in the event loop normally. When the dialog is closed, the call to run() finishes. gtk_dialog_run is probably the C name of the function. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Addind 2 Widget in 1 Container....
On Tue, 2009-12-15 at 13:50 +0100, Thibault Duponchelle wrote: So I simply search for a solution to contain a pixmap AND a drawarea . Use GtkBox is impossible because the pixmap must be in background and the drawarea center ON it. Could you use only a GtkDrawingArea widget in the container and draw the pixmap on the drawing area? ___ 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 create a thumbnail of a picture?
On Fri, 2009-12-11 at 17:50 +0800, Jianchun Zhou wrote: Hi, All: Any body knows how to create a thumbnail of a picture in GTK+? I want to load an image, then output a file which is the resized image. The GdkPixbuf object is probably what you want. See http://library.gnome.org/devel/gdk-pixbuf/stable/gdk-pixbuf-file-loading.html http://library.gnome.org/devel/gdk-pixbuf/stable/gdk-pixbuf-file-saving.html http://library.gnome.org/devel/gdk-pixbuf/stable/ http://library.gnome.org/devel/gdk-pixbuf/stable/GdkPixbufLoader.html ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Crash processing g_object_new arguments
On Mon, 2009-11-09 at 09:32 +0100, Nicola Fontana wrote: Change 0 to NULL: on 64 bit platforms 0 != NULL, hence the property list is not terminated. Even better, in C, is to use (void *)0 or (void *)NULL, since in C it is acceptable for NULL to be #defined as 0, even though that tends to make people angry when they encounter situations like this. (I don't know enough C++ to say what the situation is there.) ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: PYGTK: How can one add an argument to a callback?
On Tue, 2009-11-03 at 09:46 -0800, Daniel B. Thurman wrote: For example, I want to do the following: tvc.set_cell_data_func(cp, self.on_file_pixbuf1(t)) where 't' is another argument I wish to pass in addition to that provided by the cell so that the method results as: def on_file_pixbuf1(self, column, cell, model, iter, t): code You can create a new function: t = something def helper(column, cell, model, iter): self.on_file_pixbuf1(column, cell, model, iter, t) tvc.set_cell_data_func(cp, helper) (Untested code, but you should get the idea.) ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Loading treestore after gtk.main()?
ke, 2009-10-28 kello 16:55 -0700, Daniel B. Thurman kirjoitti: How is it possible to bring up the gtk window first, before loading your treestore, which might take a long time? I am not sure from your problem description which aspect is most troublesome for you, so I'll answer both I can think of. First, if it is going to take a long time, how are you intending to do it without the user interface freezing? There are two common approaches: either background threads or idle handlers. With background threds you start a new thread, it does whatever it needs to collect the data and add it to the treestore. This brings on all the problems of thread programming: you'll need to handle locking carefully, crashes are possibly inevitable and certainly mysterious, etc. In the idle handler case you register a callback with g_idle_add. The main loop calls the handler whenever it doesn't have anything better to do. The handler needs to do a little bit of work at a time, and then return; otherwise it freezes the main loop until it is done. In other words, the handler does not run in its own thread. The benefit is avoidance of threading related complexity, and the drawback is that it'll be slower. Second, to trigger threads or register idle handlers, you may be able to do this before calling gtk_main, or you can connect to the main window's map-event signal and trigger things from there. ___ 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 remove MenuItem from Menu?
ke, 2009-10-21 kello 23:11 +0200, Peter Daum kirjoitti: There are several functions to dynamically change/reorder menus, but I couldn't find or figure out a way how to remove a certain item from a Menu. Is this possible? How? (I tried some strange things like calling item-destroy and was not surprised that it didn't work ...) This should work (I do something similar for menu items added/removed by plugins when they are enabled/disabled): * when you create and add the menu item, keep a reference to it * when you remove it, call the function to remove a child from the container; with the Python binding's it's just the .remove(menuitem) method, but in C I guess it's gtk_container_remove. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: gtk.TreeView.set_model(TreeStore) expanders do not seem to work?
la, 2009-10-17 kello 17:16 -0700, Daniel B. Thurman kirjoitti: In my application, I am populating a treestore with new children, I then use the following method: self.treeview.set_mode(treestore) Apparently the treeview does not show expanders where there are new children. Is there something I need to do to show the expanders? You should only need to add children to the model. Perhaps there's some unrelated problem. Could you distill the program to be as small as possible while still showing the problem? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: gtk.TreeView.set_model(TreeStore) expanders do not seem to work?
su, 2009-10-18 kello 10:16 -0700, Daniel B. Thurman kirjoitti: If you wish to see the entire code, see the attachment below, Attachments don't seem to get through the list (at least not .zips). I got it from the direct e-mail you sent, though. (Might be worthwhile to attach it without zipping, or inline in the e-mail rather than as an attachment.) The program is over two hundred lines long. Could you make a smaller version that still shows the problem? This would have two benefits: it's less code to read for those trying to help, and might help you realize what the problem is yourself. treeview.set_model(ts) # == Expanders do not work for new children! You shouldn't need to set the model more than once. Just changing the model in place should result in the view updating itself. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Has anyone been able to force TreeView expander with no children?
ke, 2009-10-14 kello 18:52 -0700, Daniel B. Thurman kirjoitti: I have a FileViewer application that I am working on and so far I have not been able to force expanders on TreeView when there are only top-level directories/files populated in the TreeStore. As I understand it, the expander will only be shown for tree rows that have children. You want to show them always, so that you don't have to scan an entire directory tree to figure out which have children and which don't. Would one of the following approaches work for you? a) Add dummy items to nodes. When a node is expanded, and it has a dummy node, scan for subdirectories and replace the dummy node with real ones. This means even nodes without subdirectories will have an expander, which might be awkward for the user. b) Initially, add top level items and their immediate subdirectories. When a node is expanded the first time, scan its subdirectories' subdirectories and add those. That was confusing, let me show an example. Initially, have this ( means closed expander, v means open): aaa bbb ccc Here, you've scanned aaa and bbb and ccc for subdirectories. You know ccc doesn't have any, so it gets no children and no expander. aaa and bbb have children, so they get them and expanders. When aaa is expanded the first time, you scan aaa/* for subdirectories, and add them to their parent nodes (i.e., to children of aaa), before letting the aaa node be expanded on screen. In other words: v aaa aaa-1 aaa-2 aaa-3 bbb ccc Here, you scanned aaa-1, aaa-2, and aaa-3 for children, and found that aaa-2 has them. You can use a hidden column to keep track of which nodes have been expanded (= scanned). c) Do the scan in the background, modifying the tree when you find things. You can either let the scan go through the entire filesystem this way, or scan directories that are shown (a bit like in option b, but scanning is done in the background, not just when the node is about to be expanded). ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Has anyone been able to force TreeView expander with no children?
to, 2009-10-15 kello 07:44 -0700, Daniel B. Thurman kirjoitti: (1) I am trying to find the expander-open event for the connect method. I think it is something like: http://library.gnome.org/devel/gtk/stable/ has a list of all widgets, and lists for each widgets the signals they support. The page for each widget only lists the signals native to it, not the ones it inherits from its parent. I have not tried this, but this seems relevant to you: http://library.gnome.org/devel/gtk/stable/GtkTreeView.html#GtkTreeView-expand-collapse-cursor-row (2) I note that for some reason when I open an expander, the the icon/text next gets right justified. I am not sure what would happen to that, but my first guess is that you have one column for the expander, but no value to put in its cell, and another column for the folder name. If you remove the first column and mark the folder name column as the expander column (see link below), it might fix things. http://library.gnome.org/devel/gtk/stable/GtkTreeView.html#gtk-tree-view-set-expander-column ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list