| 9433 } |
9433 } |
| 9434 |
9434 |
| 9435 stop_anim(NULL, gtkconv); |
9435 stop_anim(NULL, gtkconv); |
| 9436 } |
9436 } |
| 9437 |
9437 |
| 9438 /* TODO: I don't know if this doable in GTK+ 3.0 */ |
|
| 9439 #if 0 |
|
| 9440 static void |
9438 static void |
| 9441 close_window(GtkWidget *w, PidginWindow *win) |
9439 close_window(GtkWidget *w, PidginWindow *win) |
| 9442 { |
9440 { |
| 9443 close_win_cb(w, NULL, win); |
9441 close_win_cb(w, NULL, win); |
| 9444 } |
9442 } |
| 9445 |
9443 |
| 9446 static void |
9444 static void |
| 9447 detach_tab_cb(GtkWidget *w, GObject *menu) |
9445 detach_tab_cb(GtkWidget *w, PidginWindow *win) |
| 9448 { |
9446 { |
| 9449 PidginWindow *win, *new_window; |
9447 PidginWindow *new_window; |
| 9450 PidginConversation *gtkconv; |
9448 PidginConversation *gtkconv; |
| 9451 |
9449 |
| 9452 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9450 gtkconv = win->clicked_tab; |
| 9453 |
9451 |
| 9454 if (!gtkconv) |
9452 if (!gtkconv) |
| 9455 return; |
9453 return; |
| 9456 |
9454 |
| 9457 win = pidgin_conv_get_window(gtkconv); |
|
| 9458 /* Nothing to do if there's only one tab in the window */ |
9455 /* Nothing to do if there's only one tab in the window */ |
| 9459 if (pidgin_conv_window_get_gtkconv_count(win) == 1) |
9456 if (pidgin_conv_window_get_gtkconv_count(win) == 1) |
| 9460 return; |
9457 return; |
| 9461 |
9458 |
| 9462 pidgin_conv_window_remove_gtkconv(win, gtkconv); |
9459 pidgin_conv_window_remove_gtkconv(win, gtkconv); |
| 9490 close_conv_cb(NULL, gconv); |
9484 close_conv_cb(NULL, gconv); |
| 9491 } |
9485 } |
| 9492 } |
9486 } |
| 9493 } |
9487 } |
| 9494 |
9488 |
| 9495 static void close_tab_cb(GtkWidget *w, GObject *menu) |
9489 static void |
| |
9490 close_tab_cb(GtkWidget *w, PidginWindow *win) |
| 9496 { |
9491 { |
| 9497 PidginConversation *gtkconv; |
9492 PidginConversation *gtkconv; |
| 9498 |
9493 |
| 9499 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9494 gtkconv = win->clicked_tab; |
| 9500 |
9495 |
| 9501 if (gtkconv) |
9496 if (gtkconv) |
| 9502 close_conv_cb(NULL, gtkconv); |
9497 close_conv_cb(NULL, gtkconv); |
| 9503 } |
9498 } |
| 9504 |
9499 |
| |
9500 static void |
| |
9501 notebook_menu_switch_cb(GtkWidget *item, GtkWidget *child) |
| |
9502 { |
| |
9503 GtkNotebook *notebook; |
| |
9504 int index; |
| |
9505 |
| |
9506 notebook = GTK_NOTEBOOK(gtk_widget_get_parent(child)); |
| |
9507 index = gtk_notebook_page_num(notebook, child); |
| |
9508 gtk_notebook_set_current_page(notebook, index); |
| |
9509 } |
| |
9510 |
| |
9511 static void |
| |
9512 notebook_menu_update_label_cb(GtkWidget *child, GParamSpec *pspec, |
| |
9513 GtkNotebook *notebook) |
| |
9514 { |
| |
9515 GtkWidget *item; |
| |
9516 GtkWidget *label; |
| |
9517 |
| |
9518 item = g_object_get_data(G_OBJECT(child), "popup-menu-item"); |
| |
9519 label = gtk_bin_get_child(GTK_BIN(item)); |
| |
9520 if (label) |
| |
9521 gtk_container_remove(GTK_CONTAINER(item), label); |
| |
9522 |
| |
9523 label = gtk_notebook_get_menu_label(notebook, child); |
| |
9524 if (label) { |
| |
9525 gtk_widget_show(label); |
| |
9526 gtk_container_add(GTK_CONTAINER(item), label); |
| |
9527 gtk_widget_show(item); |
| |
9528 } else { |
| |
9529 gtk_widget_hide(item); |
| |
9530 } |
| |
9531 } |
| |
9532 |
| |
9533 static void |
| |
9534 notebook_add_tab_to_menu_cb(GtkNotebook *notebook, GtkWidget *child, |
| |
9535 guint page_num, PidginWindow *win) |
| |
9536 { |
| |
9537 GtkWidget *item; |
| |
9538 GtkWidget *label; |
| |
9539 |
| |
9540 item = gtk_menu_item_new(); |
| |
9541 label = gtk_notebook_get_menu_label(notebook, child); |
| |
9542 if (label) { |
| |
9543 gtk_widget_show(label); |
| |
9544 gtk_container_add(GTK_CONTAINER(item), label); |
| |
9545 gtk_widget_show(item); |
| |
9546 } |
| |
9547 |
| |
9548 g_signal_connect(child, "child-notify::menu-label", |
| |
9549 G_CALLBACK(notebook_menu_update_label_cb), notebook); |
| |
9550 g_signal_connect(item, "activate", |
| |
9551 G_CALLBACK(notebook_menu_switch_cb), child); |
| |
9552 g_object_set_data(G_OBJECT(child), "popup-menu-item", item); |
| |
9553 |
| |
9554 gtk_menu_shell_insert(GTK_MENU_SHELL(win->notebook_menu), item, page_num); |
| |
9555 } |
| |
9556 |
| |
9557 static void |
| |
9558 notebook_remove_tab_from_menu_cb(GtkNotebook *notebook, GtkWidget *child, |
| |
9559 guint page_num, PidginWindow *win) |
| |
9560 { |
| |
9561 GtkWidget *item; |
| |
9562 |
| |
9563 item = g_object_get_data(G_OBJECT(child), "popup-menu-item"); |
| |
9564 gtk_container_remove(GTK_CONTAINER(win->notebook_menu), item); |
| |
9565 } |
| |
9566 |
| |
9567 |
| |
9568 static void |
| |
9569 notebook_reorder_tab_in_menu_cb(GtkNotebook *notebook, GtkWidget *child, |
| |
9570 guint page_num, PidginWindow *win) |
| |
9571 { |
| |
9572 GtkWidget *item; |
| |
9573 |
| |
9574 item = g_object_get_data(G_OBJECT(child), "popup-menu-item"); |
| |
9575 gtk_menu_reorder_child(GTK_MENU(win->notebook_menu), item, page_num); |
| |
9576 } |
| |
9577 |
| 9505 static gboolean |
9578 static gboolean |
| 9506 right_click_menu_cb(GtkNotebook *notebook, GdkEventButton *event, PidginWindow *win) |
9579 notebook_right_click_menu_cb(GtkNotebook *notebook, GdkEventButton *event, |
| 9507 { |
9580 PidginWindow *win) |
| 9508 GtkWidget *item; |
9581 { |
| |
9582 GtkWidget *menu; |
| 9509 PidginConversation *gtkconv; |
9583 PidginConversation *gtkconv; |
| 9510 GtkWidget *menu = gtk_notebook_get_menu |
|
| 9511 |
9584 |
| 9512 if (event->type != GDK_BUTTON_PRESS || event->button != 3) |
9585 if (event->type != GDK_BUTTON_PRESS || event->button != 3) |
| 9513 return FALSE; |
9586 return FALSE; |
| 9514 |
9587 |
| 9515 gtkconv = pidgin_conv_window_get_gtkconv_at_index(win, |
9588 gtkconv = pidgin_conv_window_get_gtkconv_at_index(win, |
| 9516 pidgin_conv_get_tab_at_xy(win, event->x_root, event->y_root, NULL)); |
9589 pidgin_conv_get_tab_at_xy(win, event->x_root, event->y_root, NULL)); |
| 9517 |
9590 |
| 9518 if (g_object_get_data(G_OBJECT(notebook->menu), "clicked_tab")) |
9591 win->clicked_tab = gtkconv; |
| 9519 { |
9592 |
| 9520 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9593 menu = win->notebook_menu; |
| 9521 return FALSE; |
9594 |
| 9522 } |
9595 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, event->time); |
| 9523 |
9596 |
| 9524 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9597 return TRUE; |
| 9525 |
9598 } |
| 9526 menu = notebook->menu; |
|
| 9527 pidgin_separator(GTK_WIDGET(menu)); |
|
| 9528 |
|
| 9529 item = gtk_menu_item_new_with_label(_("Close other tabs")); |
|
| 9530 gtk_widget_show(item); |
|
| 9531 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
|
| 9532 g_signal_connect(G_OBJECT(item), "activate", |
|
| 9533 G_CALLBACK(close_others_cb), menu); |
|
| 9534 |
|
| 9535 item = gtk_menu_item_new_with_label(_("Close all tabs")); |
|
| 9536 gtk_widget_show(item); |
|
| 9537 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
|
| 9538 g_signal_connect(G_OBJECT(item), "activate", |
|
| 9539 G_CALLBACK(close_window), win); |
|
| 9540 |
|
| 9541 pidgin_separator(menu); |
|
| 9542 |
|
| 9543 item = gtk_menu_item_new_with_label(_("Detach this tab")); |
|
| 9544 gtk_widget_show(item); |
|
| 9545 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
|
| 9546 g_signal_connect(G_OBJECT(item), "activate", |
|
| 9547 G_CALLBACK(detach_tab_cb), menu); |
|
| 9548 |
|
| 9549 item = gtk_menu_item_new_with_label(_("Close this tab")); |
|
| 9550 gtk_widget_show(item); |
|
| 9551 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
|
| 9552 g_signal_connect(G_OBJECT(item), "activate", |
|
| 9553 G_CALLBACK(close_tab_cb), menu); |
|
| 9554 |
|
| 9555 return FALSE; |
|
| 9556 } |
|
| 9557 #endif |
|
| 9558 |
9599 |
| 9559 static void |
9600 static void |
| 9560 remove_edit_entry(PidginConversation *gtkconv, GtkWidget *entry) |
9601 remove_edit_entry(PidginConversation *gtkconv, GtkWidget *entry) |
| 9561 { |
9602 { |
| 9562 g_signal_handlers_disconnect_matched(G_OBJECT(entry), G_SIGNAL_MATCH_DATA, |
9603 g_signal_handlers_disconnect_matched(G_OBJECT(entry), G_SIGNAL_MATCH_DATA, |
| 9895 gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(win->notebook), 0); |
9938 gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(win->notebook), 0); |
| 9896 gtk_notebook_set_tab_vborder(GTK_NOTEBOOK(win->notebook), 0); |
9939 gtk_notebook_set_tab_vborder(GTK_NOTEBOOK(win->notebook), 0); |
| 9897 #endif |
9940 #endif |
| 9898 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(win->notebook), pos); |
9941 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(win->notebook), pos); |
| 9899 gtk_notebook_set_scrollable(GTK_NOTEBOOK(win->notebook), TRUE); |
9942 gtk_notebook_set_scrollable(GTK_NOTEBOOK(win->notebook), TRUE); |
| 9900 gtk_notebook_popup_enable(GTK_NOTEBOOK(win->notebook)); |
|
| 9901 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), FALSE); |
9943 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), FALSE); |
| 9902 gtk_notebook_set_show_border(GTK_NOTEBOOK(win->notebook), TRUE); |
9944 gtk_notebook_set_show_border(GTK_NOTEBOOK(win->notebook), TRUE); |
| 9903 |
9945 |
| 9904 /* TODO: figure out how to add custom stuff to the right-click menu in |
9946 menu = win->notebook_menu = gtk_menu_new(); |
| 9905 GtkNotebook in GTK+ 3.0 */ |
9947 |
| 9906 #if 0 |
9948 pidgin_separator(GTK_WIDGET(menu)); |
| |
9949 |
| |
9950 item = gtk_menu_item_new_with_label(_("Close other tabs")); |
| |
9951 gtk_widget_show(item); |
| |
9952 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
| |
9953 g_signal_connect(G_OBJECT(item), "activate", |
| |
9954 G_CALLBACK(close_others_cb), win); |
| |
9955 |
| |
9956 item = gtk_menu_item_new_with_label(_("Close all tabs")); |
| |
9957 gtk_widget_show(item); |
| |
9958 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
| |
9959 g_signal_connect(G_OBJECT(item), "activate", |
| |
9960 G_CALLBACK(close_window), win); |
| |
9961 |
| |
9962 pidgin_separator(menu); |
| |
9963 |
| |
9964 item = gtk_menu_item_new_with_label(_("Detach this tab")); |
| |
9965 gtk_widget_show(item); |
| |
9966 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
| |
9967 g_signal_connect(G_OBJECT(item), "activate", |
| |
9968 G_CALLBACK(detach_tab_cb), win); |
| |
9969 |
| |
9970 item = gtk_menu_item_new_with_label(_("Close this tab")); |
| |
9971 gtk_widget_show(item); |
| |
9972 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
| |
9973 g_signal_connect(G_OBJECT(item), "activate", |
| |
9974 G_CALLBACK(close_tab_cb), win); |
| |
9975 |
| |
9976 g_signal_connect(G_OBJECT(win->notebook), "page-added", |
| |
9977 G_CALLBACK(notebook_add_tab_to_menu_cb), win); |
| |
9978 g_signal_connect(G_OBJECT(win->notebook), "page-removed", |
| |
9979 G_CALLBACK(notebook_remove_tab_from_menu_cb), win); |
| |
9980 g_signal_connect(G_OBJECT(win->notebook), "page-reordered", |
| |
9981 G_CALLBACK(notebook_reorder_tab_in_menu_cb), win); |
| |
9982 |
| 9907 g_signal_connect(G_OBJECT(win->notebook), "button-press-event", |
9983 g_signal_connect(G_OBJECT(win->notebook), "button-press-event", |
| 9908 G_CALLBACK(right_click_menu_cb), win); |
9984 G_CALLBACK(notebook_right_click_menu_cb), win); |
| 9909 #endif |
|
| 9910 |
9985 |
| 9911 gtk_widget_show(win->notebook); |
9986 gtk_widget_show(win->notebook); |
| 9912 |
9987 |
| 9913 g_signal_connect(G_OBJECT(win->notebook), "switch_page", |
9988 g_signal_connect(G_OBJECT(win->notebook), "switch_page", |
| 9914 G_CALLBACK(before_switch_conv_cb), win); |
9989 G_CALLBACK(before_switch_conv_cb), win); |