From: John Darrington <john@darrington.wattle.id.au> Date: Mon, 16 Mar 2009 21:37:11 +0000 (+0900) Subject: Use GtkHPaned in variable info dialog X-Git-Tag: v0.7.3~225 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e589b646894ffc013ab5e57981c8ac07bce522dd;p=pspp-builds.git Use GtkHPaned in variable info dialog 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. --- diff --git a/src/ui/gui/automake.mk b/src/ui/gui/automake.mk index 5f14e62c..e104b275 100644 --- a/src/ui/gui/automake.mk +++ b/src/ui/gui/automake.mk @@ -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 = \ diff --git a/src/ui/gui/psppire-dialog.c b/src/ui/gui/psppire-dialog.c index 22b4cf4e..6a6733d2 100644 --- a/src/ui/gui/psppire-dialog.c +++ b/src/ui/gui/psppire-dialog.c @@ -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); } diff --git a/src/ui/gui/psppire-dialog.h b/src/ui/gui/psppire-dialog.h index 05215ce9..5a1b1f57 100644 --- a/src/ui/gui/psppire-dialog.h +++ b/src/ui/gui/psppire-dialog.h @@ -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 ()) diff --git a/src/ui/gui/psppire.glade b/src/ui/gui/psppire.glade index 473d5304..8be27e38 100644 --- a/src/ui/gui/psppire.glade +++ b/src/ui/gui/psppire.glade @@ -1775,108 +1775,6 @@ </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> diff --git a/src/ui/gui/variable-info-dialog.c b/src/ui/gui/variable-info-dialog.c index 2f5495f1..6fc8dd89 100644 --- a/src/ui/gui/variable-info-dialog.c +++ b/src/ui/gui/variable-info-dialog.c @@ -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 index 00000000..147d66a2 --- /dev/null +++ b/src/ui/gui/variable-info-dialog.glade @@ -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>