Mercurial > pidgin
changeset 18625:672dd03f538a
More work on the conversation sizing/positioning stuff. Still nothing IM or chat specific
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 23 Jul 2007 23:56:01 +0000 |
parents | 81dcdd73dff0 |
children | f05360b5470d |
files | pidgin/gtkconv.c |
diffstat | 1 files changed, 35 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin/gtkconv.c Mon Jul 23 20:56:46 2007 +0000 +++ b/pidgin/gtkconv.c Mon Jul 23 23:56:01 2007 +0000 @@ -8269,8 +8269,8 @@ return FALSE; /* carry on normally */ /* store the position */ - purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/x", x); - purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/y", y); + purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/x", x); + purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/y", y); purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/width", event->width); purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/height", event->height); @@ -8279,6 +8279,38 @@ } +static void +pidgin_conv_restore_position(PidginWindow *win) { + int conv_x, conv_y, conv_width, conv_height; + + conv_width = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/im/width"); + + /* if the window exists, is hidden, we're saving positions, and the + * position is sane... */ + if (win && win->window && + !GTK_WIDGET_VISIBLE(win->window) && conv_width != 0) { + + conv_x = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/x"); + conv_y = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/y"); + conv_height = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/im/height"); + + /* ...check position is on screen... */ + if (conv_x >= gdk_screen_width()) + conv_x = gdk_screen_width() - 100; + else if (conv_x + conv_width < 0) + conv_x = 100; + + if (conv_y >= gdk_screen_height()) + conv_y = gdk_screen_height() - 100; + else if (conv_y + conv_height < 0) + conv_y = 100; + + /* ...and move it back. */ + gtk_window_move(GTK_WINDOW(win->window), conv_x, conv_y); + gtk_window_resize(GTK_WINDOW(win->window), conv_width, conv_height); + } +} + PidginWindow * pidgin_conv_window_new() { @@ -8293,8 +8325,7 @@ /* Create the window. */ win->window = pidgin_create_window(NULL, 0, "conversation", TRUE); - gtk_window_set_default_size(GTK_WINDOW(win->window), purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/im/width"), - purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/im/height")); + pidgin_conv_restore_position(win); if (available_list == NULL) { create_icon_lists(win->window);