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 */
>>>
>>> <?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
>>> <!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd";>
>>>
>>> <glade-interface>
>>>
>>> <widget class="GtkWindow" id="window1">
>>>   <property name="border_width">10</property>
>>>   <property name="visible">True</property>
>>>   <property name="title" translatable="yes">window1</property>
>>>   <property name="type">GTK_WINDOW_TOPLEVEL</property>
>>>   <property name="window_position">GTK_WIN_POS_NONE</property>
>>>   <property name="modal">False</property>
>>>   <property name="resizable">False</property>
>>>   <property name="destroy_with_parent">False</property>
>>>   <property name="decorated">True</property>
>>>   <property name="skip_taskbar_hint">False</property>
>>>   <property name="skip_pager_hint">False</property>
>>>   <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
>>>   <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
>>>   <property name="focus_on_map">True</property>
>>>   <property name="urgency_hint">False</property>
>>>
>>>   <child>
>>>     <widget class="GtkButton" id="button1">
>>>       <property name="width_request">150</property>
>>>       <property name="visible">True</property>
>>>       <property name="can_focus">True</property>
>>>       <property name="label" translatable="yes">Run</property>
>>>       <property name="use_underline">True</property>
>>>       <property name="relief">GTK_RELIEF_NORMAL</property>
>>>       <property name="focus_on_click">True</property>
>>>       <signal name="clicked" handler="on_button1_clicked"
>>> last_modification_time="Mon, 19 Feb 2007 20:34:21 GMT"/>
>>>     </widget>
>>>   </child>
>>> </widget>
>>>
>>> <widget class="GtkWindow" id="window2">
>>>   <property name="border_width">10</property>
>>>   <property name="visible">True</property>
>>>   <property name="title" translatable="yes">window2</property>
>>>   <property name="type">GTK_WINDOW_TOPLEVEL</property>
>>>   <property name="window_position">GTK_WIN_POS_NONE</property>
>>>   <property name="modal">False</property>
>>>   <property name="resizable">False</property>
>>>   <property name="destroy_with_parent">False</property>
>>>   <property name="decorated">True</property>
>>>   <property name="skip_taskbar_hint">False</property>
>>>   <property name="skip_pager_hint">False</property>
>>>   <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
>>>   <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
>>>   <property name="focus_on_map">True</property>
>>>   <property name="urgency_hint">False</property>
>>>
>>>   <child>
>>>     <widget class="GtkVBox" id="vbox1">
>>>       <property name="visible">True</property>
>>>       <property name="homogeneous">False</property>
>>>       <property name="spacing">0</property>
>>>
>>>       <child>
>>>    <widget class="GtkLabel" id="label1">
>>>      <property name="visible">True</property>
>>>      <property name="label" translatable="yes">Progress window</property>
>>>      <property name="use_underline">False</property>
>>>      <property name="use_markup">False</property>
>>>      <property name="justify">GTK_JUSTIFY_LEFT</property>
>>>      <property name="wrap">False</property>
>>>      <property name="selectable">False</property>
>>>      <property name="xalign">0.5</property>
>>>      <property name="yalign">0.5</property>
>>>      <property name="xpad">0</property>
>>>      <property name="ypad">0</property>
>>>      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
>>>      <property name="width_chars">-1</property>
>>>      <property name="single_line_mode">False</property>
>>>      <property name="angle">0</property>
>>>    </widget>
>>>    <packing>
>>>      <property name="padding">0</property>
>>>      <property name="expand">False</property>
>>>      <property name="fill">False</property>
>>>    </packing>
>>>       </child>
>>>
>>>       <child>
>>>    <widget class="GtkProgressBar" id="progressbar1">
>>>      <property name="visible">True</property>
>>>      <property name="orientation">GTK_PROGRESS_LEFT_TO_RIGHT</property>
>>>      <property name="fraction">0</property>
>>>      <property name="pulse_step">0.10000000149</property>
>>>      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
>>>    </widget>
>>>    <packing>
>>>      <property name="padding">0</property>
>>>      <property name="expand">False</property>
>>>      <property name="fill">False</property>
>>>    </packing>
>>>       </child>
>>>
>>>       <child>
>>>    <widget class="GtkLabel" id="label2">
>>>      <property name="visible">True</property>
>>>      <property name="label" 
>>> translatable="yes">progress_description</property>
>>>      <property name="use_underline">False</property>
>>>      <property name="use_markup">False</property>
>>>      <property name="justify">GTK_JUSTIFY_LEFT</property>
>>>      <property name="wrap">False</property>
>>>      <property name="selectable">False</property>
>>>      <property name="xalign">0.5</property>
>>>      <property name="yalign">0.5</property>
>>>      <property name="xpad">0</property>
>>>      <property name="ypad">0</property>
>>>      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
>>>      <property name="width_chars">-1</property>
>>>      <property name="single_line_mode">False</property>
>>>      <property name="angle">0</property>
>>>    </widget>
>>>    <packing>
>>>      <property name="padding">2</property>
>>>      <property name="expand">False</property>
>>>      <property name="fill">False</property>
>>>    </packing>
>>>       </child>
>>>     </widget>
>>>   </child>
>>> </widget>
>>>
>>> </glade-interface>
>>>
>>>
>>> /* sample.c */
>>> #include <gtk/gtk.h>
>>> #include <glade/glade.h>
>>> #include <stdlib.h>
>>>
>>> #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(5000000);
>>>       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
>>
>>     
> _______________________________________________
> 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

Reply via email to