Re: Problem to open a new window using libglade
Hello, if I use g_idle_add, then when the function from g_idle_add is executed, it blocks the 'update_pbar' function. So I probably must make it with threads but by now I think it's to early for me to work with threads. It's easier if I add the progressbar into the main window, and update it with: while (gtk_events_pending()) gtk_main_iteration(); Later I would probably try it with threads. Thanks for the help. 2007/3/6, Karl H. Beckers <[EMAIL PROTECTED]>: > Am Montag, den 05.03.2007, 17:03 +0100 schrieb patrick: > > Great! Thank you very much, this works. > > But how can I make something during gtk_dialog_run? > > I'd like to do somthing like this. > > > > g_timeout_add(1000, update_pbar, dialog); > > result = gtk_dialog_run(GTK_DIALOG(dialog)); > > ...my process which progressbar should show > > g_spawn... > > progress = 0.2 > > other work > > gtk_widget_destroy(dialog); > > dialog = NULL; > > > > > > update_pbar (gpointer dialog) > > { > > ... > > gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(probar), progress); > > ... > > } > > Well, > you either need another scheduled function (prolly g_idle_add) or start > a separate thread when entering your callback and join it before ending. > > You prolly want to avoid multi-threading for such a rather limited > use-case. > > Also, I've noted a flaw in my pseudo-code around setting dialog to NULL > which does not change the pointer that has already been passed to > update_pbar ... a static global would prolly do here or smth. similar. > > HTH, > > Karl. > > ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Problem to open a new window using libglade
Am Montag, den 05.03.2007, 17:03 +0100 schrieb patrick: > Great! Thank you very much, this works. > But how can I make something during gtk_dialog_run? > I'd like to do somthing like this. > > g_timeout_add(1000, update_pbar, dialog); > result = gtk_dialog_run(GTK_DIALOG(dialog)); > ...my process which progressbar should show > g_spawn... > progress = 0.2 > other work > gtk_widget_destroy(dialog); > dialog = NULL; > > > update_pbar (gpointer dialog) > { > ... > gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(probar), progress); > ... > } Well, you either need another scheduled function (prolly g_idle_add) or start a separate thread when entering your callback and join it before ending. You prolly want to avoid multi-threading for such a rather limited use-case. Also, I've noted a flaw in my pseudo-code around setting dialog to NULL which does not change the pointer that has already been passed to update_pbar ... a static global would prolly do here or smth. similar. HTH, Karl. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Problem to open a new window using libglade
Great! Thank you very much, this works. But how can I make something during gtk_dialog_run? I'd like to do somthing like this. g_timeout_add(1000, update_pbar, dialog); result = gtk_dialog_run(GTK_DIALOG(dialog)); ...my process which progressbar should show g_spawn... progress = 0.2 other work gtk_widget_destroy(dialog); dialog = NULL; update_pbar (gpointer dialog) { ... gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(probar), progress); ... } Thank you 2007/3/2, Karl H. Beckers <[EMAIL PROTECTED]>: > Well, > > there's prolly several ways of doing it, but smth. along the following > lines should work: > > GladeXML *gxml = glade_xml_new (GLADE_FILE, "dialog1", NULL); > GtkWidget *dialog = glade_xml_get_widget(gxml, "dialog1"); > g_assert(dialog); > GtkResponseType result; > > // register function to be executed in intervals > g_timeout_add(1000, update_pbar, dialog); > result = gtk_dialog_run(GTK_DIALOG(dialog)); > > if (result == GTK_RESPONSE_OK) > { > } > > gtk_widget_destroy(dialog); > dialog = NULL; > > then you need the timeout function: > > gboolean > update_pbar (gpointer dialog) > { > // stop executing and unregister this function if dialog has > // been set to NULL > if (!dialog) return 0; > // if dialog has not been displayed yet, don't bother updating > // the progress bar > if (!GTK_WIDGET_VISIBLE(GTK_WIDGET(dialog))) return 1; > > ... > do whatever needs to be done to update the progressbar here > > return 1; > } > > HTH, > > Karl. > > > > Am Freitag, den 02.03.2007, 23:32 +0100 schrieb patrick: > > Thanks for your answer. > > > > > if I'm not completely mistaken here, this has nothing to do with glade. > > > The thing just is, that you need to return to the main loop from the > > > callback for the widgets to be drawn properly. > > > That is prolly why you put in your gtk_main_iteration though I doubt > > > there is a guaranteed way to make this work. > > I think this is my problem. > > So I made a new dialog: > > > > GladeXML *gxml = glade_xml_new (GLADE_FILE, "dialog1", NULL); > > GtkWidget *dialog = glade_xml_get_widget(gxml, "dialog1"); > > GtkResponseType result; > > > > result = gtk_dialog_run(GTK_DIALOG(dialog)); > > > > if (result == GTK_RESPONSE_OK) > > { > > } > > gtk_widget_destroy(dialog); > > > > The window (dialog) now appears, but I want a "progress window", with > > a progressbar and a label for the description. But how can I make > > somthing while the dialog is visible so that I can show the progress > > to the user? > > > > Thanks for the help. > > > > > > 2007/3/2, Karl H. Beckers <[EMAIL PROTECTED]>: > > > Am Freitag, den 02.03.2007, 11:33 -0500 schrieb > > > [EMAIL PROTECTED]: > > > > >>> void > > > > >>> on_button1_clicked(GtkButton *button, gpointer data) > > > > >>> { > > > > >>> /* the button was clicked */ > > > > >>> //Print out to console > > > > >>> g_print("Beginn break\n"); > > > > >>> > > > > >>> //Create the new "progress" window > > > > >>> GladeXML*gxml_progress = NULL; > > > > >>> gxml_progress = glade_xml_new (GLADE_FILE, "window2", NULL); > > > > >>> > > > > >>> //show the window > > > > >>> GtkWidget *window2 = glade_xml_get_widget(gxml_progress, > > > > "window2"); > > > > >>> gtk_widget_show_all(window2); > > > > >>> > > > > >>> while (gtk_events_pending()) > > > > >>> gtk_main_iteration(); > > > > >>> > > > > >>> //Make 5 sec. break > > > > >>> g_usleep(500); > > > > >>> g_print("End break\n"); > > > > >>> } > > > > > > Hi there, > > > > > > if I'm not completely mistaken here, this has nothing to do with glade. > > > The thing just is, that you need to return to the main loop from the > > > callback for the widgets to be drawn properly. > > > That is prolly why you put in your gtk_main_iteration though I doubt > > > there is a guaranteed way to make this work. > > > > > > So the complicated version would probably involve having hooking up a > > > callback to the configure event for the second window that starts smth. > > > and then automatically deregisters itself after the first run. > > > > > > The other thing I've found to work is use a GTK_DIALOG rather than a > > > generic window and then do smth. along the lines of: > > > > > > result = gtk_dialog_run (GTK_DIALOG (dialog)); > > > > > > if (result == GTK_RESPONSE_OK) { > > > got_file_name = > > > gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); > > > > > > xml = NULL; > > > xml = glade_get_widget_tree (GTK_WIDGET (xvc_pref_main_window)); > > > g_assert (xml); > > > > > > w = NULL; > > > w = glade_xml_get_widget (xml, "xvc_pref_sf_filename_entry"); > > > g_assert (w); > > >
Re: Problem to open a new window using libglade
Well, there's prolly several ways of doing it, but smth. along the following lines should work: GladeXML *gxml = glade_xml_new (GLADE_FILE, "dialog1", NULL); GtkWidget *dialog = glade_xml_get_widget(gxml, "dialog1"); g_assert(dialog); GtkResponseType result; // register function to be executed in intervals g_timeout_add(1000, update_pbar, dialog); result = gtk_dialog_run(GTK_DIALOG(dialog)); if (result == GTK_RESPONSE_OK) { } gtk_widget_destroy(dialog); dialog = NULL; then you need the timeout function: gboolean update_pbar (gpointer dialog) { // stop executing and unregister this function if dialog has // been set to NULL if (!dialog) return 0; // if dialog has not been displayed yet, don't bother updating // the progress bar if (!GTK_WIDGET_VISIBLE(GTK_WIDGET(dialog))) return 1; ... do whatever needs to be done to update the progressbar here return 1; } HTH, Karl. Am Freitag, den 02.03.2007, 23:32 +0100 schrieb patrick: > Thanks for your answer. > > > if I'm not completely mistaken here, this has nothing to do with glade. > > The thing just is, that you need to return to the main loop from the > > callback for the widgets to be drawn properly. > > That is prolly why you put in your gtk_main_iteration though I doubt > > there is a guaranteed way to make this work. > I think this is my problem. > So I made a new dialog: > > GladeXML *gxml = glade_xml_new (GLADE_FILE, "dialog1", NULL); > GtkWidget *dialog = glade_xml_get_widget(gxml, "dialog1"); > GtkResponseType result; > > result = gtk_dialog_run(GTK_DIALOG(dialog)); > > if (result == GTK_RESPONSE_OK) > { > } > gtk_widget_destroy(dialog); > > The window (dialog) now appears, but I want a "progress window", with > a progressbar and a label for the description. But how can I make > somthing while the dialog is visible so that I can show the progress > to the user? > > Thanks for the help. > > > 2007/3/2, Karl H. Beckers <[EMAIL PROTECTED]>: > > Am Freitag, den 02.03.2007, 11:33 -0500 schrieb > > [EMAIL PROTECTED]: > > > >>> void > > > >>> on_button1_clicked(GtkButton *button, gpointer data) > > > >>> { > > > >>> /* the button was clicked */ > > > >>> //Print out to console > > > >>> g_print("Beginn break\n"); > > > >>> > > > >>> //Create the new "progress" window > > > >>> GladeXML*gxml_progress = NULL; > > > >>> gxml_progress = glade_xml_new (GLADE_FILE, "window2", NULL); > > > >>> > > > >>> //show the window > > > >>> GtkWidget *window2 = glade_xml_get_widget(gxml_progress, > > > "window2"); > > > >>> gtk_widget_show_all(window2); > > > >>> > > > >>> while (gtk_events_pending()) > > > >>> gtk_main_iteration(); > > > >>> > > > >>> //Make 5 sec. break > > > >>> g_usleep(500); > > > >>> g_print("End break\n"); > > > >>> } > > > > Hi there, > > > > if I'm not completely mistaken here, this has nothing to do with glade. > > The thing just is, that you need to return to the main loop from the > > callback for the widgets to be drawn properly. > > That is prolly why you put in your gtk_main_iteration though I doubt > > there is a guaranteed way to make this work. > > > > So the complicated version would probably involve having hooking up a > > callback to the configure event for the second window that starts smth. > > and then automatically deregisters itself after the first run. > > > > The other thing I've found to work is use a GTK_DIALOG rather than a > > generic window and then do smth. along the lines of: > > > > result = gtk_dialog_run (GTK_DIALOG (dialog)); > > > > if (result == GTK_RESPONSE_OK) { > > got_file_name = > > gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); > > > > xml = NULL; > > xml = glade_get_widget_tree (GTK_WIDGET (xvc_pref_main_window)); > > g_assert (xml); > > > > w = NULL; > > w = glade_xml_get_widget (xml, "xvc_pref_sf_filename_entry"); > > g_assert (w); > > > > gtk_entry_set_text (GTK_ENTRY (w), strdup (got_file_name)); > > } > > > > gtk_widget_destroy (dialog); > > > > Of course, if you're not really interested in the user's input you can > > just ignore the result. > > > > HTH, > > > > Karl. > > > > > > > ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Problem to open a new window using libglade
Thanks for your answer. > if I'm not completely mistaken here, this has nothing to do with glade. > The thing just is, that you need to return to the main loop from the > callback for the widgets to be drawn properly. > That is prolly why you put in your gtk_main_iteration though I doubt > there is a guaranteed way to make this work. I think this is my problem. So I made a new dialog: GladeXML *gxml = glade_xml_new (GLADE_FILE, "dialog1", NULL); GtkWidget *dialog = glade_xml_get_widget(gxml, "dialog1"); GtkResponseType result; result = gtk_dialog_run(GTK_DIALOG(dialog)); if (result == GTK_RESPONSE_OK) { } gtk_widget_destroy(dialog); The window (dialog) now appears, but I want a "progress window", with a progressbar and a label for the description. But how can I make somthing while the dialog is visible so that I can show the progress to the user? Thanks for the help. 2007/3/2, Karl H. Beckers <[EMAIL PROTECTED]>: > Am Freitag, den 02.03.2007, 11:33 -0500 schrieb > [EMAIL PROTECTED]: > > >>> void > > >>> on_button1_clicked(GtkButton *button, gpointer data) > > >>> { > > >>> /* the button was clicked */ > > >>> //Print out to console > > >>> g_print("Beginn break\n"); > > >>> > > >>> //Create the new "progress" window > > >>> GladeXML*gxml_progress = NULL; > > >>> gxml_progress = glade_xml_new (GLADE_FILE, "window2", NULL); > > >>> > > >>> //show the window > > >>> GtkWidget *window2 = glade_xml_get_widget(gxml_progress, > > "window2"); > > >>> gtk_widget_show_all(window2); > > >>> > > >>> while (gtk_events_pending()) > > >>> gtk_main_iteration(); > > >>> > > >>> //Make 5 sec. break > > >>> g_usleep(500); > > >>> g_print("End break\n"); > > >>> } > > Hi there, > > if I'm not completely mistaken here, this has nothing to do with glade. > The thing just is, that you need to return to the main loop from the > callback for the widgets to be drawn properly. > That is prolly why you put in your gtk_main_iteration though I doubt > there is a guaranteed way to make this work. > > So the complicated version would probably involve having hooking up a > callback to the configure event for the second window that starts smth. > and then automatically deregisters itself after the first run. > > The other thing I've found to work is use a GTK_DIALOG rather than a > generic window and then do smth. along the lines of: > > result = gtk_dialog_run (GTK_DIALOG (dialog)); > > if (result == GTK_RESPONSE_OK) { > got_file_name = > gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); > > xml = NULL; > xml = glade_get_widget_tree (GTK_WIDGET (xvc_pref_main_window)); > g_assert (xml); > > w = NULL; > w = glade_xml_get_widget (xml, "xvc_pref_sf_filename_entry"); > g_assert (w); > > gtk_entry_set_text (GTK_ENTRY (w), strdup (got_file_name)); > } > > gtk_widget_destroy (dialog); > > Of course, if you're not really interested in the user's input you can > just ignore the result. > > HTH, > > Karl. > > > ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Problem to open a new window using libglade
Am Freitag, den 02.03.2007, 11:33 -0500 schrieb [EMAIL PROTECTED]: > >>> void > >>> on_button1_clicked(GtkButton *button, gpointer data) > >>> { > >>> /* the button was clicked */ > >>> //Print out to console > >>> g_print("Beginn break\n"); > >>> > >>> //Create the new "progress" window > >>> GladeXML*gxml_progress = NULL; > >>> gxml_progress = glade_xml_new (GLADE_FILE, "window2", NULL); > >>> > >>> //show the window > >>> GtkWidget *window2 = glade_xml_get_widget(gxml_progress, > "window2"); > >>> gtk_widget_show_all(window2); > >>> > >>> while (gtk_events_pending()) > >>> gtk_main_iteration(); > >>> > >>> //Make 5 sec. break > >>> g_usleep(500); > >>> g_print("End break\n"); > >>> } Hi there, if I'm not completely mistaken here, this has nothing to do with glade. The thing just is, that you need to return to the main loop from the callback for the widgets to be drawn properly. That is prolly why you put in your gtk_main_iteration though I doubt there is a guaranteed way to make this work. So the complicated version would probably involve having hooking up a callback to the configure event for the second window that starts smth. and then automatically deregisters itself after the first run. The other thing I've found to work is use a GTK_DIALOG rather than a generic window and then do smth. along the lines of: result = gtk_dialog_run (GTK_DIALOG (dialog)); if (result == GTK_RESPONSE_OK) { got_file_name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); xml = NULL; xml = glade_get_widget_tree (GTK_WIDGET (xvc_pref_main_window)); g_assert (xml); w = NULL; w = glade_xml_get_widget (xml, "xvc_pref_sf_filename_entry"); g_assert (w); gtk_entry_set_text (GTK_ENTRY (w), strdup (got_file_name)); } gtk_widget_destroy (dialog); Of course, if you're not really interested in the user's input you can just ignore the result. HTH, Karl. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Problem to open a new window using libglade
Sorry, just use gtk_widget_show() - Micah Carrick Developer | http://www.micahcarrick.com | http://www.gtkforums.com patrick wrote: > If I compile it with "gtk_window_show_now" I get the following compiler error: > implicit declaration of function 'gtk_window_show_now' > I also tried it with 'gtk_widget_show_now', but there is no difference. > > 2007/3/2, Micah Carrick <[EMAIL PROTECTED]>: > >> A quick "cheap trick" you could do is: >> >> gtk_window_set_keep_above (GTK_WINDOW(window2), TRUE); >> gtk_window_show_now (GTK_WINDOW(window2)); >> >> - Micah Carrick >> Developer | http://www.micahcarrick.com | http://www.gtkforums.com >> >> >> >> patrick wrote: >> >>> Hi All, >>> >>> I'd like to open a new window, when a button is clicked by using libglade. >>> But the window appears always at the end of the function, but it >>> should appear at the beginnig, so that I can show the progrwess to the >>> user. >>> I also tried to add "while (gtk_events_pending()) >>> gtk_main_iteration();" but then only the outlines are visible, not the >>> labels, and progressbars. >>> >>> So I put together a short example to explain the problem. >>> Now the window appears with the beginning of the break, but the labels >>> etc, at the end. >>> How can I open the window, so that the labels etc. are visible, to >>> show the progress to the user? >>> thanks a lot! >>> >>> Patrick >>> >>> /* sample.glade */ >>> >>> >>> http://glade.gnome.org/glade-2.0.dtd";> >>> >>> >>> >>> >>> 10 >>> True >>> window1 >>> GTK_WINDOW_TOPLEVEL >>> GTK_WIN_POS_NONE >>> False >>> False >>> False >>> True >>> False >>> False >>> GDK_WINDOW_TYPE_HINT_NORMAL >>> GDK_GRAVITY_NORTH_WEST >>> True >>> False >>> >>> >>> >>> 150 >>> True >>> True >>> Run >>> True >>> GTK_RELIEF_NORMAL >>> True >>> >> last_modification_time="Mon, 19 Feb 2007 20:34:21 GMT"/> >>> >>> >>> >>> >>> >>> 10 >>> True >>> window2 >>> GTK_WINDOW_TOPLEVEL >>> GTK_WIN_POS_NONE >>> False >>> False >>> False >>> True >>> False >>> False >>> GDK_WINDOW_TYPE_HINT_NORMAL >>> GDK_GRAVITY_NORTH_WEST >>> True >>> False >>> >>> >>> >>> True >>> False >>> 0 >>> >>> >>> >>> True >>> Progress window >>> False >>> False >>> GTK_JUSTIFY_LEFT >>> False >>> False >>> 0.5 >>> 0.5 >>> 0 >>> 0 >>> PANGO_ELLIPSIZE_NONE >>> -1 >>> False >>> 0 >>> >>> >>> 0 >>> False >>> False >>> >>> >>> >>> >>> >>> True >>> GTK_PROGRESS_LEFT_TO_RIGHT >>> 0 >>> 0.1000149 >>> PANGO_ELLIPSIZE_NONE >>> >>> >>> 0 >>> False >>> False >>> >>> >>> >>> >>> >>> True >>> >> translatable="yes">progress_description >>> False >>> False >>> GTK_JUSTIFY_LEFT >>> False >>> False >>> 0.5 >>> 0.5 >>> 0 >>> 0 >>> PANGO_ELLIPSIZE_NONE >>> -1 >>> False >>> 0 >>> >>> >>> 2 >>> False >>> False >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> /* sample.c */ >>> #include >>> #include >>> #include >>> >>> #define GLADE_FILE "sample.glade" >>> >>> // functions >>> static gint delete_event_cb(GtkWidget* w, GdkEventAny* e, gpointer data); >>> static gint destroy_cb(GtkWidget* w, GdkEventAny* e, gpointer data); >>> static void on_button1_clicked(GtkButton *button, gpointer data); >>> >>> int main (int argc, char *argv[]) >>> { >>> GladeXML *gxml; >>> >>> gtk_init (&argc, &argv); >>> >>> //Create interface >>> gxml = glade_xml_new (GLADE_FILE, "window1", NULL); >>> >>> GtkWidget *window1 = glade_xml_get_widget(gxml, "window1"); >>> >>> //connect signals >>> glade_xml_signal_connect_data (gxml, "on_button1_clicked", >>> G_CALLBACK (on_button1_clicked), NULL); >>> >>> g_signal_connect(G_OBJECT(window1), "delete_event", >>> G_CALLBACK(delete_event_cb), NULL); >>> >>> g_signal_connect(G_OBJECT(window1), "destroy", >>> G_CALLBACK(destroy_cb), NULL); >>> >>> //beginn loop >>> gtk_main (); >>> >>> return 0; >>> } >>> >>> static gint delete_event_cb(GtkWidget* w, GdkEventAny* e, gpointer data) >>> { >>> return 0; >>> } >>> >>> static gint destroy_cb(GtkWidget* w, GdkEventAny* e, gpointer data) >>> { >>> gtk_main_quit(); >>> return 0; >>> } >>> >>> void >>> on_button1_clicked(GtkButton *button, gpointer data) >>> { >>> /* the button was clicked */ >>> //Print out to console >>> g_print("Beginn break\n"); >>> >>> //Create the new "progress" window >>> GladeXML*gxml_progress = NULL; >>> gxml_progress = glade_xml_new (GLADE_FILE, "window2", NULL); >>> >>> //show the window >>> GtkWid
Re: Problem to open a new window using libglade
If I compile it with "gtk_window_show_now" I get the following compiler error: implicit declaration of function 'gtk_window_show_now' I also tried it with 'gtk_widget_show_now', but there is no difference. 2007/3/2, Micah Carrick <[EMAIL PROTECTED]>: > A quick "cheap trick" you could do is: > > gtk_window_set_keep_above (GTK_WINDOW(window2), TRUE); > gtk_window_show_now (GTK_WINDOW(window2)); > > - Micah Carrick > Developer | http://www.micahcarrick.com | http://www.gtkforums.com > > > > patrick wrote: > > Hi All, > > > > I'd like to open a new window, when a button is clicked by using libglade. > > But the window appears always at the end of the function, but it > > should appear at the beginnig, so that I can show the progrwess to the > > user. > > I also tried to add "while (gtk_events_pending()) > > gtk_main_iteration();" but then only the outlines are visible, not the > > labels, and progressbars. > > > > So I put together a short example to explain the problem. > > Now the window appears with the beginning of the break, but the labels > > etc, at the end. > > How can I open the window, so that the labels etc. are visible, to > > show the progress to the user? > > thanks a lot! > > > > Patrick > > > > /* sample.glade */ > > > > > > http://glade.gnome.org/glade-2.0.dtd";> > > > > > > > > > > 10 > > True > > window1 > > GTK_WINDOW_TOPLEVEL > > GTK_WIN_POS_NONE > > False > > False > > False > > True > > False > > False > > GDK_WINDOW_TYPE_HINT_NORMAL > > GDK_GRAVITY_NORTH_WEST > > True > > False > > > > > > > > 150 > > True > > True > > Run > > True > > GTK_RELIEF_NORMAL > > True > >> last_modification_time="Mon, 19 Feb 2007 20:34:21 GMT"/> > > > > > > > > > > > > 10 > > True > > window2 > > GTK_WINDOW_TOPLEVEL > > GTK_WIN_POS_NONE > > False > > False > > False > > True > > False > > False > > GDK_WINDOW_TYPE_HINT_NORMAL > > GDK_GRAVITY_NORTH_WEST > > True > > False > > > > > > > > True > > False > > 0 > > > > > > > > True > > Progress window > > False > > False > > GTK_JUSTIFY_LEFT > > False > > False > > 0.5 > > 0.5 > > 0 > > 0 > > PANGO_ELLIPSIZE_NONE > > -1 > > False > > 0 > > > > > > 0 > > False > > False > > > > > > > > > > > > True > > GTK_PROGRESS_LEFT_TO_RIGHT > > 0 > > 0.1000149 > > PANGO_ELLIPSIZE_NONE > > > > > > 0 > > False > > False > > > > > > > > > > > > True > > > translatable="yes">progress_description > > False > > False > > GTK_JUSTIFY_LEFT > > False > > False > > 0.5 > > 0.5 > > 0 > > 0 > > PANGO_ELLIPSIZE_NONE > > -1 > > False > > 0 > > > > > > 2 > > False > > False > > > > > > > > > > > > > > > > > > > > /* sample.c */ > > #include > > #include > > #include > > > > #define GLADE_FILE "sample.glade" > > > > // functions > > static gint delete_event_cb(GtkWidget* w, GdkEventAny* e, gpointer data); > > static gint destroy_cb(GtkWidget* w, GdkEventAny* e, gpointer data); > > static void on_button1_clicked(GtkButton *button, gpointer data); > > > > int main (int argc, char *argv[]) > > { > > GladeXML *gxml; > > > > gtk_init (&argc, &argv); > > > > //Create interface > > gxml = glade_xml_new (GLADE_FILE, "window1", NULL); > > > > GtkWidget *window1 = glade_xml_get_widget(gxml, "window1"); > > > > //connect signals > > glade_xml_signal_connect_data (gxml, "on_button1_clicked", > > G_CALLBACK (on_button1_clicked), NULL); > > > > g_signal_connect(G_OBJECT(window1), "delete_event", > > G_CALLBACK(delete_event_cb), NULL); > > > > g_signal_connect(G_OBJECT(window1), "destroy", > > G_CALLBACK(destroy_cb), NULL); > > > > //beginn loop > > gtk_main (); > > > > return 0; > > } > > > > static gint delete_event_cb(GtkWidget* w, GdkEventAny* e, gpointer data) > > { > > return 0; > > } > > > > static gint destroy_cb(GtkWidget* w, GdkEventAny* e, gpointer data) > > { > > gtk_main_quit(); > > return 0; > > } > > > > void > > on_button1_clicked(GtkButton *button, gpointer data) > > { > > /* the button was clicked */ > > //Print out to console > > g_print("Beginn break\n"); > > > > //Create the new "progress" window > > GladeXML*gxml_progress = NULL; > > gxml_progress = glade_xml_new (GLADE_FILE, "window2", NULL); > > > > //show the window > > GtkWidget *window2 = glade_xml_get_widget(gxml_progress, "window2"); > > gtk_widget_show_all(window2); > > > > while (gtk_events_pending()) > > gtk_mai
Re: Problem to open a new window using libglade
A quick "cheap trick" you could do is: gtk_window_set_keep_above (GTK_WINDOW(window2), TRUE); gtk_window_show_now (GTK_WINDOW(window2)); - Micah Carrick Developer | http://www.micahcarrick.com | http://www.gtkforums.com patrick wrote: > Hi All, > > I'd like to open a new window, when a button is clicked by using libglade. > But the window appears always at the end of the function, but it > should appear at the beginnig, so that I can show the progrwess to the > user. > I also tried to add "while (gtk_events_pending()) > gtk_main_iteration();" but then only the outlines are visible, not the > labels, and progressbars. > > So I put together a short example to explain the problem. > Now the window appears with the beginning of the break, but the labels > etc, at the end. > How can I open the window, so that the labels etc. are visible, to > show the progress to the user? > thanks a lot! > > Patrick > > /* sample.glade */ > > > http://glade.gnome.org/glade-2.0.dtd";> > > > > > 10 > True > window1 > GTK_WINDOW_TOPLEVEL > GTK_WIN_POS_NONE > False > False > False > True > False > False > GDK_WINDOW_TYPE_HINT_NORMAL > GDK_GRAVITY_NORTH_WEST > True > False > > > > 150 > True > True > Run > True > GTK_RELIEF_NORMAL > True >last_modification_time="Mon, 19 Feb 2007 20:34:21 GMT"/> > > > > > > 10 > True > window2 > GTK_WINDOW_TOPLEVEL > GTK_WIN_POS_NONE > False > False > False > True > False > False > GDK_WINDOW_TYPE_HINT_NORMAL > GDK_GRAVITY_NORTH_WEST > True > False > > > > True > False > 0 > > > > True > Progress window > False > False > GTK_JUSTIFY_LEFT > False > False > 0.5 > 0.5 > 0 > 0 > PANGO_ELLIPSIZE_NONE > -1 > False > 0 > > > 0 > False > False > > > > > > True > GTK_PROGRESS_LEFT_TO_RIGHT > 0 > 0.1000149 > PANGO_ELLIPSIZE_NONE > > > 0 > False > False > > > > > > True > progress_description > False > False > GTK_JUSTIFY_LEFT > False > False > 0.5 > 0.5 > 0 > 0 > PANGO_ELLIPSIZE_NONE > -1 > False > 0 > > > 2 > False > False > > > > > > > > > > /* sample.c */ > #include > #include > #include > > #define GLADE_FILE "sample.glade" > > // functions > static gint delete_event_cb(GtkWidget* w, GdkEventAny* e, gpointer data); > static gint destroy_cb(GtkWidget* w, GdkEventAny* e, gpointer data); > static void on_button1_clicked(GtkButton *button, gpointer data); > > int main (int argc, char *argv[]) > { > GladeXML *gxml; > > gtk_init (&argc, &argv); > > //Create interface > gxml = glade_xml_new (GLADE_FILE, "window1", NULL); > > GtkWidget *window1 = glade_xml_get_widget(gxml, "window1"); > > //connect signals > glade_xml_signal_connect_data (gxml, "on_button1_clicked", > G_CALLBACK (on_button1_clicked), NULL); > > g_signal_connect(G_OBJECT(window1), "delete_event", > G_CALLBACK(delete_event_cb), NULL); > > g_signal_connect(G_OBJECT(window1), "destroy", > G_CALLBACK(destroy_cb), NULL); > > //beginn loop > gtk_main (); > > return 0; > } > > static gint delete_event_cb(GtkWidget* w, GdkEventAny* e, gpointer data) > { > return 0; > } > > static gint destroy_cb(GtkWidget* w, GdkEventAny* e, gpointer data) > { > gtk_main_quit(); > return 0; > } > > void > on_button1_clicked(GtkButton *button, gpointer data) > { > /* the button was clicked */ > //Print out to console > g_print("Beginn break\n"); > > //Create the new "progress" window > GladeXML*gxml_progress = NULL; > gxml_progress = glade_xml_new (GLADE_FILE, "window2", NULL); > > //show the window > GtkWidget *window2 = glade_xml_get_widget(gxml_progress, "window2"); > gtk_widget_show_all(window2); > > while (gtk_events_pending()) > gtk_main_iteration(); > > //Make 5 sec. break > g_usleep(500); > g_print("End break\n"); > } > > I compile it with: "gcc -Wall -export-dynamic -g `pkg-config --cflags > --libs gtk+-2.0` `pkg-config --cflags --libs libglade-2.0` -o sample > sample.c" on my FC6 machine. > ___ > 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
Problem to open a new window using libglade
Hi All, I'd like to open a new window, when a button is clicked by using libglade. But the window appears always at the end of the function, but it should appear at the beginnig, so that I can show the progrwess to the user. I also tried to add "while (gtk_events_pending()) gtk_main_iteration();" but then only the outlines are visible, not the labels, and progressbars. So I put together a short example to explain the problem. Now the window appears with the beginning of the break, but the labels etc, at the end. How can I open the window, so that the labels etc. are visible, to show the progress to the user? thanks a lot! Patrick /* sample.glade */ http://glade.gnome.org/glade-2.0.dtd";> 10 True window1 GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE False False False True False False GDK_WINDOW_TYPE_HINT_NORMAL GDK_GRAVITY_NORTH_WEST True False 150 True True Run True GTK_RELIEF_NORMAL True 10 True window2 GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE False False False True False False GDK_WINDOW_TYPE_HINT_NORMAL GDK_GRAVITY_NORTH_WEST True False True False 0 True Progress window False False GTK_JUSTIFY_LEFT False False 0.5 0.5 0 0 PANGO_ELLIPSIZE_NONE -1 False 0 0 False False True GTK_PROGRESS_LEFT_TO_RIGHT 0 0.1000149 PANGO_ELLIPSIZE_NONE 0 False False True progress_description False False GTK_JUSTIFY_LEFT False False 0.5 0.5 0 0 PANGO_ELLIPSIZE_NONE -1 False 0 2 False False /* sample.c */ #include #include #include #define GLADE_FILE "sample.glade" // functions static gint delete_event_cb(GtkWidget* w, GdkEventAny* e, gpointer data); static gint destroy_cb(GtkWidget* w, GdkEventAny* e, gpointer data); static void on_button1_clicked(GtkButton *button, gpointer data); int main (int argc, char *argv[]) { GladeXML *gxml; gtk_init (&argc, &argv); //Create interface gxml = glade_xml_new (GLADE_FILE, "window1", NULL); GtkWidget *window1 = glade_xml_get_widget(gxml, "window1"); //connect signals glade_xml_signal_connect_data (gxml, "on_button1_clicked", G_CALLBACK (on_button1_clicked), NULL); g_signal_connect(G_OBJECT(window1), "delete_event", G_CALLBACK(delete_event_cb), NULL); g_signal_connect(G_OBJECT(window1), "destroy", G_CALLBACK(destroy_cb), NULL); //beginn loop gtk_main (); return 0; } static gint delete_event_cb(GtkWidget* w, GdkEventAny* e, gpointer data) { return 0; } static gint destroy_cb(GtkWidget* w, GdkEventAny* e, gpointer data) { gtk_main_quit(); return 0; } void on_button1_clicked(GtkButton *button, gpointer data) { /* the button was clicked */ //Print out to console g_print("Beginn break\n"); //Create the new "progress" window GladeXML*gxml_progress = NULL; gxml_progress = glade_xml_new (GLADE_FILE, "window2", NULL); //show the window GtkWidget *window2 = glade_xml_get_widget(gxml_progress, "window2"); gtk_widget_show_all(window2); while (gtk_events_pending()) gtk_main_iteration(); //Make 5 sec. break g_usleep(500); g_print("End break\n"); } I compile it with: "gcc -Wall -export-dynamic -g `pkg-config --cflags --libs gtk+-2.0` `pkg-config --cflags --libs libglade-2.0` -o sample sample.c" on my FC6 machine. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list