Mercurial > pidgin.yaz
comparison pidgin/gtkconv.c @ 18228:3449f18ff2e2
disapproval of revision '7b9d44db746d32a4cd7a4bd39d9e070d41a94194'
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Sun, 22 Jul 2007 06:50:49 +0000 |
parents | cbc89a49e43b |
children | 8dff6641287b |
comparison
equal
deleted
inserted
replaced
18227:cbc89a49e43b | 18228:3449f18ff2e2 |
---|---|
182 static GdkColor* generate_nick_colors(guint *numcolors, GdkColor background); | 182 static GdkColor* generate_nick_colors(guint *numcolors, GdkColor background); |
183 static gboolean color_is_visible(GdkColor foreground, GdkColor background, int color_contrast, int brightness_contrast); | 183 static gboolean color_is_visible(GdkColor foreground, GdkColor background, int color_contrast, int brightness_contrast); |
184 static void pidgin_conv_update_fields(PurpleConversation *conv, PidginConvFields fields); | 184 static void pidgin_conv_update_fields(PurpleConversation *conv, PidginConvFields fields); |
185 static void focus_out_from_menubar(GtkWidget *wid, PidginWindow *win); | 185 static void focus_out_from_menubar(GtkWidget *wid, PidginWindow *win); |
186 static void pidgin_conv_tab_pack(PidginWindow *win, PidginConversation *gtkconv); | 186 static void pidgin_conv_tab_pack(PidginWindow *win, PidginConversation *gtkconv); |
187 static gboolean infopane_release_cb(GtkWidget *widget, GdkEventButton *e, PidginConversation *conv); | |
188 static gboolean infopane_press_cb(GtkWidget *widget, GdkEventButton *e, PidginConversation *conv); | |
189 | 187 |
190 static GdkColor *get_nick_color(PidginConversation *gtkconv, const char *name) { | 188 static GdkColor *get_nick_color(PidginConversation *gtkconv, const char *name) { |
191 static GdkColor col; | 189 static GdkColor col; |
192 GtkStyle *style = gtk_widget_get_style(gtkconv->imhtml); | 190 GtkStyle *style = gtk_widget_get_style(gtkconv->imhtml); |
193 float scale; | 191 float scale; |
4377 } | 4375 } |
4378 | 4376 |
4379 static GtkWidget * | 4377 static GtkWidget * |
4380 setup_common_pane(PidginConversation *gtkconv) | 4378 setup_common_pane(PidginConversation *gtkconv) |
4381 { | 4379 { |
4382 GtkWidget *paned, *vbox, *frame, *imhtml_sw, *event_box; | 4380 GtkWidget *paned, *vbox, *frame, *imhtml_sw; |
4383 GtkCellRenderer *rend; | 4381 GtkCellRenderer *rend; |
4384 GtkTreePath *path; | 4382 GtkTreePath *path; |
4385 PurpleConversation *conv = gtkconv->active_conv; | 4383 PurpleConversation *conv = gtkconv->active_conv; |
4386 gboolean chat = (conv->type == PURPLE_CONV_TYPE_CHAT); | 4384 gboolean chat = (conv->type == PURPLE_CONV_TYPE_CHAT); |
4387 GtkPolicyType imhtml_sw_hscroll; | 4385 GtkPolicyType imhtml_sw_hscroll; |
4393 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); | 4391 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); |
4394 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); | 4392 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); |
4395 gtk_widget_show(vbox); | 4393 gtk_widget_show(vbox); |
4396 | 4394 |
4397 /* Setup the info pane */ | 4395 /* Setup the info pane */ |
4398 event_box = gtk_event_box_new(); | |
4399 gtk_widget_show(event_box); | |
4400 gtkconv->infopane_hbox = gtk_hbox_new(FALSE, 0); | 4396 gtkconv->infopane_hbox = gtk_hbox_new(FALSE, 0); |
4401 gtk_box_pack_start(GTK_BOX(vbox), event_box, FALSE, FALSE, 0); | 4397 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->infopane_hbox, FALSE, FALSE, 0); |
4402 gtk_container_add(GTK_CONTAINER(event_box), gtkconv->infopane_hbox); | |
4403 gtk_widget_show(gtkconv->infopane_hbox); | 4398 gtk_widget_show(gtkconv->infopane_hbox); |
4404 gtk_widget_add_events(event_box, | |
4405 GDK_BUTTON1_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); | |
4406 g_signal_connect(G_OBJECT(event_box), "button_press_event", | |
4407 G_CALLBACK(infopane_press_cb), gtkconv); | |
4408 g_signal_connect(G_OBJECT(event_box), "button_release_event", | |
4409 G_CALLBACK(infopane_release_cb), gtkconv); | |
4410 | |
4411 | 4399 |
4412 gtkconv->infopane = gtk_cell_view_new(); | 4400 gtkconv->infopane = gtk_cell_view_new(); |
4413 gtkconv->infopane_model = gtk_list_store_new(NUM_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING); | 4401 gtkconv->infopane_model = gtk_list_store_new(NUM_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING); |
4414 gtk_cell_view_set_model(GTK_CELL_VIEW(gtkconv->infopane), | 4402 gtk_cell_view_set_model(GTK_CELL_VIEW(gtkconv->infopane), |
4415 GTK_TREE_MODEL(gtkconv->infopane_model)); | 4403 GTK_TREE_MODEL(gtkconv->infopane_model)); |
7604 } | 7592 } |
7605 | 7593 |
7606 /* | 7594 /* |
7607 * THANK YOU GALEON! | 7595 * THANK YOU GALEON! |
7608 */ | 7596 */ |
7609 | |
7610 static gboolean | |
7611 infopane_press_cb(GtkWidget *widget, GdkEventButton *e, PidginConversation *gtkconv) | |
7612 { | |
7613 int nb_x, nb_y; | |
7614 | |
7615 if (e->button != 1 || e->type != GDK_BUTTON_PRESS) | |
7616 return FALSE; | |
7617 | |
7618 if (gtkconv->win->in_drag) { | |
7619 purple_debug(PURPLE_DEBUG_WARNING, "gtkconv", | |
7620 "Already in the middle of a window drag at tab_press_cb\n"); | |
7621 return TRUE; | |
7622 } | |
7623 | |
7624 gtkconv->win->in_predrag = TRUE; | |
7625 gtkconv->win->drag_tab = gtk_notebook_page_num(GTK_NOTEBOOK(gtkconv->win->notebook), gtkconv->tab_cont); | |
7626 | |
7627 gdk_window_get_origin(gtkconv->infopane_hbox->window, &nb_x, &nb_y); | |
7628 | |
7629 gtkconv->win->drag_min_x = gtkconv->infopane_hbox->allocation.x + nb_x; | |
7630 gtkconv->win->drag_min_y = gtkconv->infopane_hbox->allocation.y + nb_y; | |
7631 gtkconv->win->drag_max_x = gtkconv->infopane_hbox->allocation.width + gtkconv->win->drag_min_x; | |
7632 gtkconv->win->drag_max_y = gtkconv->infopane_hbox->allocation.height + gtkconv->win->drag_min_y; | |
7633 | |
7634 | |
7635 /* Connect the new motion signals. */ | |
7636 gtkconv->win->drag_motion_signal = | |
7637 g_signal_connect(G_OBJECT(gtkconv->win->notebook), "motion_notify_event", | |
7638 G_CALLBACK(notebook_motion_cb), gtkconv->win); | |
7639 | |
7640 gtkconv->win->drag_leave_signal = | |
7641 g_signal_connect(G_OBJECT(gtkconv->win->notebook), "leave_notify_event", | |
7642 G_CALLBACK(notebook_leave_cb), gtkconv->win); | |
7643 | |
7644 return FALSE; | |
7645 | |
7646 } | |
7647 | |
7648 static gboolean | 7597 static gboolean |
7649 notebook_press_cb(GtkWidget *widget, GdkEventButton *e, PidginWindow *win) | 7598 notebook_press_cb(GtkWidget *widget, GdkEventButton *e, PidginWindow *win) |
7650 { | 7599 { |
7651 gint nb_x, nb_y, x_rel, y_rel; | 7600 gint nb_x, nb_y, x_rel, y_rel; |
7652 int tab_clicked; | 7601 int tab_clicked; |
7729 win->drag_leave_signal = | 7678 win->drag_leave_signal = |
7730 g_signal_connect(G_OBJECT(widget), "leave_notify_event", | 7679 g_signal_connect(G_OBJECT(widget), "leave_notify_event", |
7731 G_CALLBACK(notebook_leave_cb), win); | 7680 G_CALLBACK(notebook_leave_cb), win); |
7732 | 7681 |
7733 return FALSE; | 7682 return FALSE; |
7734 } | |
7735 | |
7736 static gboolean | |
7737 infopane_release_cb(GtkWidget *widget, GdkEventButton *e, PidginConversation *gtkconv) | |
7738 { | |
7739 } | 7683 } |
7740 | 7684 |
7741 static gboolean | 7685 static gboolean |
7742 notebook_release_cb(GtkWidget *widget, GdkEventButton *e, PidginWindow *win) | 7686 notebook_release_cb(GtkWidget *widget, GdkEventButton *e, PidginWindow *win) |
7743 { | 7687 { |
8428 | 8372 |
8429 if (pidgin_conv_window_get_gtkconv_count(win) == 1) { | 8373 if (pidgin_conv_window_get_gtkconv_count(win) == 1) { |
8430 /* Er, bug in notebooks? Switch to the page manually. */ | 8374 /* Er, bug in notebooks? Switch to the page manually. */ |
8431 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | 8375 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); |
8432 | 8376 |
8433 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), FALSE); | 8377 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), |
8378 purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/tabs")); | |
8434 } else | 8379 } else |
8435 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), TRUE); | 8380 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), TRUE); |
8436 | 8381 |
8437 focus_gtkconv = g_list_nth_data(pidgin_conv_window_get_gtkconvs(win), | 8382 focus_gtkconv = g_list_nth_data(pidgin_conv_window_get_gtkconvs(win), |
8438 gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook))); | 8383 gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook))); |
8544 g_object_ref(gtkconv->tab_cont); | 8489 g_object_ref(gtkconv->tab_cont); |
8545 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); | 8490 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); |
8546 | 8491 |
8547 gtk_notebook_remove_page(GTK_NOTEBOOK(win->notebook), index); | 8492 gtk_notebook_remove_page(GTK_NOTEBOOK(win->notebook), index); |
8548 | 8493 |
8549 /* go back to tabless */ | 8494 /* go back to tabless if need be */ |
8550 if (pidgin_conv_window_get_gtkconv_count(win) <= 2) { | 8495 if (pidgin_conv_window_get_gtkconv_count(win) <= 2) { |
8551 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), FALSE); | 8496 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), |
8497 purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/tabs")); | |
8552 } | 8498 } |
8553 | 8499 |
8554 win->gtkconvs = g_list_remove(win->gtkconvs, gtkconv); | 8500 win->gtkconvs = g_list_remove(win->gtkconvs, gtkconv); |
8555 | |
8556 if (!win->gtkconvs || !win->gtkconvs->next) | |
8557 gtk_notebook_set_show_tabs(win->notebook, FALSE); | |
8558 | 8501 |
8559 if (!win->gtkconvs && win != hidden_convwin) | 8502 if (!win->gtkconvs && win != hidden_convwin) |
8560 pidgin_conv_window_destroy(win); | 8503 pidgin_conv_window_destroy(win); |
8561 } | 8504 } |
8562 | 8505 |