Use GtkHPaned in variable info dialog
authorJohn Darrington <john@darrington.wattle.id.au>
Mon, 16 Mar 2009 21:37:11 +0000 (06:37 +0900)
committerJohn Darrington <john@darrington.wattle.id.au>
Mon, 16 Mar 2009 21:37:11 +0000 (06:37 +0900)
Moved variable info dialog spec from psppire.glade into
its own file.  Added a "sliding" property to PsppireDialog
which causes Gtk[VH]Paned to be used instead of Gtk[VH]Box.
Set the sliding property for the variable info dialog.

src/ui/gui/automake.mk
src/ui/gui/psppire-dialog.c
src/ui/gui/psppire-dialog.h
src/ui/gui/psppire.glade
src/ui/gui/variable-info-dialog.c
src/ui/gui/variable-info-dialog.glade [new file with mode: 0644]

index 5f14e62c9e7418517268da48e63a1d7203ecf787..e104b275e45e2705258d55544b203388d5dda2f0 100644 (file)
@@ -73,7 +73,8 @@ nodist_src_ui_gui_psppire_DATA = \
        $(top_builddir)/src/ui/gui/syntax-editor.ui \
        $(top_builddir)/src/ui/gui/text-data-import.ui \
        $(top_builddir)/src/ui/gui/t-test.ui \
-       $(top_builddir)/src/ui/gui/var-sheet-dialogs.ui
+       $(top_builddir)/src/ui/gui/var-sheet-dialogs.ui \
+       $(top_builddir)/src/ui/gui/variable-info-dialog.ui
 
 
 dist_src_ui_gui_psppire_DATA = \
@@ -225,7 +226,8 @@ src_ui_gui_psppire_SOURCES = \
        src/ui/gui/syntax-editor.glade \
        src/ui/gui/text-data-import.glade \
        src/ui/gui/t-test.glade \
-       src/ui/gui/var-sheet-dialogs.glade
+       src/ui/gui/var-sheet-dialogs.glade \
+       src/ui/gui/variable-info-dialog.glade
 
 
 nodist_src_ui_gui_psppire_SOURCES = \
index 22b4cf4eb339d752f0442fa6231b66696e10c29e..6a6733d2f457897ae8e89dfb08e53053d4b5d18b 100644 (file)
@@ -73,7 +73,6 @@ psppire_dialog_get_type (void)
       g_type_add_interface_static (dialog_type,
                                   GTK_TYPE_BUILDABLE,
                                   &buildable_info);
-
     }
 
   return dialog_type;
@@ -104,7 +103,8 @@ psppire_dialog_finalize (GObject *object)
 enum
 {
   PROP_0,
-  PROP_ORIENTATION
+  PROP_ORIENTATION,
+  PROP_SLIDING
 };
 
 
@@ -120,14 +120,17 @@ psppire_dialog_get_property (GObject         *object,
     {
     case PROP_ORIENTATION:
       {
-       if ( GTK_IS_VBOX (dialog->box) )
+       if ( GTK_IS_VBOX (dialog->box) || GTK_VPANED (dialog->box))
          g_value_set_enum (value, PSPPIRE_VERTICAL);
-       else if ( GTK_IS_HBOX (dialog->box))
+       else if ( GTK_IS_HBOX (dialog->box) || GTK_HPANED (dialog->box))
          g_value_set_enum (value, PSPPIRE_HORIZONTAL);
        else if ( GTK_IS_TABLE (dialog->box))
          g_value_set_enum (value, PSPPIRE_TABULAR);
       }
       break;
+    case PROP_SLIDING:
+      g_value_set_boolean (value, dialog->slidable);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -136,22 +139,26 @@ psppire_dialog_get_property (GObject         *object,
 
 
 static void
-dialog_set_orientation (PsppireDialog *dialog, const GValue *orval)
+dialog_set_container (PsppireDialog *dialog)
 {
-  PsppireOrientation orientation = g_value_get_enum (orval);
-
   if ( dialog->box != NULL)
     {
       gtk_container_remove (GTK_CONTAINER (dialog), dialog->box);
     }
 
-  switch ( orientation )
+  switch (dialog->orientation)
     {
     case PSPPIRE_HORIZONTAL:
-      dialog->box = gtk_hbox_new (FALSE, 5);
+      if ( dialog->slidable)
+       dialog->box = gtk_hpaned_new();
+      else
+       dialog->box = gtk_hbox_new (FALSE, 5);
       break;
     case PSPPIRE_VERTICAL:
-      dialog->box = gtk_vbox_new (FALSE, 5);
+      if ( dialog->slidable)
+       dialog->box = gtk_vpaned_new();
+      else
+       dialog->box = gtk_vbox_new (FALSE, 5);
       break;
     case PSPPIRE_TABULAR:
       dialog->box = gtk_table_new (2, 3, FALSE);
@@ -162,6 +169,7 @@ dialog_set_orientation (PsppireDialog *dialog, const GValue *orval)
       break;
     }
 
+  gtk_widget_show_all (dialog->box);
   gtk_container_add (GTK_CONTAINER (dialog), dialog->box);
 }
 
@@ -177,13 +185,18 @@ psppire_dialog_set_property (GObject         *object,
 
   switch (prop_id)
     {
+    case PROP_SLIDING:
+      dialog->slidable = g_value_get_boolean (value);
+      break;
     case PROP_ORIENTATION:
-      dialog_set_orientation (dialog, value);
+      dialog->orientation = g_value_get_enum (value);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
     };
+
+  dialog_set_container (dialog);
 }
 
 
@@ -194,6 +207,7 @@ psppire_dialog_class_init (PsppireDialogClass *class)
 {
   GObjectClass *object_class = (GObjectClass *) class;
 
+  GParamSpec *sliding_spec ;
 
   orientation_spec =
     g_param_spec_enum ("orientation",
@@ -203,6 +217,14 @@ psppire_dialog_class_init (PsppireDialogClass *class)
                       PSPPIRE_HORIZONTAL /* default value */,
                       G_PARAM_CONSTRUCT_ONLY |G_PARAM_READWRITE);
 
+  sliding_spec =
+    g_param_spec_boolean ("slidable",
+                         "Slidable",
+                         "Can the container be sized by the user",
+                         FALSE,
+                         G_PARAM_CONSTRUCT_ONLY |G_PARAM_READWRITE);
+
+
 
   object_class->set_property = psppire_dialog_set_property;
   object_class->get_property = psppire_dialog_get_property;
@@ -212,6 +234,11 @@ psppire_dialog_class_init (PsppireDialogClass *class)
                                    orientation_spec);
 
 
+  g_object_class_install_property (object_class,
+                                   PROP_SLIDING,
+                                   sliding_spec);
+
+
 
   signals [DIALOG_REFRESH] =
     g_signal_new ("refresh",
@@ -305,6 +332,7 @@ psppire_dialog_init (PsppireDialog *dialog)
   dialog->box = NULL;
   dialog->contents_are_valid = NULL;
   dialog->validity_data = NULL;
+  dialog->slidable = FALSE;
 
   g_value_init (&value, orientation_spec->value_type);
   g_param_value_set_default (orientation_spec, &value);
@@ -312,8 +340,6 @@ psppire_dialog_init (PsppireDialog *dialog)
   gtk_window_set_type_hint (GTK_WINDOW (dialog),
        GDK_WINDOW_TYPE_HINT_DIALOG);
 
-  dialog_set_orientation (dialog, &value);
-
   g_value_unset (&value);
 
   g_signal_connect (dialog, "delete-event",
@@ -333,8 +359,6 @@ psppire_dialog_init (PsppireDialog *dialog)
        GDK_WINDOW_TYPE_HINT_DIALOG);
 
   g_object_set (dialog, "icon-name", "psppicon", NULL);
-
-  gtk_widget_show_all (dialog->box);
 }
 
 
index 05215ce984e2b14bd332aad5bb02f86ffd25d2ef..5a1b1f57b598e8c2be76ed0fddece2e77605a4e0 100644 (file)
@@ -42,6 +42,14 @@ typedef struct _PsppireDialogClass  PsppireDialogClass;
 
 typedef gboolean (*ContentsAreValid) (gpointer);
 
+typedef enum
+  {
+    PSPPIRE_HORIZONTAL,
+    PSPPIRE_VERTICAL,
+    PSPPIRE_TABULAR
+  } PsppireOrientation;
+
+
 
 struct _PsppireDialog
 {
@@ -54,6 +62,8 @@ struct _PsppireDialog
 
   ContentsAreValid contents_are_valid;
   gpointer validity_data;
+  gboolean slidable;
+  PsppireOrientation orientation;
 };
 
 struct _PsppireDialogClass
@@ -77,13 +87,6 @@ void           psppire_dialog_notify_change (PsppireDialog *);
 GType psppire_orientation_get_type (void);
 
 
-typedef enum
-  {
-    PSPPIRE_HORIZONTAL,
-    PSPPIRE_VERTICAL,
-    PSPPIRE_TABULAR
-  } PsppireOrientation;
-
 #define G_TYPE_PSPPIRE_ORIENTATION (psppire_orientation_get_type ())
 
 
index 473d530473894da5915f747c82e838707630b2bc..8be27e381f54e28ba0ec49ca9c159aa8a0aa4538 100644 (file)
       </widget>
     </child>
   </widget>
-  <widget class="PsppireDialog" id="variable-info-dialog">
-    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-    <property name="title">Variables</property>
-    <property name="modal">True</property>
-    <child internal-child="hbox">
-      <widget class="GtkHBox" id="dialog-hbox6">
-        <property name="visible">True</property>
-        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-        <property name="spacing">5</property>
-        <child>
-          <widget class="GtkScrolledWindow" id="scrolledwindow11">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-            <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
-            <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
-            <property name="shadow_type">GTK_SHADOW_IN</property>
-            <child>
-              <widget class="GtkTreeView" id="treeview2">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="headers_visible">False</property>
-                <property name="reorderable">True</property>
-                <property name="fixed_height_mode">True</property>
-              </widget>
-            </child>
-          </widget>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="padding">5</property>
-          </packing>
-        </child>
-        <child>
-          <widget class="GtkVBox" id="vbox23">
-            <property name="visible">True</property>
-            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-            <property name="spacing">5</property>
-            <child>
-              <widget class="GtkLabel" id="label24">
-                <property name="visible">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">Variable Information:</property>
-              </widget>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="padding">5</property>
-              </packing>
-            </child>
-            <child>
-              <widget class="GtkScrolledWindow" id="scrolledwindow12">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
-                <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
-                <property name="shadow_type">GTK_SHADOW_IN</property>
-                <child>
-                  <widget class="GtkTextView" id="textview1">
-                    <property name="height_request">200</property>
-                    <property name="visible">True</property>
-                    <property name="events">GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                    <property name="editable">False</property>
-                    <property name="wrap_mode">GTK_WRAP_WORD_CHAR</property>
-                    <property name="left_margin">3</property>
-                    <property name="cursor_visible">False</property>
-                    <property name="accepts_tab">False</property>
-                  </widget>
-                </child>
-              </widget>
-              <packing>
-                <property name="padding">5</property>
-                <property name="position">2</property>
-              </packing>
-            </child>
-            <child>
-              <widget class="PsppireHButtonBox" id="psppire-hbuttonbox3">
-                <property name="visible">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="border_width">5</property>
-                <property name="homogeneous">True</property>
-                <property name="buttons">PSPPIRE_BUTTON_GOTO_MASK | PSPPIRE_BUTTON_CANCEL_MASK | PSPPIRE_BUTTON_HELP_MASK | PSPPIRE_BUTTON_PASTE_MASK</property>
-              </widget>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="pack_type">GTK_PACK_END</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </widget>
-          <packing>
-            <property name="padding">5</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-      </widget>
-    </child>
-  </widget>
   <widget class="PsppireDialog" id="select-cases-range-dialog">
     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
     <property name="title">Select Cases: Range</property>
index 2f5495f137dd5a41f0e889cc847a210f7bf4b3e7..6fc8dd89221759c9d24f1050d2fd8ab6384e9ebd 100644 (file)
@@ -167,7 +167,7 @@ variable_info_dialog (GObject *o, gpointer data)
 
   gint response ;
 
-  GtkBuilder *xml = builder_new ("psppire.ui");
+  GtkBuilder *xml = builder_new ("variable-info-dialog.ui");
 
   GtkWidget *dialog = get_widget_assert (xml, "variable-info-dialog");
   GtkWidget *treeview = get_widget_assert (xml, "treeview2");
diff --git a/src/ui/gui/variable-info-dialog.glade b/src/ui/gui/variable-info-dialog.glade
new file mode 100644 (file)
index 0000000..147d66a
--- /dev/null
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--*- mode: xml -*-->
+<glade-interface>
+  <requires lib="psppire"/>
+  <widget class="PsppireDialog" id="variable-info-dialog">
+    <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+    <property name="title">Variables</property>
+    <property name="modal">True</property>
+    <property name="slidable">True</property>
+    <child internal-child="hbox">
+      <widget class="GtkHPaned" id="dialog-hbox2">
+        <property name="visible">True</property>
+        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+        <child>
+          <widget class="GtkScrolledWindow" id="scrolledwindow13">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+            <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
+            <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+            <property name="shadow_type">GTK_SHADOW_IN</property>
+            <child>
+              <widget class="GtkTreeView" id="treeview2">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="headers_visible">False</property>
+                <property name="reorderable">True</property>
+                <property name="fixed_height_mode">True</property>
+              </widget>
+            </child>
+          </widget>
+          <packing>
+            <property name="resize">False</property>
+            <property name="shrink">True</property>
+          </packing>
+        </child>
+        <child>
+          <widget class="GtkVBox" id="vbox23">
+            <property name="visible">True</property>
+            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+            <property name="spacing">5</property>
+            <child>
+              <widget class="GtkLabel" id="label24">
+                <property name="visible">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">Variable Information:</property>
+              </widget>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="padding">5</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkScrolledWindow" id="scrolledwindow14">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
+                <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+                <property name="shadow_type">GTK_SHADOW_IN</property>
+                <child>
+                  <widget class="GtkTextView" id="textview1">
+                    <property name="height_request">200</property>
+                    <property name="visible">True</property>
+                    <property name="events">GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                    <property name="editable">False</property>
+                    <property name="wrap_mode">GTK_WRAP_WORD_CHAR</property>
+                    <property name="left_margin">3</property>
+                    <property name="cursor_visible">False</property>
+                    <property name="accepts_tab">False</property>
+                  </widget>
+                </child>
+              </widget>
+              <packing>
+                <property name="padding">5</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="PsppireHButtonBox" id="psppire-hbuttonbox4">
+                <property name="visible">True</property>
+                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                <property name="border_width">5</property>
+                <property name="homogeneous">True</property>
+                <property name="buttons">PSPPIRE_BUTTON_GOTO_MASK | PSPPIRE_BUTTON_CANCEL_MASK | PSPPIRE_BUTTON_HELP_MASK | PSPPIRE_BUTTON_PASTE_MASK</property>
+              </widget>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="pack_type">GTK_PACK_END</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="resize">True</property>
+            <property name="shrink">True</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
+</glade-interface>