comparison pidgin/gtkconv.c @ 30037:f988f25259c7

merged with im.pidgin.pidgin
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Wed, 24 Mar 2010 17:44:40 +0900
parents 8cf8a75875c8 8a2ab625753e
children bd0ce3844104
comparison
equal deleted inserted replaced
29995:2292d8896b0b 30037:f988f25259c7
232 g_list_free(list); 232 g_list_free(list);
233 return FALSE; 233 return FALSE;
234 } 234 }
235 235
236 static gboolean 236 static gboolean
237 close_conv_cb(GtkWidget *w, GdkEventButton *dontuse, PidginConversation *gtkconv) 237 close_conv_cb(GtkButton *button, PidginConversation *gtkconv)
238 { 238 {
239 /* We are going to destroy the conversations immediately only if the 'close immediately' 239 /* We are going to destroy the conversations immediately only if the 'close immediately'
240 * preference is selected. Otherwise, close the conversation after a reasonable timeout 240 * preference is selected. Otherwise, close the conversation after a reasonable timeout
241 * (I am going to consider 10 minutes as a 'reasonable timeout' here. 241 * (I am going to consider 10 minutes as a 'reasonable timeout' here.
242 * For chats, close immediately if the chat is not in the buddylist, or if the chat is 242 * For chats, close immediately if the chat is not in the buddylist, or if the chat is
1379 static void 1379 static void
1380 menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget) 1380 menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget)
1381 { 1381 {
1382 PidginWindow *win = data; 1382 PidginWindow *win = data;
1383 1383
1384 close_conv_cb(NULL, NULL, PIDGIN_CONVERSATION(pidgin_conv_window_get_active_conversation(win))); 1384 close_conv_cb(NULL, PIDGIN_CONVERSATION(pidgin_conv_window_get_active_conversation(win)));
1385 } 1385 }
1386 1386
1387 static void 1387 static void
1388 menu_logging_cb(gpointer data, guint action, GtkWidget *widget) 1388 menu_logging_cb(gpointer data, guint action, GtkWidget *widget)
1389 { 1389 {
4893 if (node) 4893 if (node)
4894 pidgin_blist_draw_tooltip(node, gtkconv->infopane); 4894 pidgin_blist_draw_tooltip(node, gtkconv->infopane);
4895 return FALSE; 4895 return FALSE;
4896 } 4896 }
4897 4897
4898 /* Close button {{{ */
4899 static gboolean
4900 close_button_left_cb(GtkWidget *widget, GdkEventCrossing *event, GtkLabel *label)
4901 {
4902 static GdkCursor *ptr = NULL;
4903 if (ptr == NULL) {
4904 ptr = gdk_cursor_new(GDK_LEFT_PTR);
4905 }
4906
4907 gtk_label_set_markup(label, "×");
4908 gdk_window_set_cursor(event->window, ptr);
4909 return FALSE;
4910 }
4911
4912 static gboolean
4913 close_button_entered_cb(GtkWidget *widget, GdkEventCrossing *event, GtkLabel *label)
4914 {
4915 static GdkCursor *hand = NULL;
4916 if (hand == NULL) {
4917 hand = gdk_cursor_new(GDK_HAND2);
4918 }
4919
4920 gtk_label_set_markup(label, "<u>×</u>");
4921 gdk_window_set_cursor(event->window, hand);
4922 return FALSE;
4923 }
4924
4925 static GtkWidget *
4926 create_close_button(void)
4927 {
4928 GtkWidget *ebox = gtk_event_box_new();
4929 GtkWidget *close_image;
4930
4931 gtk_event_box_set_visible_window(GTK_EVENT_BOX(ebox), FALSE);
4932 gtk_widget_set_events(ebox, GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
4933 close_image = gtk_label_new("×");
4934 g_signal_connect(G_OBJECT(ebox), "enter-notify-event", G_CALLBACK(close_button_entered_cb), close_image);
4935 g_signal_connect(G_OBJECT(ebox), "leave-notify-event", G_CALLBACK(close_button_left_cb), close_image);
4936 gtk_widget_show(close_image);
4937 gtk_container_add(GTK_CONTAINER(ebox), close_image);
4938
4939 return ebox;
4940 }
4941
4942 /* }}} */
4943
4944 /* Quick Find {{{ */ 4898 /* Quick Find {{{ */
4945 static gboolean 4899 static gboolean
4946 pidgin_conv_end_quickfind(PidginConversation *gtkconv) 4900 pidgin_conv_end_quickfind(PidginConversation *gtkconv)
4947 { 4901 {
4948 gtk_widget_modify_base(gtkconv->quickfind.entry, GTK_STATE_NORMAL, NULL); 4902 gtk_widget_modify_base(gtkconv->quickfind.entry, GTK_STATE_NORMAL, NULL);
4985 4939
4986 static void 4940 static void
4987 pidgin_conv_setup_quickfind(PidginConversation *gtkconv, GtkWidget *container) 4941 pidgin_conv_setup_quickfind(PidginConversation *gtkconv, GtkWidget *container)
4988 { 4942 {
4989 GtkWidget *widget = gtk_hbox_new(FALSE, 0); 4943 GtkWidget *widget = gtk_hbox_new(FALSE, 0);
4990 GtkWidget *label, *entry, *close; 4944 GtkWidget *label, *entry, *close, *image;
4991 4945
4992 gtk_box_pack_start(GTK_BOX(container), widget, FALSE, FALSE, 0); 4946 gtk_box_pack_start(GTK_BOX(container), widget, FALSE, FALSE, 0);
4993 4947
4994 close = create_close_button(); 4948 image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
4949 close = pidgin_create_small_button(image);
4995 gtk_box_pack_start(GTK_BOX(widget), close, FALSE, FALSE, 0); 4950 gtk_box_pack_start(GTK_BOX(widget), close, FALSE, FALSE, 0);
4996 gtk_tooltips_set_tip(gtkconv->tooltips, close, 4951 gtk_tooltips_set_tip(gtkconv->tooltips, close,
4997 _("Close Find bar"), NULL); 4952 _("Close Find bar"), NULL);
4998 4953
4999 label = gtk_label_new(_("Find:")); 4954 label = gtk_label_new(_("Find:"));
8811 8766
8812 if (tab_clicked == -1) 8767 if (tab_clicked == -1)
8813 return FALSE; 8768 return FALSE;
8814 8769
8815 gtkconv = pidgin_conv_window_get_gtkconv_at_index(win, tab_clicked); 8770 gtkconv = pidgin_conv_window_get_gtkconv_at_index(win, tab_clicked);
8816 close_conv_cb(NULL, NULL, gtkconv); 8771 close_conv_cb(NULL, gtkconv);
8817 return TRUE; 8772 return TRUE;
8818 } 8773 }
8819 8774
8820 8775
8821 if (e->button != 1 || e->type != GDK_BUTTON_PRESS) 8776 if (e->button != 1 || e->type != GDK_BUTTON_PRESS)
9079 PidginConversation *gconv = iter->data; 9034 PidginConversation *gconv = iter->data;
9080 iter = iter->next; 9035 iter = iter->next;
9081 9036
9082 if (gconv != gtkconv) 9037 if (gconv != gtkconv)
9083 { 9038 {
9084 close_conv_cb(NULL, NULL, gconv); 9039 close_conv_cb(NULL, gconv);
9085 } 9040 }
9086 } 9041 }
9087 } 9042 }
9088 9043
9089 static void close_tab_cb(GtkWidget *w, GObject *menu) 9044 static void close_tab_cb(GtkWidget *w, GObject *menu)
9091 PidginConversation *gtkconv; 9046 PidginConversation *gtkconv;
9092 9047
9093 gtkconv = g_object_get_data(menu, "clicked_tab"); 9048 gtkconv = g_object_get_data(menu, "clicked_tab");
9094 9049
9095 if (gtkconv) 9050 if (gtkconv)
9096 close_conv_cb(NULL, NULL, gtkconv); 9051 close_conv_cb(NULL, gtkconv);
9097 } 9052 }
9098 9053
9099 static gboolean 9054 static gboolean
9100 right_click_menu_cb(GtkNotebook *notebook, GdkEventButton *event, PidginWindow *win) 9055 right_click_menu_cb(GtkNotebook *notebook, GdkEventButton *event, PidginWindow *win)
9101 { 9056 {
9555 gtk_widget_destroy(win->dialogs.search); 9510 gtk_widget_destroy(win->dialogs.search);
9556 9511
9557 if (win->gtkconvs) { 9512 if (win->gtkconvs) {
9558 while (win->gtkconvs) { 9513 while (win->gtkconvs) {
9559 gboolean last = (win->gtkconvs->next == NULL); 9514 gboolean last = (win->gtkconvs->next == NULL);
9560 close_conv_cb(NULL, NULL, win->gtkconvs->data); 9515 close_conv_cb(NULL, win->gtkconvs->data);
9561 if (last) 9516 if (last)
9562 break; 9517 break;
9563 } 9518 }
9564 return; 9519 return;
9565 } 9520 }
9629 PurpleConversation *conv = gtkconv->active_conv; 9584 PurpleConversation *conv = gtkconv->active_conv;
9630 PidginConversation *focus_gtkconv; 9585 PidginConversation *focus_gtkconv;
9631 GtkWidget *tab_cont = gtkconv->tab_cont; 9586 GtkWidget *tab_cont = gtkconv->tab_cont;
9632 PurpleConversationType conv_type; 9587 PurpleConversationType conv_type;
9633 const gchar *tmp_lab; 9588 const gchar *tmp_lab;
9589 GtkWidget *close_image;
9634 9590
9635 conv_type = purple_conversation_get_type(conv); 9591 conv_type = purple_conversation_get_type(conv);
9636 9592
9637 win->gtkconvs = g_list_append(win->gtkconvs, gtkconv); 9593 win->gtkconvs = g_list_append(win->gtkconvs, gtkconv);
9638 gtkconv->win = win; 9594 gtkconv->win = win;
9640 if (win->gtkconvs && win->gtkconvs->next && win->gtkconvs->next->next == NULL) 9596 if (win->gtkconvs && win->gtkconvs->next && win->gtkconvs->next->next == NULL)
9641 pidgin_conv_tab_pack(win, ((PidginConversation*)win->gtkconvs->data)); 9597 pidgin_conv_tab_pack(win, ((PidginConversation*)win->gtkconvs->data));
9642 9598
9643 9599
9644 /* Close button. */ 9600 /* Close button. */
9645 gtkconv->close = create_close_button(); 9601 close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
9602 gtkconv->close = pidgin_create_small_button(close_image);
9646 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, 9603 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close,
9647 _("Close conversation"), NULL); 9604 _("Close conversation"), NULL);
9648 9605
9649 g_signal_connect(G_OBJECT(gtkconv->close), "button-press-event", 9606 g_signal_connect(gtkconv->close, "clicked", G_CALLBACK (close_conv_cb), gtkconv);
9650 G_CALLBACK(close_conv_cb), gtkconv);
9651 9607
9652 /* Status icon. */ 9608 /* Status icon. */
9653 gtkconv->icon = gtk_image_new(); 9609 gtkconv->icon = gtk_image_new();
9654 gtkconv->menu_icon = gtk_image_new(); 9610 gtkconv->menu_icon = gtk_image_new();
9655 g_object_set(G_OBJECT(gtkconv->icon), 9611 g_object_set(G_OBJECT(gtkconv->icon),