Enabled the minimise_all menu, and set the title bar to reflect the usage of the...
authorJohn Darrington <john@darrington.wattle.id.au>
Tue, 30 Dec 2008 07:27:27 +0000 (16:27 +0900)
committerJohn Darrington <john@darrington.wattle.id.au>
Tue, 30 Dec 2008 07:27:27 +0000 (16:27 +0900)
src/ui/gui/psppire-output-window.c
src/ui/gui/psppire-syntax-window.c
src/ui/gui/psppire-window.c
src/ui/gui/psppire-window.h

index 69e7c05130b7950ca89aedc585d07549bae1daaa..1bb7a455780245d50c1b25a39cab7e76823e9b8b 100644 (file)
@@ -249,12 +249,10 @@ psppire_output_window_init (PsppireOutputWindow *window)
                    G_CALLBACK (reference_manual),
                    NULL);
 
-#if 0
   g_signal_connect (get_widget_assert (xml,"windows_minimise-all"),
                    "activate",
-                   G_CALLBACK (minimise_all_windows),
+                   G_CALLBACK (psppire_window_minimise_all),
                    NULL);
-#endif
 
   g_object_unref (xml);
 
@@ -266,7 +264,9 @@ psppire_output_window_init (PsppireOutputWindow *window)
 GtkWidget*
 psppire_output_window_new (void)
 {
-  return GTK_WIDGET (g_object_new (psppire_output_window_get_type (), NULL));
+  return GTK_WIDGET (g_object_new (psppire_output_window_get_type (),
+                                  "usage", PSPPIRE_WINDOW_USAGE_OUTPUT,
+                                  NULL));
 }
 
 static void reload_viewer (PsppireOutputWindow *ow);
index 534e6cfc71933bab9580b02f5466e4d7e96e5856..56a39b8526ccc4bb0fc9a994a75e3ce4279c7755 100644 (file)
@@ -576,12 +576,10 @@ psppire_syntax_window_init (PsppireSyntaxWindow *window)
                    G_CALLBACK (on_run_to_end),
                    window);
 
-#if 0
   g_signal_connect (get_widget_assert (xml,"windows_minimise_all"),
                    "activate",
-                   G_CALLBACK (minimise_all_windows),
+                   G_CALLBACK (psppire_window_minimise_all),
                    NULL);
-#endif
 
   g_object_unref (xml);
 
@@ -593,7 +591,9 @@ psppire_syntax_window_init (PsppireSyntaxWindow *window)
 GtkWidget*
 psppire_syntax_window_new (void)
 {
-  return GTK_WIDGET (g_object_new (psppire_syntax_window_get_type (), NULL));
+  return GTK_WIDGET (g_object_new (psppire_syntax_window_get_type (),
+                                  "usage", PSPPIRE_WINDOW_USAGE_SYNTAX,
+                                  NULL));
 }
 
 
index 3848b897300744611007d2b22e407d94228d65d2..909075b02e7ae610dabc84adf663013a5c44e9b5 100644 (file)
@@ -34,6 +34,8 @@ static void psppire_window_class_init    (PsppireWindowClass *class);
 static void psppire_window_init          (PsppireWindow      *window);
 
 
+static PsppireWindowClass *the_class;
+
 
 GType
 psppire_window_get_type (void)
@@ -68,7 +70,8 @@ psppire_window_get_type (void)
 enum
 {
   PROP_0,
-  PROP_FILENAME
+  PROP_FILENAME,
+  PROP_USAGE
 };
 
 
@@ -78,6 +81,8 @@ uniquify (const gchar *str, int *x)
   return g_strdup_printf ("%s%d", str, (*x)++);
 }
 
+
+
 static void
 psppire_window_set_property (GObject         *object,
                             guint            prop_id,
@@ -87,9 +92,11 @@ psppire_window_set_property (GObject         *object,
   PsppireWindow *window = PSPPIRE_WINDOW (object);
 
   PsppireWindowClass *class = PSPPIRE_WINDOW_CLASS (G_OBJECT_GET_CLASS (object));
-  
   switch (prop_id)
     {
+    case PROP_USAGE:
+      window->usage = g_value_get_enum (value);
+      break;
     case PROP_FILENAME:
       {
        gchar mdash[6] = {0,0,0,0,0,0};
@@ -107,7 +114,23 @@ psppire_window_set_property (GObject         *object,
        basename = g_path_get_basename (candidate_name);
        g_unichar_to_utf8 (0x2014, mdash);
 
-       title = g_strdup_printf ( _("%s %s PSPPIRE Syntax Editor"), basename, mdash);
+       switch (window->usage)
+         {
+         case PSPPIRE_WINDOW_USAGE_SYNTAX:
+           title = g_strdup_printf ( _("%s %s PSPPIRE Syntax Editor"),
+                                     basename, mdash);
+           break;
+         case PSPPIRE_WINDOW_USAGE_OUTPUT:
+           title = g_strdup_printf ( _("%s %s PSPPIRE Output"),
+                                     basename, mdash);
+         case PSPPIRE_WINDOW_USAGE_DATA:
+           title = g_strdup_printf ( _("%s %s PSPPIRE Data Editor"),
+                                     basename, mdash);
+           break;
+         default:
+           g_assert_not_reached ();
+           break;
+         }
 
        gtk_window_set_title (GTK_WINDOW (window), title);
 
@@ -138,6 +161,9 @@ psppire_window_get_property (GObject         *object,
 
   switch (prop_id)
     {
+    case PROP_USAGE:
+      g_value_set_enum (value, window->usage);
+      break;
     case PROP_FILENAME:
       g_value_set_string (value, window->name);
       break;
@@ -175,8 +201,17 @@ psppire_window_finalize (GObject *object)
 static void
 psppire_window_class_init (PsppireWindowClass *class)
 {
- GObjectClass *object_class = G_OBJECT_CLASS (class);
+  GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+  GParamSpec *use_class_spec =
+    g_param_spec_enum ("usage",
+                      "Usage",
+                      "What the window is used for",
+                      G_TYPE_PSPPIRE_WINDOW_USAGE,
+                      PSPPIRE_WINDOW_USAGE_SYNTAX /* default value */,
+                      G_PARAM_CONSTRUCT_ONLY |G_PARAM_READABLE | G_PARAM_WRITABLE);
+
+
   GParamSpec *filename_spec =
     g_param_spec_string ("filename",
                       "File name",
@@ -193,11 +228,16 @@ psppire_window_class_init (PsppireWindowClass *class)
                                    PROP_FILENAME,
                                    filename_spec);
 
+  g_object_class_install_property (object_class,
+                                   PROP_USAGE,
+                                   use_class_spec);
 
 
   class->name_table = g_hash_table_new (g_str_hash, g_str_equal);
 
   g_hash_table_insert (class->name_table, "Untitled", NULL);
+
+  the_class = class;
 }
 
 
@@ -207,7 +247,6 @@ psppire_window_base_init (PsppireWindowClass *class)
   GObjectClass *object_class = G_OBJECT_CLASS (class);
 
   object_class->finalize = psppire_window_finalize;
-  
 }
 
 
@@ -230,9 +269,12 @@ psppire_window_init (PsppireWindow *window)
 
 
 GtkWidget*
-psppire_window_new (void)
+psppire_window_new (PsppireWindowUsage usage)
 {
-  return GTK_WIDGET (g_object_new (psppire_window_get_type (), "type", GTK_WINDOW_TOPLEVEL, NULL));
+  return GTK_WIDGET (g_object_new (psppire_window_get_type (),
+                                  "type", GTK_WINDOW_TOPLEVEL,
+                                  "usage", usage,
+                                  NULL));
 }
 
 
@@ -251,3 +293,51 @@ psppire_window_set_filename (PsppireWindow *w, const gchar *filename)
   g_object_set (w, "filename", filename, NULL);
 }
 
+
+static void
+minimise_all  (gpointer key,
+              gpointer value,
+              gpointer user_data)
+{
+  PsppireWindow *w = PSPPIRE_WINDOW (value);
+
+  gtk_window_iconify (w);
+}
+
+
+
+void
+psppire_window_minimise_all (void)
+{
+  g_hash_table_foreach (the_class->name_table, minimise_all, NULL);
+}
+
+
+
+\f
+
+GType
+psppire_window_usage_get_type (void)
+{
+  static GType etype = 0;
+  if (etype == 0)
+    {
+      static const GEnumValue values[] = {
+       { PSPPIRE_WINDOW_USAGE_SYNTAX, "PSPPIRE_WINDOW_USAGE_SYNTAX",
+         "Syntax" },
+
+       { PSPPIRE_WINDOW_USAGE_OUTPUT, "PSPPIRE_WINDOW_USAGE_OUTPUT",
+         "Output" },
+
+       { PSPPIRE_WINDOW_USAGE_DATA,   "PSPPIRE_WINDOW_USAGE_DATA",
+         "Data" },
+
+       { 0, NULL, NULL }
+      };
+
+      etype = g_enum_register_static
+       (g_intern_static_string ("PsppireWindowUsage"), values);
+    }
+
+  return etype;
+}
index d0eba02490bd07071831b15458eafc807f794346..ca5136a7bafc32cd28696ab0c0efdc52479a5858 100644 (file)
 
 G_BEGIN_DECLS
 
+typedef enum {
+  PSPPIRE_WINDOW_USAGE_SYNTAX,
+  PSPPIRE_WINDOW_USAGE_OUTPUT,
+  PSPPIRE_WINDOW_USAGE_DATA
+} PsppireWindowUsage;
+
+
+GType psppire_window_usage_get_type (void);
+
+
+#define G_TYPE_PSPPIRE_WINDOW_USAGE \
+  (psppire_window_usage_get_type())
+
+\f
+
+
 #define PSPPIRE_WINDOW_TYPE            (psppire_window_get_type ())
 #define PSPPIRE_WINDOW(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), PSPPIRE_WINDOW_TYPE, PsppireWindow))
 #define PSPPIRE_WINDOW_CLASS(class)    (G_TYPE_CHECK_CLASS_CAST ((class), \
@@ -47,6 +63,7 @@ struct _PsppireWindow
   /* <private> */
   gchar *name;
   gboolean finalized;
+  PsppireWindowUsage usage;
 };
 
 struct _PsppireWindowClass
@@ -57,12 +74,14 @@ struct _PsppireWindowClass
 };
 
 GType      psppire_window_get_type        (void);
-GtkWidget* psppire_window_new             (void);
+GtkWidget* psppire_window_new             (PsppireWindowUsage usage);
 
 const gchar * psppire_window_get_filename (PsppireWindow *);
 
 void psppire_window_set_filename (PsppireWindow *w, const gchar *filename);
 
+void psppire_window_minimise_all (void);
+
 
 G_END_DECLS