aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@gmail.com>2009-11-16 02:45:36 +0800
committerXavier Claessens <xclaesse@gmail.com>2009-11-16 20:24:22 +0800
commit441909cbcd7c740f49b714b61e31a5236d808538 (patch)
tree2d09957cc29d0ad396ce00adddf7ed69105a61cf /src
parent9bfe3cdd27190113f8da56cf718c3af7ff9da5d9 (diff)
downloadgsoc2013-empathy-441909cbcd7c740f49b714b61e31a5236d808538.tar
gsoc2013-empathy-441909cbcd7c740f49b714b61e31a5236d808538.tar.gz
gsoc2013-empathy-441909cbcd7c740f49b714b61e31a5236d808538.tar.bz2
gsoc2013-empathy-441909cbcd7c740f49b714b61e31a5236d808538.tar.lz
gsoc2013-empathy-441909cbcd7c740f49b714b61e31a5236d808538.tar.xz
gsoc2013-empathy-441909cbcd7c740f49b714b61e31a5236d808538.tar.zst
gsoc2013-empathy-441909cbcd7c740f49b714b61e31a5236d808538.zip
Correctly store/restore maximized state of windows.
Diffstat (limited to 'src')
-rw-r--r--src/empathy-chat-window.c85
-rw-r--r--src/empathy-ft-manager.c59
-rw-r--r--src/empathy-main-window.c59
3 files changed, 11 insertions, 192 deletions
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c
index 4d99afd31..ca3375306 100644
--- a/src/empathy-chat-window.c
+++ b/src/empathy-chat-window.c
@@ -73,7 +73,6 @@ typedef struct {
GList *chats_composing;
gboolean page_added;
gboolean dnd_same_window;
- guint save_geometry_id;
EmpathyChatroomManager *chatroom_manager;
EmpathyNotifyManager *notify_mgr;
GtkWidget *dialog;
@@ -725,63 +724,6 @@ chat_window_contacts_toggled_cb (GtkToggleAction *toggle_action,
empathy_chat_set_show_contacts (priv->current_chat, active);
}
-static const gchar *
-chat_get_window_id_for_geometry (EmpathyChat *chat)
-{
- const gchar *res = NULL;
- gboolean separate_windows;
-
- empathy_conf_get_bool (empathy_conf_get (),
- EMPATHY_PREFS_UI_SEPARATE_CHAT_WINDOWS,
- &separate_windows);
-
- if (separate_windows) {
- res = empathy_chat_get_id (chat);
- }
-
- return res ? res : "chat-window";
-}
-
-static gboolean
-chat_window_save_geometry_timeout_cb (EmpathyChatWindow *window)
-{
- EmpathyChatWindowPriv *priv;
- gint x, y, w, h;
-
- priv = GET_PRIV (window);
-
- gtk_window_get_size (GTK_WINDOW (priv->dialog), &w, &h);
- gtk_window_get_position (GTK_WINDOW (priv->dialog), &x, &y);
-
- empathy_geometry_save (chat_get_window_id_for_geometry (priv->current_chat),
- x, y, w, h);
-
- priv->save_geometry_id = 0;
-
- return FALSE;
-}
-
-static gboolean
-chat_window_configure_event_cb (GtkWidget *widget,
- GdkEventConfigure *event,
- EmpathyChatWindow *window)
-{
- EmpathyChatWindowPriv *priv;
-
- priv = GET_PRIV (window);
-
- if (priv->save_geometry_id != 0) {
- g_source_remove (priv->save_geometry_id);
- }
-
- priv->save_geometry_id =
- g_timeout_add_seconds (1,
- (GSourceFunc) chat_window_save_geometry_timeout_cb,
- window);
-
- return FALSE;
-}
-
static void
chat_window_close_activate_cb (GtkAction *action,
EmpathyChatWindow *window)
@@ -1511,10 +1453,6 @@ chat_window_finalize (GObject *object)
g_object_unref (priv->ui_manager);
g_object_unref (priv->chatroom_manager);
g_object_unref (priv->notify_mgr);
- if (priv->save_geometry_id != 0) {
- g_source_remove (priv->save_geometry_id);
- chat_window_save_geometry_timeout_cb (window);
- }
if (priv->notification != NULL) {
notify_notification_close (priv->notification, NULL);
@@ -1591,7 +1529,6 @@ empathy_chat_window_init (EmpathyChatWindow *window)
g_free (filename);
empathy_builder_connect (gui, window,
- "chat_window", "configure-event", chat_window_configure_event_cb,
"menu_conv", "activate", chat_window_conv_activate_cb,
"menu_conv_clear", "activate", chat_window_clear_activate_cb,
"menu_conv_favorite", "toggled", chat_window_favorite_toggled_cb,
@@ -1758,7 +1695,6 @@ empathy_chat_window_add_chat (EmpathyChatWindow *window,
GtkWidget *label;
GtkWidget *popup_label;
GtkWidget *child;
- gint x, y, w, h;
g_return_if_fail (window != NULL);
g_return_if_fail (EMPATHY_IS_CHAT (chat));
@@ -1770,21 +1706,18 @@ empathy_chat_window_add_chat (EmpathyChatWindow *window,
/* If this window has just been created, position it */
if (priv->chats == NULL) {
- empathy_geometry_load (chat_get_window_id_for_geometry (chat), &x, &y, &w, &h);
+ const gchar *name = "chat-window";
+ gboolean separate_windows;
- if (x >= 0 && y >= 0) {
- /* Let the window manager position it if we don't have
- * good x, y coordinates.
- */
- gtk_window_move (GTK_WINDOW (priv->dialog), x, y);
- }
+ empathy_conf_get_bool (empathy_conf_get (),
+ EMPATHY_PREFS_UI_SEPARATE_CHAT_WINDOWS,
+ &separate_windows);
- if (w > 0 && h > 0) {
- /* Use the defaults from the ui file if we don't have
- * good w, h geometry.
- */
- gtk_window_resize (GTK_WINDOW (priv->dialog), w, h);
+ if (separate_windows) {
+ name = empathy_chat_get_id (chat);
}
+
+ empathy_geometry_bind (GTK_WINDOW (priv->dialog), name);
}
child = GTK_WIDGET (chat);
diff --git a/src/empathy-ft-manager.c b/src/empathy-ft-manager.c
index ff12c9b6b..e681f8441 100644
--- a/src/empathy-ft-manager.c
+++ b/src/empathy-ft-manager.c
@@ -66,8 +66,6 @@ typedef struct {
GtkWidget *open_button;
GtkWidget *abort_button;
GtkWidget *clear_button;
-
- guint save_geometry_id;
} EmpathyFTManagerPriv;
enum
@@ -868,38 +866,6 @@ ft_manager_stop (EmpathyFTManager *manager)
g_object_unref (handler);
}
-static gboolean
-ft_manager_save_geometry_timeout_cb (EmpathyFTManager *manager)
-{
- EmpathyFTManagerPriv *priv = GET_PRIV (manager);
- gint x, y, w, h;
-
- gtk_window_get_size (GTK_WINDOW (priv->window), &w, &h);
- gtk_window_get_position (GTK_WINDOW (priv->window), &x, &y);
-
- empathy_geometry_save ("ft-manager", x, y, w, h);
-
- priv->save_geometry_id = 0;
-
- return FALSE;
-}
-
-static gboolean
-ft_manager_configure_event_cb (GtkWidget *widget,
- GdkEventConfigure *event,
- EmpathyFTManager *manager)
-{
- EmpathyFTManagerPriv *priv = GET_PRIV (manager);
-
- if (priv->save_geometry_id != 0)
- g_source_remove (priv->save_geometry_id);
-
- priv->save_geometry_id = g_timeout_add (500,
- (GSourceFunc) ft_manager_save_geometry_timeout_cb, manager);
-
- return FALSE;
-}
-
static void
ft_manager_response_cb (GtkWidget *widget,
gint response,
@@ -970,7 +936,6 @@ static void
ft_manager_build_ui (EmpathyFTManager *manager)
{
GtkBuilder *gui;
- gint x, y, w, h;
GtkTreeView *view;
GtkListStore *liststore;
GtkTreeViewColumn *column;
@@ -993,28 +958,13 @@ ft_manager_build_ui (EmpathyFTManager *manager)
"ft_manager_dialog", "destroy", ft_manager_destroy_cb,
"ft_manager_dialog", "response", ft_manager_response_cb,
"ft_manager_dialog", "delete-event", ft_manager_delete_event_cb,
- "ft_manager_dialog", "configure-event", ft_manager_configure_event_cb,
"ft_manager_dialog", "key-press-event", ft_manager_key_press_event_cb,
NULL);
empathy_builder_unref_and_keep_widget (gui, priv->window);
/* Window geometry. */
- empathy_geometry_load ("ft-manager", &x, &y, &w, &h);
-
- if (x >= 0 && y >= 0)
- {
- /* Let the window manager position it if we don't have
- * good x, y coordinates. */
- gtk_window_move (GTK_WINDOW (priv->window), x, y);
- }
-
- if (w > 0 && h > 0)
- {
- /* Use the defaults from the ui file if we don't have
- * good w, h geometry. */
- gtk_window_resize (GTK_WINDOW (priv->window), w, h);
- }
+ empathy_geometry_bind (GTK_WINDOW (priv->window), "ft-manager");
/* Setup the tree view */
view = GTK_TREE_VIEW (priv->treeview);
@@ -1093,19 +1043,12 @@ ft_manager_build_ui (EmpathyFTManager *manager)
static void
empathy_ft_manager_finalize (GObject *object)
{
- EmpathyFTManager *self = EMPATHY_FT_MANAGER (object);
EmpathyFTManagerPriv *priv = GET_PRIV (object);
DEBUG ("FT Manager %p", object);
g_hash_table_destroy (priv->ft_handler_to_row_ref);
- if (priv->save_geometry_id != 0)
- {
- g_source_remove (priv->save_geometry_id);
- ft_manager_save_geometry_timeout_cb (self);
- }
-
G_OBJECT_CLASS (empathy_ft_manager_parent_class)->finalize (object);
}
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index 473e47706..2a316b99e 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -117,9 +117,6 @@ typedef struct {
static EmpathyMainWindow *main_window = NULL;
-static gboolean main_window_configure_event_timeout_cb (
- EmpathyMainWindow *window);
-
static void
main_window_flash_stop (EmpathyMainWindow *window)
{
@@ -659,11 +656,6 @@ main_window_destroy_cb (GtkWidget *widget,
/* Save user-defined accelerators. */
main_window_accels_save ();
- if (window->size_timeout_id) {
- g_source_remove (window->size_timeout_id);
- main_window_configure_event_timeout_cb (window);
- }
-
g_list_free (window->actions_connected);
g_object_unref (window->account_manager);
@@ -1104,37 +1096,6 @@ main_window_throbber_button_press_event_cb (GtkWidget *throbber_ebox,
return FALSE;
}
-static gboolean
-main_window_configure_event_timeout_cb (EmpathyMainWindow *window)
-{
- gint x, y, w, h;
-
- gtk_window_get_size (GTK_WINDOW (window->window), &w, &h);
- gtk_window_get_position (GTK_WINDOW (window->window), &x, &y);
-
- empathy_geometry_save (GEOMETRY_NAME, x, y, w, h);
-
- window->size_timeout_id = 0;
-
- return FALSE;
-}
-
-static gboolean
-main_window_configure_event_cb (GtkWidget *widget,
- GdkEventConfigure *event,
- EmpathyMainWindow *window)
-{
- if (window->size_timeout_id) {
- g_source_remove (window->size_timeout_id);
- }
-
- window->size_timeout_id = g_timeout_add_seconds (1,
- (GSourceFunc) main_window_configure_event_timeout_cb,
- window);
-
- return FALSE;
-}
-
static void
main_window_account_removed_cb (TpAccountManager *manager,
TpAccount *account,
@@ -1247,7 +1208,6 @@ empathy_main_window_show (void)
GtkAction *show_map_widget;
GtkToolItem *item;
gboolean show_offline;
- gint x, y, w, h;
gchar *filename;
GSList *l;
@@ -1282,7 +1242,6 @@ empathy_main_window_show (void)
empathy_builder_connect (gui, window,
"main_window", "destroy", main_window_destroy_cb,
- "main_window", "configure_event", main_window_configure_event_cb,
"chat_quit", "activate", main_window_chat_quit_cb,
"chat_new_message", "activate", main_window_chat_new_message_cb,
"view_history", "activate", main_window_view_history_cb,
@@ -1388,23 +1347,7 @@ empathy_main_window_show (void)
main_window_accels_load ();
/* Set window size. */
- empathy_geometry_load (GEOMETRY_NAME, &x, &y, &w, &h);
-
- if (w >= 1 && h >= 1) {
- /* Use the defaults from the ui file if we
- * don't have good w, h geometry.
- */
- DEBUG ("Configuring window default size w:%d, h:%d", w, h);
- gtk_window_set_default_size (GTK_WINDOW (window->window), w, h);
- }
-
- if (x >= 0 && y >= 0) {
- /* Let the window manager position it if we
- * don't have good x, y coordinates.
- */
- DEBUG ("Configuring window default position x:%d, y:%d", x, y);
- gtk_window_move (GTK_WINDOW (window->window), x, y);
- }
+ empathy_geometry_bind (GTK_WINDOW (window->window), GEOMETRY_NAME);
/* Enable event handling */
window->event_manager = empathy_event_manager_dup_singleton ();