-/*
- 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 <http://www.gnu.org/licenses/>. */
#include <config.h>
}
+
+/* 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;
+
+ 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),
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);
}
{
g_signal_emit (dialog, signals [DIALOG_REFRESH], 0);
}
+
+
+
+
+GType
+psppire_orientation_get_type (void)
+{
+ 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;
+}