Added a "Windows" menu, and a "minimise all windows" item.
authorJohn Darrington <john@darrington.wattle.id.au>
Thu, 28 Dec 2006 00:44:45 +0000 (00:44 +0000)
committerJohn Darrington <john@darrington.wattle.id.au>
Thu, 28 Dec 2006 00:44:45 +0000 (00:44 +0000)
src/ui/gui/data-editor.c
src/ui/gui/data-editor.glade
src/ui/gui/syntax-editor-source.c
src/ui/gui/syntax-editor.c
src/ui/gui/syntax-editor.glade
src/ui/gui/window-manager.c
src/ui/gui/window-manager.h

index 5c2eaf4f30b29b65d111ba9d396215507c9fd05d..76612b5e9461fe7296a3c201ab791ef48cf353f3 100644 (file)
@@ -24,7 +24,7 @@
 #include <glade/glade.h>
 #include <gtk/gtk.h>
 
-
+#include "window-manager.h"
 #include <gtksheet/gtksheet.h>
 
 #include "helper.h"
@@ -116,7 +116,7 @@ new_data_editor (void)
 
   connect_help (de->xml);
 
-  e->window = get_widget_assert (de->xml, "data_editor");
+  e->window = GTK_WINDOW (get_widget_assert (de->xml, "data_editor"));
 
   g_signal_connect (get_widget_assert (de->xml,"file_new_data"),
                    "activate",
@@ -230,6 +230,11 @@ new_data_editor (void)
                    G_CALLBACK (file_quit), de);
 
 
+  g_signal_connect (get_widget_assert (de->xml, "windows_minimise_all"),
+                   "activate",
+                   G_CALLBACK (minimise_all_windows), NULL);
+
+
   select_sheet (de, PAGE_DATA_SHEET);
 
   return de;
index 085555563f43c697af08421bc7e7f7dfc552607e..419a9c604ee0f450f8c7072422d28aaa964f97a3 100644 (file)
                      <property name="use_underline">True</property>
 
                      <child internal-child="image">
-                       <widget class="GtkImage" id="image41">
+                       <widget class="GtkImage" id="image44">
                          <property name="visible">True</property>
                          <property name="stock">gtk-find</property>
                          <property name="icon_size">1</property>
                      <signal name="activate" handler="on_go_to_case_activate" last_modification_time="Mon, 19 Jun 2006 10:29:37 GMT"/>
 
                      <child internal-child="image">
-                       <widget class="GtkImage" id="image42">
+                       <widget class="GtkImage" id="image45">
                          <property name="visible">True</property>
                          <property name="stock">gtk-jump-to</property>
                          <property name="icon_size">1</property>
            </widget>
          </child>
 
+         <child>
+           <widget class="GtkMenuItem" id="Windows">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">_Windows</property>
+             <property name="use_underline">True</property>
+             <signal name="activate" handler="on_Windows_activate" last_modification_time="Wed, 27 Dec 2006 23:16:44 GMT"/>
+
+             <child>
+               <widget class="GtkMenu" id="Windows_menu">
+
+                 <child>
+                   <widget class="GtkMenuItem" id="windows_minimise_all">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">_Minimise All Windows</property>
+                     <property name="use_underline">True</property>
+                     <signal name="activate" handler="on_minimiseall_activate" last_modification_time="Wed, 27 Dec 2006 23:17:26 GMT"/>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+           </widget>
+         </child>
+
          <child>
            <widget class="GtkMenuItem" id="menuitem5">
              <property name="visible">True</property>
index dcb644a3036107582ee597b794fce67f52e01d4d..9e0a556482f2511f8a966b0046a8e3328c30ebd4 100644 (file)
@@ -52,7 +52,7 @@ name (const struct getl_interface *i)
   const struct syntax_editor_source *ses =
     (const struct syntax_editor_source *) i;
 
-  return window_name ((struct window_editor *) ses->se);
+  return window_name ((const struct editor_window *) ses->se);
 }
 
 
index 95148d2cf12c46066bac89e6cf93351d8c247a7f..643013a3371c90c38c6442a8ae1823c12b2742d2 100644 (file)
@@ -110,7 +110,7 @@ save_if_modified (struct syntax_editor *se)
        return ;
     }
 
-  gtk_widget_destroy (e->window);
+  gtk_widget_destroy (GTK_WIDGET (e->window));
 }
 
 /* Callback for the File->SaveAs menuitem */
@@ -331,7 +331,7 @@ new_syntax_editor (void)
 
   e = (struct editor_window *)se;
 
-  e->window = get_widget_assert (xml, "syntax_editor");
+  e->window = GTK_WINDOW (get_widget_assert (xml, "syntax_editor"));
   text_view = get_widget_assert (xml, "syntax_text_view");
   se->buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
   se->lexer = lex_create (the_source_stream);
@@ -408,6 +408,13 @@ new_syntax_editor (void)
                    se);
 
 
+  g_signal_connect (get_widget_assert (xml,"windows_minimise_all"),
+                   "activate",
+                   G_CALLBACK (minimise_all_windows),
+                   NULL);
+
+
+
   g_object_unref (xml);
 
   g_signal_connect (e->window, "delete-event",
index f5473006ff4a23aa37d6df42d94d093468e5176a..80e6bff31147a438328cb61c3d9c23dcc6960a41 100644 (file)
            </widget>
          </child>
 
+         <child>
+           <widget class="GtkMenuItem" id="windows">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">_Windows</property>
+             <property name="use_underline">True</property>
+             <signal name="activate" handler="on_windows_activate" last_modification_time="Thu, 28 Dec 2006 00:31:09 GMT"/>
+
+             <child>
+               <widget class="GtkMenu" id="windows_menu">
+
+                 <child>
+                   <widget class="GtkMenuItem" id="windows_minimise_all">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">_Minimise All Windows</property>
+                     <property name="use_underline">True</property>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+           </widget>
+         </child>
+
          <child>
            <widget class="GtkMenuItem" id="menuitem9">
              <property name="visible">True</property>
index 8ecce98c7c1a2e3581341aac7be78fd216fe1e62..d7c543a40e70d7944cc6f381491eb6959d4b06a1 100644 (file)
@@ -1,3 +1,4 @@
+#include <glib.h>
 #include "syntax-editor.h"
 #include "data-editor.h"
 
 #include "window-manager.h"
 
 
-static int window_count = 0;
+
+/* A list of struct editor_windows */
+static GSList *window_list = NULL;
+
 
 static void
-deregister (GtkObject *o, gpointer data)
+deregister_window (GtkWindow *w, gpointer data)
 {
-  window_count --;
+  struct editor_window *e = data;
 
-  if ( 0 == window_count )
+  window_list = g_slist_remove (window_list, e);
+
+  if ( g_slist_length (window_list) == 0 )
     gtk_main_quit ();
 };
 
+
+static void
+register_window (struct editor_window *e)
+{
+  window_list = g_slist_prepend (window_list, e);
+}
+
+
+static gint
+next_window_id (void)
+{
+  return g_slist_length (window_list);
+}
+
+void
+minimise_all_windows (void)
+{
+  const GSList *i = NULL;
+
+  for (i = window_list; i != NULL ; i = i->next)
+    {
+      struct editor_window *e = i->data;
+      gtk_window_iconify (e->window);
+    }
+}
+
 static void set_window_name (struct editor_window *e, const gchar *name );
 
 
@@ -48,11 +80,12 @@ window_create (enum window_type type, const gchar *name)
   gtk_window_set_icon_from_file (GTK_WINDOW (e->window),
                                 PKGDATADIR "/psppicon.png", 0);
 
-  g_signal_connect (e->window, "destroy", G_CALLBACK (deregister), NULL);
+  g_signal_connect (e->window, "destroy",
+                   G_CALLBACK (deregister_window), e);
 
-  gtk_widget_show (e->window);
+  register_window (e);
 
-  window_count ++;
+  gtk_widget_show (e->window);
 
   return e;
 }
@@ -75,11 +108,11 @@ set_window_name (struct editor_window *e,
   switch (e->type )
     {
     case WINDOW_SYNTAX:
-      e->name = g_strdup_printf (_("Syntax%d"), window_count);
+      e->name = g_strdup_printf (_("Syntax%d"), next_window_id () );
       title = g_strdup_printf (_("%s --- PSPP Syntax Editor"), e->name);
       break;
     case WINDOW_DATA:
-      e->name = g_strdup_printf (_("Untitled%d"), window_count);
+      e->name = g_strdup_printf (_("Untitled%d"), next_window_id () );
       title = g_strdup_printf (_("%s --- PSPP Data Editor"), e->name);
       break;
     default:
@@ -119,13 +152,6 @@ window_set_name_from_filename (struct editor_window *e,
   g_free (title);
 }
 
-
-GtkWindow *
-window_toplevel (const struct editor_window *e)
-{
-  return GTK_WINDOW (e->window);
-}
-
 const gchar *
 window_name (const struct editor_window *e)
 {
index ee137dbc48a00f888531900a14d9dba02bd72e60..3c5655ed2b35e8ca971718f345374f48ccdbe026 100644 (file)
@@ -12,7 +12,7 @@ enum window_type
 
 struct editor_window
  {
-  GtkWidget *window;      /* The top level window of the editor */
+  GtkWindow *window;      /* The top level window of the editor */
   gchar *name;            /* The name of this editor */
   enum window_type type;
  } ;
@@ -20,12 +20,12 @@ struct editor_window
 struct editor_window * window_create (enum window_type type,
                                      const gchar *name);
 
-
-GtkWindow * window_toplevel (const struct editor_window *);
-
 const gchar * window_name (const struct editor_window *);
 
 void window_set_name_from_filename (struct editor_window *e,
                                    const gchar *filename);
 
+void minimise_all_windows (void);
+
+
 #endif