comparison pidgin/gtkconv.c @ 18328:df4ae80156d2

Handle size saving
author Sean Egan <seanegan@gmail.com>
date Wed, 27 Jun 2007 23:53:34 +0000
parents f9551bdd54a6
children 7f2c22c705a5 636679fb98ad
comparison
equal deleted inserted replaced
18327:f9551bdd54a6 18328:df4ae80156d2
254 * size of the last resized new window. */ 254 * size of the last resized new window. */
255 /* I think that the above justification is not the majority, and that the new tab resizing should 255 /* I think that the above justification is not the majority, and that the new tab resizing should
256 * negate it anyway. --luke */ 256 * negate it anyway. --luke */
257 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) 257 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM)
258 { 258 {
259 if (w == gtkconv->imhtml) {
260 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/default_width", allocation->width);
261 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/default_height", allocation->height);
262 }
263 if (w == gtkconv->lower_hbox) 259 if (w == gtkconv->lower_hbox)
264 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/entry_height", allocation->height); 260 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/entry_height", allocation->height);
265 } 261 }
266 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) 262 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT)
267 { 263 {
268 if (w == gtkconv->imhtml) {
269 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/chat/default_width", allocation->width);
270 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/chat/default_height", allocation->height);
271 }
272 if (w == gtkconv->lower_hbox) 264 if (w == gtkconv->lower_hbox)
273 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/chat/entry_height", allocation->height); 265 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/chat/entry_height", allocation->height);
274 } 266 }
275 267
276 return FALSE; 268 return FALSE;
4478 gtk_scrolled_window_get_policy(GTK_SCROLLED_WINDOW(imhtml_sw), 4470 gtk_scrolled_window_get_policy(GTK_SCROLLED_WINDOW(imhtml_sw),
4479 &imhtml_sw_hscroll, NULL); 4471 &imhtml_sw_hscroll, NULL);
4480 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(imhtml_sw), 4472 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(imhtml_sw),
4481 imhtml_sw_hscroll, GTK_POLICY_ALWAYS); 4473 imhtml_sw_hscroll, GTK_POLICY_ALWAYS);
4482 4474
4483 gtk_widget_set_size_request(gtkconv->imhtml,
4484 chat ? purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/chat/default_width") :
4485 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/im/default_width"),
4486 chat ? purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/chat/default_height") :
4487 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/im/default_height"));
4488
4489 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate",
4490 G_CALLBACK(size_allocate_cb), gtkconv);
4491
4492 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", 4475 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event",
4493 G_CALLBACK(entry_stop_rclick_cb), NULL); 4476 G_CALLBACK(entry_stop_rclick_cb), NULL);
4494 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", 4477 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event",
4495 G_CALLBACK(refocus_entry_cb), gtkconv); 4478 G_CALLBACK(refocus_entry_cb), gtkconv);
4496 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", 4479 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event",
7073 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/conversations/font_face", ""); 7056 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/conversations/font_face", "");
7074 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/font_size", 3); 7057 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/font_size", 3);
7075 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/tabs", TRUE); 7058 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/tabs", TRUE);
7076 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/tab_side", GTK_POS_TOP); 7059 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/tab_side", GTK_POS_TOP);
7077 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/scrollback_lines", 4000); 7060 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/scrollback_lines", 4000);
7061 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/x", 0);
7062 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/y", 0);
7078 7063
7079 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/use_theme_font", TRUE); 7064 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/use_theme_font", TRUE);
7080 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/conversations/custom_font", ""); 7065 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/conversations/custom_font", "");
7081 7066
7082 /* Conversations -> Chat */ 7067 /* Conversations -> Chat */
8222 plugin_changed_cb(PurplePlugin *p, gpointer data) 8207 plugin_changed_cb(PurplePlugin *p, gpointer data)
8223 { 8208 {
8224 regenerate_plugins_items(data); 8209 regenerate_plugins_items(data);
8225 } 8210 }
8226 8211
8212 static gboolean gtk_conv_configure_cb(GtkWidget *w, GdkEventConfigure *event, gpointer data) {
8213 int x, y;
8214
8215 if (GTK_WIDGET_VISIBLE(w))
8216 gtk_window_get_position(GTK_WINDOW(w), &x, &y);
8217 else
8218 return FALSE; /* carry on normally */
8219
8220 /* Workaround for GTK+ bug # 169811 - "configure_event" is fired
8221 * when the window is being maximized */
8222 if (gdk_window_get_state(w->window) & GDK_WINDOW_STATE_MAXIMIZED)
8223 return FALSE;
8224
8225 /* don't save if nothing changed */
8226 if (x == purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/x") &&
8227 y == purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/y") &&
8228 event->width == purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/im/default_width") &&
8229 event->height == purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/im/default_height"))
8230 return FALSE; /* carry on normally */
8231
8232 /* don't save off-screen positioning */
8233 if (x + event->width < 0 ||
8234 y + event->height < 0 ||
8235 x > gdk_screen_width() ||
8236 y > gdk_screen_height())
8237 return FALSE; /* carry on normally */
8238
8239 /* store the position */
8240 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/x", x);
8241 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/y", y);
8242 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/width", event->width);
8243 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/height", event->height);
8244
8245 /* continue to handle event normally */
8246 return FALSE;
8247
8248 }
8249
8227 PidginWindow * 8250 PidginWindow *
8228 pidgin_conv_window_new() 8251 pidgin_conv_window_new()
8229 { 8252 {
8230 PidginWindow *win; 8253 PidginWindow *win;
8231 GtkPositionType pos; 8254 GtkPositionType pos;
8236 8259
8237 window_list = g_list_append(window_list, win); 8260 window_list = g_list_append(window_list, win);
8238 8261
8239 /* Create the window. */ 8262 /* Create the window. */
8240 win->window = pidgin_create_window(NULL, 0, "conversation", TRUE); 8263 win->window = pidgin_create_window(NULL, 0, "conversation", TRUE);
8264 gtk_window_set_default_size(GTK_WINDOW(win->window), purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/im/width"),
8265 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/im/height"));
8241 8266
8242 if (available_list == NULL) { 8267 if (available_list == NULL) {
8243 create_icon_lists(win->window); 8268 create_icon_lists(win->window);
8244 } 8269 }
8245 8270
8246 g_signal_connect(G_OBJECT(win->window), "delete_event", 8271 g_signal_connect(G_OBJECT(win->window), "delete_event",
8247 G_CALLBACK(close_win_cb), win); 8272 G_CALLBACK(close_win_cb), win);
8248 8273 g_signal_connect(G_OBJECT(win->window), "configure_event",
8274 G_CALLBACK(gtk_conv_configure_cb), NULL);
8249 g_signal_connect(G_OBJECT(win->window), "focus_in_event", 8275 g_signal_connect(G_OBJECT(win->window), "focus_in_event",
8250 G_CALLBACK(focus_win_cb), win); 8276 G_CALLBACK(focus_win_cb), win);
8251 8277
8252 /* Create the notebook. */ 8278 /* Create the notebook. */
8253 win->notebook = gtk_notebook_new(); 8279 win->notebook = gtk_notebook_new();