X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-dialog.c;h=d961c7dcf02c48c559c6da074ff4d24980833c20;hb=41630b04567029a807d1b154977c66067397bbc7;hp=8bb783587807168bb206de410de4642406128be7;hpb=09a1109ddc398f36fe720208e1d38053850cbd2a;p=pspp-builds.git
diff --git a/src/ui/gui/psppire-dialog.c b/src/ui/gui/psppire-dialog.c
index 8bb78358..d961c7dc 100644
--- a/src/ui/gui/psppire-dialog.c
+++ b/src/ui/gui/psppire-dialog.c
@@ -1,23 +1,22 @@
-/*
- PSPPIRE --- A Graphical User Interface for PSPP
- Copyright (C) 2007 Free Software Foundation
+/* PSPPIRE - a graphical user interface for PSPP.
+ Copyright (C) 2007 Free Software Foundation
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA. */
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+#include
+
#include
#include
#include "psppire-dialog.h"
@@ -29,7 +28,7 @@ static void psppire_dialog_init (PsppireDialog *);
enum {DIALOG_REFRESH,
n_SIGNALS};
-static guint signal [n_SIGNALS];
+static guint signals [n_SIGNALS];
GType
@@ -79,12 +78,111 @@ psppire_dialog_finalize (GObject *object)
}
+
+/* Properties */
+enum
+{
+ PROP_0,
+ PROP_ORIENTATION
+};
+
+
+static void
+psppire_dialog_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ PsppireDialog *dialog = PSPPIRE_DIALOG (object);
+
+ switch (prop_id)
+ {
+ case PROP_ORIENTATION:
+ {
+ if ( GTK_IS_VBOX (dialog->box) )
+ g_value_set_enum (value, PSPPIRE_VERTICAL);
+ else if ( GTK_IS_HBOX (dialog->box))
+ g_value_set_enum (value, PSPPIRE_HORIZONTAL);
+ }
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ };
+}
+
+
+static void
+dialog_set_orientation (PsppireDialog *dialog, const GValue *orval)
+{
+ PsppireOrientation orientation = g_value_get_enum (orval);
+
+ if ( dialog->box != NULL)
+ {
+ gtk_container_remove (GTK_CONTAINER (dialog), dialog->box);
+ }
+
+ if ( orientation == PSPPIRE_HORIZONTAL)
+ {
+ dialog->box = gtk_hbox_new (FALSE, 5);
+ }
+ else
+ {
+ dialog->box = gtk_vbox_new (FALSE, 5);
+ }
+
+ gtk_container_add (GTK_CONTAINER (dialog), dialog->box);
+}
+
+
+static void
+psppire_dialog_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+
+{
+ PsppireDialog *dialog = PSPPIRE_DIALOG (object);
+
+ switch (prop_id)
+ {
+ case PROP_ORIENTATION:
+ dialog_set_orientation (dialog, value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ };
+}
+
+
+static GParamSpec *orientation_spec ;
+
static void
psppire_dialog_class_init (PsppireDialogClass *class)
{
GObjectClass *object_class = (GObjectClass *) class;
- signal [DIALOG_REFRESH] =
+
+ orientation_spec =
+ g_param_spec_enum ("orientation",
+ "Orientation",
+ "Which way widgets are packed",
+ G_TYPE_PSPPIRE_ORIENTATION,
+ PSPPIRE_HORIZONTAL /* default value */,
+ G_PARAM_CONSTRUCT_ONLY |G_PARAM_READWRITE);
+
+
+ object_class->set_property = psppire_dialog_set_property;
+ object_class->get_property = psppire_dialog_get_property;
+
+ g_object_class_install_property (object_class,
+ PROP_ORIENTATION,
+ orientation_spec);
+
+
+
+ signals [DIALOG_REFRESH] =
g_signal_new ("refresh",
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_FIRST,
@@ -127,16 +225,26 @@ delete_event_callback (GtkWidget *w, GdkEvent *e, gpointer data)
static void
psppire_dialog_init (PsppireDialog *dialog)
{
- dialog->box = gtk_hbox_new (FALSE, 5);
+ GValue value = {0};
+ dialog->box = NULL;
+ g_value_init (&value, orientation_spec->value_type);
+ g_param_value_set_default (orientation_spec, &value);
- gtk_container_add (GTK_CONTAINER (dialog), dialog->box);
+ 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 (G_OBJECT (dialog), "delete-event",
G_CALLBACK (delete_event_callback),
dialog);
+ gtk_window_set_type_hint (GTK_WINDOW (dialog),
+ GDK_WINDOW_TYPE_HINT_DIALOG);
+
gtk_widget_show_all (dialog->box);
}
@@ -158,6 +266,8 @@ psppire_dialog_run (PsppireDialog *dialog)
gtk_widget_show (GTK_WIDGET (dialog));
+ g_signal_emit (dialog, signals [DIALOG_REFRESH], 0);
+
g_main_loop_run (dialog->loop);
return dialog->response;
@@ -165,7 +275,30 @@ psppire_dialog_run (PsppireDialog *dialog)
void
-psppire_dialog_reload (PsppireDialog *dialog, gpointer data)
+psppire_dialog_reload (PsppireDialog *dialog)
+{
+ g_signal_emit (dialog, signals [DIALOG_REFRESH], 0);
+}
+
+
+
+
+GType
+psppire_orientation_get_type (void)
{
- g_signal_emit (dialog, signal [DIALOG_REFRESH], 0, data);
+ static GType etype = 0;
+ if (etype == 0)
+ {
+ static const GEnumValue values[] =
+ {
+ { PSPPIRE_HORIZONTAL, "PSPPIRE_HORIZONTAL", "Horizontal" },
+ { PSPPIRE_VERTICAL, "PSPPIRE_VERTICAL", "Vertical" },
+ { 0, NULL, NULL }
+ };
+
+ etype = g_enum_register_static
+ (g_intern_static_string ("PsppireOrientation"), values);
+
+ }
+ return etype;
}