aboutsummaryrefslogtreecommitdiffstats
path: root/shell/e-shell-window.c
diff options
context:
space:
mode:
authorSven Herzberg <herzi@gnome-de.org>2006-04-28 19:19:51 +0800
committerSven Herzberg <herzi@src.gnome.org>2006-04-28 19:19:51 +0800
commit3b5da8e9378667774815abf00a80eddb4fadda89 (patch)
treef3d19ae19785aacba6cf252e8e2ad06e85659d30 /shell/e-shell-window.c
parent3871eb6425bbd343bb14c0442c38fb7ab3b4427c (diff)
downloadgsoc2013-evolution-3b5da8e9378667774815abf00a80eddb4fadda89.tar
gsoc2013-evolution-3b5da8e9378667774815abf00a80eddb4fadda89.tar.gz
gsoc2013-evolution-3b5da8e9378667774815abf00a80eddb4fadda89.tar.bz2
gsoc2013-evolution-3b5da8e9378667774815abf00a80eddb4fadda89.tar.lz
gsoc2013-evolution-3b5da8e9378667774815abf00a80eddb4fadda89.tar.xz
gsoc2013-evolution-3b5da8e9378667774815abf00a80eddb4fadda89.tar.zst
gsoc2013-evolution-3b5da8e9378667774815abf00a80eddb4fadda89.zip
reviewed by: Srinivasa Ragavan
2006-04-28 Sven Herzberg <herzi@gnome-de.org> reviewed by: Srinivasa Ragavan * shell/apps_evolution_shell.schemas.in.in: added boolean key for the maximized state of the window * shell/e-shell-window.c: added window state saving and updated window size saving to work as expected (fixes bug 243962) svn path=/trunk/; revision=31926
Diffstat (limited to 'shell/e-shell-window.c')
-rw-r--r--shell/e-shell-window.c80
1 files changed, 74 insertions, 6 deletions
diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c
index 92c903a203..f0c5903936 100644
--- a/shell/e-shell-window.c
+++ b/shell/e-shell-window.c
@@ -116,6 +116,9 @@ struct _EShellWindowPrivate {
GtkWidget *offline_toggle;
GtkWidget *offline_toggle_image;
GtkWidget *menu_hint_label;
+
+ /* The timeout for saving the window size */
+ guint store_window_size_timer;
};
@@ -859,6 +862,69 @@ impl_finalize (GObject *object)
(* G_OBJECT_CLASS (e_shell_window_parent_class)->finalize) (object);
}
+/* GtkWidget methods */
+static void
+e_shell_window_remove_resize_timer (EShellWindow* self)
+{
+ if (self->priv->store_window_size_timer) {
+ g_source_remove (self->priv->store_window_size_timer);
+ self->priv->store_window_size_timer = 0;
+ }
+}
+
+static gboolean
+impl_window_state (GtkWidget *widget, GdkEventWindowState* ev)
+{
+ gboolean retval = FALSE;
+
+ /* store only if the window state really changed */
+ if ((ev->changed_mask & GDK_WINDOW_STATE_MAXIMIZED) != 0) {
+ GConfClient* client = gconf_client_get_default ();
+ gconf_client_set_bool (client, "/apps/evolution/shell/view_defaults/maximized",
+ (ev->new_window_state & GDK_WINDOW_STATE_MAXIMIZED) != 0, NULL);
+ g_object_unref(client);
+ }
+
+ if ((ev->new_window_state & GDK_WINDOW_STATE_MAXIMIZED) != 0) {
+ e_shell_window_remove_resize_timer (E_SHELL_WINDOW (widget));
+ }
+
+ if (GTK_WIDGET_CLASS (e_shell_window_parent_class)->window_state_event) {
+ retval |= GTK_WIDGET_CLASS (e_shell_window_parent_class)->window_state_event (widget, ev);
+ }
+
+ return retval;
+}
+
+static gboolean
+store_window_size (GtkWidget* widget)
+{
+ GConfClient* client = gconf_client_get_default ();
+ gconf_client_set_int (client, "/apps/evolution/shell/view_defaults/width",
+ widget->allocation.width, NULL);
+ gconf_client_set_int (client, "/apps/evolution/shell/view_defaults/height",
+ widget->allocation.height, NULL);
+ g_object_unref(client);
+
+ E_SHELL_WINDOW (widget)->priv->store_window_size_timer = 0;
+ return FALSE; // remove this timeout
+}
+
+static void
+impl_size_alloc (GtkWidget* widget, GtkAllocation* alloc)
+{
+ EShellWindow* self = E_SHELL_WINDOW (widget);
+ e_shell_window_remove_resize_timer(self);
+
+ if (GTK_WIDGET_REALIZED(widget) && !(gdk_window_get_state(widget->window) & GDK_WINDOW_STATE_MAXIMIZED)) {
+ /* update the size storage timer */
+ self->priv->store_window_size_timer = g_timeout_add (1000, (GSourceFunc)store_window_size, self);
+ }
+
+ if (GTK_WIDGET_CLASS (e_shell_window_parent_class)->size_allocate) {
+ GTK_WIDGET_CLASS (e_shell_window_parent_class)->size_allocate (widget, alloc);
+ }
+}
/* Initialization. */
@@ -866,10 +932,14 @@ static void
e_shell_window_class_init (EShellWindowClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->dispose = impl_dispose;
object_class->finalize = impl_finalize;
+ widget_class->window_state_event = impl_window_state;
+ widget_class->size_allocate = impl_size_alloc;
+
signals[COMPONENT_CHANGED] = g_signal_new ("component_changed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
@@ -951,7 +1021,7 @@ e_shell_window_new (EShell *shell,
setup_widgets (window);
- if(gconf_client_get_bool (gconf_client_get_default(),"/apps/evolution/shell/view_defaults/sidebar_visible",NULL))
+ if(gconf_client_get_bool (gconf_client,"/apps/evolution/shell/view_defaults/sidebar_visible",NULL))
gtk_widget_show (priv->sidebar);
else
gtk_widget_hide (priv->sidebar);
@@ -977,6 +1047,9 @@ e_shell_window_new (EShell *shell,
gtk_window_set_default_size (GTK_WINDOW (window),
gconf_client_get_int (gconf_client, "/apps/evolution/shell/view_defaults/width", NULL),
gconf_client_get_int (gconf_client, "/apps/evolution/shell/view_defaults/height", NULL));
+ if (gconf_client_get_bool (gconf_client, "/apps/evolution/shell/view_defaults/maximized", NULL)) {
+ gtk_window_maximize (GTK_WINDOW (window));
+ }
g_object_unref (gconf_client);
return GTK_WIDGET (window);
@@ -1065,11 +1138,6 @@ e_shell_window_save_defaults (EShellWindow *window)
const char *style;
gboolean visible;
- gconf_client_set_int (client, "/apps/evolution/shell/view_defaults/width",
- GTK_WIDGET (window)->allocation.width, NULL);
- gconf_client_set_int (client, "/apps/evolution/shell/view_defaults/height",
- GTK_WIDGET (window)->allocation.height, NULL);
-
gconf_client_set_int (client, "/apps/evolution/shell/view_defaults/folder_bar/width",
gtk_paned_get_position (GTK_PANED (window->priv->paned)), NULL);