src/ui/gui/psppire-vbuttonbox.h \
src/ui/gui/psppire-window.c \
src/ui/gui/psppire-window.h \
+ src/ui/gui/psppire-window-base.c \
+ src/ui/gui/psppire-window-base.h \
src/ui/gui/psppire-window-register.c \
src/ui/gui/psppire-window-register.h \
src/ui/gui/rank-dialog.c \
#include "psppire-dialog.h"
#include "psppire-buttonbox.h"
#include "psppire-selector.h"
-#include "psppire-conf.h"
#include <string.h>
#include "builder-wrapper.h"
#include "help-menu.h"
+#include "psppire-window-base.h"
+
static void psppire_dialog_class_init (PsppireDialogClass *);
static void psppire_dialog_init (PsppireDialog *);
NULL
};
- dialog_type = g_type_register_static (GTK_TYPE_WINDOW,
+ dialog_type = g_type_register_static (PSPPIRE_TYPE_WINDOW_BASE,
"PsppireDialog", &dialog_info, 0);
g_type_add_interface_static (dialog_type,
}
-static gboolean
-configure_event_callback (GtkDialog *dialog,
- GdkEvent *event, gpointer data)
-{
- const gchar *base;
-
- PsppireConf *conf = psppire_conf_new ();
-
- if ( ! gtk_widget_get_mapped (GTK_WIDGET (dialog)))
- return FALSE;
-
- base = gtk_buildable_get_name (GTK_BUILDABLE (dialog));
-
- psppire_conf_save_window_geometry (conf, base, GTK_WINDOW (dialog));
-
- return FALSE;
-}
-
-
-static void
-on_realize (GtkWindow *dialog, gpointer data)
-{
- PsppireConf *conf = psppire_conf_new ();
-
- const gchar *base = gtk_buildable_get_name (GTK_BUILDABLE (dialog));
-
- psppire_conf_set_window_geometry (conf, base, dialog);
-}
-
-
-
static void
psppire_dialog_init (PsppireDialog *dialog)
{
G_CALLBACK (delete_event_callback),
dialog);
- g_signal_connect (dialog, "configure-event",
- G_CALLBACK (configure_event_callback),
- dialog);
-
- g_signal_connect (dialog, "realize",
- G_CALLBACK (on_realize),
- dialog);
-
-
gtk_window_set_type_hint (GTK_WINDOW (dialog),
GDK_WINDOW_TYPE_HINT_DIALOG);
--- /dev/null
+/* PSPPIRE - a graphical user interface for PSPP.
+ Copyright (C) 2012 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 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.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/*
+ This is an abstract base class upon which all (well almost all) windows in
+ psppire are based. The exceptions are transient windows such as the
+ splash screen and popups.
+
+ It currently provides the feature where the window's geometry "persists"
+ so that she gets the windows appearing in her favourite size/shape/position.
+*/
+
+
+#include <config.h>
+
+#include "psppire-window-base.h"
+#include "psppire-conf.h"
+#include <string.h>
+
+#include <gtk/gtk.h>
+
+static void psppire_window_base_class_init (PsppireWindowBaseClass *class);
+static void psppire_window_base_init (PsppireWindowBase *window);
+
+G_DEFINE_ABSTRACT_TYPE (PsppireWindowBase, psppire_window_base, GTK_TYPE_WINDOW);
+
+
+/* Obtain a string identifying this window.
+
+ If the window has a name, we use that.
+ Otherwise we fall back on the class name.
+ */
+static const char *
+get_window_id (GtkWidget *wb)
+{
+ const gchar *name = NULL;
+
+ g_object_get (wb, "name", &name, NULL);
+
+ if (NULL == name || 0 == strcmp ("", name))
+ name = G_OBJECT_TYPE_NAME (wb);
+
+ return name;
+}
+
+/*
+ On realization, we read the desired geometry from the config, and set the
+ window accordingly.
+ */
+static void
+realize (GtkWidget *wb)
+{
+ PsppireConf *conf = psppire_conf_new ();
+
+ psppire_conf_set_window_geometry (conf, get_window_id (wb), GTK_WINDOW (wb));
+
+ if (GTK_WIDGET_CLASS (psppire_window_base_parent_class)->realize)
+ return GTK_WIDGET_CLASS (psppire_window_base_parent_class)->realize (wb) ;
+}
+
+
+/*
+ When the window is resized/repositioned, write the new geometry to the config.
+*/
+static gboolean
+configure_event (GtkWidget *wb, GdkEventConfigure *event)
+{
+ if (gtk_widget_get_mapped (wb))
+ {
+ PsppireConf *conf = psppire_conf_new ();
+
+ psppire_conf_save_window_geometry (conf, get_window_id (wb), GTK_WINDOW (wb));
+ }
+
+ if (GTK_WIDGET_CLASS (psppire_window_base_parent_class)->configure_event)
+ return GTK_WIDGET_CLASS (psppire_window_base_parent_class)->configure_event (wb, event) ;
+
+ return FALSE;
+}
+
+static void
+psppire_window_base_class_init (PsppireWindowBaseClass *class)
+{
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
+ widget_class->configure_event = configure_event;
+ widget_class->realize = realize;
+}
+
+static void
+psppire_window_base_init (PsppireWindowBase *window)
+{
+}
+
--- /dev/null
+/* PSPPIRE - a graphical user interface for PSPP.
+ Copyright (C) 2012 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 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.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/*
+ This is an abstract base class upon which all (well almost all) windows in
+ psppire are based. The exceptions are transient windows such as the
+ splash screen and popups.
+*/
+
+#ifndef __PSPPIRE_WINDOW_BASE_H__
+#define __PSPPIRE_WINDOW_BASE_H__
+
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+
+#define PSPPIRE_TYPE_WINDOW_BASE (psppire_window_base_get_type ())
+
+#define PSPPIRE_WINDOW_BASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ PSPPIRE_TYPE_WINDOW_BASE, PsppireWindowBase))
+
+#define PSPPIRE_WINDOW_BASE_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \
+ PSPPIRE_TYPE_WINDOW_BASE, PsppireWindowBaseClass))
+
+#define PSPPIRE_IS_WINDOW_BASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ PSPPIRE_TYPE_WINDOW_BASE))
+
+#define PSPPIRE_IS_WINDOW_BASE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \
+ PSPPIRE_TYPE_WINDOW_BASE))
+
+
+typedef struct _PsppireWindowBase PsppireWindowBase;
+typedef struct _PsppireWindowBaseClass PsppireWindowBaseClass;
+
+
+struct _PsppireWindowBase
+{
+ GtkWindow parent;
+
+ /* <private> */
+};
+
+
+struct _PsppireWindowBaseClass
+{
+ GtkWindowClass parent_class;
+};
+
+
+
+GType psppire_window_base_get_type (void);
+GType psppire_window_base_model_get_type (void);
+
+G_END_DECLS
+
+#endif /* __PSPPIRE_WINDOW_BASE_H__ */
#include <config.h>
#include "psppire-window.h"
+#include "psppire-window-base.h"
#include <gtk/gtk.h>
#include "data/dataset.h"
#include "helper.h"
-#include "psppire-conf.h"
#include "psppire-data-window.h"
#include "psppire-encoding-selector.h"
#include "psppire-syntax-window.h"
};
psppire_window_type =
- g_type_register_static (GTK_TYPE_WINDOW, "PsppireWindow",
+ g_type_register_static (PSPPIRE_TYPE_WINDOW_BASE, "PsppireWindow",
&psppire_window_info, G_TYPE_FLAG_ABSTRACT);
}
}
-static void
-on_realize (GtkWindow *window, gpointer data)
-{
- PsppireConf *conf = psppire_conf_new ();
-
- const gchar *base = G_OBJECT_TYPE_NAME (window);
-
- psppire_conf_set_window_geometry (conf, base, window);
-}
-
-
static void
psppire_window_finalize (GObject *object)
{
{
PsppireWindowRegister *reg = psppire_window_register_new ();
- const gchar *base = G_OBJECT_TYPE_NAME (w);
-
- PsppireConf *conf = psppire_conf_new ();
-
- psppire_conf_save_window_geometry (conf, base, GTK_WINDOW (w));
-
-
if ( w->dirty )
{
gint response = psppire_window_query_save (w);
g_signal_connect_swapped (window, "delete-event", G_CALLBACK (on_delete), window);
g_object_set (window, "icon-name", "pspp", NULL);
-
- g_signal_connect (window, "realize",
- G_CALLBACK (on_realize), window);
}
/*