Re: Threads and idle functions
(sorry forgot list) On 3 July 2012 01:50, David Buchan pdbuc...@yahoo.com wrote: My understanding is that child threads must never alter the UI in any way. If I have a program which spawns a child thread to download some data and I want to be able to have a dialog pop up should an error occur, is it correct to say that I need an idle function to be running concurrently to monitor some global variable which would contain the status (set by the download thread), and then the idle function would create the dialog pop-up? Put another way, if only the GTK+ main iteration is allowed to alter the GUI, then how does someone get information out of a child thread and to the UI? Well from what I hear, g_idle_add offers some form of thread safety so a child thread can communicate some item of data via a callback executed in the GUI thread. The documentation also seems to support this view: http://developer.gnome.org/glib/2.31/glib-The-Main-Event-Loop.html#glib-The-Main-Event-Loop.description your child/download thread does the monitoring of the error status and when an error is found, use g_idle_add to wait some moments and then communicate the error to a callback. HTH, James. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Threads and idle functions
On 3 July 2012 02:10, James Morris jwm.art@gmail.com wrote: (sorry forgot list) On 3 July 2012 01:50, David Buchan pdbuc...@yahoo.com wrote: My understanding is that child threads must never alter the UI in any way. If I have a program which spawns a child thread to download some data and I want to be able to have a dialog pop up should an error occur, is it correct to say that I need an idle function to be running concurrently to monitor some global variable which would contain the status (set by the download thread), and then the idle function would create the dialog pop-up? Put another way, if only the GTK+ main iteration is allowed to alter the GUI, then how does someone get information out of a child thread and to the UI? Well from what I hear, g_idle_add offers some form of thread safety so a child thread can communicate some item of data via a callback executed in the GUI thread. The documentation also seems to support this view: http://developer.gnome.org/glib/2.31/glib-The-Main-Event-Loop.html#glib-The-Main-Event-Loop.description Forgive me if I speak as if the thread safety of g_idle_add is something to be doubted. Multi-threaded applications are typically complicated affairs and the ease of use of g_idle_add rather contrasts with my (non-professional) experience. That being said, there are probably limits to what can be accomplished using it but for basic use-cases such as these it is perfect. your child/download thread does the monitoring of the error status and when an error is found, use g_idle_add to wait some moments and then communicate the error to a callback. HTH, James. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
custom widget theme change problem
Hi, I have a custom GTK widget which renders using Cairo. In the expose callback gtk_widget_get_style is called to obtain colours to render the widget with some theme consistency. When a theme is changed (ie using gtk-chtheme) any of my custom widgets that are visible are not updated. However, after switching to a different notebook tab, I can see previously hidden instances of the custom widget have been updated (switching notebook tabs back again does not trigger update). Can anyone give any pointers as to what might be happening? Thanks, James. GTK 2.24.10 ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: custom widget theme change problem
Hello again, Seems to be a habit of mine here, I ask a question, don't get an immediate response and then look further into it and find some sort of solution... On 21 June 2012 10:42, James Morris jwm.art@gmail.com wrote: Hi, I have a custom GTK widget which renders using Cairo. In the expose callback gtk_widget_get_style is called to obtain colours to render the widget with some theme consistency. When a theme is changed (ie using gtk-chtheme) any of my custom widgets that are visible are not updated. However, after switching to a different notebook tab, I can see previously hidden instances of the custom widget have been updated (switching notebook tabs back again does not trigger update). Can anyone give any pointers as to what might be happening? I've found the culprit, or put another way, I've found what to comment out to fix the problem. In my custom_widget_realize callback it has the following code which if I comment out the last three lines of, the problem resolves: window = gtk_widget_get_parent_window (widget); gtk_widget_set_window(widget, window); g_object_ref (window); style = gtk_widget_get_style(widget); style = gtk_style_attach(style, window); gtk_widget_set_style(widget, style); It is code I updated from this old code (which won't compile with GTK_DISABLE_DEPRECATED etc): widget-window = gtk_widget_get_parent_window (widget); g_object_ref (widget-window); widget-style = gtk_style_attach (widget-style, widget-window); This old code (which uses GDK rather than Cairo) doesn't have any problem with theme changes... but without it the widgets aren't updated after theme changes. Scratching head.. James. Thanks, James. GTK 2.24.10 ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: custom widget theme change problem
On 22 June 2012 01:50, James Morris jwm.art@gmail.com wrote: Can anyone give any pointers as to what might be happening? I've found the culprit, or put another way, I've found what to comment out to fix the problem. In my custom_widget_realize callback it has the following code which if I comment out the last three lines of, the problem resolves: window = gtk_widget_get_parent_window (widget); gtk_widget_set_window(widget, window); g_object_ref (window); style = gtk_widget_get_style(widget); style = gtk_style_attach(style, window); gtk_widget_set_style(widget, style); Ok I discovered that solution to cause an alternative problem: Gtk-CRITICAL **: IA__gtk_style_detach: assertion `style-attach_count 0' failed Which caused me to the first two of the last three lines (ie without gtk_widget_set_style). The docs for gtk_style_attach say: Since this function may return a new object, you have to use it in the following way: style = gtk_style_attach (style, window) So what am I meant to do with it? thanks james. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
GtkFileChooser selection-changed signal emission on gtk_dialog_run()
Hi, I've got a problem with the selection-changed signal being emitted as soon as gtk_dialog_run is called on a GtkFileChooserDialog. I tried delaying connection of the callback until right before calling gtk_dialog_run but there were still four calls (in a row AFAICT) to the callback. I am now using g_timeout_add as a work-around to delay connection of the signal to my callback and thus prevent the four initial selection-changed emissions activating the callback. Is this normal? Is there a more standard way of doing this? I'm using GTK 2.24.10 in 64bit Arch Linux. Thanks, James. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GtkFileChooser selection-changed signal emission on gtk_dialog_run()
On 14 June 2012 16:54, James Morris jwm.art@gmail.com wrote: Hi, I've got a problem with the selection-changed signal being emitted as soon as gtk_dialog_run is called on a GtkFileChooserDialog. I tried delaying connection of the callback until right before calling gtk_dialog_run but there were still four calls (in a row AFAICT) to the callback. I am now using g_timeout_add as a work-around to delay connection of the signal to my callback and thus prevent the four initial selection-changed emissions activating the callback. To put this in context, it's for auto-previewing audio files. The simple implementation causes an audio file to be previewed when gtk_dialog_run is called* or when the current folder is changed in the chooser. By using a dont_preview boolean and connecting the current-folder-changed signal to a callback I can then use g_timeout_add to cancel the dont_preview flag. The flag must be set before gtk_dialog_run is called, and will always be set when the folder is changed. *provided the item initially selected in the chooser is an audio file. Is this normal? Is there a more standard way of doing this? I'm guessing it is normal/standard and that work-a-rounds are necessary if you want to do something like this. I'm using GTK 2.24.10 in 64bit Arch Linux. Thanks, James. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: gtk-app to search google scholar
On 22 May 2012 21:20, Rudra Banerjee bnrj.ru...@yahoo.com wrote: Dear friends, I am trying to make a gtk application that will create a bibtex. The problem is I am a novice in C/gtk programming(this will be only my 2nd programme in gtk). To do that, First and foremost, I need to search google scholar from the code. I tried using lynx and failed. Can anyone kindly show me a simple code in C that can fetch data from google scholar with Import into bibtex entry on? According to http://en.wikipedia.org/wiki/Google_Scholar#Features_and_specifications As of March 2012, Google Scholar is not yet available to the Google AJAX API. So I would guess there will not be any simple C code to achieve what you want. James. Best and Regards, -- Rudra Banerjee If possible, plz. don't send me MsWord/PowerPoint mails. Why? See http://www.gnu.org/philosophy/no-word-attachments.html ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: no luck with dialogs and ecrooolbars, and gtktext..
n Tue, Dec 20, 2011 at 02:52:10PM -0800, Gary Kline wrote: text = gtk_text_view_new(); gtk_container_add(GTK_CONTAINER(window),text); buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)); and fopen some file and display the text in the buffer. The question remains: how? what am i missing to display some miscellaneous words in the text window? http://www.gtk.org/documentation.php ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: 'irregular shaped' windows without deprecated gdk code or compositing
On 31 July 2011 23:24, James Morris jwm.art@gmail.com wrote: Hi, It appears that the 'irregularly shaped' windows which used to be possible by using now-deprecated GDK code even without full compositing available, are no longer possible using non-deprecated code. Using the old deprecated code, a GdkRegion could be created with the desired window shape (with the region defining fully transparent and fully opaque areas) and a call to gdk_window_shape_combine_region to bring it about. I've been trying to work around this but feel like a dog running in circles chasing my tail. gdk_window_shape_combine_region is not deprecated, but GdkRegion will be replaced in GTK3.0 with cairo_region_t for which there is no gdk_window_shape_combine_region equivalent. Furthermore the gdk_region_polygon call necessary to create the GdkRegion of the desired shape, is deprecated without replacement. So I look into gdk_window_shape_combine_mask instead, but gdk_bitmap_create_from_data is of course deprecated. The docs do at least suggest cairo alternatives, but none of which are compatible with gdk_window_shape_combine_mask. I'm just going to start looking into these functions: cairo_xlib_surface_create_for_bitmap as they *might* do what I wish. Please please tell me if there's anyway around this mess. I can't force or assume use of compositing. Cheers, James. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
'irregular shaped' windows without deprecated gdk code or compositing
Hi, It appears that the 'irregularly shaped' windows which used to be possible by using now-deprecated GDK code even without full compositing available, are no longer possible using non-deprecated code. Using the old deprecated code, a GdkRegion could be created with the desired window shape (with the region defining fully transparent and fully opaque areas) and a call to gdk_window_shape_combine_region to bring it about. I've been trying to work around this but feel like a dog running in circles chasing my tail. gdk_window_shape_combine_region is not deprecated, but GdkRegion will be replaced in GTK3.0 with cairo_region_t for which there is no gdk_window_shape_combine_region equivalent. Furthermore the gdk_region_polygon call necessary to create the GdkRegion of the desired shape, is deprecated without replacement. So I look into gdk_window_shape_combine_mask instead, but gdk_bitmap_create_from_data is of course deprecated. The docs do at least suggest cairo alternatives, but none of which are compatible with gdk_window_shape_combine_mask. Please please tell me if there's anyway around this mess. I can't force or assume use of compositing. Cheers, James. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Making widgets visible outside their containing window
2011/7/13 Felix H. Dahlke f...@ubercode.de: Thanks for your answers. I did fool around with a popup, but it would also overlap other windows, transient or not. Furthermore, I need it to move relative to the window if that is moved. Maybe it's best if I tell you what I'm trying to do in particular: I'm working on something like a tooltip. However, I don't think I can use normal tooltips, since I need to position it manually (actually, I need it to move out of the way if the mouse cursor approaches it). A popup sounds like the right way to do this, but I need to somehow wire the popup's movement to the window's movement. Is there an easy way to do that? Take a look at PHAT fan sliders. These are sliders which vertical-mouse-movement brings up a fan through which the user gains more precision in the slider position. The fans are not bounded by any window the widget is associated with. There might be some pointers in there for how to do what you want, but note it's unmaintained code by now, and also contains some deprecated code. http://phat.berlios.de/ James. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
gobject and gtk_widget_set_sensitive
Hi, I have a custom widget I've created which uses widgets from a 3rd party library. When I use gtk_widget_set_sensitive(my_widget, FALSE), some of the widgets from the other library remain sensitive. Is this a bug in the 3rd party library? Or should I be using a callback to handle the state-changed signal to set_sensitive on all the widgets? Cheers, James. ___ 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 GtkToolButton icon_widget on the fly
On 22 June 2011 05:43, James jamesstew...@optusnet.com.au wrote: Hi, I've been trying to change the icon_widget that's displayed for a toolbar button while the main window is displayed. I can't seem to get the actual image to change, although the functions that call gtk_tool_button_set_icon_widget(0 do get called. There's no warnings either. I do something like... GtkWidget *eject_widget; GtkWidget *eject_red_widget; GtkToolButton *eject_button; void green(void) { gtk_tool_button_set_icon_widget(eject_button, eject_widget); } void red(void) { gtk_tool_button_set_icon_widget(eject_button, eject_red_widget); } int main(int argc, char **argv) { snip GtkBuilder *builder; builder = gtk_builder_new(); gtk_builder_add_from_file(builder, stridemaster.xml, NULL); eject_widget = GTK_WIDGET(gtk_builder_get_object(builder, eject_tracker_image)); eject_red_widget = GTK_WIDGET(gtk_builder_get_object(builder, eject_tracker_red_image)); eject_button = GTK_TOOL_BUTTON(gtk_builder_get_object(builder, toolbutton_eject_tracker)); g_object_unref(G_OBJECT(builder)); gtk_widget_show(window); gtk_main(); snip } What am I missing? The problem might be to do with floating versus fixed references. GTK will usually unreference the images once it thinks they're finished with - ie when you change the icon, it will think you no longer wish to use the previous icon. Try calling g_object_ref_sink on all of the widget icons once you've created them, and then g_object_unref after you're done. James. Regards, James. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: How to make the toolbar button flashing
On 1 March 2011 08:20, Miroslav Rajcic raj...@sokrates.hr wrote: I am trying to make the Pause button flash (or show any similar behaviour similar to that) when the pause state is active. So far I tried many things, but none of these seem to work: - changing the button background color - changing the button stock icon Alternating between two different stock items is quite easy when you know how, but I had to ask here for help. If you have two images, --8--- img1 = gtk_image_new_from_stock( GTK_STOCK_MEDIA_PLAY, GTK_ICON_SIZE_SMALL_TOOLBAR); img2 = gtk_image_new_from_stock( GTK_STOCK_MEDIA_STOP, GTK_ICON_SIZE_SMALL_TOOLBAR); /* convert img1 and img2 from floating references which are deleted when no longer in use, to a normal reference. this prevents either of the images being deleted when we swap the play/stop button images. unref'd after gtk_main. */ g_object_ref_sink(img1); g_object_ref_sink(img2); --8--- then in your idle callback simply use gtk_button_set_image, alternating between the two images every time the function is called (ie you could use a static gboolean to track which button to show each time). then once gtk_main returns: --8--- gtk_main(); /* free the play stop images */ g_object_unref(img1); g_object_unref(img2); --8--- http://github.com/jwm-art-net/BoxySeq/blob/master/boxyseq_gui/gui_main.c - changing the button relief style Relevant code is following: //start timer to alternate the button state nBlinkButtonTimerID = g_timeout_add (900, flash_pause_button_timer, NULL); gboolean flash_pause_button_timer(gpointer data) { static bool bFlipFlop = false; bFlipFlop = !bFlipFlop; //get pointers to the relevant buttons GtkToolbar *toolbar2 = (GtkToolbar *)lookup_widget(window1, toolbar2); GtkWidget *tool_pause = (GtkWidget *)gtk_toolbar_get_nth_item(toolbar2, 2); GList *children1 = gtk_container_get_children(GTK_CONTAINER(tool_pause)); GtkButton *button = (GtkButton *)g_list_nth_data (children1, 0); g_list_free(children1); GtkWidget *tool_stop = (GtkWidget *)gtk_toolbar_get_nth_item(toolbar2, 1); //create two alternating colors (standard bkg and black bkg) GtkStyle* style = gtk_rc_get_style(tool_stop); GdkColor rgbStart = style-bg[GTK_STATE_NORMAL]; GdkColor rgbEnd = { 0, 0, 0, 0 }; //modify color gtk_widget_modify_bg (GTK_WIDGET(button), GTK_STATE_NORMAL, (bFlipFlop)? rgbEnd : rgbStart); gtk_widget_modify_bg (GTK_WIDGET(button), GTK_STATE_ACTIVE, (bFlipFlop)? rgbEnd : rgbStart); gtk_widget_modify_base (GTK_WIDGET(button), GTK_STATE_NORMAL, (bFlipFlop)? rgbEnd : rgbStart); gtk_widget_modify_base (GTK_WIDGET(button), GTK_STATE_ACTIVE, (bFlipFlop)? rgbEnd : rgbStart); gtk_widget_queue_draw (GTK_WIDGET(button)); #if GTK_CHECK_VERSION(2,18,0) gdk_window_process_updates (gtk_widget_get_window(GTK_WIDGET(button)), TRUE); #else gdk_window_process_updates (GTK_WIDGET(button)-window, TRUE); #endif /* GtkWidget *w1 = gtk_tool_button_get_icon_widget(GTK_TOOL_BUTTON(tool_pause)); gtk_widget_modify_bg (w1, GTK_STATE_NORMAL, (bFlipFlop)? rgbEnd : rgbStart); gtk_widget_modify_bg (w1, GTK_STATE_ACTIVE, (bFlipFlop)? rgbEnd : rgbStart); gtk_widget_modify_base (w1, GTK_STATE_NORMAL, (bFlipFlop)? rgbEnd : rgbStart); gtk_widget_modify_base (w1, GTK_STATE_ACTIVE, (bFlipFlop)? rgbEnd : rgbStart); */ //modify relief style gtk_button_set_relief(button, (bFlipFlop)? GTK_RELIEF_NORMAL:GTK_RELIEF_NONE); //modify stock icon gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(tool_pause), (bFlipFlop)? GTK_STOCK_MEDIA_PAUSE : GTK_STOCK_MEDIA_RECORD); gtk_tool_item_toolbar_reconfigured (GTK_TOOL_ITEM(tool_pause)); return TRUE; } Why doesn't any of these work ? Any tips ? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list -- _ : http://jwm-art.net/ -audio/image/text/code/ ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: g_remove
On 17 February 2011 12:27, Craig Bakalian craigbakal...@verizon.net wrote: Hi, I am using g_remove to remove some temporary files from the /tmp folder. It is working as expected. Yet, gcc is complaining that I am making an implicit declaration. What is up with this? You've not #include-ed the necessary files? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: adding button events to a gtkdrawingarea based gobject
On 14 February 2011 13:20, James Morris jwm.art@gmail.com wrote: Hi, (forgive some imprecise names here, am writing from memory and in a rush before work) I'm adapting some code which uses gobject to create a widget. The code previously used GtkWidget as the parent_class but I am trying to adapt it to GtkDrawingArea as the parent_class. However, the button_press_event code is no longer activated within the custom widget now that it's a drawing area. How do I activate it? I know with an ordinary GtkDrawingArea if I want to add button-press-events to use gtk_add_events, but the code that uses the custom widget shouldn't need to do this and besides the widget needs to connect to it's own internal private implementation code anyway so gtk_add_events is obviously wrong. Can anyone provide some pointers please? Yes James, just add the call to gtk_widget_add_events into the yourwidget_init function. HTH! ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
adding button events to a gtkdrawingarea based gobject
Hi, (forgive some imprecise names here, am writing from memory and in a rush before work) I'm adapting some code which uses gobject to create a widget. The code previously used GtkWidget as the parent_class but I am trying to adapt it to GtkDrawingArea as the parent_class. However, the button_press_event code is no longer activated within the custom widget now that it's a drawing area. How do I activate it? I know with an ordinary GtkDrawingArea if I want to add button-press-events to use gtk_add_events, but the code that uses the custom widget shouldn't need to do this and besides the widget needs to connect to it's own internal private implementation code anyway so gtk_add_events is obviously wrong. Can anyone provide some pointers please? Thanks, James. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Memory leaks
On 9 February 2011 11:13, Tor Lillqvist t...@iki.fi wrote: With the right tool there is no problem at all in finding such true leaks. How does one gain this mysterious tool for Linux? I have used Valgrind but as mentioned by numerous souls at numerous times in the past, a suppressions file is needed for GTK/GLIB. And creating a suppressions file is more work than actually writing the code of the program I'm trying to debug in the first place is. james. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Memory leaks
On 9 February 2011 16:10, Michael Cronenworth m...@cchtml.com wrote: James Morris wrote: How does one gain this mysterious tool for Linux? It's called Google. There's a web page[1] that details how to setup valgrind to debug gtk/glib apps and even a preliminary suppression file. [1] http://live.gnome.org/Valgrind That's called patronising. I have been there already. What good is a work in progress when the progress stopped over two years ago? Not only do we have to write our own code, we have to put work into making other peoples code ignore the errors in other peoples code so we can see the errors in our own code. It's a bloody outrage! ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: gobject construction with parameter
On 1 February 2011 00:39, James Morris jwm.art@gmail.com wrote: On 31 January 2011 13:32, Jannis Pohlmann jan...@xfce.org wrote: Can anyone point me in the direction of code examples where the construction of the g object requires a parameter so I can see how to do it please? - I can't make sense of the documentation. I usually do this by adding a construct or construct-only property to the object class and creating a my_object_new() function that takes a parameter for this property that I can then pass to g_object_new(). Here's a simple example from Xfce's XDG menu library garcon: GarconMenu is the object and it needs a menu file (a GFile object) to be constructed properly. So what we did is to to install a construct-only property like this: http://git.xfce.org/libs/garcon/tree/garcon/garcon-menu.c#n246 It looks straight forward at first glance but soon becomes apparent it's not at all :/ I want to pass a const char** null terminated list of C strings - which is obviously not a G_TYPE_FILE! I thought maybe I could use G_TYPE_ARRAY but that results in: GLib-GObject-CRITICAL **: g_param_spec_object: assertion `g_type_is_a (object_type, G_TYPE_OBJECT)' failed So I've no idea what to do there. It's as clear as mud; I'm a GObject newb. I've solved it in a way. Have gone back to using a parameter-less constructor, and a much simplified init function. Instead the code to generate the widgets is in an 'add' style function in which I do all the things intended. It works. Thanks, James. -- _ : http://jwm-art.net/ -audio/image/text/code/ ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
gobject construction with parameter
Hi, I'm trying to modify some existing code which uses gobject so that the function to create a new object can take a parameter. The existing code is quite simple, and my modifications simplify it further so I don't want to spend a great deal of time messing about with Gobject things. Can anyone point me in the direction of code examples where the construction of the g object requires a parameter so I can see how to do it please? - I can't make sense of the documentation. Cheers, James. -- _ : http://jwm-art.net/ -audio/image/text/code/ ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: gobject construction with parameter
On 31 January 2011 13:32, Jannis Pohlmann jan...@xfce.org wrote: Can anyone point me in the direction of code examples where the construction of the g object requires a parameter so I can see how to do it please? - I can't make sense of the documentation. I usually do this by adding a construct or construct-only property to the object class and creating a my_object_new() function that takes a parameter for this property that I can then pass to g_object_new(). Here's a simple example from Xfce's XDG menu library garcon: GarconMenu is the object and it needs a menu file (a GFile object) to be constructed properly. So what we did is to to install a construct-only property like this: http://git.xfce.org/libs/garcon/tree/garcon/garcon-menu.c#n246 It looks straight forward at first glance but soon becomes apparent it's not at all :/ I want to pass a const char** null terminated list of C strings - which is obviously not a G_TYPE_FILE! I thought maybe I could use G_TYPE_ARRAY but that results in: GLib-GObject-CRITICAL **: g_param_spec_object: assertion `g_type_is_a (object_type, G_TYPE_OBJECT)' failed So I've no idea what to do there. It's as clear as mud; I'm a GObject newb. and write a _new() function that takes a GFile for this property and passes it to g_object_new(): http://git.xfce.org/libs/garcon/tree/garcon/garcon-menu.c#n459 This property will not be available in the init function (e.g. garcon_menu_init) but if you want to do something with it before the object can be used by the outside world, you can do that by overriding the GObject constructed function like you do with finalize or get_property. In constructed, the construct and construct-only properties will be set and you can do something with them. Anyway, thanks for making an effort to help. I think the only way anyone could provide any further help here would be to show me an example that works using a const char ** null terminated list of c strings as a parameter to the constructor. I will most likely avoid GObject all together and do it the old fashioned C way as this only seems to be making it more complex than necessary. Thanks, James. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: bug in Cairo or Gtk - peculiar behaviour on resizing or exposing window
On 13 November 2010 22:18, N James Bridge ja...@xmas.demon.co.uk wrote: I am hoping someone will have the time to look at this. I have been developing a gtk/cairo program to draw views of the Mandelbrot set. I wanted to show how the usual iteration progressed for an arbitrary starting point; it worked but occasionally seemed to misbehave. Below is a cut-back version which illustrates the problem. A left click with the mouse sets a starting point which behaves correctly; a right click sets a nearby point which produces a very similar figure but which misbehaves. To see this first try resizing the window - for some sizes it is drawn correctly but for others not. With a bad version, slide another window in front and then away to the side, when the picture is redrawn correctly. Then try minimising it and restoring it, which makes it go wrong again. I am using gtk2-2.22.0-1.fc14.1.x86_64, cairo-1.10.0-2.fc14.x86_64 and gcc-4.5.1-4.fc14.x86_64 So, first: have I done something wrong (probably in draw_iter())? I can't see anything wrong exactly. I tried explicitly initializing z in draw_iter with z.x = cc.x; z.y = cc.y, and used gtk_widget_queue_draw instead of gdk_window_invalidate_rect but both of these made no difference. I also added some printf statements to check what's happening. For the values of cc, the code never returns in the first for loop, and the values of z.x and z.y after both loops never changes other than when cc does. In other words, the drawing may change, but z.x and z.y after both loops does not. The next thing I'd try would be to run it through valgrind but I need to reboot to do that as valgrind is unusable on my current system. james. If not, is there a bug in gtk or gdk or cairo ? Many thanks for any help James Bridge === /* mbrot.c compile with: cc `pkg-config --cflags gtk+-2.0 --libs gtk+-2.0` mbrot.c -lm */ #include gtk/gtk.h #include math.h typedef struct {gdouble x, y;} complex_t; GtkWidget *map; complex_t cc = {0., 0.}; /**/ static gdouble step (complex_t* z, const complex_t* c); void draw_iter (GtkWidget *area, const complex_t *c); static void destroy( GtkWidget *widget, gpointer data ); static gboolean expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer data ); static gboolean button_pressed (GtkWidget* widget, GdkEventButton* event, gpointer data); static gboolean motion_notify (GtkWidget* map, GdkEventMotion* event, GtkLabel *z_label); /**/ static gdouble step (complex_t* z, const complex_t* c) { gdouble xsq = z-x * z-x; gdouble ysq = z-y * z-y; z-y = 2 * z-x * z-y + c-y; z-x = xsq - ysq + c-x; return xsq + ysq; } /**/ void draw_iter (GtkWidget *area, const complex_t *c) { GtkAllocation alloc; gtk_widget_get_allocation (area, alloc); gdouble scale = 3.5 / alloc.width; gint n; gdouble r; complex_t z = cc; cairo_t *cra = gdk_cairo_create (gtk_widget_get_window (area)); cairo_translate (cra, 0.5, 0.5); cairo_set_source_rgb (cra, .2, .2, .2); cairo_set_line_width (cra, 1.0); cairo_move_to (cra, (z.x + 2.5) / scale, - (z.y - 1.4) / scale); for (n = 0; n 70; n++) if ((r = step (z, c)) 9.0) return; for (; n 100; n++) { if ((r = step (z, c)) 9.0) break; cairo_line_to (cra, (z.x + 2.5) / scale, - (z.y - 1.4) / scale); } cairo_stroke (cra); cairo_destroy (cra); return; } /**/ static void destroy( GtkWidget *widget, gpointer data ) { gtk_main_quit (); } /**/ static gboolean expose_event( GtkWidget *area, GdkEventExpose *event, gpointer data ) { if (cc.x != 0) draw_iter (area, cc); return FALSE; } /**/ static gboolean button_pressed (GtkWidget* map, GdkEventButton* event, gpointer data) { if (event-button == 1) { cc.x = -.99439; cc.y = 0.2626584; gdk_window_invalidate_rect (gtk_widget_get_window (map), NULL, FALSE); } else if (event-button == 3) { cc.x = -.99063; cc.y = 0.26797; gdk_window_invalidate_rect (gtk_widget_get_window (map), NULL, FALSE); } return FALSE; }
Re: bug in Cairo or Gtk - peculiar behaviour on resizing or exposing window
On 14 November 2010 12:40, N James Bridge ja...@xmas.demon.co.uk wrote: Thanks for input. I assume you did see the same error in drawing - some areas inside the drawing come out solid black? Yes. I will have to look up valgrind. All of this is a big learning exercise! Valgrind sometimes spots initialization errors that just looking at the code does not, but I'm doubtful it will in this case, but I don't know what else to try. James. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Using RTL variants of GTK_STOCK_* icons
Hi, Is it possible to use an RTL variant of a stock icon (in an LTR language, without breaking RTL languages)? ta james ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Shortcut for GtkEntry Icon?
How can I make the icon for GtkEntry activiated by pressing enter/return within the entry itself? I can't switch focus to it using tab. Cheers, james. -- _ : http://jwm-art.net/ -audio/image/text/code ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
moving message on a gtk dialog
On 19 October 2010 11:01, Guruprasad Bhat guruprasad...@gmail.com wrote: Hi all, I was thinking of a application for showing moving message. In gtk is it possible to do that? I want a small gtk dialog displaying moving message. Can any one suggest in this regard. *Regards,* * Guruprasad Bhat.* The simplest form would scroll the message string itself by placing the first character of the message string at the end of the message string and repeating. You'll need a few extra spaces at the end of the message. Then you'll need an idle callback or timeout to call the string scrolling routine and then to redisplay it as a label. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: gtk filechooser dialog error
On 1 October 2010 07:22, Nagaraja nagar...@ncoretech.com wrote: Hi all, I supposed use gtk_wdget_hide instead of gtk_widget_destroy in this case,now it is working as expected. What about all the errors/warnings, have they gone, or do they still appear? Did the errors appear the first time the dialog was opened, or only when the dialog was re-opened? Using gtk_widget_hide instead of gtk_widget_destroy is quite likely only hiding the errors - the errors are still there and just waiting to crash your code more seriously. Take a look at the typical usage examples of the GtkFileChooserDialog[1] in the documentation. If you still have problems we'll probably need to see the code. James. [1] http://library.gnome.org/devel/gtk/stable/GtkFileChooserDialog.html Best regards, Nagaraja. Hi all, I am running glade-3.6.7, my gtk application have main window with buttons and File Menu to open and save a file . I build it from glade file. For File/Open and File/Save operation the filechooser dialog works fine it brings up the file chooser dialog window , where I can select the desired file or edit the defaut filename which appares in text entry of file save dialog. Upon selecting or editing the default filename the dialog disappears as expected and filename in gchar *filename. The callback for menuitem to open/save calls open_dialog() and save_dialog() which return a gchar * pointer to the filename. But what is hapennig is that am able Open/Save first time wihout any problem but if I try to open filechooser dialog window again it is not providing me the filechooser dialog window any more. More over when I try to open second time it is giving the below error. Can any one here suggest me how do I implement( Desing gtk GUI) gtk app for File Operation. your valuable suggest and help is greatly appriciated. Thanks in advance. Nagaraja. Enter the file save (recorder:3747): Gtk-CRITICAL **: gtk_widget_grab_default: assertion `GTK_WIDGET_CAN_DEFAULT (widget)' failed FILE IS /root/oop.wav Enter the file save (recorder:3514): GLib-GObject-WARNING **: invalid uninstantiatable type `(null)' in cast to `GtkWindow' (recorder:3514): Gtk-CRITICAL **: gtk_window_set_title: assertion `GTK_IS_WINDOW (window)' failed (recorder:3514): GLib-GObject-WARNING **: invalid uninstantiatable type `(null)' in cast to `GtkFileChooser' (recorder:3514): Gtk-CRITICAL **: gtk_file_chooser_set_do_overwrite_confirmation: assertion `GTK_IS_FILE_CHOOSER (chooser)' failed (recorder:3514): GLib-GObject-WARNING **: invalid uninstantiatable type `(null)' in cast to `GtkFileChooser' (recorder:3514): Gtk-CRITICAL **: gtk_file_chooser_set_current_folder: assertion `GTK_IS_FILE_CHOOSER (chooser)' failed (recorder:3514): GLib-GObject-WARNING **: invalid uninstantiatable type `(null)' in cast to `GtkFileChooser' (recorder:3514): Gtk-CRITICAL **: gtk_file_chooser_set_current_name: assertion `GTK_IS_FILE_CHOOSER (chooser)' failed (recorder:3514): GLib-GObject-WARNING **: invalid uninstantiatable type `(null)' in cast to `GtkDialog' (recorder:3514): Gtk-CRITICAL **: gtk_dialog_run: assertion `GTK_IS_DIALOG (dialog)' failed (recorder:3514): GLib-GObject-WARNING **: invalid uninstantiatable type `(null)' in cast to `GtkWidget' (recorder:3514): Gtk-CRITICAL **: gtk_widget_destroy: assertion `GTK_IS_WIDGET (widget)' failed inside open (recorder:3514): Gtk-CRITICAL **: gtk_widget_grab_default: assertion `GTK_WIDGET_CAN_DEFAULT (widget)' failed The file name in open /root/001.wav The Selected file in call back /root/001.wav inside open (recorder:3514): GLib-GObject-WARNING **: invalid uninstantiatable type `(null)' in cast to `GtkFileChooser' (recorder:3514): Gtk-CRITICAL **: gtk_file_chooser_set_select_multiple: assertion `GTK_IS_FILE_CHOOSER (chooser)' failed (recorder:3514): GLib-GObject-WARNING **: invalid uninstantiatable type `(null)' in cast to `GtkFileChooser' (recorder:3514): Gtk-CRITICAL **: gtk_file_chooser_set_current_folder: assertion `GTK_IS_FILE_CHOOSER (chooser)' failed (recorder:3514): GLib-GObject-WARNING **: invalid uninstantiatable type `(null)' in cast to `GtkDialog' (recorder:3514): Gtk-CRITICAL **: gtk_dialog_run: assertion `GTK_IS_DIALOG (dialog)' failed (recorder:3514): GLib-GObject-WARNING **: invalid uninstantiatable type `(null)' in cast to `GtkWidget' (recorder:3514): Gtk-CRITICAL **: gtk_widget_destroy: assertion `GTK_IS_WIDGET (widget)' failed The Selected file in call back (null) (recorder:3514): GLib-CRITICAL **: g_stpcpy: assertion `src != NULL' failed ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list -- _ : http://jwm-art.net/
obtaining current viewport/scrolled window dimensions
Hi, I have a GtkDrawingArea within a GtkViewport within a GtkScrolledWindow. I need the viewport dimensions so I can center the contents of the drawing area when the drawn contents are smaller than the viewport/window. There is a vague mention of page_size in the documentation for scrolled window but no other clues. How do I get these dimensions please? Cheers, James. -- _ : http://jwm-art.net/ -audio/image/text/code ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: obtaining current viewport/scrolled window dimensions
On 22 September 2010 23:49, James Morris jwm.art@gmail.com wrote: Hi, I have a GtkDrawingArea within a GtkViewport within a GtkScrolledWindow. I need the viewport dimensions so I can center the contents of the drawing area when the drawn contents are smaller than the viewport/window. There is a vague mention of page_size in the documentation for scrolled window but no other clues. How do I get these dimensions please? Sorry for the noise, I figured it out once I wrote the email and clicked send: width = gtk_adjustment_get_page_size(gtk_scrolled_window_get_hadjustment(my_scrolled_window)); height = gtk_adjustment_get_page_size(gtk_scrolled_window_get_vadjustment(my_scrolled_window)); ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
scrolled window adjustment 'changed' signal question
Hi, As from my previous email, I require the dimensions of the scrolled window. I decided to detect when they change (due to the top level window being resized) by using the 'changed' signal emitted by the hadjustment and vadjustment respectively. So I create two user functions one for when window width is changed, and the other for when window height is changed. Using g_signal_connect I connect the scrolled window's hadjustment and vadjustments respectively (to the user functions). The behaviour seems a little odd though: if I only change width OR height (NOT both) then BOTH adjustments emit the 'changed' signal. Is this supposed to happen like this? (gtk version 2.20) Thanks, James. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Performance issues of GDK deprecation in favour of Cairo
On 18 August 2010 15:57, Stefan Kost enso...@hora-obscura.de wrote: hi, On 17.08.2010 12:01, James Morris wrote: Hi, I see that some GDK drawing functions and graphics contexts have been deprecated in favour of using Cairo. Yesterday I spent a few hours *removing* Cairo code from my fledgling GTK application and replacing it with gdk_draw_rectangle, gdk_gc_set_rgb_fg_color, and gdk_gc_set_function. I did this for performance reasons[1] I am wondering if my approach to drawing is wrong however and if a better approach might yield less CPU usage? It begins with a 33ms timeout. The timeout callback calls gtk_widget_queue_draw on the window and the drawing area. Would it be possible to isolate this into a standalone demo. Or could you point us to the actual code? Hi Stefan, The actual code is here: http://github.com/jwm-art-net/BoxySeq/blob/97f6d674a2a182a143ef82b03bde11689fedcf18/gui_grid.c I'm probably not going to work on it for a while. Probably going to make the back-end into a library first and then investigate the possibility of using FLTK. Cheers, James. Stefan (Imagine rectangles appearing each time a note is played in a piece of music and disappearing when that note ends.) In the expose event callback a linked-list of rectangles is maintained. Rectangles are added to the list and removed from the list as notes start and end (The application is an experimental MIDI sequencer/arpeggiator operating in real time). Each and every time the expose event callback is called (every 33ms) the background and the entire list of rectangles is drawn as well as various maintenance functions performed on the list. The documentation of gdk_cairo_create seems to suggest this is the only way of doing it when it says: Note that due to double-buffering, Cairo contexts created in a GTK+ expose event handler cannot be cached and reused between different expose events. Is it possible to do this any other way? Cheers, James. [1]My machine is a 64bit 3.0ghz dual core desktop. Using GDK for drawing, the CPU usage is at worst 5% on both cores. Using Cairo on the other hand, the CPU usage can reach as much as 20% on both cores. The project is here: http://github.com/jwm-art-net/BoxySeq Cairo routines is here: http://github.com/jwm-art-net/BoxySeq/tree/97f6d674a2a182a143ef82b03bde11689fedcf18 GDK routines is here: http://github.com/jwm-art-net/BoxySeq/tree/29f412b41b2371ec136aa86da50d858f5892bfa0 ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
custom widgets - advice on where to start?
Hi, I need to create some complex widgets for my program. The first of which is the main widget which will show static rectangles within which other rectangles appear and disappear at musical rates (think fast electronic dance music rates). The static rectangles may overlap each other, but the other rectangles may not. I'm working in C. Can anyone recommend a good tutorial for this kind of thing? I've looked over http://zetcode.com/tutorials/cairographicstutorial/ but it doesn't explain much about creating custom widgets, nor am I sure if I should use Cairo or not. While I want the display to be colourful and attractive, I also want lightweight resource requirements and speed. Thanks, James. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: custom widgets - advice on where to start?
On 7 July 2010 17:34, Staffan Gimåker staf...@gimaker.se wrote: Is there a particular reason that you need a custom widget? Can you not just use a GtkDrawingArea and use Cairo to draw things in it? That's the thing I'm unsure of, when to use a GtkDrawingArea and when to use a custom widget. I've never required anything beyond the standard widgets before now. I'll look at the Cairo documentation. Cheers, James. The official Cairo documentation (the tutorial is here: http://cairographics.org/tutorial/) and the Gtk documentation are probably good places to start. /Staffan On Wed, 2010-07-07 at 13:05 +0100, James Morris wrote: Hi, I need to create some complex widgets for my program. The first of which is the main widget which will show static rectangles within which other rectangles appear and disappear at musical rates (think fast electronic dance music rates). The static rectangles may overlap each other, but the other rectangles may not. I'm working in C. Can anyone recommend a good tutorial for this kind of thing? I've looked over http://zetcode.com/tutorials/cairographicstutorial/ but it doesn't explain much about creating custom widgets, nor am I sure if I should use Cairo or not. While I want the display to be colourful and attractive, I also want lightweight resource requirements and speed. Thanks, James. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
g_atomic_pointer*
Hi, I need to use an atomic pointer for my app. The documentation for the glib atomic operations is not exactly helpful. Anyway, I wrote a test program: 8 /* atomic.c */ #include glib.h int main() { char* myptr = 0; char* str = Hello; g_atomic_pointer_set(myptr, str); char* p = g_atomic_pointer_get(myptr); return 0; } 8 I had to use the output of gcc `pkg-config --cflags glib-2.0` atomic.c -E to understand what was meant to be used as the parameters. Anyway, the output of this does not look at all atomic: (not that i'm any expert) 8 ... # 4 atomic.c 2 int main() { char* myptr = 0; char* str = Hello; ((void) (*(myptr) = (str))); char* p = ((gpointer)*(myptr)); return 0; } 8 This is on a x86_64, running Gentoo, glib-2.20.5. I don't know if I've got the idea right for how these functions are supposed to be used. Any ideas? Cheers, james. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
stock buttons without labels
Is it possible to create a new stock button and it have no label? I only want media play, media previous, media pause, the labels just look naff for these sorts of obvious buttons. Cheers, James. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: locale, gui vs command line question?
On 1/2/2010, Freddie Unpenstein fredde...@excite.com wrote: There's nothing at all wrong with it in the context you specified -- i.e. you want to ensure that floating-point values written to and read from file always use '.' as the decimal separator. I do that in my app, gretl (also for reasons of portability). The problem would be the potential that the library may have cached locale features under a different locale, wouldn't it? That could lead to either uninitialised bytes, or buffer overrun. So what's the point of having a setlocale function which can tell you the locale in use and/or set a new locale to use if this stuff is going to be stored in cache and read/write of locale settings is going to break the library and your program? Or are you saying the libraries (gtk/mpfr/stdc) I'm using may be caching the locale and may not heed my changes? From personal experience; I've first-use-allocated strings with all the thousands characters, and an array of byte offsets at which to put the higher portions of numbers, and then used a regular floating point format to write the last thousand (sprintf comes to mind). If the locale were to unexpectedly change to one that uses a multi-byte decimal point, a buffer overrun would certainly occur. In the opposing case, that same function would likely write out a null character following the number. Are you talking about a change from outside the program? Say, whichever X environment changes locale settings (do running programs take notice then?). Cheers, James. Could cause quite some stress. Fredderic Best Weight Loss Program - Click Here! Weight Loss Program http://tagline.excite.com/c?cp=vXYG-fGF-EFlsgtFzMFtVgAAKZSqLQhMVy_O-FcGiDoF0G0BAAYAAADNAAAEUkg= ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: locale, gui vs command line question?
On 2/2/2010, David Ne#269;as y...@physics.muni.cz wrote: On Mon, 1 Feb 2010, Freddie Unpenstein wrote: On Sun, 31 Jan 2010, james morris wrote: Why is store/change/restore of locale bad? There's nothing at all wrong with it in the context you specified -- i.e. you want to ensure that floating-point values written to and read from file always use '.' as the decimal separator. I do that in my app, gretl (also for reasons of portability). The problem would be the potential that the library may have cached locale features under a different locale, wouldn't it? A bigger problem is that setlocale() is non-local hence it breaks anything asynchronous, namely threads. It may not matter in a single-threaded program but it's something you should never do in a library. I was about ask something along similar lines. Presumably, if the X environment changes locale it will be GTK which deals with it and as GTK is not threaded, and, my code which stores/restores locale only operates within the GTK thread (my code is multi-threaded) then GTK will only deal with the locale change when it is doing it's internal stuff and not going about my code? James. Yeti ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
locale, gui vs command line question?
Hi, A user has reported a problem with my app being unable to load a settings file from the command line when the program runs without a GUI. The OPs locale uses commas as the decimal point and the programs use of locale changes when GTK is initialized. However, the same file which does not load from the command line without a GUI will load with the GUI up. I want these files to always be written in the C locale so they're portable across locales, but I don't want to clobber the GUI to do so. I've read archived posts recommending to use the glib conversion functions, however these are limited to double precision, and the minimum precision my app is using is long double, as it also uses the MPFR library for unlimited multiple precision maths. I've not had to deal with locales before, and I'm trying to understand what GTK does to the locale when it initializes so I can work around it and save data files as C locale. I've tried adding setlocale(LC_NUMERIC, C) to the start of main, and after calling gtk_init, but it seems to make no difference. Any help/pointers appreciated. James Morris. PS I asked this 4 hours ago on stackoverflow, but any question older than an hour is practically dead and lost by that point. http://stackoverflow.com/questions/2171527/how-do-i-remove-the-difference-in-locale-between-gui-and-commandline-interfaces-o ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list