| 7066 |
7066 |
| 7067 stop_anim(NULL, gtkconv); |
7067 stop_anim(NULL, gtkconv); |
| 7068 } |
7068 } |
| 7069 |
7069 |
| 7070 static void |
7070 static void |
| 7071 close_window(GtkWidget *w, PidginConvWindow *win) |
|
| 7072 { |
|
| 7073 close_win_cb(w, NULL, win); |
|
| 7074 } |
|
| 7075 |
|
| 7076 static void |
|
| 7077 detach_tab_cb(GtkWidget *w, PidginConvWindow *win) |
|
| 7078 { |
|
| 7079 PidginConvWindow *new_window; |
|
| 7080 PidginConversation *gtkconv; |
|
| 7081 |
|
| 7082 gtkconv = win->clicked_tab; |
|
| 7083 |
|
| 7084 if (!gtkconv) |
|
| 7085 return; |
|
| 7086 |
|
| 7087 /* Nothing to do if there's only one tab in the window */ |
|
| 7088 if (pidgin_conv_window_get_gtkconv_count(win) == 1) |
|
| 7089 return; |
|
| 7090 |
|
| 7091 pidgin_conv_window_remove_gtkconv(win, gtkconv); |
|
| 7092 |
|
| 7093 new_window = pidgin_conv_window_new(); |
|
| 7094 pidgin_conv_window_add_gtkconv(new_window, gtkconv); |
|
| 7095 pidgin_conv_window_show(new_window); |
|
| 7096 } |
|
| 7097 |
|
| 7098 static void |
|
| 7099 close_others_cb(GtkWidget *w, PidginConvWindow *win) |
|
| 7100 { |
|
| 7101 GList *iter; |
|
| 7102 PidginConversation *gtkconv; |
|
| 7103 |
|
| 7104 gtkconv = win->clicked_tab; |
|
| 7105 |
|
| 7106 if (!gtkconv) |
|
| 7107 return; |
|
| 7108 |
|
| 7109 for (iter = pidgin_conv_window_get_gtkconvs(win); iter; ) |
|
| 7110 { |
|
| 7111 PidginConversation *gconv = iter->data; |
|
| 7112 iter = iter->next; |
|
| 7113 |
|
| 7114 if (gconv != gtkconv) |
|
| 7115 { |
|
| 7116 close_conv_cb(NULL, gconv); |
|
| 7117 } |
|
| 7118 } |
|
| 7119 } |
|
| 7120 |
|
| 7121 static void |
|
| 7122 close_tab_cb(GtkWidget *w, PidginConvWindow *win) |
|
| 7123 { |
|
| 7124 PidginConversation *gtkconv; |
|
| 7125 |
|
| 7126 gtkconv = win->clicked_tab; |
|
| 7127 |
|
| 7128 if (gtkconv) |
|
| 7129 close_conv_cb(NULL, gtkconv); |
|
| 7130 } |
|
| 7131 |
|
| 7132 static void |
|
| 7133 notebook_menu_switch_cb(GtkWidget *item, GtkWidget *child) |
|
| 7134 { |
|
| 7135 GtkNotebook *notebook; |
|
| 7136 int index; |
|
| 7137 |
|
| 7138 notebook = GTK_NOTEBOOK(gtk_widget_get_parent(child)); |
|
| 7139 index = gtk_notebook_page_num(notebook, child); |
|
| 7140 gtk_notebook_set_current_page(notebook, index); |
|
| 7141 } |
|
| 7142 |
|
| 7143 static void |
|
| 7144 notebook_menu_update_label_cb(GtkWidget *child, GParamSpec *pspec, |
|
| 7145 GtkNotebook *notebook) |
|
| 7146 { |
|
| 7147 GtkWidget *item; |
|
| 7148 GtkWidget *label; |
|
| 7149 |
|
| 7150 item = g_object_get_data(G_OBJECT(child), "popup-menu-item"); |
|
| 7151 label = gtk_bin_get_child(GTK_BIN(item)); |
|
| 7152 if (label) |
|
| 7153 gtk_container_remove(GTK_CONTAINER(item), label); |
|
| 7154 |
|
| 7155 label = gtk_notebook_get_menu_label(notebook, child); |
|
| 7156 if (label) { |
|
| 7157 gtk_widget_show(label); |
|
| 7158 gtk_container_add(GTK_CONTAINER(item), label); |
|
| 7159 gtk_widget_show(item); |
|
| 7160 } else { |
|
| 7161 gtk_widget_hide(item); |
|
| 7162 } |
|
| 7163 } |
|
| 7164 |
|
| 7165 static void |
|
| 7166 notebook_add_tab_to_menu_cb(GtkNotebook *notebook, GtkWidget *child, |
|
| 7167 guint page_num, PidginConvWindow *win) |
|
| 7168 { |
|
| 7169 GtkWidget *item; |
|
| 7170 GtkWidget *label; |
|
| 7171 |
|
| 7172 item = gtk_menu_item_new(); |
|
| 7173 label = gtk_notebook_get_menu_label(notebook, child); |
|
| 7174 if (label) { |
|
| 7175 gtk_widget_show(label); |
|
| 7176 gtk_container_add(GTK_CONTAINER(item), label); |
|
| 7177 gtk_widget_show(item); |
|
| 7178 } |
|
| 7179 |
|
| 7180 g_signal_connect(child, "child-notify::menu-label", |
|
| 7181 G_CALLBACK(notebook_menu_update_label_cb), notebook); |
|
| 7182 g_signal_connect(item, "activate", |
|
| 7183 G_CALLBACK(notebook_menu_switch_cb), child); |
|
| 7184 g_object_set_data(G_OBJECT(child), "popup-menu-item", item); |
|
| 7185 |
|
| 7186 gtk_menu_shell_insert(GTK_MENU_SHELL(win->notebook_menu), item, page_num); |
|
| 7187 } |
|
| 7188 |
|
| 7189 static void |
|
| 7190 notebook_remove_tab_from_menu_cb(GtkNotebook *notebook, GtkWidget *child, |
|
| 7191 guint page_num, PidginConvWindow *win) |
|
| 7192 { |
|
| 7193 GtkWidget *item; |
|
| 7194 |
|
| 7195 /* Disconnecting the "child-notify::menu-label" signal. */ |
|
| 7196 g_signal_handlers_disconnect_by_data(child, notebook); |
|
| 7197 |
|
| 7198 item = g_object_get_data(G_OBJECT(child), "popup-menu-item"); |
|
| 7199 gtk_container_remove(GTK_CONTAINER(win->notebook_menu), item); |
|
| 7200 } |
|
| 7201 |
|
| 7202 |
|
| 7203 static void |
|
| 7204 notebook_reorder_tab_in_menu_cb(GtkNotebook *notebook, GtkWidget *child, |
|
| 7205 guint page_num, PidginConvWindow *win) |
|
| 7206 { |
|
| 7207 GtkWidget *item; |
|
| 7208 |
|
| 7209 item = g_object_get_data(G_OBJECT(child), "popup-menu-item"); |
|
| 7210 gtk_menu_reorder_child(GTK_MENU(win->notebook_menu), item, page_num); |
|
| 7211 } |
|
| 7212 |
|
| 7213 static gboolean |
|
| 7214 notebook_right_click_menu_cb(GtkNotebook *notebook, GdkEventButton *event, |
|
| 7215 PidginConvWindow *win) |
|
| 7216 { |
|
| 7217 GtkWidget *menu; |
|
| 7218 PidginConversation *gtkconv; |
|
| 7219 |
|
| 7220 if (!gdk_event_triggers_context_menu((GdkEvent *)event)) |
|
| 7221 return FALSE; |
|
| 7222 |
|
| 7223 gtkconv = pidgin_conv_window_get_gtkconv_at_index(win, |
|
| 7224 pidgin_conv_get_tab_at_xy(win, event->x_root, event->y_root, NULL)); |
|
| 7225 |
|
| 7226 win->clicked_tab = gtkconv; |
|
| 7227 |
|
| 7228 menu = win->notebook_menu; |
|
| 7229 |
|
| 7230 gtk_menu_popup_at_pointer(GTK_MENU(menu), (GdkEvent *)event); |
|
| 7231 |
|
| 7232 return TRUE; |
|
| 7233 } |
|
| 7234 |
|
| 7235 static void |
|
| 7236 remove_edit_entry(PidginConversation *gtkconv, GtkWidget *entry) |
7071 remove_edit_entry(PidginConversation *gtkconv, GtkWidget *entry) |
| 7237 { |
7072 { |
| 7238 g_signal_handlers_disconnect_matched(G_OBJECT(entry), G_SIGNAL_MATCH_DATA, |
7073 g_signal_handlers_disconnect_matched(G_OBJECT(entry), G_SIGNAL_MATCH_DATA, |
| 7239 0, 0, NULL, NULL, gtkconv); |
7074 0, 0, NULL, NULL, gtkconv); |
| 7240 gtk_widget_show(gtkconv->infopane); |
7075 gtk_widget_show(gtkconv->infopane); |
| 7574 |
7406 |
| 7575 |
7407 |
| 7576 /* Create the notebook. */ |
7408 /* Create the notebook. */ |
| 7577 win->notebook = gtk_notebook_new(); |
7409 win->notebook = gtk_notebook_new(); |
| 7578 |
7410 |
| 7579 pos = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/tab_side"); |
7411 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(win->notebook), GTK_POS_LEFT); |
| 7580 |
|
| 7581 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(win->notebook), pos); |
|
| 7582 gtk_notebook_set_scrollable(GTK_NOTEBOOK(win->notebook), TRUE); |
7412 gtk_notebook_set_scrollable(GTK_NOTEBOOK(win->notebook), TRUE); |
| 7583 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), FALSE); |
7413 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), FALSE); |
| 7584 gtk_notebook_set_show_border(GTK_NOTEBOOK(win->notebook), TRUE); |
7414 gtk_notebook_set_show_border(GTK_NOTEBOOK(win->notebook), TRUE); |
| 7585 |
|
| 7586 menu = win->notebook_menu = gtk_menu_new(); |
|
| 7587 |
|
| 7588 pidgin_separator(GTK_WIDGET(menu)); |
|
| 7589 |
|
| 7590 item = gtk_menu_item_new_with_label(_("Close other tabs")); |
|
| 7591 gtk_widget_show(item); |
|
| 7592 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
|
| 7593 g_signal_connect(G_OBJECT(item), "activate", |
|
| 7594 G_CALLBACK(close_others_cb), win); |
|
| 7595 |
|
| 7596 item = gtk_menu_item_new_with_label(_("Close all tabs")); |
|
| 7597 gtk_widget_show(item); |
|
| 7598 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
|
| 7599 g_signal_connect(G_OBJECT(item), "activate", |
|
| 7600 G_CALLBACK(close_window), win); |
|
| 7601 |
|
| 7602 pidgin_separator(menu); |
|
| 7603 |
|
| 7604 item = gtk_menu_item_new_with_label(_("Detach this tab")); |
|
| 7605 gtk_widget_show(item); |
|
| 7606 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
|
| 7607 g_signal_connect(G_OBJECT(item), "activate", |
|
| 7608 G_CALLBACK(detach_tab_cb), win); |
|
| 7609 |
|
| 7610 item = gtk_menu_item_new_with_label(_("Close this tab")); |
|
| 7611 gtk_widget_show(item); |
|
| 7612 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
|
| 7613 g_signal_connect(G_OBJECT(item), "activate", |
|
| 7614 G_CALLBACK(close_tab_cb), win); |
|
| 7615 |
|
| 7616 g_signal_connect(G_OBJECT(win->notebook), "page-added", |
|
| 7617 G_CALLBACK(notebook_add_tab_to_menu_cb), win); |
|
| 7618 g_signal_connect(G_OBJECT(win->notebook), "page-removed", |
|
| 7619 G_CALLBACK(notebook_remove_tab_from_menu_cb), win); |
|
| 7620 g_signal_connect(G_OBJECT(win->notebook), "page-reordered", |
|
| 7621 G_CALLBACK(notebook_reorder_tab_in_menu_cb), win); |
|
| 7622 |
|
| 7623 g_signal_connect(G_OBJECT(win->notebook), "button-press-event", |
|
| 7624 G_CALLBACK(notebook_right_click_menu_cb), win); |
|
| 7625 |
7415 |
| 7626 gtk_widget_show(win->notebook); |
7416 gtk_widget_show(win->notebook); |
| 7627 |
7417 |
| 7628 g_signal_connect(G_OBJECT(win->notebook), "switch_page", |
7418 g_signal_connect(G_OBJECT(win->notebook), "switch_page", |
| 7629 G_CALLBACK(before_switch_conv_cb), win); |
7419 G_CALLBACK(before_switch_conv_cb), win); |