ges-ui: add new command, remove quit command (closing last window quits app)
authorBrandon Lewis <brandon@collabora.co.uk>
Fri, 8 Oct 2010 11:32:15 +0000 (12:32 +0100)
committerEdward Hervey <edward.hervey@collabora.co.uk>
Sat, 27 Nov 2010 17:12:49 +0000 (18:12 +0100)
tests/examples/ges-ui.c
tests/examples/ges-ui.glade

index d0eec48..466c388 100644 (file)
@@ -87,13 +87,16 @@ typedef struct App
   GtkSpinButton *frequency;
 } App;
 
+static int n_instances = 0;
+
 /* Prototypes for auto-connected signal handlers ***************************/
 
 /**
  * These are declared non-static for signal auto-connection
  */
 
-gboolean window_delete_event_cb (GtkObject * window, App * app);
+gboolean window_delete_event_cb (GtkObject * window, GdkEvent * event,
+    App * app);
 void quit_item_activate_cb (GtkMenuItem * item, App * app);
 void delete_activate_cb (GtkAction * item, App * app);
 void play_activate_cb (GtkAction * item, App * app);
@@ -999,6 +1002,12 @@ app_dispose (App * app)
 
     g_free (app);
   }
+
+  n_instances--;
+
+  if (n_instances == 0) {
+    gtk_main_quit ();
+  }
 }
 
 static App *
@@ -1006,6 +1015,7 @@ app_new (void)
 {
   App *ret;
   ret = g_new0 (App, 1);
+  n_instances++;
 
   ret->selected_type = G_TYPE_NONE;
 
@@ -1040,10 +1050,10 @@ fail:
 /* UI callbacks  ************************************************************/
 
 gboolean
-window_delete_event_cb (GtkObject * window, App * app)
+window_delete_event_cb (GtkObject * window, GdkEvent * event, App * app)
 {
-  gtk_main_quit ();
-  return TRUE;
+  app_dispose (app);
+  return FALSE;
 }
 
 void
@@ -1283,7 +1293,6 @@ main (int argc, char *argv[])
 
   if ((app = app_new ())) {
     gtk_main ();
-    app_dispose (app);
   }
 
   return 0;
index bd5431e..9f536a4 100644 (file)
@@ -60,7 +60,9 @@
                       <object class="GtkImageMenuItem" id="new_item">
                         <property name="label">gtk-new</property>
                         <property name="use_underline">True</property>
+                        <property name="visible">True</property>
                         <property name="use_stock">True</property>
+                        <signal name="activate" handler="new_activate_cb"/>
                       </object>
                     </child>
                     <child>
                         <property name="use_stock">True</property>
                       </object>
                     </child>
-                    <child>
-                      <object class="GtkSeparatorMenuItem" id="separatormenuitem1">
-                        <property name="visible">True</property>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="GtkImageMenuItem" id="quit_item">
-                        <property name="label">gtk-quit</property>
-                        <property name="visible">True</property>
-                        <property name="use_underline">True</property>
-                        <property name="use_stock">True</property>
-                        <signal name="activate" handler="quit_item_activate_cb"/>
-                      </object>
-                    </child>
                   </object>
                 </child>
               </object>