Re: Question on gtk_label_set_selectable
On Fri, Oct 19, 2007 at 03:06:55PM +0200, Gian Mario Tagliaretti wrote: You can also set the can-focus property to FALSE on the label which will be still selectable. Not exactly. It will be only selectable *with mouse*. 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
Re: Question on gtk_label_set_selectable
On Fri, Oct 19, 2007 at 07:44:19PM +0800, Gregory Hosler wrote: Gregory Hosler wrote: Hi all, I have labels, which I wish to allow the user to select the text for the purpose of cut/pasting. So I set gtk_label_set_selectable (GTK_LABEL (dlabel), 1) on the label. The problem I have now is that when the label is created, not only is the text selectable, but it is also SELECTED as an initial state. I would prefer for the text to be selectable, BUT NOT selected (at least as a default state). How might I turn off selected ? any tips ? After some exploring, and looking at the gtk samples, I have an answer. I'm not happy with it. It seems (to me) like there is a bug, so let me explain what works, and what doesn't work. If I have a window (dwindow), and then create a label as follows: dlabel=gtk_label_new(); gtk_label_set_text(GTK_LABEL(dlabel), my text); gtk_label_set_line_wrap(GTK_LABEL(dlabel),1); gtk_label_set_selectable (GTK_LABEL (dlabel), 1); Then attach my label to the window and then: gtk_widget_show_all(dwindow); My label will show up, as selectable, BUT the label text will be initially selected. If I change the above sequence to this: dlabel=gtk_label_new(); gtk_label_set_text(GTK_LABEL(dlabel), my text); gtk_label_set_line_wrap(GTK_LABEL(dlabel),1); Then attach my label to the window and then: gtk_widget_show_all(dwindow); gtk_label_set_selectable (GTK_LABEL (dlabel), 1); i.e. setting the selectable attribute AFTER the label is realized, created, etc. *then* the label text will NOT be selected (but it is still selectable). I do not understand why in one case the initial state of the text is selected and in the 2nd case it is NOT selected. Is this a bug? Or is there a reason this is like this? thoughts ? I have not seen the code, but... Your label the first widget in the window that accepts focus (selectable labels can receive focus, unlike normal labels). Therefore the label will get focus, which selects its text -- at least this seems to be the default behaviour. If you add the label after it's decided which widget should receive focus, the label does not get focus and therefore its text is not selected. 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
Re: ld error multiple definitions
On Sat, Oct 13, 2007 at 11:50:17AM +0200, Joël Krähemann wrote: hello I get strange errors like /home/link/ags/file/ags_file.o: In function `ags_file_class_init': /home/link/ags/file/ags_file.c:32: multiple definition of `ags_file_class_init' /home/link/ags/file/ags_file.o:/home/link/ags/file/ags_file.c:32: first defined here If you get definitions from the very same file and line clashing, you are trying to link this file twice -- one way or another. Also, I wonder why ags_file_class_init() is exported; it should be static. 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
Re: GtkPageSetupUnixDialog and GtkPrintUnixDialog
On Tue, Oct 09, 2007 at 10:26:30AM -0700, Lance Dillon wrote: GtkPageSetupUnixDialog and GtkPrintUnixDialog don't exist on my system, even though it seems that they should. They do. Fedora 7 gtk2-2.10.14-3.fc7 gtk2-devel-2.10.14-3.fc7 rpm -q gtk2-devel | grep unix should clarify things a lot... ... So, is something wrong with my system? With the packages provided by Fedora? Or is the documentation incorrect? The Gtk+ Unix printing stuff is in gtk+-unix-print-2.0 pkg-config package. If you really need to use the non-portable Unix part of the API, you have to add flags from this package. 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
Re: calling functions defined in gtk's source file
On Sun, Oct 07, 2007 at 03:15:57PM +0200, Joël Krähemann wrote: hello I want to call in my application functions like gtk_window_show, gtk_widget_real_show and others You cannot. These are private Gtk+ functions (you should have noticed they are delcared as static and therefore visible ony to the source file that contains them). They do not belong to the public API and they can disappear, be renamed or change the arguments and return values any time Well, those implementing a virtual method cannot really change arguments, but if they implement a virtual method, then you should invoke the virtual method, NOT the function implementing it. the c file void ags_window_class_init(AgsWindow *window) { GtkWidgetClass *widget = (GtkWidgetClass *) window; widget-show = ags_window_show; } void ags_window_show(GtkWidget *widget) { gtk_window_show(widget); } And if you want to call the parent's virtual method in a subclass, do precisely that. How do you know the nearest parent that actually implements the method? In most cases you cannot. It can even change from version to version. That's why you can find this idiom common in the Gtk+ code: if (GTK_WIDGET_CLASS(args_window_parent_class)-show) GTK_WIDGET_CLASS(args_window_parent_class)-show(widget); where args_window_parent_class is defined automatically if you use the G_DEFINE_TYPE template macros. If you are 100% sure the parent class always has implemented and always will implement the virtual function, you can omit the if-clause and just call the method. 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
Re: Switch contents in the same window
On Mon, Oct 01, 2007 at 10:54:32AM +0200, [EMAIL PROTECTED] wrote: Sorry Yeti, but it's not what I'm searching for: I cannot implement GtkAssistant because I'm working on GTK+ 2.6 on an embedded system... You can still look at GtkAssistant source code as an example implementation (although perhaps a bit too complex for your needs). 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
Re: pixbuf color count
On Mon, Oct 01, 2007 at 10:49:06AM -0600, Kevin DeKorte wrote: Is there a way to get the number of unique colors in that pixbuf. gdk-pixbuf is not a full-fledged image manipulation library, it provides just a few basic functions related to loading, saving and on-screen rendering. So you have to either use an image manipulation library or count the distinct colours yourself. 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
Re: Spontaneous background colors in treeview
On Sun, Sep 30, 2007 at 11:08:05AM -0600, Jeffrey Barish wrote: After making some changes to my program (not directly related to the GUI), I find that one treeview has a background of alternating light and dark bands, but only for certain data sets. I never set the background in my code, so I expect it to be white for every data set. The program has this behavior only under Ubuntu. On another platform, I do get a white background for all data sets (with the same code). Does anyone have a clue what might be causing this bizarre behavior? Can it be http://library.gnome.org/devel/gtk/stable/GtkTreeView.html#GtkTreeView--rules-hint http://library.gnome.org/devel/gtk/stable/GtkTreeView.html#GtkTreeView--allow-rules ? The alternating colors are controlled by the theme then. 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
Re: How to get all the key press event in a textview?
On Fri, Sep 28, 2007 at 05:40:56PM +0800, Magicloud Magiclouds wrote: As in Emacs, something like Ctrl+Alt+a work, even in a gnome-terminal. How is Emacs related to this? But in my simple gtk program, What program? I just get ctrl+65507(keyval) in key release event. This is the release of Ctrl (when Alt is no longer pressed). If you release Alt before Ctrl, you should get this event. If you release Ctrl first, the Alt flag will be set too in the Ctrl-release event because Alt is still held. Do you mean this is the *only* key release event you receive? How to make it work? Thanks. In *my* simple Gtk+ program, it works normally. Pressing Ctrl, pressing Alt, pressing l (Ctrl-Alt-a is taken by my window manager), releasing l, releasing Alt, releasing Ctrl prints: press: keyval=ffe3 state=0x press: keyval=ffe9 state=0x0004 press: keyval=006c state=0x000c release: keyval=006c state=0x000c release: keyval=ffe9 state=0x000c release: keyval=ffe3 state=0x0004 This is what xev prints, too. Of course, since the modifier state is the state when the event occurred, you can get various combinations of states in the l-release event depending on the order of key releases. But in all cases user's actions are faithfully reprorted. Yeti -- http://gwyddion.net/ = #include gtk/gtk.h static gboolean key_event(G_GNUC_UNUSED GtkWidget *widget, GdkEventKey *event) { g_printerr(%s: keyval=%04x state=0x%04x\n, event-type == GDK_KEY_PRESS ? press : release, event-keyval, event-state); return FALSE; } int main(int argc, char *argv[]) { GtkWidget *window, *view; gtk_init(argc, argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size(GTK_WINDOW(window), 320, 240); g_signal_connect(window, destroy, G_CALLBACK(gtk_main_quit), NULL); view = gtk_text_view_new(); g_signal_connect(view, key-press-event, G_CALLBACK(key_event), NULL); g_signal_connect(view, key-release-event, G_CALLBACK(key_event), NULL); gtk_container_add(GTK_CONTAINER(window), view); gtk_widget_show_all(window); gtk_main(); return 0; } ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: 16 bits grayscale images
On Thu, Sep 27, 2007 at 04:45:10PM +0200, alex wrote: I want to create a grayscale image from a CCD camera. Data are from a function wich gives me an 16 bits array corresponding to the CCD's pixels. I take a look at the pixbuf class, but it seems to use a RGB structure. How can I do my job ? If you don't expect the graphics system to be actually capable of displaying 16bpc images, it is easiest to just convert the data to 8bpp RGB (which is a trivial operation). 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
Re: Updating (showing) the widgets of a dialog in a g_thread
On Sat, Sep 22, 2007 at 10:49:56PM -0400, Andrew Smith wrote: I have the following setup: gpointer thread1(gpointer data) { run_long_function(); return NULL; } gpointer thread2(gpointer data) { GtkWidget* dialog; gdk_threads_enter(); dialog = gtk_message_dialog_new(GTK_WINDOW(win_main), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, asd); gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); gtk_widget_show(dialog); gdk_threads_leave(); while (thread1 is running) { gdk_threads_enter(); //!! I want to make sure the dialog is shown // the following does not help while (gtk_events_pending()) gtk_main_iteration(); gdk_threads_leave(); usleep(50); } gdk_threads_enter(); gtk_widget_destroy(dialog); gdk_threads_leave(); return NULL; } Scratch all this. Access the GUI only from the thread running gtk_main() (AKA main thread). Never manually serialize Gtk+ main loop iterations with gtk_main_iteration() (you are writing a *multithreaded* program, remember). NEVER do things like usleep(50); in the main thread. Just construct and show the dialog and let the Gtk+ main loop run normally (by quitting the function that constructs it). Add g_idle_add(long_function_finished, whatever); to the end of the thread running long_function(): long_function_finished() will be executed in the main loop, i.e. the main thread. No locks, no obscure constructs, works on Win32 too. 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
Re: emit keypress event into event loop
On Fri, Sep 21, 2007 at 03:32:49PM -0100, vano wrote: Anybody has idea how to emit in GTK (2.11.6) some keypress event into main event loop? I have mouse clickable button and want to send to my text_view a keyboard press. I'm doing this way: in main code: g_signal_connect(G_OBJECT(my_button), button-press-event, G_CALLBACK(press_callback), G_OBJECT(textview)); Why on Earth you are connecting to button-press-event instead of clicked of the button? (And with a handler that has the wrong prototype -- event signals have a boolean return value.) in callback: static void press_callback( GtkWidget *widget, GdkEventButton *e, GtkWidget *text_view ) { g_print(button press\n); GdkEvent *event; event = gdk_event_new(GDK_KEY_PRESS); event-key.keyval = GDK_K; event-key.window = gtk_text_view_get_window(text_view, GTK_TEXT_WINDOW_TEXT); event-key.time = 0; gtk_main_do_event(event); If your compiler does not complain loudly on this line, enable some warnings, it will save you lots of troubles. (And if it does, read what is says before asking in the list...) You pass the wrong type to gtk_main_do_event() (one level of pointerness too many). or if trying another approach with sending event directly to text_view widget: static void press_callback( GtkWidget *widget, GdkEventButton *e, GtkWidget *text_view ) { g_print(button press\n); GdkEvent *event; event = gdk_event_new(GDK_KEY_PRESS); event-key.keyval = GDK_K; event-key.window = gtk_text_view_get_window(text_view, GTK_TEXT_WINDOW_TEXT); event-key.time = 0; g_signal_emit_by_name(GTK_TEXT_VIEW(text_view), key_press_event, event); } the program seems go in correct way, but I get segmentation fault: First, event signals cannot be sent this simple way as other signals. Anyway, event signals have boolean return value and you do not pass any return location (see g_signal_emit_by_name() documentation), therefore it overwrites some stuff on the stack that follows the arguments. Now something constructive: Synthetizing events is almost always a bad idea. At the end, you want the button to behave normally (i.e. connect to clicked) and perform some specific action: insert text, delete text, change text, ... For all these things GtkTextView/Buffer have methods. Use them directly. 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
Re: GdkPixbuf object from stock icons
On Sat, Sep 22, 2007 at 03:17:51PM +0300, Zeeshan Ali wrote: I was looking for a non-hackish way of creating a GdkPixbuf object out of stock icon. The first thing that comes to mind is: --CODE SNIPPET BEGIN-- image = gtk_image_new_from_stock (stock_id, size); pixbuf = gtk_image_get_pixbuf (image); --CODE SNIPPET END- However that doesn't work since the created image if of storage type GTK_IMAGE_STOCK and gtk_image_get_pixbuf() doesn't like that. Yes, the image is not backed by a pixbuf therefore it cannot return it (a GtkImage method to render the image to a pixbuf whatever it is backed with could be perhaps written, but it would be something different). Following is the only way i could come up with: --CODE SNIPPET BEGIN-- image = gtk_image_new (); pixbuf = gtk_widget_render_icon (image, stock_id, size, NULL); --CODE SNIPPET END- This one works quite fine but is obviously hackish, Does anyone know of any better way of doing the same? Not so obviously. The primary difficulty is that your problem is ill-posed. The stock icon look is affected by theme, state and whatnot. It can even differ for different widgets. So depending on your preferred amount of manual work you have the choice of gtk_widget_render_icon() gtk_icon_set_render_icon() gtk_style_render_icon() The most raw method is gtk_icon_theme_lookup_icon() + gtk_icon_info_load_icon() However, the icon will probably end up rendered on some widget -- and then use gtk_widget_render_icon() for this widget. 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
Re: start-editing signal?
On Fri, Sep 21, 2007 at 03:11:12PM -0400, Allin Cottrell wrote: I'm trying to connect a callback to start-editing on a cell renderer, but I must be doing something wrong. My code is basically static void create_cell_renderer (gpointer p) { GtkCellRenderer *r; r = gtk_cell_renderer_text_new(); g_object_set(r, ypad, 1, xalign, 1.0, mode, GTK_CELL_RENDERER_MODE_EDITABLE, NULL); g_signal_connect(r, start-editing, G_CALLBACK(cell_edit_start), p); } When this code is invoked, I'm getting GLib-GObject-WARNING **: gsignal.c:1669: signal `start-editing' is invalid for instance `0x822a5f0' I've verified that 0x822a5f0 is indeed the return value from gtk_cell_renderer_text_new. Can anyone tell me how to make a valid hook-up? Start with the correct signal name: http://library.gnome.org/devel/gtk/stable/GtkCellRenderer.html#GtkCellRenderer-editing-started Looking at the documentation should be first thing when you get a GObject complaint about invalid signal/property name. 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
Re: Abstract string properties with getter/setter functions
On Wed, Sep 19, 2007 at 06:48:25PM +0200, Raffaele Sandrini wrote: Since we do not see a way around this (yet) and we could not find an example with strings in another project. I'm asking here if there is a nice way around this. i'm really not sure i understand your problem here... We need a way to steal the string from the property i.e. to make sure its not a copy of the original. The property does not need to be actually backed by a string. It just has to accept a string in the setter and produce a string -- a new string -- in the getter. For instance GtkCellRendererText has properties background wich is a string (write-only though) and background-gdk which is a GdkColor. They are views of same thing and what is this actual internal representation is none of your business. To sum it up, you cannot steal something that is owned by you from the begining. Yeti -- http://gwyddion.net/ ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: Window with no maximize button
On Mon, Sep 17, 2007 at 05:01:05PM +0530, aniket ray wrote: I wanted to create a Window with only the minimize and close decoration buttons (and no maximize button). The code of what I basically did was: windowPointer = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_realize(windowPointer); mainWindow = windowPointer-window; gdk_window_set_decorations(mainWindow, GDK_DECOR_BORDER | GDK_DECOR_RESIZEH | GDK_DECOR_TITLE | GDK_DECOR_MENU | GDK_DECOR_MINIMIZE); //everything but maximize gtk_widget_show(windowPointer); This does not seem to work as I still get the maximize button on the window. I am using an FC6, with default GNOME installation (and its Metacity WM). On the other hand, if I give a DIALOG hint to the window with gtk_window_set_type_hint(), I am able to remove the maximize and minimize buttons. Is there a difference in which the 2 methods send hints to the WM? The DIALOG hint (_NET_WM_WINDOW_TYPE_DIALOG) is an independent hit. So it can influence the window manager decisions independently. Hints are just hints. The window manager decides how to decorate the windows. Apparently, Metacity thinks it's a good idea to remove the two buttons from dialogs. Whatever. My window manager always shows the buttons I told it and only them. Someone else's window manager never shows any window frame at all. You cannot rely on window managers following the hints, some do not even have any meaning with some window management styles. Just set the hints logicaally, i.e. do not randomly choose hints that happen to make your particular window manager behave as you wish. How can I get this to work? You cannot ultimately control the window decorations. And let me immediately add, it's a good thing. 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
Re: Behaviour of getters wrt dup/ref
On Sat, Sep 15, 2007 at 11:08:38PM -0400, Behdad Esfahbod wrote: On Fri, 2007-09-14 at 10:35 -0400, Alexander Larsson wrote: char * g_data_input_stream_get_line (GDataInputStream *data_stream, gsize *length, GCancellable *cancellable, GError **error); This actually reads new data from the stream, so it has to dup. One could imagine a similar call that returns some form of object instead of a string. I think it's pretty common in glib and pango at least to return g_strdup'ed strings. The no-ref-count rule is mostly for objects that have a literal ref/unref pair. Other than that, for functions that return read data from the stream, some people may have reasons to want to avoid malloc/free'ing on each line. One way to work around that is to have the function take a GString, so you can reuse the buffer from the previous line. I know most people are not a big fan of that idea though. The right interface for this type of functions have been already invented: that of glibc's getline. It can allocate new buffers, it can reuse existing buffers resizing them if necessary -- and it can be even used with GStrings [if they use the same memory allocator] although that's a bit dirty. Yeti -- http://gwyddion.net/ ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: Behaviour of getters wrt dup/ref
On Sun, Sep 16, 2007 at 12:12:11PM -0400, Behdad Esfahbod wrote: The right interface for this type of functions have been already invented: that of glibc's getline. It can allocate new buffers, it can reuse existing buffers resizing them if necessary -- and it can be even used with GStrings [if they use the same memory allocator] although that's a bit dirty. Well, that's exactly what happens if you make the API take GString. I reacted to the remark that many people do not like having to pass a GString (perhaps understandably). The `decomposed GString' interface of getline() is then the next reasonable candidate. Yeti -- http://gwyddion.net/ ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: Lower case to upper case german ess-zet
On Thu, Sep 13, 2007 at 10:01:03PM +0200, Luis Ramirez wrote: Thanks for your comments. I have entered the enclosed code in the begining and I get: Headers version: 2.12 Lib version: 2.12 I have compiled the code in GNU/Linux and in Windows XP with Mingw and I get the same version 2.12, and the same results. Which version do you have used? Installed: glib2-2.12.13-1.fc7.x86_64 (Fedora 7 RPM) Reading code of: svn trunk In http://svn.gnome.org/viewcvs/glib/trunk/glib/guniprop.c?annotate=5713 line 575 you can see what happens when the character is lowercase (line 570) and its uppercase counterpart is a number = 0x100 (line 573). These contions are true for sharp s (U+00DF) as you can see in http://svn.gnome.org/viewcvs/glib/trunk/glib/gunichartables.h?annotate=4897 line 117 (G_UNICODE_LOWERCASE_LETTER) and line 9484 (the 0x100 value). Since the uppercase value is 0x100, p will point to the first entry of special_case_table in gunichartables.h, line 11978: \x00\x53\x53\x00\x53\x73\0 /* offset 0 */ It starts with \x00 (single-char uppercase does not exist), therefore val at line 576 of guniprop.c becomes 0. And in this case the original character is returned at line 582. The code was changed on Thu Mar 22 09:11:27 2007 UTC, so if your GLib is older than that (i.e. a stable release older than 2.12.12), it's too old. 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
Re: Changing a previously created GtkImage
On Wed, Sep 12, 2007 at 01:52:43PM -0700, tsaud wrote: I have created an image from a file using image1 = gtk_image_new_from_file(pictures/Empty.gif); gtk_widget_set_name (image1, image1); and displalyed it using: gtk_widget_show(image1); gtk_box_pack_start(GTK_BOX (hbox1), image1, TRUE, TRUE, 0); and that works fine. The image is correctly displayed where I want it. Later, when a particular event happens (right now I have assigned it to a button press), I want to change the image to the image in the file pictures/Full.gif (which is exactly the same size as Empty.gif). To do that, I did the following: void on_button1_pressed (GtkButton *button, gpointer user_data) { GtkWidget *imageptr; imageptr = lookup_widget(GTK_WIDGET(button), image1); if(imageptr != NULL) { gtk_image_set_from_file(GTK_IMAGE(imageptr), pictures/Full.gif); } else fprintf(stderr, image1 not found\n); } When I press the button, the image is replaced by a broken image icon, not the new image. What am I doing wrong? I am obviously getting the correct widget with the lookup_widget call, since the image changed. The file Empty.gif and the file Full.gif are in the same directory, and when I change the gtk_image_new_from_file() call to load the Full.gif file, that works fine as well, so I know the file is there and readable. I just don't understand why it didn't change to the new image. Can't the working directory change meanwhile? Paths such as pictures/Full.gif seem quite fragile to me. 1) Try g_file_test() to check whether pictures/Full.gif exists as the time on_button1_pressed() is called. 2) Try to load the image with gdk_pixbuf_load() and look at the error your obtain. 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
Re: Question about gchar g_strconcat()
On Wed, Sep 12, 2007 at 08:20:18PM +0200, [EMAIL PROTECTED] wrote: gchar *file; file=test; file = g_strconcat(/some/path/, file, .txt, NULL); g_printf(%s, file); My question is do i must allocate memory for file ? The topic of this list is the development of Gtk+, not with Gtk+. Direct questions like this to gtk-list. The short answer is: No, but you have to *free* it. See the documentation of g_strconcat(). And you should use g_build_filename(). Yeti -- http://gwyddion.net/ ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: How to detect gtk widget partial visible? visibility-notify-event?
On Tue, Sep 11, 2007 at 05:54:54PM +0800, MD Tsai wrote: Is it possible for a gtk widget to detect it is partial visible? For example, I can drag one window on another window. The covered window can be notified that it is partial visible? I've registered the visibility-notify-event but never receive callback, gtk_widget_add_events(widget, GDK_VISIBILITY_NOTIFY_MASK); 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
Re: Lower case to upper case german ess-zet
On Tue, Sep 11, 2007 at 06:12:53PM +, Luis Ramirez wrote: I have a problem converting german ess-zet (ß) from lower to uppercase when using g_unichar_toupper, but it works fine using g_utf8_strup. Using g_unichar_toupper I get a 0 as result. You should not, both according to my reading of GLib source code and experiment. Since the uppercase is not repesentable with a signle character, you should get the input character back from g_unichar_toupper(), exactly as the documentation states -- and this is also what I observe. Here it is a sample. The output is: Note embedding these things in mail makes them subject to abritrary reencoding and can result in recipients trying entirely different code if they are not very careful -- use \xc3\x9f representation. g_unichar_toupper. Lower:'ß', Upper:'' g_utf8_strup. Lower:'ß', Upper:'SS' I get g_unichar_toupper. Lower:'ß', Upper:'ß' g_utf8_strup. Lower:'ß', Upper:'SS' as expected. Perhaps a too old GLib? 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
Re: How to convert a jpg image to a GtkImage ?
On Tue, Sep 11, 2007 at 10:53:02PM +0200, Jonathan Winterflood wrote: As for adding a click to the reference count, if it works, would probably be the best way to go Of course it works and it is recommended in gdk_pixbuf_loader_get_pixbuf() documentation -- if anyone bothered to read it... 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
Re: gtk pango draw rotated text
On Mon, Sep 10, 2007 at 01:27:48PM +0100, Luis Rodrigues wrote: It's not on my system. I use Debian, do you happen do know the package name? http://packages.debian.org/search?searchon=contentskeywords=gtk-demomode=pathsuite=stablearch=any 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
Re: Using GtkFileChooserWidget
On Sun, Sep 09, 2007 at 11:54:01PM +0200, Nikolaj Thygesen wrote: 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?? Probably bugzilla.gnome.org. 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
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
Re: Regrading gtk thread
On Sat, Sep 08, 2007 at 02:17:11AM -0700, Sohel wrote: I have two buttons using one button I start a thread and using the other button I want to stop this thread. I get the following error when trying to do this : Xlib: unexpected async reply (sequence 0x26ad)! How do I solve this error and if there is a better way to do this ?? Filter question: Did you read and follow http://library.gnome.org/devel/gdk/stable/gdk-Threads.html ? 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
Re: Conversion functions.
On Fri, Sep 07, 2007 at 05:02:37PM +0200, Magnus Myrefors wrote: By the way I have found out that I used a way of reading lines from the input-file which can cause some problem. I read in a book that fgets(string, sizeof(string), input) should read one line up to sizeof(string) -1 or to the first newline- character. But when I tested I found out that that wasn't the case. If sizeof(sizeof) does not stand for the allocated size of the string but is meant literally, then either the book was utter crap or you misunderstood it. I suggest to read the GNU libc info pages instead, the explanations there are clear. sizeof(a-pointer-to-char) is the size of the pointer, usually 8 or 4. The second fgets() argument should be the allocated size of the string (or a smaller positive number). 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
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, I suppose you have read thread http://mail.gnome.org/archives/gtk-list/2007-September/msg00015.html I am getting mouse events nicely from the drawing area, but have been entirely stumped in getting keyboard events. I have done google searches on the topic and taken the advice given, the code that I think is relevant is: GTK_WIDGET_SET_FLAGS ( da, GTK_CAN_FOCUS ); This is OK. g_signal_connect ( GTK_OBJECT(da), focus_event, GTK_SIGNAL_FUNC(focus_handler), NULL ); This is written in some archaic dialect (although not entirely, the corresponding archaic counterpart of g_signal_connect() is gtk_signal_connect()). Code written in the last 5 years should read g_signal_connect(da, focus-event, G_CALLBACK(focus_handler), NULL); Nevertheless, the functionality is the same. gtk_widget_add_events ( GTK_WIDGET(da), GDK_FOCUS_CHANGE ); 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. Ditto in the key press case. Also ensure you add events before the widget is realized. 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
Re: Conversion functions.
On Fri, Sep 07, 2007 at 01:45:09AM +0200, Magnus Myrefors wrote: yeti I have tested your minimal testprogram with the whole test-file. Unfortunately the program doesn't print anything to stdout. It doesn't seem to be any data stored in the GSList or in the datastructure, Data *data. If there is any line that starts with a digit (after possible whitespace), it has to print either the data or an error. If it doesn't, then there is no line whose first non-whitespace character would satisfy g_ascii_isdigit(c) or it does not end up in the list. This means either - g_ascii_isdigit(c) does not evaluate to TRUE for digits on your system - g_slist_prepend() does not work - g_slist_reverse() does not work - the file looks different than you sent Which one is it? (I tried to print a field every time a new line was about to be read in the while-loop). Furthermore, I wonder if the test, if(end == start) failfield = Latitude;, can conclude that the string was converted correctly with g_ascii_strtod(). If g_ascii_strtod() converts only a fraction of the string, it will result in (end != start) and failfield won't be set which results in no output to stderr. end is the input to the next conversion, therefore failfield will be set in the next conversion (or trailing garbage message will be printed if it was the last). Unless the file contain one of the few possible cases of concatenated floating point numbers that can be parsed back -- these can be catched by checking whether *end is space or '\0'. But this does not matter at all. Either way you get *some* output, either data or errors (or both in the case of trailing garbage). You must get some output even if g_ascii_strtod() and strtol() return completely random values. So I just don't believe you. Period. 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
Re: Conversion functions.
On Thu, Sep 06, 2007 at 11:00:11AM -0300, Matías Alejandro Torres wrote: Here's the minimal program to read that. The reading part is kind of crappy but it works with that example. The trouble with the reading part is not that it's kind of crappy (well, it is IMO, reading by character makes no sense when g_ascii_strtod() and strtol() can perfectly iterate themselves *and* have error-reporting, g_slist_append() is O(N) making the reading O(N^2), it is a waste of time to construct a big GSList just to fill a GtkListStore from it instead of filling the store directly -- and if Data is a data structure used elsewhere in the program it makes little sense to break it into columns instead of storing it directly in a G_TYPE_BOXED/G_TYPE_POINTER column), but that: - it assigns the fgetc() return value to a gchar, breaking EOF testing - it uses a fixed unchecked buffer of size 50 we do now know whether overflows or not on your data - it takes any sequence of non-[ \t] as a field and reads it without checking so we do not know what actually happens on your data - it uses g_strtod() (NOT g_ascii_strtod() you've been talking about) which tries to accept both C and your current locale formats and therefore is not predictable (and won't help reading data that someone with a *different* local wrote in the locale-specific manner anyway) If the attached program reads the complete file and prints back its contents correctly, then I dare to say your problem is not broken g_ascii_strtod(). As a bonus, the attached program prints a detailed error to stderr if there are malformed data rows in the file. Yeti -- http://gwyddion.net/ = #define _GNU_SOURCE 1 #include stdlib.h #include stdio.h #include string.h #include errno.h #include glib.h typedef struct _Data { gchar *log; gdouble latitude; gintaltitude; gintinterval; gintheartbeat; gdouble speed; } Data; int main(int argc, char *argv[]) { const gchar *filename, *failfield; gchar *buf = NULL; size_t buf_size = 0, lineno; ssize_t line_len; FILE *fh; GSList *l, *stuff = NULL; Data *data; if (argc != 2) { g_printerr(readstuff FILE\n); return 1; } filename = argv[1]; if (!(fh = fopen(filename, r))) { g_printerr(Cannot open %s: %s\n, filename, g_strerror(errno)); return 1; } lineno = 0; failfield = NULL; while ((line_len = getline(buf, buf_size, fh)) != -1) { gchar *start, *end; guint len; lineno++; start = g_strstrip(buf); /* Skip non-data lines */ if (!buf[0] || !g_ascii_isdigit(buf[0])) continue; data = g_new(Data, 1); len = strcspn(start, \t); data-log = g_strndup(start, len); start += len; data-latitude = g_ascii_strtod(start, end); if (end == start) { failfield = Latitude; break; } start = end; data-altitude = strtol(start, end, 10); if (end == start) { failfield = Altitude; break; } start = end; data-interval = strtol(start, end, 10); if (end == start) { failfield = IntervalTime; break; } start = end; data-heartbeat = strtol(start, end, 10); if (end == start) { failfield = HeartRate; break; } start = end; data-speed = g_ascii_strtod(start, end); if (end == start) { failfield = Speed; break; } stuff = g_slist_prepend(stuff, data); if (*end) fprintf(stderr, Warning: trailing garbage at line %lu of %s: %s\n, (unsigned long int)lineno, filename, buf); } fclose(fh); free(buf); if (failfield) { fprintf(stderr, Cannot parse %s at line %lu of %s: %s\n, failfield, (unsigned long int)lineno, filename, buf); g_free(data-log); g_free(data); } else { stuff = g_slist_reverse(stuff); for (l = stuff; l; l = l-next) { data = (Data*)l-data; printf(%s %.5f %d %d %d %.2f\n, data-log, data-latitude, data-altitude, data-interval, data-heartbeat, data-speed); } } for (l = stuff; l; l = l-next) { data = (Data*)l-data; g_free(data-log); g_free(data); } g_slist_free(stuff); return !!failfield; } ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: focus-out-event and GtkEntry
On Thu, Sep 06, 2007 at 02:49:12PM -0400, Zvi Sebrow wrote: I need to check data a user inputs on one of numerous GtkEntry's on window, and I need to handle the situation when the entry loses focus (by TABing out of the field, or by mouse control. When I encouter bad input, I bring up a dialog box. The problem is I get an GtkWarning and GtkError: ... Check the focus-out-event signal handler prototype http://library.gnome.org/devel/gtk/stable/GtkWidget.html#GtkWidget-focus-out-event *including the return value*, you must return FALSE if you want the default handler to run. 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
Re: Pass multiple arguments to a signal event
On Wed, Sep 05, 2007 at 03:58:25PM +0200, [EMAIL PROTECTED] wrote: I can't figure how to pass multiple arguments to a signal event.I'll be very grateful if someone could explain it to me or write some example. You can pass a pointer and this is enough becuase a pointer can point to arbitrarily complex data structures. Therefore you can pass arbitrarily complex data structures, even though sometimes it can be less convenient than passing multiple arguments directly. Also, in some cases you can use g_object_set_data() to attach data related to widgets (and other objects) directly to them and pick them later in the callback with g_object_get_data(). For example, let's say I have in a window 2 entries and a button. How can I pass the 2 entry widgets to the signal function for working with them? As far as I know I can't do something like: g_signal_connect_swapped(button, clicked, G_CALLBACK (callback_func_example), here_the_two_widgets ); You can: GtkWidget **here_the_two_widgets; here_the_two_widgets = g_new(GtkWidget*, 2); here_the_two_widgets[0] = entry1; here_the_two_widgets[1] = entry2; g_signal_connect_swapped(button, clicked, G_CALLBACK(callback_func_example), here_the_two_widgets); (not the best example, but hopefully gives the idea). 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
Re: Conversion functions.
On Tue, Sep 04, 2007 at 01:12:11AM +0200, Magnus Myrefors wrote: when I start the test I am in the same state and I use the same text-file evey time. The converted values can be different or the same between different test-runs so the wrong values seem to occur randomly. Then try valgrind as I suggested, it's the easiest thing to try. 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
Re: Conversion functions.
On Tue, Sep 04, 2007 at 11:55:58PM +0200, Magnus Myrefors wrote: I tried with strtod() but it only worked with strings with no decimal-point, otherwise the resulting double was truncated. ... - if the numbers are normal, i.e. supported by underlying strtod(), try to use it directly -- be careful with the ^^^ locale in this case ^^^ strtod() is locale dependent, g_ascii_strtod() is not (well, sort of, it uses strtod() so if the locale or strtod() implementation is weird, g_ascii_strtod() can be still affected). This is what g_ascii_strtod() is all about. Your locale uses decimal comma or something like that. As if I didn't warn... I also tried to copy g_ascii_strtod() (from glib-2.12-9) into my code but it didn't compile My crystal ball says you are missing #include locale.h but it's a bit cloudy. and I didn't quite understand the if-statement if(decimal_point_pos) {} where decimal_point_pos was declared as const char *decimal_point_pos. I thought that a pointer was an address in memory and I haven't seen a pointer in a if-statement like that before. That's a common idiom. NULL is zero and zero is false. Anything else is nonzero and therefore true. I guess I have to write my own conversion-function. Good luck with that (I still think a bug in the program and not in GLib is the most probable cause). 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
Re: Conversion functions.
On Mon, Sep 03, 2007 at 08:46:51PM +0200, Magnus Myrefors wrote: I am currently trying to use the glib-functions g_ascii_strtod(x,y) and g_ascii_strtoll(x,y) to convert values from a text-file. It works fine most of the time but occasionally the converted values are absolutely wrong or just a bit wrong. I am using the glib libraries (libglib2.0-dev v.2.12.4-2) and (libglib2.0-0 v.2.12.4-2). Has anyone had similar problems with these functions ? No; can you extract the problem into a simple test case? If the wrong values occur randomly and/or depend on the state of the rest of the program in a complex way, memory corruption elsewhere in your program is the likely cause (try valgrind). If wrong values are rare but reproducible, it should be easy to prepare a simple test case. 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
Re: Toggle and the Inconsistent Property
On Sun, Sep 02, 2007 at 01:07:48PM -0400, dhk wrote: What is the inconsistent property to a toggle? I want to be able to flag rows in a treeview for possible deletion so they can be reviewed before flagging them for deletion. So the check box needs to have three states, kind of like the minesweeper game, checked, unchecked, and an inbetween state. Does anyone know how to do this? The inconsistent property is to display the toggle as in-between, or rather neither-yes-nor-no, state. However, what you describe does not really look like an in-between state. You have two states: - not marked for deletion - marked for deletion where the second has two sub-states. I suggest to think about a different presentation than abusing inconsistent (adding a small mark to one of the substates for instance), especially since the rendering of the states is theme dependent. 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
Re: How to convert a jpg image to a GtkImage ?
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(). 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
Re: Setting treeview column width
On Thu, Aug 30, 2007 at 01:22:31PM +0800, Binary Chen wrote: With following code, I still can't make a fixed sized treeview column, the column's width is large even after I have set its size, whats wrong with it? Any other thing affect it? column = gtk_tree_view_column_new(); gtk_tree_view_column_set_title(column, _(Name)); gtk_tree_view_column_set_fixed_width(column, 3); gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1); gtk_tree_view_column_set_resizable(column, FALSE); If the column is the last in the treeview, it will fill all the remaning width even if it's fixed-size -- unless there are some expanding columns present. 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
Re: Check Boxes Don't Work Independently
On Thu, Aug 30, 2007 at 10:00:55AM -0400, dhk wrote: The attached and inline program Please, please, send it with something that does not wrap lines the next time, the code does not like it when it happens in the middle of a string or //-comment. Can someone explain why this happens and where the mouseover event is coming from? If you run the program you'll see what I mean. ... /* Redisplay the toggle with the appropriate state. * gtk-demo doesn't have this but it seems necessary. */ gtk_cell_renderer_toggle_set_active(cell, toggle_item); The Gtk+ demo is right and your are wrong here. Please read what I replied you the last time -- or the Gtk+ Tree View Tutorial if my gibbernglish is too hard to understand -- to grasp the concepts. Your code (equivalent to g_object_set(cell, active, TRUE, NULL);) here says: I'm setting the active property to TRUE. Therefore any time in the future, if you wish to render a cell with this renderer, render it as active. And that's exactly what happens, all cells start to be rendered as active (or inactive). You have to either use a cell data function or bind the model column to the active property. But not // Why does setting attributes cause errors and seems unnecessary anyway? //gtk_tree_view_column_set_attributes(column, renderer, activatable, TRUE, active, FALSE, NULL); like this. The arguments of gtk_tree_view_column_set_attributes() are *columns* (column numbers), not values. Since TRUE is 1 and FALSE is 0, you bind activatable to the model column 1 and active to the model column 0. Not what you want. You always want the cell renderer to be activatable, so just set g_object_set(renderer, activatable, TRUE, NULL); and you want its active property be controlled by the column DISABLE so just set gtk_tree_view_column_add_attribute(column, renderer, active, COL_DISABLE); (the meaning will be `enable' not `disable' of course, if you want the view to display the opposite of what's in the model, you have to set a cell data function -- like for essentially any other transform). 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
Re: Send mouse button press event to widget??
On Thu, Aug 30, 2007 at 05:24:21AM -0700, eminemence wrote: I am creating a virtual cursor on a web page and want to simulate the left click of the mouse button when the user presses the enter button. So I tried even using the gdk_event_put on the global window itself,assuming the event would find it's way to the control under the cursor. The gdk_event_put has not been successful,so what is the way to achieve this? I don't recall a working example now (the Gtk+ source code has some though), but: - create the event with gdk_event_new() - fill the fields - cursor position (in GdkWindow coordinates) can be obtained with gdk_window_get_pointer() - window fields have to be g_object_ref()ed IIRC as something unrefs them later - send_event should be TRUE - other information can be obtained from the original event or other means - send the event with gtk_widget_event() - free event - remember if you send a button presses and no button releases, widgets can get confused 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
Re: pixbuf in event box in treeview
On Thu, Aug 30, 2007 at 09:59:33PM +0800, Binary Chen wrote: I want to put a event box in a treeview column, with a pixbuf in the event box, how to set the column render? Cell renderers are not widgets, so this is impossible (== does not make sense). In some cases you can use (or abuse) the `activate' mechanism, subclass a cell renderer class and and override the activate() virtual method. But IIRC only button press events are delivered this way. So generally it will be probably necessary to track the events in the whole tree view and use the provided helper functions to find the cell corresponding to the event's coordinates. 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
Re: elastic tabstops implemented for GTK
On Wed, Aug 29, 2007 at 07:11:35PM +0200, Nick Gravgaard wrote: On 29/08/2007, David Nečas (Yeti) [EMAIL PROTECTED] wrote: Alex Jones wrote: I really can't wait to get this functionality, it finally puts an end to all of the nonsense over how many spaces there should be in a tab! The option to avoid tabs has been here since ever. Did it put an end to the tab size nonsense? What makes you think this option will? Because the usual way to interpret a tab character has been to place the text after it at the next tabstop where the tabstop was a multiple of N. Elastic tabstops don't work like that all. Please read the website linked to in an earlier post. You missed the point. It is irrelevant *what* it does. The primary problem is the undefined meaning of tabs. How inventing yet another option solves this problem? Not at all, it makes it worse. Unless, of cousre, you are going to eliminate all people who use tabs differently than you... Yeti -- http://gwyddion.net/ ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: elastic tabstops implemented for GTK
On Wed, Aug 29, 2007 at 01:38:36PM +0200, Nick Gravgaard wrote: The problem is that indenting is already broken regardless of whether you use tabs or spaces. Tabs are broken because if you don't get the size right things won't line up (appear all wrong), and spaces are broken because you're forcing everyone to use your indentation size. Please explain how spaces break compatibility with other editors (the original objection). Spaces are not broken. Granted, you get one particular indentation with spaces, but it is unambiguous and everyone can display this particular style right. The amount of indentation is a single coding style issue of many. Does it worth the ado if the rest is still present (`enforced' in your terms)? In addition, the most problematic part of identation is figuring out what to do with tabs -- incidentally the part you seem to intend to make *much harder*. My approach fixes these problems. To me it looks like an attempt to force everyone to use gedit (or whatever chosen editor) to display the text. Also please explain how another possible interpretation of tabs fixes anything instead of creating more mess. If you look at the plugin I made for gedit (watch the video at the link I mentioned above) you can see that it is possible to convert between elastic tabstops and spaces. You lose some of the advantages this way (you can't manipulate the files using tools like sed and still have everything line up when you load it in the editor), but can work on projects that mandate the use of spaces for indenting/alignment. Manipluating the text with sed is a cool idea, but I guess most people would trade it for the ability to display the text as intended (which can be ensured only by expanding to spaces). The editor can present the text any way it wishes and let the user do any transforms on it. No problem with this. But changing the storage format and expecting everyone else to adapt? Have Microsoft arrived here? Yeti P.S.: I should probably welcome this after all. Each new misuse of tabs is a point against using them at all. -- http://gwyddion.net/ ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: elastic tabstops implemented for GTK
Alex Jones wrote: I really can't wait to get this functionality, it finally puts an end to all of the nonsense over how many spaces there should be in a tab! The option to avoid tabs has been here since ever. Did it put an end to the tab size nonsense? What makes you think this option will? Yeti -- http://gwyddion.net/ ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: gtk_cell_renderer_toggle_new()
On Mon, Aug 27, 2007 at 07:33:54AM -0400, dhk wrote: Why do all toggles get activated or deactivated in a treeview when only one gets clicked? Also, moving the mouse over the rows seems to redisplay the toggles as checked or unchecked depending on the value of the last toggle. I'm not sure what exactly you do (I cannot see any code posted) but likely you use the cell renderer wrong. The cell renderer is one and it is used to render cells in all rows. The look is determined by its properties at the moment the rendering is performed. Something has to set its properties before rednering each cell to defined how this particular cell should be rendered. This is done by any combination of: - binding a property to a model column with (e.g.) gtk_tree_view_column_add_attribute() - sepcifying a cell data function called before rendering each cell with gtk_tree_view_column_set_cell_data_func(), that sets the properties with g_object_set() - setting the properties globally with g_object_set() -- only possible for those that are the same for all rows See for instance the Gtk+ demo (or the source code of any Gtk+ application that has a tree view with toggles) for a correct use of cell renderers. 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
Re: GtkDialog problems again
On Mon, Aug 27, 2007 at 03:01:00PM +0200, [EMAIL PROTECTED] wrote: I need a dialog in my application that simply show a label (so without any button) and then hide itself after some processing occurred. The problem is that I can't send any :response signal to the dialog, so it remains blocked in the loop after gtk_dialog_run has been called. I tried to use the example posted in the GTK+ reference manual, but without success. Here is the code snippet: appdata-dialogLabel = gtk_label_new(NULL); gtk_label_set_text(GTK_LABEL(appdata-dialogLabel), Opening camera...); appdata-dialog = gtk_dialog_new_with_buttons(Open Camera, GTK_WINDOW(appdata-window), GTK_DIALOG_NO_SEPARATOR | GTK_DIALOG_DESTROY_WITH_PARENT, NULL); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(appdata-dialog)-vbox), appdata-dialogLabel); gtk_widget_show_all(appdata-dialog); // program stops here gint result = gtk_dialog_run(GTK_DIALOG(appdata-dialog)); switch (result) { case GTK_RESPONSE_ACCEPT: gtk_widget_hide_all(appdata-dialog); break; default: gtk_dialog_response(GTK_DIALOG(appdata-dialog), GTK_RESPONSE_DELETE_EVENT); start_pipeline(appdata); add_camera_tab(appdata); break; } gtk_widget_destroy(appdata-dialog); I need that the dialog hides itself after start_pipeline() and add_camera_tab() is called. Make the dialog non-modal, i.e. do not use gtk_dialog_run(), just show_all the dialog, connect to its response signal (process any user response in the callback) and let the main loop continue. Otherwise I'm unsure what you are trying (things such as calling gtk_widget_hide_all() and then immediately gtk_widget_destroy() on the dialog do not make much sense to me). 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
Re: GtkColorButton and GtkFontButton problems
On Fri, Aug 24, 2007 at 09:10:30AM +0200, Miroslav Rajcic wrote: I am having two GtkColorButton and GtkFontButton widgets on my options dialog. My problem is that when user clicks to one of those widgets, selection dialog that opens on the click, is opened correctly, but is being displayed underneath the options dialog (which uses gtk_window_set_keep_above(GTK_WINDOW (Options), TRUE); )! Is there any way to get the signal when such selector windows are displayed, and to bring them into the top of the stack (I want to keep keep_above style on Option dialog) ? If this happens on MS Windows and the dialogs are modal, a workaround is to make the parent dialog temporarily non-modal for the time the child dialog is displayed. However, it's not so easy to do this for the selectors as they do not provide any interface regarding the child dialogs. Is this a bug in those widgets ? Should I report this as a bug ? More likely elsewhere, I encountered it with various kinds of modal dialogs, e.g. child message dialogs and my own subdialogs. If you can create a minimal example and the bug has not been reported yet, then please report. 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
Re: multiple selection and drag-n-drop
On Thu, Aug 23, 2007 at 10:29:47AM -0400, Allin Cottrell wrote: I suppose somebody else must have come across this issue -- and if so I'd be grateful for any ideas. I have a treeview in which GTK_SELECTION_MULTIPLE is enabled. And there's a meaning attached to dragging elements from this treeview to another window. The design problem is that if the user has selected multiple elements in the treeview (using shift- or ctrl-click), and then she presses the mouse button to start a drag, that press undoes the multiple selection, and only the element directly under the mouse pointer actually gets dragged. A very old bug. See http://bugzilla.gnome.org/show_bug.cgi?id=70479 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
Re: how to scroll a gtk_scrolled_window ?
On Sun, Aug 19, 2007 at 09:32:20PM +0800, Gregory Hosler wrote: I have a gtk_scrolled_window() in a window, and occasionally there times when I wish to force the window to be at the last line, regardless of where the scrollbar is presently set. In particular, I have widgets below the scrolled_window that hide/show themselves as times, and when then show themselves, the scrolled window will shrink a little (that's ok), but the scrolling effect is such that the top line of the scrolled window remains in place, and the bottom lines are now scrolled out of the viewport. When this happens, I want to automatically, scroll down to the last line of the view port. Any idea as to how might I achieve this ? I have looked at the gtk_scrolled_window page for some methods of controlling the viewport position and/or the scrollbar and didn't see anything that looked like what I wanted. I also followed up with looking at the scrollbar routines, to see if there was anything there, and nothing jumped out at me and looked like what i was looking for. gtk_scrolled_window_get_[hv]adjustment() return the adjustments. Set them to the desired positions. See the description of GtkScrolledWindow for how it uses them (paragraph 5: The position of the scrollbars is controlled...). 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
Re: Editing in GtkTreeView - Automatic Edit and Unwanted Edit Box?
On Sun, Aug 19, 2007 at 05:16:49PM +0100, Tony Cowderoy wrote: First question - is there any (preferably easy) way with a GtkTreeView to make any editable cell that is selected automatically enter edit mode and automatically commit the changes when focus moves elsewhere? IIRC this is tricky to get right, so easy probably no. Hopefuly someone who has a working example will post it... Second - in the application that I'm trying to develop I have a GtkTreeview with data in a GtkListStore and some, but not all, of the cells editable. If I have a cell selected, but not opened for editing (this includes non-editable cells) and I then start typing, an editable box appears in the bottom right-hand corner of the GtkTreeView, which displays what I'm typing. If I press enter, it goes away and the text of the selected cell is not updated. Does anyone know why this odd behaviour is happening and what I can do to stop it? I suppose it's the search box. In such case: gtk_tree_view_set_enable_search(treeview, FALSE); (or set the corresponding property). 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
Re: Ok to redirect http://developer.gnome.org/doc/API/2.0/ to GNOME Library?
On Tue, Aug 14, 2007 at 11:26:03PM +0200, Frederic Peters wrote: David Nečas (Yeti) wrote: What is the unversioned link to the latest available API reference of a library? http://library.gnome.org/developers/gtk/ is a page listing available versions of the documentation; But this does not allow to construct links, because http://library.gnome.org/developers/gobject/gobject-The-Base-Object-Type.html#GObject does not exist, only versioned URLs such as http://library.gnome.org/developers/gobject/2.10/gobject-The-Base-Object-Type.html#GObject I want to fix a particular cross-library link, for instance /home/mclasen/gnome-2.18/install/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject in Gtk+ API reference to something equivalent to http://developer.gnome.org/doc/API/2.0/gobject/gobject-The-Base-Object-Type.html#GObject So, if only versioned URLs were available, the links would have to point to a random version of GObject, determined by what the guy making dists had installed. do you believe a latest symlink would be useful ? As well as a stable symlink ? A stable or latest alias would be definitely useful, but... Let me explain: The conclusion on gtk-doc was that it is not feasible to keep the on-line location of everything in gtk-doc, instead libraries should advertise their on-line reference base URLs (if there is any) and a mechanisms for this and for base URL switching/correction have been already implemented. This would work well with the current state when each library has one on-line location (containing the latest version). The new scheme leaves me wondering what to do when one just wants to link to GObject (gboolean, whatever) documentation. What is the canonical link? Is there any? Also, the possibility to use relative links such as ../gobject/gobject-The-Base-Object-Type.html#GObject that would work both on-line and in the typical off-line installation has been lost as the new URLs are one directory level more separated, though this is not a big problem. Yeti -- http://gwyddion.net/ ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: How to use GtkPrint
On Tue, Aug 14, 2007 at 11:55:33AM +0400, Alexander S.Kresin wrote: Does this GtkPrint exist at all :) ? I had trying to compile that printing.c, but have found that appropriate header files ( gtkprintcontext.h, gtkprintoperation.h, ... ) doesn't present in my system, through gtk2-devel-2.8.8 is installed ... http://www.gtk.org/gtk-2.10-announcement.html See namely `What is new in GTK+ 2.10'. Also http://developer.gnome.org/doc/API/2.0/gtk/gtk-High-level-Printing-API.html is full of `Since 2.10' and `Printing support was added in GTK+ 2.10.' So where exactly you checked if it exists in your version of Gtk+? 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
Re: Ok to redirect http://developer.gnome.org/doc/API/2.0/ to GNOME Library?
On Tue, Aug 14, 2007 at 10:31:52PM +0200, Olav Vitters wrote: GTK+ is the main user of the developer API reference with links from: http://www.gtk.org/api/ I want to redirect: http://developer.gnome.org/doc/API/2.0/ to: http://library.gnome.org/developer/ See for instance the GTK+ API reference on: http://library.gnome.org/developers/gtk/2.11/ What is the unversioned link to the latest available API reference of a library? Will old documentation versions be kept there? What is the Right Way to reference on-line documentation of other libraries when there are version numbers now? Do I have to pick a particular version? Work is currently under way in gtk-doc to neutralize the cross-references to other libraries to on-line locations when making dists -- and to fix them in `make install' to local files if the corresponding local documentation is found (without having to perform the dreadful HTML rebuild). In most cases this means people will get working cross-links instead of random hrefs such as /home/mclasen/gnome-2.18/install/share/gtk-doc/html/glib However, if they are left with the on-line cross-links, these links should be functional. Yeti -- http://gwyddion.net/ ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: Problems Re-populating GtkTreeView
On Sun, Aug 12, 2007 at 03:16:45PM -0400, Andrew Rowland wrote: I've been working at this for several days now and I'm hoping someone can guide me down the right path (although I'm not opposed to just being given the answer). Let me say TIA now and I apologize if I've included too much code, error messages, etc. You are the first after a long time who bothered to use a debugger himself before posting to the list and included the actual code, the actual error messages and noted the place where it crashes (sort of) in the post. This is not a reason for an apology, but for opening a bottle of champagne... BTW, ever heard of libgda/gnome-db? ... The following is thrown in the terminal. (reliafree:32523): Gtk-CRITICAL **: gtk_tree_model_get_iter: assertion `GTK_IS_TREE_MODEL (tree_model)' failed ... Evidently, the tree model does not exist any more here (the other likely possibility would be passing a wrong pointer as the model, but I just happen to know). And that's because here g_object_unref( part_model ); you release your reference to it. The only remaining reference is that owned by the treeview, which is released when the treeview is closed (destroyed) and then the model goes poof because it is not used by anything (more precisely, nothing claims any use of it -- you still think you use it, but since you do not own any reference, nothing knows you want to use it). Keep your reference until you are done with the model (and don't release references more times than you took them). Unreferencing the model immediately after gtk_tree_view_set_model() is convenient when you want the model to be destroyed together with the view and/or when a different model is set -- but that's the opposite of what you want. Also, clearing the model and filling it with something completely different will not save much. Creating a new model, filling it, calling gtk_tree_view_set_model() and unreferencing the new model can be even more efficient. 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
Re: gtk_tree_model_iter_next works, what should I do about prev]
= gtk_cell_renderer_text_new(); g_object_set(G_OBJECT(renderer), xalign, 1.0, NULL); column = gtk_tree_view_column_new_with_attributes(Size, renderer, text, COLUMN_SIZE, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes(Date, renderer, NULL); gtk_tree_view_column_set_cell_data_func(column, renderer, render_date, NULL, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view)); gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE); g_signal_connect(selection, changed, G_CALLBACK(selection_changed), NULL); gtk_widget_show_all(window); gtk_main(); return 0; } 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
Re: How to make GtkTreeview columns invisible
On Fri, Aug 10, 2007 at 05:47:07PM +0530, Prasanna Kumar K wrote: I don't want any columns of GtkTreeView visible in my application. I want only rows to be shown. is it possible? It was answered when you asked the first time: http://mail.gnome.org/archives/gtk-list/2007-August/msg00042.html This message (including any attachment) is confidential and may be legally privileged. Access to this message by anyone other than the intended recipient(s) listed above is unauthorized. If you are not the intended recipient you are hereby notified that any disclosure, copying, or distribution of the message, or any action taken or omission of action by you in reliance upon it, is prohibited and may be unlawful. Please immediately notify the sender by reply e-mail and permanently delete all copies of the message if you have received this message in error. The author of this dislaimer is hereby notified that I will continue to disclose, copy and distribute anything I receive from a public mailing list. If he/she/it does not want this disclaimer to lose any threatening weight (it does not have any legal weight anyway), he/she/it will have to sue me. 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
Re: color of vscrollbar
On Wed, Aug 08, 2007 at 12:24:11PM +0200, Jonathan Winterflood wrote: Fair enough, but for work-related stuff, we should (and should be able to) use the work adress, it's much easier than having to check 2 email adresses, one of which would probably have to be a webmail. And quite frankly, how hard is it to just ignore the message, knowing that you're on a public list? I personally subscribe to 2 lists for personal use w/ my gmail @, and 3 work-related with my corporate @ On the work-related one, many ppl have these messages appended, but no one really minds. Hereby I inform you I do really mind. Actually, rejecting all messages with this confidental bullshit is a perfectly legally safe thing to do and mailing list software should do it automatically. Yes, the goal is really to cause negative effect to those companies in the long term, by reducing employee productivity or other means. I am even thinking about reporting all e-mail with this confidental bullshit (which is usually significantly longer than the message itself) as spam. 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
Re: Font width in gtk 2.x
On Tue, Aug 07, 2007 at 05:08:17PM +0200, [EMAIL PROTECTED] wrote: Iam porting my application from gtk 1.x to gtk 2.x what is th eqivalent api for gdk_string_width(widget-style-font,m) in gtk 1.x in gtk 2.x I want to dynamicly set the size for Entry Widgets the lenghts of the selected Font of the application. gtk_entry_set_width_chars() cannot be used? 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
Re: Who to replace deprecated functions
On Fri, Aug 03, 2007 at 06:13:08PM +0200, Joerg Anders wrote: 2.) How can I replace gtk_menu_append()? In concrete case I want to add and remove some GtkMenuItems dynamically. After a long search I found that a combination of: gtk_action_group_add_action(...) gtk_ui_manager_add_ui_from_string(...) can append a new menu item. But how can I remove a menu item? This one is easy: gtk_ui_manager_add_ui_from_string() returns a merge id. And that's what you pass to gtk_ui_manager_remove_ui() remove it again. 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
Re: Xlib: unexpected async reply (sequence #####)!
On Sat, Aug 04, 2007 at 09:38:25PM +0800, Gregory Hosler wrote: I have a threaded gtk application. The threads create some gui (gtk widgets/windows). and most of the time (maybe 80%) everything works as expected. Occassionally I will get the message on stdout Xlib: unexpected async reply (sequence #)! the ### is an x event sequence number I am suspecting that this is because of the x calls from 2 different threads. Is this a known problem? Any way around this ? (I thought gtk was supposed to be thread ok :) The answer depends on your defintions of `OK', `known' and `problem': - Gtk+ is thread-aware - Gtk+ is not thread-safe If you operate on the GUI from multiple threads: - you are responsible for the locking on Unix/X - it will just not work on MS Windows See http://developer.gnome.org/doc/API/2.0/gdk/gdk-Threads.html People typically operate on the GUI only from the main thread (i.e. running gtk_main()) and pass work requests to it via g_idle_add() or some other queue mechanism. This topic is discussed here every other week, see the list archives. 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
Re: Question about signals in GObject
On Sun, Jul 29, 2007 at 12:45:38PM +0200, Tomasz Jankowski wrote: My code looks like this, please tell me if it may occur any memory allocation errors: A = g_alloca (); g_signal_emit(..., A and other args); g_free (A); If you call g_free() on g_alloca()-allocated memory, errors will occur. 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
Re: Compiling simple GTK+ input methods
On Sat, Jul 28, 2007 at 04:21:54AM -0400, Kyle James Cardoza wrote: Now, I've tried. My google-fu has failed me. Googling is pointless, if you have the Gtk+ Makefile that compiles the input methods... What I've got is a single .c file, containing a GTK+ input method for Eastern Ojibwe, using Canadian Aboriginal Syllabics. I based it on the GTK+ Inuktitut IM. What I want is to compile that .c file into a GTK+ input method, so I can test it, debug it, etc. I asuume you have config.h or removed #include config.h and gtk/gtkintl.h is replaced with glib/gi18n.h (or the header copied from Gtk+ sources). (a) Manually libtool --mode=compile cc $(pkg-config --cflags gtk+-2.0) -DGETTEXT_PACKAGE=\gtk+\ -DGTK_LOCALEDIR=\$(pkg-config --variable=prefix gtk+-2.0)/share/locale\ -Wall -W -g -O2 -c iminuktitut.c libtool --mode=link cc $(pkg-config --cflags --libs gtk+-2.0) -Wall -W -g -O2 -avoid-version -module -rpath $(pkg-config --variable=libdir gtk+-2.0)/gtk+-2.0/$(pkg-config --variable=gtk_binary_version gtk+-2.0)/immodules -o iminuktitut.la iminuktitut.lo libtool --mode=install install -c iminuktitut.la $(pkg-config --variable=libdir gtk+-2.0)/gtk+-2.0/$(pkg-config --variable=gtk_binary_version gtk+-2.0)/immodules/iminuktitut.la (b) Properly Copy the relevant delcarations from Gtk+'s modules/input/Makefile.am, add the corresponding configure and it will compile. The only non-obvious trick may be finding out the Gtk+ binary version for determining the installation directory with pkg-config --variable=gtk_binary_version gtk+-2.0 (you should put all this configuration into proper configure tests of course). 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
Re: .desktop files and Makefile.am
On Fri, Jul 27, 2007 at 02:01:23PM +0100, [EMAIL PROTECTED] wrote: On 7/27/07, Dani [EMAIL PROTECTED] wrote: I'm changing the main Makefile.am and putting the .desktop in the main project folder.. but without success :( I have something like: install-exec-hook: $(mkinstalldirs) ${DESTDIR}$(datadir)/applications -cp poop.desktop ${DESTDIR}$(datadir)/applications Though there's probably a better (always seem to be true with auto*). Yes, manual cp is almost never necessary (also mkinstalldirs is a bit obsolete now, use mkdir_p). To create an install/uninstall rule couple, just add fooappdir = $(datadir)/applications fooapp_DATA = foo.desktop You can also add something like install-data-hook: $(UPDATE_DESKTOP_DATABASE) $(DESTDIR)$(datadir)/applications $(UPDATE_MIME_DATABASE) $(DESTDIR)$(datadir)/mime uninstall-hook: $(UPDATE_DESKTOP_DATABASE) $(DESTDIR)$(datadir)/applications $(UPDATE_MIME_DATABASE) $(DESTDIR)$(datadir)/mime but this should be inside an automake conditional -- first, desktop-file-utils might be unavailable so they need a configure check, second, this is counterproductive when building a distro package and installling into a staging area. None of this is actually related to Gtk+... 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
Re: Locking the width of a column in a tree view
On Tue, Jul 24, 2007 at 10:48:16AM -0600, Kevin DeKorte wrote: I would like to make it so that the first column is the column that is stretched and the second column remains the smallest size it can be based on contents and font. gtk_tree_view_column_set_expand() 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
Re: Image Loading Problem on Windows Box
On Tue, Jul 24, 2007 at 10:10:27PM +0100, Gavin Keighren wrote: I am in the process of porting a very simple program from OS X (X11) to Windows (please don't ask why, it's not my choice). The program compiles without any errors on both systems (and also works for the main part). However, the program is meant to display an image, but the Windows version will not load the file. My (limited) understanding is that the image loader is not being linked properly, but without any error messages from the linker, I am not sure how to fix it. I have tried linking with a range of libraries, and the path to the required loader is part of the appropriate environment variable. I have also tried various forms of the filename string, to no avail. The code which should load the file is: GtkPixbuf * logoBuffer = gdk_pixbuf_new_from_file(images/logo.jpg, NULL); although the following also does not work (a broken image graphic is displayed): GtkWidget * logo = gtk_image_new_from_file(images/logo.jpg); The only other reason I can think of, is that I am using the wrong compiler. I am currently using Microsoft's cl compiler version 14.00.50727.42. I had tried Borland's C compiler, but that threw up a whole host of problems with linking to DLLs. Any help would be greatly appreciated, For start, have you tried to pass a GError to gdk_pixbuf_new_from_file() and look at the error you get? 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
Re: How Tab brings widgets into focus
On Tue, Jul 17, 2007 at 10:25:42PM -0700, varun_shrivastava wrote: i tried to find out how pressing Tab key brings widgets into focus, but couldn;t find out. Start at the end of gtk_window_class_init() where add_arrow_bindings() and add_tab_bindings() are called and follow from there... it should lead you to places such as gtk_container_focus(). Yeti -- http://gwyddion.net/ ___ gtk-devel-list mailing list gtk-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-devel-list
Re: Designing objects with GObject
On Fri, Jun 29, 2007 at 06:39:47PM +0800, Konstantin Evdokimenko wrote: If you will make properties of interface C writable and readable in object A and only readable in object B then objects A and B will not implement the same interface. The common interface is the read-only property here, A implements an extension: read-write. Try ignore writing these properties for object B. But I don't know how this may be done =(. You can do this, as you control set_property(). The problem is that this is a hack invisible to inspection, therefore it can lead to all sorts of odd behaviour. 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
Re: Designing objects with GObject
On Fri, Jun 29, 2007 at 12:25:38PM -0400, Tristan Van Berkom wrote: If you want to override the default value or read/write flags on a property you can simply re-install it in the subclass. Basically, your implementing class can g_object_class_install_property and if its the same name it will replace whatever properties were installed by parent classes or interfaces. Why this isn't written anywhere... sigh 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
Re: Problem with gtk_label_set_text
On Thu, Jun 28, 2007 at 09:07:06AM +0530, Divya yadav wrote: I am using gtk_label_set_text in a dynamic gui and label keeps on changing around 1-2 times every second.My program crashes because of this. Why I can't see the backtrace in your post? Not even any code? You don't even say whether the program is single- or multi-threaded. Calling gtk_label_set_text() 1-2 times per second does not crash programs. That's a fact. If you program crashes, it contains bugs. Use valgrind and/or your preferred gdb frontend to debug it. This is all one can say based on the detailed information you provided. 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
Re: Problem with gtk_label_set_text
Please don't top-post. On Thu, Jun 28, 2007 at 02:38:01PM +0530, Divya yadav wrote: Forgot to mention again its a multithreaded program It is not possible to randomly call Gtk+ function from multiple threads. Either queue all updates to be performed in the main thread (i.e. the one running gtk_main()) for instance via g_idle_add(), or add locking with gdk_gthreads_enter(), gdk_gthreads_leave() -- and note the latter will still not allow you to call Gtk+ function from multiple threads on MS Windows. For details, see the mailing list archives, this topic is discussed twice a week. 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
Re: geometry hints screwing up window sizes
On Wed, Jun 27, 2007 at 05:03:48PM -0700, David J. Andruczyk wrote: I have an app that creates a window. inside this window is an eventbox and inside that is a GtkFixed (no slapping me for using a GtkFixed, it works well for this purpose) I want to be a be able to scale the window to ANY size. (yes i know the fixed widget doesn't handle scaling, I plan on handling that once i can sort out the resizing problems) I've used gtk_window_set_geometry_hints to set the aspect ratio, and minimum size. The problem is the windows ALWAYS default displays at the minimum size. NOT at a size I specify using (gtk_window_resize) or similar. If I do NOT set the minimum geometry hint. I CAN set the size to be larger than the Fixed widget (with its children). All I want to be able to do is tell GTK/window manager that there's a window that can be no smaller than 100x100 and no larger than 1000x1000, and I want ot be able ot set the size to any point in between those extremes. (GTK ignores me, when using the hints) any ideas? Where exactly is the problem? This works flawlessly for me: === #include gtk/gtk.h #include gdk/gdkkeysyms.h static gboolean key_press(GtkWidget *widget, GdkEventKey *event) { if (event-keyval = GDK_0 event-keyval = GDK_9) { gint size = 60*(event-keyval - GDK_0 + 1); gtk_window_resize(GTK_WINDOW(widget), size, size); return TRUE; } return FALSE; } int main(int argc, char *argv[]) { GtkWidget *window, *fixed, *widget; GdkGeometry geometry = { 60, 60, 600, 600, 0, 0, 0, 0, 0.0, 0.0, 0 }; gint i; gtk_init(argc, argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); fixed = gtk_fixed_new(); gtk_container_add(GTK_CONTAINER(window), fixed); for (i = 0; i 33; i++) { widget = gtk_label_new(Bloody); gtk_fixed_put(GTK_FIXED(fixed), widget, g_random_int_range(0, 560), g_random_int_range(0, 590)); } gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, geometry, GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE); gtk_window_set_default_size(GTK_WINDOW(window), 300, 300); g_signal_connect(window, destroy, G_CALLBACK(gtk_main_quit), NULL); g_signal_connect(window, key-press-event, G_CALLBACK(key_press), NULL); g_print(Press 0-9 to resize me.\n); gtk_widget_show_all(window); gtk_main(); return 0; } === 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
Re: Designing objects with GObject
On Thu, Jun 28, 2007 at 01:54:29PM +0200, Tomasz Jankowski wrote: I have such situation. I have two objects A and B and interface C, which should be implemented by both of them. The problem is that some of properties of interface C should be writable and readable in object A and only readable in object B. Is there any way to keep them in interface C and don't do any ugly tricks to go around GObject rules? I really don't want to implement separately for both objects. You will use g_object_class_override_property() anyway. Doesn't it allow to make a READABLE proeprty READWRITE? 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
Re: motion-notify-event works only once
On Wed, Jun 27, 2007 at 05:46:57PM +0200, Jerome Blondel wrote: I've set up a motion-notify-event handler in a GtkDrawingArea, adding the POINTER_MOTION and POINTER_MOTION_HINT event masks to the widget. The event is triggered only when the pointer moves into the window. I'd like to receive an event for each movement of the pointer. Is there something I might have missed, Yes, the fact that no one knows what your code really does if you don't post it. Anyway, this works: #include gtk/gtk.h static gboolean motion(GtkWidget *area, GdkEventMotion *event) { if (event-is_hint) { gint x, y; gdk_window_get_pointer(area-window, x, y, NULL); g_print(Motion (hint): %d %d\n, x, y); } else g_print(Motion: %g %g\n, event-x, event-y); return FALSE; } int main(int argc, char *argv[]) { GtkWidget *window, *area; gtk_init(argc, argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(window, destroy, G_CALLBACK(gtk_main_quit), NULL); area = gtk_drawing_area_new(); gtk_widget_add_events(area, GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK); gtk_container_add(GTK_CONTAINER(window), area); g_signal_connect(area, motion-notify-event, G_CALLBACK(motion), NULL); gtk_widget_show_all(window); gtk_main(); return 0; } The thing you *possibly* forgot is to call gdk_window_get_pointer() which you have to as you explicitly asked -- by using GDK_POINTER_MOTION_HINT_MASK -- not to get any further events until you call gdk_window_get_pointer(). 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
Re: Gtk with .po files
On Tue, Jun 26, 2007 at 02:53:26PM +0530, Kumar Siddharth wrote: http://inti.sourceforge.net/tutorial/libinti/internationalization.html Ignore the inti parts there, though. I'd rather point to http://www.gnu.org/software/gettext/manual/gettext.html and after groking the basic concepts, look at any internationalized Gtk+ application as working real world examples are better than tutorials. 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
Re: FW: Text wrapping along with ellipsizing
On Tue, Jun 26, 2007 at 02:10:51AM -0700, Suma H.S wrote: Does anyone know how to have text wrapping along with ellipsizing? I want to have text wrapped to three lines and have ellipsis in the last line if the text exceeds three lines. I have used GtkLabel and set the properties for both wrapping and ellipsizing. The problem that I am facing is that if I try to wrap the text and ellipsize, the text gets reduced to a single line and the ellipsis appear. Yes, in ellipsize mode, every `paragraph' (run of text without any forced break) is ellipsized to fit the width. You can probably achieve this ellipsization by using the more low-level functionality. Iterating over PangoLayoutLines and rendering them yourself can be a bit too low-level, however, obtaining PangoLayoutLines and then inserting corresponding hard newlines into the original text and reflowing can give an acceptable result if lines are broken only between `words' (whatever it means for the script). You can also try to measure the three lines, limit the rendering area accordingly, and then uses some graphic effect such as fade out instead of ellipsis. Or something like that. 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
Re: Getting a GDK_CONFIGURE event from a GtkImage
On Tue, Jun 26, 2007 at 11:28:48AM -0600, Jim George wrote: I'll take that back, the handler keeps getting called even if I block it before calling gtk_image_set_from_pixbuf. If I disconnect it, it doesn't get called again. Seems like the allocate-event occurs with some delay after gtk_image_set_from_pixbuf is called. It does a round-trip through the X server, so the allocation is performed after you return from the signal handler. I do not follow this thread, but can't you just compare the new allocation to the current one and do nothing when they are equal? 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
Re: macro IS_xxx
On Sun, Jun 24, 2007 at 09:48:01AM +0200, Andrea Zagli wrote: i have GObject A and GObject B; B is a A's subclass obj_a = a_new (); obj_b = b_new (); (a_new() and b_new() return GObject) when i call IS_OBJECT_A (obj_b) it returns TRUE: why? Because obj_b *is* also an instance of A. That's the whole point of subclassing. To check the exact type you can get it with G_TYPE_FROM_INSTANCE and compare. However, in most cases needing this means there's something wrong with your design. is it a bug? or is it normal? Show me a single object system implementation that behaves differently in this regard... 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
Re: Proper Handling of GtkTreeModelFilters
On Fri, Jun 22, 2007 at 02:47:30PM -0400, Matthew Yaconis wrote: I have an underlying model for a TreeView in my application that I am filtering based on certain user selections. I maintain a global reference to the base TreeModel (which is sometimes attached to the TreeView used to display the information.) The mechanism I am using goes something like this: 1. User selects a new filter criteria 2. (Depending on the selection) Either a) gtk_tree_model_filter_new to create a new filter based on the user's criteria from the global base model or b) use the base model. 3. gtk_tree_view_set_model( [selected model]) GtkTreeModelFilter does not contain much data to preserve. So, to get a different filter, just take the current filter and call gtk_tree_model_filter_set_visible_func() or gtk_tree_model_filter_set_modify_func() on it -- or change the private data the filter uses and call gtk_tree_model_filter_refilter(). And instead of switching to the base model you can set the visible func to one that always returns TRUE (for some reason it is not possible to set the filter functions back to NULL). This saves you testing whether to convert iters and paths or not as you convert them always. I only physically replace the filter if the virtual root has to change as it is construction only property. Sometimes one has a handful of well-defined (semi)fixed filters that it makes sense to keep around, but usually not. I was thinking this is probably leaving a bunch of filtered tree models around that aren't doing anything but taking up space...do I need to be g_object_unref'ing the old filter models? I attempted a replace function that looks something like: void replaceTreeModel(GtkTreeModel *model) { GtkTreeView *treeview = [get the widget]; GtkTreeModel *currentModel = gtk_tree_view_get_model(treeview); gtk_tree_view_set_model( treeview, model ); // The following makes the application unstable and crash in the filter function so I've commented it out for now //if (GTK_IS_TREE_MODEL_FILTER( currentModel)) //{ // g_object_unref( G_OBJECT(currentModel)); //} } What holds references to currentModel after the gtk_tree_view_set_model() call? GtkTreeModelFilter is created with reference count 1, so you should be left with this inital reference at the end -- but only if you didn't released it earlier. And if you did, then currentModel is already destroyed when you try GTK_IS_TREE_MODEL_FILTER(). It's hard to deduce anything from such code fragment. If you don't need to keep the filters around, it's probably easiest to release the inital reference immediately after you do gtk_tree_view_set_model() and do not care about them any more as they will be destroyed automatically once nothing needs them. 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
Re: GtkTreeView in a Scrolled Window
On Wed, Jun 20, 2007 at 12:38:31PM +0530, Divya yadav wrote: I tried adding a Treeview inside a scroll window. and i am updating my treeview using *gtk_list_store_prepend *it is working fine but the scrollbar is also moving along with these updates by the end of all updates it is somewhere in the middle of the list. My application area screen is 240X320 and i have to maintain a scrollabel list with loads of data. everything is wroking fine except that new rows are getting appended on the top but are not visible to me until i scroll up manually till there.My need is to show the latest row added always so that my screen looks updated. http://developer.gnome.org/doc/API/2.0/gtk/GtkTreeView.html#gtk-tree-view-scroll-to-cell 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
Re: Invalid UTF-8 string being sent to callback function on toggled signal from GtkCellRendererToggle
On Wed, Jun 20, 2007 at 05:52:04PM -0400, Justin Stallard wrote: The subject pretty much says it all. The tree path string that is being sent to my callback function as a result of the toggled signal from a GtkCellRendererToggle in a GtkTreeView is an Invalid path. The following is the output to the terminal upon toggling one of the GtkCellRendererToggle(s), followed by the code that will reproduce this problem. What am I doing wrong? A `*' is missing in on_cell_renderer_toggle_toggled() delcaration. 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
Re: GSlice: g_thread_init() must be called before all other GLib functions;
On Tue, Jun 19, 2007 at 03:53:30PM +0200, John Zoidberg wrote: I get the following error message when running my GTK app: GSlice: g_thread_init() must be called before all other GLib functions; memory corruption due to late invocation of g_thread_init() has been detected; this program is likely to crash, leak or unexpectedly abort soon... I read herehttp://blogs.gnome.org/timj/2007/01/02/28122006-g_slicedebug-blocks/that the correct workaround is to call g_thread_init(NULL). This is a bit taken out of context. This is not so much of a workaround as something you always have to do when you use threads. And you have to do this very early. And the problem was that even if people were told to do this very early, they didn't (because it had used to work and because sometimes the responsibility was not clear) -- and then GSlice came and made programs that did not call g_thread_init() early actually break. If you do not use threads, nothing of this concerns you. However, when I try to do that I get an undefined reference to g_thread_init error. And this happens even if I include glib.h. I did a grep on the header files I have in /usr/include and got this: glib-1.2/glib.h:void g_thread_init (GThreadFunctions *vtable); glib-2.0/glib/gthread.h:voidg_thread_init (GThreadFunctions *vtable); glib-2.0/glib/gthread.h:voidg_thread_init_with_errorcheck_mutexes (GThreadFunctions* vtable); glib-2.0/glib/gthread.h:#define g_thread_init(vtable) g_thread_init_with_errorcheck_mutexes (vtable) glibmm-2.4/glibmm/thread.h: g_thread_init(vtable); grep: warning: lua50/lua: recursive directory loop So I added the corresponding headers: #include glib-2.0/glib/gthread.h #include glib-1.2/glib.h Well, this is extremely fishy. Are you trying to use GLib 1.2 and 2.0 simultaneously in one program? This will not work. After some printf debugging, I traced the origin of the warning to the creation of a filechooser button. And when I create a new GTK project with Anjuta+Glade2 and place a filechooser button, I do indeed always get this warning. How can I get rid of this warning the correct way? For start, get rid of everything GLib-1.2-ish. This itself can fix the problems. Or maybe not. Where am I supposed to place the g_thread_init() call? If you use threads, or something you use uses threads, then before any other GLib call, or call to something that uses GLib (for instance to Gtk+). The very first line of main() can be a good place. And you have to add `gthread-2.0' to the list of pkg-config packages your program depends on (have no idea how to do this in Anjuta or Glade, but it typically should appear in an argument of PKG_CHECK_MODULES() in configure.ac at the end). 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
Re: multi thread app and often variable accessing
On Fri, Jun 08, 2007 at 09:27:38PM +0200, David Nečas (Yeti) wrote: Attempts to use atomic operations without considering memory [*] access ordering guarantee subtle bugs... [*] as a substitute for locking. 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
Re: multi thread app and often variable accessing
On Fri, Jun 08, 2007 at 08:51:08PM +0200, Jonathan Winterflood wrote: If you don't know what memory ordering, barriers, etc. [...] Indeed I don't know what these are either. Any chance that someone does? See Documentation/memory-barriers.txt in Linux source code, on-line available for instance at http://www.mjmwired.net/kernel/Documentation/memory-barriers.txt for a good overview of the concepts and issues. The later parts of the document are kernel specific, but you may get more information than you want even before you get to these parts. Attempts to use atomic operations without considering memory access ordering guarantee subtle bugs... 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
Re: Buttons in groups
On Thu, Jun 07, 2007 at 07:25:13AM +0100, Christopher Garrett wrote: Is there a way of placing a GtkToggleButton into a group so that when one button is selected the others in the group automatically get unselected? By using GtkRadioButtons? 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
Re: Buttons in groups
Please don't top-post. On Thu, Jun 07, 2007 at 07:41:42AM +0100, Christopher Garrett wrote: I should have said that its for groups of tools, and I'd like to have icons on the buttons - I'm not sure that GtkRadioButtons can use icons, but if they can they'd be perfect for me. GtkRadioButton is a GtkContainer (as any button) and can contain anything, just don't use the convenience cosntructors and pack the icon or whatever yourself. And see also gtk_toggle_button_set_mode(). You should also consider GtkToolbar if you want to create a toolbar... 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
Re: Setting G_SLICE=always_malloc at runtime
On Thu, Jun 07, 2007 at 08:04:08PM +0100, Raja Mukherji wrote: I'm writing a binding for Gtk to my programming language Wrapl, and want to make sure that all memory is allocated by the Hans-Boehm garbage collector. The glib/gobject shared libraries are loaded dynamically and I call g_mem_set_vtable to change to GC_malloc, GC_realloc, GC_free, etc. However g_slice doesn't use these. I know that setting the environment variable G_SLICE to always_malloc will solve this, but I want to do this at runtime, just after the relevant shared libraries are loaded, but before they are used (basically at the same time as when I'd call g_mem_set_vtable). Is this possible? GSlice is initialized, i.e. it looks at G_SLICE, on the first use or when thread support is initialized. So just set the variable before that. 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
Re: Segmentation fault while reading from entry.
On Sun, Jun 03, 2007 at 12:28:03PM +0200, Szymon Ząbkiewicz wrote: I'm am new to gtk+ and I try to write a simple application, I need to read a double from an entry, I've already written a parsing *char-double function Is it really necessary to write yet another floating point number parser? You have a whole range of functions from atof and strtod to sscanf to g_ascii_strtod() available. but I can't even read from the entry using gtk_editable_get_chars because I get Segmentation Fault. I don't know what is the reason for this, so I'll post parts of the code so that you could help me in finding the bug: ... The function signature... void calculate_cb(GtkWidget *widget, GdkEvent *event, gpointer data) ...does not match the prototype of the callback g_signal_connect(G_OBJECT(main_window-calc_btn), clicked, G_CALLBACK(calculate_cb), main_window); GtkButton::clicked has no GdkEvent* argument http://developer.gnome.org/doc/API/2.0/gtk/GtkButton.html#GtkButton-clicked as it is not an event signal. Looking at the backtrace with gdb and looking at the values you expected the function to get, you could see calculate_cb() got main_window as its second argument, not third, which could be a sufficient hint to check the function signatures -- just an advice for the future... 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
Re: gtk+ about dialog doesn't close
On Sat, Jun 02, 2007 at 07:26:02AM +0200, John Zoidberg wrote: I have a problem with the gtk about dialog: When I click on the Close button it doesn't close. There seems to be no event connected to the close button clicked signal. And I can't add one either in Glade (v2 as well as v3). What am I supposed to add to the code so that it works? Connect to response signal of the about dialog and if the response id is one of GTK_RESPONSE_CLOSE (Close button should emit this) GTK_RESPONSE_CANCEL (but Close button actually emits this) GTK_RESPONSE_DELETE_EVENT (closed by window manager means) destroy/hide/whatever the dialog. I find GtkAboutDialog a textbook example of second system effect -- I mean an about dialog with several nested subdialogs, at least one of them tabbed? The complete user interface of some applications is simplier than GtkAboutDialog. 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
Re: Clear A Pixmap
On Fri, Jun 01, 2007 at 05:38:54PM -0700, nahuel9728 wrote: Thaxs Yeti for the answer but Sorry I'm not able to do it. I explain a little bit what im doing and i would like to do: main(){ mem_map=gtk_drawing_area_new(); gtk_signal_connect (GTK_OBJECT (mem_map), expose_event,(GtkSignalFunc) expose_event, NULL); gtk_signal_connect (GTK_OBJECT(mem_map),configure_event,(GtkSignalFunc)configure_event, NULL); gtk_signal_connect (GTK_OBJECT (mem_map), button_press_event,(GtkSignalFunc) button_press_event, NULL); /*A button to erase all the drawed and paint things*/ boton = gtk_button_new_with_label (Clear and paint); gtk_signal_connect_object (GTK_OBJECT (boton), clicked,GTK_SIGNAL_FUNC (clear_and_paint),GTK_OBJECT (main_window)); show } void expose_event(){ gdk_draw_pixmap } void clear_and_pain(GtkWidget *widget, GdkEventExpose *event){ /*HERE I WANNA CLEAN ALL MY DRAWED AREA*/ gtk_widget_queue_draw_area(GTK_WIDGET(mem_map),0,0,910,440); /*This up should clean all the area??? */ /*And later draw things.*/ draw_brush(); } Any idea anyone??? Has done somthing similar Sorry, this is a mess, I have no idea what you are doing. However, you seem to started from the Gtk+ scribble example, so here's a patch to scribble-simple.c that adds a Clear button: === --- scribble-simple.c.orig 2007-05-02 18:27:36.0 +0200 +++ scribble-simple.c 2007-06-02 12:25:02.0 +0200 @@ -115,12 +115,21 @@ exit (0); } +static void +clear(GtkWidget *widget) +{ +gdk_draw_rectangle(pixmap, widget-style-white_gc, TRUE, + 0, 0, + widget-allocation.width, widget-allocation.height); +gtk_widget_queue_draw(widget); +} + int main( int argc, char *argv[] ) { GtkWidget *window; GtkWidget *drawing_area; - GtkWidget *vbox; + GtkWidget *vbox, *hbox; GtkWidget *button; @@ -164,16 +173,19 @@ | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK); - /* .. And a quit button */ - button = gtk_button_new_with_label (Quit); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - - g_signal_connect_swapped (G_OBJECT (button), clicked, - G_CALLBACK (gtk_widget_destroy), - G_OBJECT (window)); - gtk_widget_show (button); + hbox = gtk_hbox_new(TRUE, 0); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); + + button = gtk_button_new_with_label(Clear); + gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0); + g_signal_connect_swapped(button, clicked, G_CALLBACK(clear), drawing_area); + + button = gtk_button_new_with_label(Quit); + gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0); + g_signal_connect_swapped(button, clicked, + G_CALLBACK(gtk_widget_destroy), window); - gtk_widget_show (window); + gtk_widget_show_all(window); gtk_main (); === 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
Re: Virtual list boxes (using GtkTreeView or other)
On Fri, Jun 01, 2007 at 03:47:36PM +0100, Nuno Lucas wrote: You have to derive your own GtkTreeModel, if the predefined GtkListStore or GtkTreeStore are not sufficient (They simply stores all data at once). I may be missing something, but I don't see a way to set the number of virtual rows. See http://gwyddion.net/documentation/head/libgwydgets/GwyNullStore.php for a simple purely virtual store. This is a cheap hack, but it demonstrates the point IMO. From what I see in the documentation, the only way to grow is by appending a single row at a time (which I guess then emits the row-changed signal and updates the scrollbar). You are mixing two things here: - if the model grows is must emit the row-inserted signal, because if it does not do this, the tree views showing it break - however, if no one is watching, namely when the model is created, it can be instantaneously created with a million of rows There are more troubles with huge tree views, namely the tree view needs to know the sizes of the columns and rows -- even those not currently visible as they still affect what is visible. So you will probably end up using all the confusing fixed size modes, and avoiding work in cell data functions for invisible cells. However, for a milion of rows scrolling through the tree manually is no longer useful anyway, i.e. the user interface ceases to be suitable for the task. You may want to use a multilevel or search+paging base interface instead -- essentially something that avoids the signle list with a million of rows by design. 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
Re: Clear A Pixmap
On Thu, May 31, 2007 at 03:35:07PM -0700, nahuel9728 wrote: I explain my thing... I have a pixmap, a drawing area. There are events that draw on it. But i have a button that must clear, erase all the painted on the drawing area. Any idea how to make it happen Make the drawing area repaint (e.g. with gtk_widget_queue_draw()) and just do not draw anything there in the expose-event handler this time. 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
Re: Shared or dynamic?!
On Wed, May 30, 2007 at 07:59:40AM +0200, Tomasz Jankowski wrote: I'm going to write network library hardly based on GLib to improve my programming skills. However I haven't wrote any library so far, so I haven't got any experience with it. :( After reading libtool documentation I became a bit confused, because I don't know what kind of library should I build. My library should be linked with program while compilation process, not loaded during runtime, Why? (If the library is private to one package, that counts as a reason, but see below.) so I thought, that I must build a static library, but libraries such as GTK+ or GLib in /usr/lib directory have *.so prefix. I don't understand it... :( These are shared libraries. In most cases shared libraries are what you want. Can someone explain it for my? What kind of library should I build? If the library will be used only inside one package, build it as a libtool convenience library. Otherwise build shared, static or both depending on what the user wants. This works automatically, AC_PROG_LIBTOOL adds corresponding options to configure, with the default to build both types (provided that it's possible on the target platform). 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
Re: Window receiving button-release-event
On Wed, May 30, 2007 at 03:25:12PM +0200, Peter Daum wrote: I have a dialog that represents some sort of database values. The dialog has a save button, that I would like to enable only if the dialogs data differs from the stored data. I wrote an appropriate is_modified function that checks this. Now I am looking for the right event slot to run this function after every action that might have changed some widget's value. There is no way to change anything without either a mouse button or a key press. And what if someone invents other methods? (And they already exist, for instance you can change the contents of entries with DnD. And assistive technologies may have other means too.) Is the mechanism of the change crucial, or at least relevant? No. You want to know whether the value changed. Every Gtk+ widget that enables to enter/change values has a signal, or several signals, emitted when the value changes. So connect to these signals and you are done. In addition, you will not be checking whether something has changed every time user interacts with the window in a way that does not change anything. I hoped, the following should do the job, without having to mess with all the single child widgets ... `Messing with the widgets' is the conceptually correct approach, whereas what you try is `these thing often occur together so let's pretend thy are one'. $self-add_events(button-release-mask); $self-signal_connect_after(button-release-event, $check_modified); $self-signal_connect_after(key-release-event, $check_modified); The key-release part works as intended, but for some reason, I don't get any button-release event that occurs within a child widget that is also interested in button-release (i.e. pretty much everything except frames and labels). The GTK documentation says about signal_connect_after: The handler will be called after the default handler of the signal instance, so I hoped it should work even when there is another signal handler installed. This would be true for non-event handlers. Once an event handler returns TRUE the event is considered handled and the remaining handlers are never run. 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
Re: How to add stuff to treeviews??
On Tue, May 29, 2007 at 08:15:40AM +0800, Jason Brisbane wrote: I too am trying to use a Treeview model view, etc. I have created a list store before and that works fine. Now I am creating a new program and want to create a Treeview with a parent iter and 6 set child iter (ie you create a new row and the row auto creates the 6 children underneath) But I am having trouble doing ANYTHING with the treeview. Cut/paste the example from the gtk 2.0 API simply fails to do anything. I am left with a blank screen. inserting g_print shows that the code is being called, but nothing is being displayed. Since the gtk_tree_view is created in glade, I am simply doing a lookup_widget on the treeview and adding columns to it (ie none exist) and then populating the data. My code, very stripped down (to remove possible errors) is: Please post selfcontained (compilable) code. Anyway, you exchanged the child and parent iters in the tree store construction. 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
Re: GdkImage from GdkPixbuf
On Tue, May 29, 2007 at 11:04:53AM -0400, Tristan Van Berkom wrote: I've been beating my head against the tree for this one for the last 2 days... so, is there some code out there that will gdk_pixbuf_render_image() ? I actually dont even want compositing, something like: memcpy (image-mem, pixbuf-pixels, image-bpl * image-height) would do fine (minus the alpha channel)... but I can see its going to be a little more complex (taking byte order into account, image depths etc). If I have to end up writing this myself, are there any interesting bits of lowlevel gdk that will help me ? You can draw GdkPxibuf on a GdkDrawable (i.e. GdkPixmap) with gdk_draw_pixbuf() and get the contents of the GdkDrawable to a GdkImage with gdk_drawable_get_image() or gdk_drawable_copy_to_image(). On full Moon if it's even Tuesday. And it goes through the X server. Actually I think if you use GdkImage you deserve it... There are some useful bits in GdkRGB, but more in its source code than its API. And by bits I mean almost complete gdkrgb.c including the dithering matrices. 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
Re: Problem with gtk drawing primitive
On Mon, May 28, 2007 at 08:21:01PM +0200, Jerome Blondel wrote: I'm making a widget from scratch using the tutorial's GtkDial as a base. For now I just want to draw something in my widget. The following error occurs (test_sw:4242): Gtk-CRITICAL **: gtk_paint_polygon: assertion `style-depth == gdk_drawable_get_depth (window)' failed This is the code in the WIDGET_expose callback: blankstyle = gtk_style_new(); blankstyle-bg[GTK_STATE_NORMAL] = sw-color; gtk_style_set_background(blankstyle, w-window, GTK_STATE_NORMAL); gtk_paint_polygon(blankstyle, w-window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, w, NULL, points, 8, TRUE); Please could anyone help me with this problem? I suspect blankstyle = gtk_style_attach(blankstyle, w-window); is missing. 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
Re: Access to a single character in a button label
On Sat, May 26, 2007 at 03:11:24AM +0200, Jean-Louis Schmitt wrote: Is it possible to change the color or to underline only one character of a gtt_button label? Do you want to underline a character that is NOT a mnemonic character of the button? That would be highly confusing. Anyway, you can pack a GtkLabel into the button manually instead of using gtk_button_new_with...(), and you can use Pango markup in this label to change color, font or anything. 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
Re: How to build a GtkTree?
On Sat, May 26, 2007 at 04:17:58PM +0200, Guenther Meyer wrote: Am Samstag 26 Mai 2007 schrieben Sie: You need to insert rows with parents. Take a look at the definition of: gtk_tree_store_insert () if parent is null, the row will be a root row... if parent is non-null the row will be a child of parent. Yes, I know that. Maybe I have asked the wrong question... The problem is, I don't know the iter of the parent entry, that I have to use. You know it. In the example it's either the same parent iter as you used in the last insertion or it is the iter you *obtained* in the last insertion. If you want to go up a level, use gtk_tree_model_iter_parent(). Wwhat I need is the iter to a given entry; to say it in sql-style: SELECT iter FROM tree WHERE content=someparententry; How would you express content=someparententry? after that I can use the result value as parent for the new gtk_tree_store_insert statement. Is there a function for this, or did I miss something. If you want to search the whole tree using some custom condition, use gtk_tree_model_foreach(). That's not exactly efficient to do repeatedly though. If you can tell on each tree level what to look for (i.e. you don't have to search all leafs), you can easily walk through the tree and always descend one level when you find what you are looking for on that level -- AFAIK there's no function for that, it would be probably equally complicated to use as walking though the tree manually... 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