[gedit] Bug 137128 - Fix saving the size of an unmaximixed window
- From: Garrett Regier <gregier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Bug 137128 - Fix saving the size of an unmaximixed window
- Date: Mon, 17 May 2010 22:09:31 +0000 (UTC)
commit 3d0281d787d266ea3402087e1abe1d8bef080300
Author: Garrett Regier <alias301 gmail com>
Date: Mon May 17 15:09:03 2010 -0700
Bug 137128 - Fix saving the size of an unmaximixed window
gedit/gedit-app.c | 15 +++-----
gedit/gedit-window-private.h | 2 +-
gedit/gedit-window.c | 76 ++++++++++++++++++++++-------------------
3 files changed, 47 insertions(+), 46 deletions(-)
---
diff --git a/gedit/gedit-app.c b/gedit/gedit-app.c
index 09bc65b..b0f2cca 100644
--- a/gedit/gedit-app.c
+++ b/gedit/gedit-app.c
@@ -675,20 +675,15 @@ gedit_app_create_window_real (GeditApp *app,
state = g_settings_get_int (app->priv->window_settings,
GEDIT_SETTINGS_WINDOW_STATE);
+ g_settings_get (app->priv->window_settings,
+ GEDIT_SETTINGS_WINDOW_SIZE,
+ "(ii)", &w, &h);
+ gtk_window_set_default_size (GTK_WINDOW (window), w, h);
+
if ((state & GDK_WINDOW_STATE_MAXIMIZED) != 0)
- {
- _gedit_window_get_default_size (&w, &h);
- gtk_window_set_default_size (GTK_WINDOW (window), w, h);
gtk_window_maximize (GTK_WINDOW (window));
- }
else
- {
- g_settings_get (app->priv->window_settings,
- GEDIT_SETTINGS_WINDOW_SIZE,
- "(ii)", &w, &h);
- gtk_window_set_default_size (GTK_WINDOW (window), w, h);
gtk_window_unmaximize (GTK_WINDOW (window));
- }
if ((state & GDK_WINDOW_STATE_STICKY ) != 0)
gtk_window_stick (GTK_WINDOW (window));
diff --git a/gedit/gedit-window-private.h b/gedit/gedit-window-private.h
index 898a7fa..7287618 100644
--- a/gedit/gedit-window-private.h
+++ b/gedit/gedit-window-private.h
@@ -104,7 +104,7 @@ struct _GeditWindowPrivate
gint num_tabs_with_error;
gint width;
- gint height;
+ gint height;
GdkWindowState window_state;
gint side_panel_size;
diff --git a/gedit/gedit-window.c b/gedit/gedit-window.c
index 4482ea0..c361926 100644
--- a/gedit/gedit-window.c
+++ b/gedit/gedit-window.c
@@ -68,9 +68,6 @@
#define LANGUAGE_DATA "GeditWindowLanguageData"
#define FULLSCREEN_ANIMATION_SPEED 4
-#define GEDIT_WINDOW_DEFAULT_WIDTH 650
-#define GEDIT_WINDOW_DEFAULT_HEIGHT 500
-
#define GEDIT_WINDOW_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object),\
GEDIT_TYPE_WINDOW, \
GeditWindowPrivate))
@@ -131,12 +128,6 @@ save_panes_state (GeditWindow *window)
gedit_debug (DEBUG_WINDOW);
- g_settings_set (window->priv->window_settings, GEDIT_SETTINGS_WINDOW_SIZE,
- "(ii)", window->priv->width, window->priv->height);
-
- g_settings_set_int (window->priv->window_settings, GEDIT_SETTINGS_WINDOW_STATE,
- window->priv->window_state);
-
if (window->priv->side_panel_size > 0)
g_settings_set_int (window->priv->window_settings,
GEDIT_SETTINGS_SIDE_PANEL_SIZE,
@@ -212,6 +203,26 @@ gedit_window_focus_out_event (GtkWidget *widget,
#endif
static void
+save_window_state (GtkWidget *widget)
+{
+ GeditWindow *window = GEDIT_WINDOW (widget);
+
+ if ((window->priv->window_state &
+ (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN)) == 0)
+ {
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation (widget, &allocation);
+
+ window->priv->width = allocation.width;
+ window->priv->height = allocation.height;
+
+ g_settings_set (window->priv->window_settings, GEDIT_SETTINGS_WINDOW_SIZE,
+ "(ii)", window->priv->width, window->priv->height);
+ }
+}
+
+static void
gedit_window_dispose (GObject *object)
{
GeditWindow *window;
@@ -220,6 +231,8 @@ gedit_window_dispose (GObject *object)
window = GEDIT_WINDOW (object);
+ save_window_state (GTK_WIDGET (window));
+
/* Stop tracking removal of panes otherwise we always
* end up with thinking we had no pane active, since they
* should all be removed below */
@@ -341,8 +354,11 @@ gedit_window_window_state_event (GtkWidget *widget,
window->priv->window_state = event->new_window_state;
- if (event->changed_mask &
- (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN))
+ g_settings_set_int (window->priv->window_settings, GEDIT_SETTINGS_WINDOW_STATE,
+ window->priv->window_state);
+
+ if ((event->changed_mask &
+ (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN)) != 0)
{
gboolean show;
@@ -353,17 +369,24 @@ gedit_window_window_state_event (GtkWidget *widget,
show);
}
+ if (GTK_WIDGET_CLASS (gedit_window_parent_class)->window_state_event)
+ return GTK_WIDGET_CLASS (gedit_window_parent_class)->window_state_event (widget, event);
+
return FALSE;
}
-static gboolean
+static gboolean
gedit_window_configure_event (GtkWidget *widget,
GdkEventConfigure *event)
{
GeditWindow *window = GEDIT_WINDOW (widget);
- window->priv->width = event->width;
- window->priv->height = event->height;
+ if (gtk_widget_get_realized (widget) &&
+ (window->priv->window_state &
+ (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN)) == 0)
+ {
+ save_window_state (widget);
+ }
return GTK_WIDGET_CLASS (gedit_window_parent_class)->configure_event (widget, event);
}
@@ -2146,22 +2169,14 @@ clone_window (GeditWindow *origin)
screen = gtk_window_get_screen (GTK_WINDOW (origin));
window = gedit_app_create_window (app, screen);
- if ((origin->priv->window_state & GDK_WINDOW_STATE_MAXIMIZED) != 0)
- {
- gint w, h;
+ gtk_window_set_default_size (GTK_WINDOW (window),
+ origin->priv->width,
+ origin->priv->height);
- _gedit_window_get_default_size (&w, &h);
- gtk_window_set_default_size (GTK_WINDOW (window), w, h);
+ if ((origin->priv->window_state & GDK_WINDOW_STATE_MAXIMIZED) != 0)
gtk_window_maximize (GTK_WINDOW (window));
- }
else
- {
- gtk_window_set_default_size (GTK_WINDOW (window),
- origin->priv->width,
- origin->priv->height);
-
gtk_window_unmaximize (GTK_WINDOW (window));
- }
if ((origin->priv->window_state & GDK_WINDOW_STATE_STICKY ) != 0)
gtk_window_stick (GTK_WINDOW (window));
@@ -4931,13 +4946,4 @@ gedit_window_get_message_bus (GeditWindow *window)
return window->priv->message_bus;
}
-void
-_gedit_window_get_default_size (gint *width, gint *height)
-{
- g_return_if_fail (width != NULL && height != NULL);
-
- *width = GEDIT_WINDOW_DEFAULT_WIDTH;
- *height = GEDIT_WINDOW_DEFAULT_HEIGHT;
-}
-
/* ex:ts=8:noet: */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]