diff options
author | Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk> | 2011-07-12 01:27:52 +0800 |
---|---|---|
committer | Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk> | 2011-07-12 16:48:15 +0800 |
commit | ee432f2c641a383ad8b32cb1ef7d2d2c2ee9c880 (patch) | |
tree | fcc2f56caf1549cfc2bdc9850e6bb5aeb56f32b0 | |
parent | 3535c55225076c649883aa4a497893b1f165a110 (diff) | |
download | gsoc2013-empathy-ee432f2c641a383ad8b32cb1ef7d2d2c2ee9c880.tar gsoc2013-empathy-ee432f2c641a383ad8b32cb1ef7d2d2c2ee9c880.tar.gz gsoc2013-empathy-ee432f2c641a383ad8b32cb1ef7d2d2c2ee9c880.tar.bz2 gsoc2013-empathy-ee432f2c641a383ad8b32cb1ef7d2d2c2ee9c880.tar.lz gsoc2013-empathy-ee432f2c641a383ad8b32cb1ef7d2d2c2ee9c880.tar.xz gsoc2013-empathy-ee432f2c641a383ad8b32cb1ef7d2d2c2ee9c880.tar.zst gsoc2013-empathy-ee432f2c641a383ad8b32cb1ef7d2d2c2ee9c880.zip |
CallWindow: save the window geometry without the sidebar
Since we don't show the sidebar when creating new call windows,
we should not take the sidebar into account when saving the
window geometry.
https://bugzilla.gnome.org/show_bug.cgi?id=634809
-rw-r--r-- | libempathy-gtk/empathy-geometry.c | 47 | ||||
-rw-r--r-- | libempathy-gtk/empathy-geometry.h | 7 | ||||
-rw-r--r-- | src/empathy-call-window.c | 47 |
3 files changed, 85 insertions, 16 deletions
diff --git a/libempathy-gtk/empathy-geometry.c b/libempathy-gtk/empathy-geometry.c index b549b8bad..986015452 100644 --- a/libempathy-gtk/empathy-geometry.c +++ b/libempathy-gtk/empathy-geometry.c @@ -126,14 +126,15 @@ geometry_get_key_file (void) return key_file; } -static void -empathy_geometry_save (GtkWindow *window) +void +empathy_geometry_save_values (GtkWindow *window, + gint x, + gint y, + gint w, + gint h, + gboolean maximized) { GKeyFile *key_file; - GdkWindow *gdk_window; - GdkWindowState window_state; - gint x, y, w, h; - gboolean maximized; gchar *position_str = NULL; GHashTable *names; GHashTableIter iter; @@ -144,16 +145,6 @@ empathy_geometry_save (GtkWindow *window) g_return_if_fail (GTK_IS_WINDOW (window)); g_return_if_fail (names != NULL); - if (!gtk_widget_get_visible (GTK_WIDGET (window))) - return; - - /* Get window geometry */ - gtk_window_get_position (window, &x, &y); - gtk_window_get_size (window, &w, &h); - gdk_window = gtk_widget_get_window (GTK_WIDGET (window)); - window_state = gdk_window_get_state (gdk_window); - maximized = (window_state & GDK_WINDOW_STATE_MAXIMIZED) != 0; - /* Don't save off-screen positioning */ if (!EMPATHY_RECT_IS_ON_SCREEN (x, y, w, h)) return; @@ -190,6 +181,30 @@ empathy_geometry_save (GtkWindow *window) } static void +empathy_geometry_save (GtkWindow *window) +{ + GdkWindow *gdk_window; + GdkWindowState window_state; + gboolean maximized; + gint x, y, w, h; + + g_return_if_fail (GTK_IS_WINDOW (window)); + + if (!gtk_widget_get_visible (GTK_WIDGET (window))) + return; + + /* Get window geometry */ + gtk_window_get_position (window, &x, &y); + gtk_window_get_size (window, &w, &h); + + gdk_window = gtk_widget_get_window (GTK_WIDGET (window)); + window_state = gdk_window_get_state (gdk_window); + maximized = (window_state & GDK_WINDOW_STATE_MAXIMIZED) != 0; + + empathy_geometry_save_values (window, x, y, w, h, maximized); +} + +static void empathy_geometry_load (GtkWindow *window, const gchar *name) { diff --git a/libempathy-gtk/empathy-geometry.h b/libempathy-gtk/empathy-geometry.h index 80ea92ebf..f9f85c1c9 100644 --- a/libempathy-gtk/empathy-geometry.h +++ b/libempathy-gtk/empathy-geometry.h @@ -35,6 +35,13 @@ void empathy_geometry_bind (GtkWindow *window, void empathy_geometry_unbind (GtkWindow *window, const gchar *name); +void empathy_geometry_save_values (GtkWindow *window, + gint x, + gint y, + gint w, + gint h, + gboolean maximized); + G_END_DECLS #endif /* __EMPATHY_GEOMETRY_H__ */ diff --git a/src/empathy-call-window.c b/src/empathy-call-window.c index 091a6e3c7..8fd10dea0 100644 --- a/src/empathy-call-window.c +++ b/src/empathy-call-window.c @@ -207,6 +207,9 @@ struct _EmpathyCallWindowPriv gint original_width_before_fs; gint original_height_before_fs; + gint x, y, w, h, sidebar_width; + gboolean maximized; + /* TRUE if the call should be started when the pipeline is playing */ gboolean start_call_when_playing; /* TRUE if we requested to set the pipeline in the playing state */ @@ -952,6 +955,41 @@ create_pipeline (EmpathyCallWindow *self) g_object_unref (bus); } +static gboolean +empathy_call_window_configure_event_cb (GtkWidget *widget, + GdkEvent *event, + EmpathyCallWindow *self) +{ + GdkWindow *gdk_window; + GdkWindowState window_state; + + gtk_window_get_position (GTK_WINDOW (self), &self->priv->x, &self->priv->y); + gtk_window_get_size (GTK_WINDOW (self), &self->priv->w, &self->priv->h); + + gtk_widget_get_preferred_width (self->priv->sidebar, + &self->priv->sidebar_width, NULL); + + gdk_window = gtk_widget_get_window (widget); + window_state = gdk_window_get_state (gdk_window); + self->priv->maximized = (window_state & GDK_WINDOW_STATE_MAXIMIZED); + + return FALSE; +} + +static void +empathy_call_window_destroyed_cb (GtkWidget *object, + EmpathyCallWindow *self) +{ + if (gtk_widget_get_visible (self->priv->sidebar)) + { + /* Save the geometry as if the sidebar was hidden. */ + empathy_geometry_save_values (GTK_WINDOW (self), + self->priv->x, self->priv->y, + self->priv->w - self->priv->sidebar_width, self->priv->h, + self->priv->maximized); + } +} + static void empathy_call_window_init (EmpathyCallWindow *self) { @@ -1152,6 +1190,15 @@ empathy_call_window_init (EmpathyCallWindow *self) priv->sound_mgr = empathy_sound_manager_dup_singleton (); empathy_geometry_bind (GTK_WINDOW (self), "call-window"); + /* These signals are used to track the window position and save it + * when the window is destroyed. We need to do this as we don't want + * the window geometry to be saved with the sidebar taken into account. */ + g_signal_connect (self, "destroy", + G_CALLBACK (empathy_call_window_destroyed_cb), self); + g_signal_connect (self, "configure-event", + G_CALLBACK (empathy_call_window_configure_event_cb), self); + g_signal_connect (self, "window-state-event", + G_CALLBACK (empathy_call_window_configure_event_cb), self); } /* Instead of specifying a width and a height, we specify only one size. That's |