| 776 GtkSelectionData *sd, guint inf, guint t, gpointer data) |
776 GtkSelectionData *sd, guint inf, guint t, gpointer data) |
| 777 { |
777 { |
| 778 InviteBuddyInfo *info = (InviteBuddyInfo *)data; |
778 InviteBuddyInfo *info = (InviteBuddyInfo *)data; |
| 779 const char *convprotocol; |
779 const char *convprotocol; |
| 780 gboolean success = TRUE; |
780 gboolean success = TRUE; |
| 781 |
781 GdkAtom target = gtk_selection_data_get_target(sd); |
| |
782 |
| 782 convprotocol = purple_account_get_protocol_id(purple_conversation_get_account(info->conv)); |
783 convprotocol = purple_account_get_protocol_id(purple_conversation_get_account(info->conv)); |
| 783 |
784 |
| 784 if (sd->target == gdk_atom_intern("PURPLE_BLIST_NODE", FALSE)) |
785 if (target == gdk_atom_intern("PURPLE_BLIST_NODE", FALSE)) |
| 785 { |
786 { |
| 786 PurpleBlistNode *node = NULL; |
787 PurpleBlistNode *node = NULL; |
| 787 PurpleBuddy *buddy; |
788 PurpleBuddy *buddy; |
| 788 |
789 const guchar *data = gtk_selection_data_get_data(sd); |
| 789 memcpy(&node, sd->data, sizeof(node)); |
790 |
| |
791 memcpy(&node, data, sizeof(node)); |
| 790 |
792 |
| 791 if (PURPLE_BLIST_NODE_IS_CONTACT(node)) |
793 if (PURPLE_BLIST_NODE_IS_CONTACT(node)) |
| 792 buddy = purple_contact_get_priority_buddy((PurpleContact *)node); |
794 buddy = purple_contact_get_priority_buddy((PurpleContact *)node); |
| 793 else if (PURPLE_BLIST_NODE_IS_BUDDY(node)) |
795 else if (PURPLE_BLIST_NODE_IS_BUDDY(node)) |
| 794 buddy = (PurpleBuddy *)node; |
796 buddy = (PurpleBuddy *)node; |
| 803 success = FALSE; |
805 success = FALSE; |
| 804 } |
806 } |
| 805 else |
807 else |
| 806 gtk_entry_set_text(GTK_ENTRY(info->entry), purple_buddy_get_name(buddy)); |
808 gtk_entry_set_text(GTK_ENTRY(info->entry), purple_buddy_get_name(buddy)); |
| 807 |
809 |
| 808 gtk_drag_finish(dc, success, (dc->action == GDK_ACTION_MOVE), t); |
810 gtk_drag_finish(dc, success, |
| 809 } |
811 gdk_drag_context_get_actions(dc) == GDK_ACTION_MOVE, t); |
| 810 else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) |
812 } |
| |
813 else if (target == gdk_atom_intern("application/x-im-contact", FALSE)) |
| 811 { |
814 { |
| 812 char *protocol = NULL; |
815 char *protocol = NULL; |
| 813 char *username = NULL; |
816 char *username = NULL; |
| 814 PurpleAccount *account; |
817 PurpleAccount *account; |
| 815 |
818 |
| 816 if (pidgin_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
819 if (pidgin_parse_x_im_contact((const char *) data, FALSE, &account, |
| 817 &protocol, &username, NULL)) |
820 &protocol, &username, NULL)) |
| 818 { |
821 { |
| 819 if (account == NULL) |
822 if (account == NULL) |
| 820 { |
823 { |
| 821 purple_notify_error(PIDGIN_CONVERSATION(info->conv), NULL, |
824 purple_notify_error(PIDGIN_CONVERSATION(info->conv), NULL, |
| 878 |
882 |
| 879 gtk_dialog_set_default_response(GTK_DIALOG(invite_dialog), |
883 gtk_dialog_set_default_response(GTK_DIALOG(invite_dialog), |
| 880 GTK_RESPONSE_OK); |
884 GTK_RESPONSE_OK); |
| 881 gtk_container_set_border_width(GTK_CONTAINER(invite_dialog), PIDGIN_HIG_BOX_SPACE); |
885 gtk_container_set_border_width(GTK_CONTAINER(invite_dialog), PIDGIN_HIG_BOX_SPACE); |
| 882 gtk_window_set_resizable(GTK_WINDOW(invite_dialog), FALSE); |
886 gtk_window_set_resizable(GTK_WINDOW(invite_dialog), FALSE); |
| |
887 /* TODO: set no separator using GTK+ 3.0 */ |
| |
888 /* |
| 883 gtk_dialog_set_has_separator(GTK_DIALOG(invite_dialog), FALSE); |
889 gtk_dialog_set_has_separator(GTK_DIALOG(invite_dialog), FALSE); |
| 884 |
890 */ |
| |
891 |
| 885 info->window = GTK_WIDGET(invite_dialog); |
892 info->window = GTK_WIDGET(invite_dialog); |
| 886 |
893 |
| 887 /* Setup the outside spacing. */ |
894 /* Setup the outside spacing. */ |
| 888 vbox = GTK_DIALOG(invite_dialog)->vbox; |
895 vbox = gtk_dialog_get_content_area(GTK_DIALOG(invite_dialog)); |
| 889 |
896 |
| 890 gtk_box_set_spacing(GTK_BOX(vbox), PIDGIN_HIG_BORDER); |
897 gtk_box_set_spacing(GTK_BOX(vbox), PIDGIN_HIG_BORDER); |
| 891 gtk_container_set_border_width(GTK_CONTAINER(vbox), PIDGIN_HIG_BOX_SPACE); |
898 gtk_container_set_border_width(GTK_CONTAINER(vbox), PIDGIN_HIG_BOX_SPACE); |
| 892 |
899 |
| 893 /* Setup the inner hbox and put the dialog's icon in it. */ |
900 /* Setup the inner hbox and put the dialog's icon in it. */ |
| 1076 return; |
1083 return; |
| 1077 |
1084 |
| 1078 gtkblist = pidgin_blist_get_default_gtk_blist(); |
1085 gtkblist = pidgin_blist_get_default_gtk_blist(); |
| 1079 |
1086 |
| 1080 cursor = gdk_cursor_new(GDK_WATCH); |
1087 cursor = gdk_cursor_new(GDK_WATCH); |
| 1081 gdk_window_set_cursor(gtkblist->window->window, cursor); |
1088 gdk_window_set_cursor(gtk_widget_get_window(gtkblist->window), cursor); |
| 1082 gdk_window_set_cursor(win->window->window, cursor); |
1089 gdk_window_set_cursor(gtk_widget_get_window(win->window), cursor); |
| 1083 gdk_cursor_unref(cursor); |
1090 gdk_cursor_unref(cursor); |
| 1084 #if GTK_CHECK_VERSION(2,4,0) && !GTK_CHECK_VERSION(2,6,0) //FIXME: What? |
1091 #if GTK_CHECK_VERSION(2,4,0) && !GTK_CHECK_VERSION(2,6,0) //FIXME: What? |
| 1085 gdk_display_flush(gdk_drawable_get_display(GDK_DRAWABLE(widget->window))); |
1092 gdk_display_flush(gdk_drawable_get_display(GDK_DRAWABLE(widget->window))); |
| 1086 #endif |
1093 #endif |
| 1087 |
1094 |
| 1094 PurpleBlistNode *node = cur->data; |
1101 PurpleBlistNode *node = cur->data; |
| 1095 if ((node != NULL) && ((node->prev != NULL) || (node->next != NULL))) |
1102 if ((node != NULL) && ((node->prev != NULL) || (node->next != NULL))) |
| 1096 { |
1103 { |
| 1097 pidgin_log_show_contact((PurpleContact *)node->parent); |
1104 pidgin_log_show_contact((PurpleContact *)node->parent); |
| 1098 g_slist_free(buddies); |
1105 g_slist_free(buddies); |
| 1099 gdk_window_set_cursor(gtkblist->window->window, NULL); |
1106 gdk_window_set_cursor(gtk_widget_get_window(gtkblist->window), NULL); |
| 1100 gdk_window_set_cursor(win->window->window, NULL); |
1107 gdk_window_set_cursor(gtk_widget_get_window(win->window), NULL); |
| 1101 return; |
1108 return; |
| 1102 } |
1109 } |
| 1103 } |
1110 } |
| 1104 g_slist_free(buddies); |
1111 g_slist_free(buddies); |
| 1105 |
1112 |
| 1106 pidgin_log_show(type, name, account); |
1113 pidgin_log_show(type, name, account); |
| 1107 |
1114 |
| 1108 gdk_window_set_cursor(gtkblist->window->window, NULL); |
1115 gdk_window_set_cursor(gtk_widget_get_window(gtkblist->window), NULL); |
| 1109 gdk_window_set_cursor(win->window->window, NULL); |
1116 gdk_window_set_cursor(gtk_widget_get_window(win->window), NULL); |
| 1110 } |
1117 } |
| 1111 |
1118 |
| 1112 static void |
1119 static void |
| 1113 menu_clear_cb(GtkAction *action, gpointer data) |
1120 menu_clear_cb(GtkAction *action, gpointer data) |
| 1114 { |
1121 { |
| 1917 pidgin_tooltip_destroy(); |
1924 pidgin_tooltip_destroy(); |
| 1918 |
1925 |
| 1919 /* If CTRL was held down... */ |
1926 /* If CTRL was held down... */ |
| 1920 if (event->state & GDK_CONTROL_MASK) { |
1927 if (event->state & GDK_CONTROL_MASK) { |
| 1921 switch (event->keyval) { |
1928 switch (event->keyval) { |
| 1922 case GDK_Page_Down: |
1929 case GDK_KEY_Page_Down: |
| 1923 case ']': |
1930 case ']': |
| 1924 if (!pidgin_conv_window_get_gtkconv_at_index(win, curconv + 1)) |
1931 if (!pidgin_conv_window_get_gtkconv_at_index(win, curconv + 1)) |
| 1925 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); |
1932 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); |
| 1926 else |
1933 else |
| 1927 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv + 1); |
1934 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv + 1); |
| 1928 return TRUE; |
1935 return TRUE; |
| 1929 break; |
1936 break; |
| 1930 |
1937 |
| 1931 case GDK_Page_Up: |
1938 case GDK_KEY_Page_Up: |
| 1932 case '[': |
1939 case '[': |
| 1933 if (!pidgin_conv_window_get_gtkconv_at_index(win, curconv - 1)) |
1940 if (!pidgin_conv_window_get_gtkconv_at_index(win, curconv - 1)) |
| 1934 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), -1); |
1941 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), -1); |
| 1935 else |
1942 else |
| 1936 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv - 1); |
1943 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv - 1); |
| 1937 return TRUE; |
1944 return TRUE; |
| 1938 break; |
1945 break; |
| 1939 |
1946 |
| 1940 case GDK_Tab: |
1947 case GDK_KEY_Tab: |
| 1941 case GDK_KP_Tab: |
1948 case GDK_KEY_KP_Tab: |
| 1942 case GDK_ISO_Left_Tab: |
1949 case GDK_KEY_ISO_Left_Tab: |
| 1943 if (event->state & GDK_SHIFT_MASK) { |
1950 if (event->state & GDK_SHIFT_MASK) { |
| 1944 move_to_next_unread_tab(gtkconv, FALSE); |
1951 move_to_next_unread_tab(gtkconv, FALSE); |
| 1945 } else { |
1952 } else { |
| 1946 move_to_next_unread_tab(gtkconv, TRUE); |
1953 move_to_next_unread_tab(gtkconv, TRUE); |
| 1947 } |
1954 } |
| 1948 |
1955 |
| 1949 return TRUE; |
1956 return TRUE; |
| 1950 break; |
1957 break; |
| 1951 |
1958 |
| 1952 case GDK_comma: |
1959 case GDK_KEY_comma: |
| 1953 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1960 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
| 1954 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), |
1961 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), |
| 1955 curconv - 1); |
1962 curconv - 1); |
| 1956 return TRUE; |
1963 return TRUE; |
| 1957 break; |
1964 break; |
| 1958 |
1965 |
| 1959 case GDK_period: |
1966 case GDK_KEY_period: |
| 1960 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1967 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
| 1961 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), |
1968 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), |
| 1962 (curconv + 1) % gtk_notebook_get_n_pages(GTK_NOTEBOOK(win->notebook))); |
1969 (curconv + 1) % gtk_notebook_get_n_pages(GTK_NOTEBOOK(win->notebook))); |
| 1963 return TRUE; |
1970 return TRUE; |
| 1964 break; |
1971 break; |
| 1965 case GDK_F6: |
1972 case GDK_KEY_F6: |
| 1966 if (gtkconv_cycle_focus(gtkconv, event->state & GDK_SHIFT_MASK ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD)) |
1973 if (gtkconv_cycle_focus(gtkconv, event->state & GDK_SHIFT_MASK ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD)) |
| 1967 return TRUE; |
1974 return TRUE; |
| 1968 break; |
1975 break; |
| 1969 } /* End of switch */ |
1976 } /* End of switch */ |
| 1970 } |
1977 } |
| 2118 } |
2125 } |
| 2119 |
2126 |
| 2120 /* If neither CTRL nor ALT were held down... */ |
2127 /* If neither CTRL nor ALT were held down... */ |
| 2121 else { |
2128 else { |
| 2122 switch (event->keyval) { |
2129 switch (event->keyval) { |
| 2123 case GDK_Tab: |
2130 case GDK_KEY_Tab: |
| 2124 case GDK_KP_Tab: |
2131 case GDK_KEY_KP_Tab: |
| 2125 case GDK_ISO_Left_Tab: |
2132 case GDK_KEY_ISO_Left_Tab: |
| 2126 if (gtkconv->entry != entry) |
2133 if (gtkconv->entry != entry) |
| 2127 break; |
2134 break; |
| 2128 return tab_complete(conv); |
2135 return tab_complete(conv); |
| 2129 break; |
2136 break; |
| 2130 |
2137 |
| 2131 case GDK_Page_Up: |
2138 case GDK_KEY_Page_Up: |
| 2132 gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml)); |
2139 gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml)); |
| 2133 return TRUE; |
2140 return TRUE; |
| 2134 break; |
2141 break; |
| 2135 |
2142 |
| 2136 case GDK_Page_Down: |
2143 case GDK_KEY_Page_Down: |
| 2137 gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml)); |
2144 gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml)); |
| 2138 return TRUE; |
2145 return TRUE; |
| 2139 break; |
2146 break; |
| 2140 |
2147 |
| 2141 } |
2148 } |
| 2175 { |
2182 { |
| 2176 PidginConversation *gtkconv = data; |
2183 PidginConversation *gtkconv = data; |
| 2177 |
2184 |
| 2178 /* If we have a valid key for the conversation display, then exit */ |
2185 /* If we have a valid key for the conversation display, then exit */ |
| 2179 if ((event->state & GDK_CONTROL_MASK) || |
2186 if ((event->state & GDK_CONTROL_MASK) || |
| 2180 (event->keyval == GDK_F6) || |
2187 (event->keyval == GDK_KEY_F6) || |
| 2181 (event->keyval == GDK_F10) || |
2188 (event->keyval == GDK_KEY_F10) || |
| 2182 (event->keyval == GDK_Shift_L) || |
2189 (event->keyval == GDK_KEY_Shift_L) || |
| 2183 (event->keyval == GDK_Shift_R) || |
2190 (event->keyval == GDK_KEY_Shift_R) || |
| 2184 (event->keyval == GDK_Control_L) || |
2191 (event->keyval == GDK_KEY_Control_L) || |
| 2185 (event->keyval == GDK_Control_R) || |
2192 (event->keyval == GDK_KEY_Control_R) || |
| 2186 (event->keyval == GDK_Escape) || |
2193 (event->keyval == GDK_KEY_Escape) || |
| 2187 (event->keyval == GDK_Up) || |
2194 (event->keyval == GDK_KEY_Up) || |
| 2188 (event->keyval == GDK_Down) || |
2195 (event->keyval == GDK_KEY_Down) || |
| 2189 (event->keyval == GDK_Left) || |
2196 (event->keyval == GDK_KEY_Left) || |
| 2190 (event->keyval == GDK_Right) || |
2197 (event->keyval == GDK_KEY_Right) || |
| 2191 (event->keyval == GDK_Page_Up) || |
2198 (event->keyval == GDK_KEY_Page_Up) || |
| 2192 (event->keyval == GDK_Page_Down) || |
2199 (event->keyval == GDK_KEY_Page_Down) || |
| 2193 (event->keyval == GDK_Home) || |
2200 (event->keyval == GDK_KEY_Home) || |
| 2194 (event->keyval == GDK_End) || |
2201 (event->keyval == GDK_KEY_End) || |
| 2195 (event->keyval == GDK_Tab) || |
2202 (event->keyval == GDK_KEY_Tab) || |
| 2196 (event->keyval == GDK_KP_Tab) || |
2203 (event->keyval == GDK_KEY_KP_Tab) || |
| 2197 (event->keyval == GDK_ISO_Left_Tab)) |
2204 (event->keyval == GDK_KEY_ISO_Left_Tab)) |
| 2198 { |
2205 { |
| 2199 if (event->type == GDK_KEY_PRESS) |
2206 if (event->type == GDK_KEY_PRESS) |
| 2200 return conv_keypress_common(gtkconv, event); |
2207 return conv_keypress_common(gtkconv, event); |
| 2201 return FALSE; |
2208 return FALSE; |
| 2202 } |
2209 } |
| 4656 GtkTextIter iter; |
4663 GtkTextIter iter; |
| 4657 int lines; |
4664 int lines; |
| 4658 GdkRectangle oneline; |
4665 GdkRectangle oneline; |
| 4659 int height, diff; |
4666 int height, diff; |
| 4660 int pad_top, pad_inside, pad_bottom; |
4667 int pad_top, pad_inside, pad_bottom; |
| 4661 int total_height = (gtkconv->imhtml->allocation.height + gtkconv->entry->allocation.height); |
4668 int total_height; |
| 4662 int max_height = total_height / 2; |
4669 int max_height; |
| 4663 int min_lines = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/minimum_entry_lines"); |
4670 int min_lines = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/minimum_entry_lines"); |
| 4664 int min_height; |
4671 int min_height; |
| 4665 gboolean interior_focus; |
4672 gboolean interior_focus; |
| 4666 int focus_width; |
4673 int focus_width; |
| 4667 |
4674 GtkAllocation imhtml_allocation; |
| |
4675 GtkAllocation entry_allocation; |
| |
4676 GtkAllocation lower_hbox_allocation; |
| |
4677 |
| |
4678 gtk_widget_get_allocation(gtkconv->imhtml, &imhtml_allocation); |
| |
4679 gtk_widget_get_allocation(gtkconv->entry, &entry_allocation); |
| |
4680 gtk_widget_get_allocation(gtkconv->lower_hbox, &lower_hbox_allocation); |
| |
4681 total_height = imhtml_allocation.height + entry_allocation.height; |
| |
4682 max_height = total_height / 2; |
| |
4683 |
| 4668 pad_top = gtk_text_view_get_pixels_above_lines(GTK_TEXT_VIEW(gtkconv->entry)); |
4684 pad_top = gtk_text_view_get_pixels_above_lines(GTK_TEXT_VIEW(gtkconv->entry)); |
| 4669 pad_bottom = gtk_text_view_get_pixels_below_lines(GTK_TEXT_VIEW(gtkconv->entry)); |
4685 pad_bottom = gtk_text_view_get_pixels_below_lines(GTK_TEXT_VIEW(gtkconv->entry)); |
| 4670 pad_inside = gtk_text_view_get_pixels_inside_wrap(GTK_TEXT_VIEW(gtkconv->entry)); |
4686 pad_inside = gtk_text_view_get_pixels_inside_wrap(GTK_TEXT_VIEW(gtkconv->entry)); |
| 4671 |
4687 |
| 4672 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
4688 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
| 4695 "focus-line-width", &focus_width, |
4711 "focus-line-width", &focus_width, |
| 4696 NULL); |
4712 NULL); |
| 4697 if (!interior_focus) |
4713 if (!interior_focus) |
| 4698 height += 2 * focus_width; |
4714 height += 2 * focus_width; |
| 4699 |
4715 |
| 4700 diff = height - gtkconv->entry->allocation.height; |
4716 diff = height - entry_allocation.height; |
| 4701 if (ABS(diff) < oneline.height / 2) |
4717 if (ABS(diff) < oneline.height / 2) |
| 4702 return FALSE; |
4718 return FALSE; |
| 4703 |
4719 |
| 4704 gtk_widget_set_size_request(gtkconv->lower_hbox, -1, |
4720 gtk_widget_set_size_request(gtkconv->lower_hbox, -1, |
| 4705 diff + gtkconv->lower_hbox->allocation.height); |
4721 diff + lower_hbox_allocation.height); |
| 4706 |
4722 |
| 4707 return FALSE; |
4723 return FALSE; |
| 4708 } |
4724 } |
| 4709 |
4725 |
| 4710 static void |
4726 static void |
| 4747 gtk_widget_set_size_request(gtkchat->topic_text, -1, BUDDYICON_SIZE_MIN); |
4763 gtk_widget_set_size_request(gtkchat->topic_text, -1, BUDDYICON_SIZE_MIN); |
| 4748 |
4764 |
| 4749 if(prpl_info->set_chat_topic == NULL) { |
4765 if(prpl_info->set_chat_topic == NULL) { |
| 4750 gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE); |
4766 gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE); |
| 4751 } else { |
4767 } else { |
| 4752 g_signal_connect(GTK_OBJECT(gtkchat->topic_text), "activate", |
4768 g_signal_connect(GTK_WIDGET(gtkchat->topic_text), "activate", |
| 4753 G_CALLBACK(topic_callback), gtkconv); |
4769 G_CALLBACK(topic_callback), gtkconv); |
| 4754 } |
4770 } |
| 4755 |
4771 |
| 4756 gtk_box_pack_start(GTK_BOX(hbox), gtkchat->topic_text, TRUE, TRUE, 0); |
4772 gtk_box_pack_start(GTK_BOX(hbox), gtkchat->topic_text, TRUE, TRUE, 0); |
| 4757 g_signal_connect(G_OBJECT(gtkchat->topic_text), "key_press_event", |
4773 g_signal_connect(G_OBJECT(gtkchat->topic_text), "key_press_event", |
| 4922 pidgin_conv_end_quickfind(PidginConversation *gtkconv) |
4938 pidgin_conv_end_quickfind(PidginConversation *gtkconv) |
| 4923 { |
4939 { |
| 4924 gtk_widget_modify_base(gtkconv->quickfind.entry, GTK_STATE_NORMAL, NULL); |
4940 gtk_widget_modify_base(gtkconv->quickfind.entry, GTK_STATE_NORMAL, NULL); |
| 4925 |
4941 |
| 4926 gtk_imhtml_search_clear(GTK_IMHTML(gtkconv->imhtml)); |
4942 gtk_imhtml_search_clear(GTK_IMHTML(gtkconv->imhtml)); |
| 4927 gtk_widget_hide_all(gtkconv->quickfind.container); |
4943 gtk_widget_hide(gtkconv->quickfind.container); |
| 4928 |
4944 |
| 4929 gtk_widget_grab_focus(gtkconv->entry); |
4945 gtk_widget_grab_focus(gtkconv->entry); |
| 4930 return TRUE; |
4946 return TRUE; |
| 4931 } |
4947 } |
| 4932 |
4948 |
| 4933 static gboolean |
4949 static gboolean |
| 4934 quickfind_process_input(GtkWidget *entry, GdkEventKey *event, PidginConversation *gtkconv) |
4950 quickfind_process_input(GtkWidget *entry, GdkEventKey *event, PidginConversation *gtkconv) |
| 4935 { |
4951 { |
| 4936 switch (event->keyval) { |
4952 switch (event->keyval) { |
| 4937 case GDK_Return: |
4953 case GDK_KEY_Return: |
| 4938 case GDK_KP_Enter: |
4954 case GDK_KEY_KP_Enter: |
| 4939 if (gtk_imhtml_search_find(GTK_IMHTML(gtkconv->imhtml), gtk_entry_get_text(GTK_ENTRY(entry)))) { |
4955 if (gtk_imhtml_search_find(GTK_IMHTML(gtkconv->imhtml), gtk_entry_get_text(GTK_ENTRY(entry)))) { |
| 4940 gtk_widget_modify_base(gtkconv->quickfind.entry, GTK_STATE_NORMAL, NULL); |
4956 gtk_widget_modify_base(gtkconv->quickfind.entry, GTK_STATE_NORMAL, NULL); |
| 4941 } else { |
4957 } else { |
| 4942 GdkColor col; |
4958 GdkColor col; |
| 4943 col.red = 0xffff; |
4959 col.red = 0xffff; |
| 4944 col.green = 0xafff; |
4960 col.green = 0xafff; |
| 4945 col.blue = 0xafff; |
4961 col.blue = 0xafff; |
| 4946 gtk_widget_modify_base(gtkconv->quickfind.entry, GTK_STATE_NORMAL, &col); |
4962 gtk_widget_modify_base(gtkconv->quickfind.entry, GTK_STATE_NORMAL, &col); |
| 4947 } |
4963 } |
| 4948 break; |
4964 break; |
| 4949 case GDK_Escape: |
4965 case GDK_KEY_Escape: |
| 4950 pidgin_conv_end_quickfind(gtkconv); |
4966 pidgin_conv_end_quickfind(gtkconv); |
| 4951 break; |
4967 break; |
| 4952 default: |
4968 default: |
| 4953 return FALSE; |
4969 return FALSE; |
| 4954 } |
4970 } |
| 5187 PidginWindow *win = gtkconv->win; |
5203 PidginWindow *win = gtkconv->win; |
| 5188 PurpleConversation *c; |
5204 PurpleConversation *c; |
| 5189 PurpleAccount *convaccount = purple_conversation_get_account(conv); |
5205 PurpleAccount *convaccount = purple_conversation_get_account(conv); |
| 5190 PurpleConnection *gc = purple_account_get_connection(convaccount); |
5206 PurpleConnection *gc = purple_account_get_connection(convaccount); |
| 5191 PurplePluginProtocolInfo *prpl_info = gc ? PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl) : NULL; |
5207 PurplePluginProtocolInfo *prpl_info = gc ? PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl) : NULL; |
| 5192 |
5208 GdkAtom target = gtk_selection_data_get_target(sd); |
| 5193 if (sd->target == gdk_atom_intern("PURPLE_BLIST_NODE", FALSE)) |
5209 const guchar *data = gtk_selection_data_get_data(sd); |
| |
5210 |
| |
5211 if (target == gdk_atom_intern("PURPLE_BLIST_NODE", FALSE)) |
| 5194 { |
5212 { |
| 5195 PurpleBlistNode *n = NULL; |
5213 PurpleBlistNode *n = NULL; |
| 5196 PurpleBuddy *b; |
5214 PurpleBuddy *b; |
| 5197 PidginConversation *gtkconv = NULL; |
5215 PidginConversation *gtkconv = NULL; |
| 5198 PurpleAccount *buddyaccount; |
5216 PurpleAccount *buddyaccount; |
| 5199 const char *buddyname; |
5217 const char *buddyname; |
| 5200 |
5218 |
| 5201 n = *(PurpleBlistNode **)sd->data; |
5219 n = *(PurpleBlistNode **) data; |
| 5202 |
5220 |
| 5203 if (PURPLE_BLIST_NODE_IS_CONTACT(n)) |
5221 if (PURPLE_BLIST_NODE_IS_CONTACT(n)) |
| 5204 b = purple_contact_get_priority_buddy((PurpleContact*)n); |
5222 b = purple_contact_get_priority_buddy((PurpleContact*)n); |
| 5205 else if (PURPLE_BLIST_NODE_IS_BUDDY(n)) |
5223 else if (PURPLE_BLIST_NODE_IS_BUDDY(n)) |
| 5206 b = (PurpleBuddy*)n; |
5224 b = (PurpleBuddy*)n; |
| 5244 |
5262 |
| 5245 /* Make this conversation the active conversation */ |
5263 /* Make this conversation the active conversation */ |
| 5246 pidgin_conv_window_switch_gtkconv(win, gtkconv); |
5264 pidgin_conv_window_switch_gtkconv(win, gtkconv); |
| 5247 } |
5265 } |
| 5248 |
5266 |
| 5249 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
5267 gtk_drag_finish(dc, TRUE, |
| 5250 } |
5268 gdk_drag_context_get_actions(dc) == GDK_ACTION_MOVE, t); |
| 5251 else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) |
5269 } |
| |
5270 else if (target == gdk_atom_intern("application/x-im-contact", FALSE)) |
| 5252 { |
5271 { |
| 5253 char *protocol = NULL; |
5272 char *protocol = NULL; |
| 5254 char *username = NULL; |
5273 char *username = NULL; |
| 5255 PurpleAccount *account; |
5274 PurpleAccount *account; |
| 5256 PidginConversation *gtkconv; |
5275 PidginConversation *gtkconv; |
| 5257 |
5276 |
| 5258 if (pidgin_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
5277 if (pidgin_parse_x_im_contact((const char *) data, FALSE, &account, |
| 5259 &protocol, &username, NULL)) |
5278 &protocol, &username, NULL)) |
| 5260 { |
5279 { |
| 5261 if (account == NULL) |
5280 if (account == NULL) |
| 5262 { |
5281 { |
| 5263 purple_notify_error(win, NULL, |
5282 purple_notify_error(win, NULL, |
| 5284 } |
5303 } |
| 5285 |
5304 |
| 5286 g_free(username); |
5305 g_free(username); |
| 5287 g_free(protocol); |
5306 g_free(protocol); |
| 5288 |
5307 |
| 5289 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
5308 gtk_drag_finish(dc, TRUE, |
| 5290 } |
5309 gdk_drag_context_get_actions(dc) == GDK_ACTION_MOVE, t); |
| 5291 else if (sd->target == gdk_atom_intern("text/uri-list", FALSE)) { |
5310 } |
| |
5311 else if (target == gdk_atom_intern("text/uri-list", FALSE)) { |
| 5292 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) |
5312 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) |
| 5293 pidgin_dnd_file_manage(sd, convaccount, purple_conversation_get_name(conv)); |
5313 pidgin_dnd_file_manage(sd, convaccount, purple_conversation_get_name(conv)); |
| 5294 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
5314 gtk_drag_finish(dc, TRUE, |
| |
5315 gdk_drag_context_get_actions(dc) == GDK_ACTION_MOVE, t); |
| 5295 } |
5316 } |
| 5296 else |
5317 else |
| 5297 gtk_drag_finish(dc, FALSE, FALSE, t); |
5318 gtk_drag_finish(dc, FALSE, FALSE, t); |
| 5298 } |
5319 } |
| 5299 |
5320 |
| 5695 if (event->type == GDK_BUTTON_PRESS |
5716 if (event->type == GDK_BUTTON_PRESS |
| 5696 || event->type == GDK_2BUTTON_PRESS) { |
5717 || event->type == GDK_2BUTTON_PRESS) { |
| 5697 GdkEventButton *btn_event = (GdkEventButton*) event; |
5718 GdkEventButton *btn_event = (GdkEventButton*) event; |
| 5698 PurpleConversation *conv = data; |
5719 PurpleConversation *conv = data; |
| 5699 char *buddyname; |
5720 char *buddyname; |
| 5700 |
5721 gchar *name; |
| |
5722 |
| |
5723 g_object_get(G_OBJECT(tag), "name", &name, NULL); |
| |
5724 |
| 5701 /* strlen("BUDDY " or "HILIT ") == 6 */ |
5725 /* strlen("BUDDY " or "HILIT ") == 6 */ |
| 5702 g_return_val_if_fail((tag->name != NULL) |
5726 g_return_val_if_fail((name != NULL) && (strlen(name) > 6), FALSE); |
| 5703 && (strlen(tag->name) > 6), FALSE); |
5727 |
| 5704 |
5728 buddyname = name + 6; |
| 5705 buddyname = (tag->name) + 6; |
5729 |
| 5706 |
5730 |
| 5707 if (btn_event->button == 1 && |
5731 if (btn_event->button == 1 && |
| 5708 event->type == GDK_2BUTTON_PRESS) { |
5732 event->type == GDK_2BUTTON_PRESS) { |
| 5709 chat_do_im(PIDGIN_CONVERSATION(conv), buddyname); |
5733 chat_do_im(PIDGIN_CONVERSATION(conv), buddyname); |
| |
5734 g_free(name); |
| |
5735 |
| 5710 return TRUE; |
5736 return TRUE; |
| 5711 } else if (btn_event->button == 2 |
5737 } else if (btn_event->button == 2 |
| 5712 && event->type == GDK_2BUTTON_PRESS) { |
5738 && event->type == GDK_2BUTTON_PRESS) { |
| 5713 chat_do_info(PIDGIN_CONVERSATION(conv), buddyname); |
5739 chat_do_info(PIDGIN_CONVERSATION(conv), buddyname); |
| 5714 |
5740 |
| |
5741 g_free(name); |
| |
5742 |
| 5715 return TRUE; |
5743 return TRUE; |
| 5716 } else if (btn_event->button == 3 |
5744 } else if (btn_event->button == 3 |
| 5717 && event->type == GDK_BUTTON_PRESS) { |
5745 && event->type == GDK_BUTTON_PRESS) { |
| 5718 GtkTextIter start, end; |
5746 GtkTextIter start, end; |
| 5719 |
5747 |
| 6861 gtk_widget_queue_draw(gtkconv->infopane); |
6893 gtk_widget_queue_draw(gtkconv->infopane); |
| 6862 |
6894 |
| 6863 if (title != markup) |
6895 if (title != markup) |
| 6864 g_free(markup); |
6896 g_free(markup); |
| 6865 |
6897 |
| 6866 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) |
6898 if (!gtk_widget_get_realized(gtkconv->tab_label)) |
| 6867 gtk_widget_realize(gtkconv->tab_label); |
6899 gtk_widget_realize(gtkconv->tab_label); |
| 6868 |
6900 |
| 6869 accessibility_obj = gtk_widget_get_accessible(gtkconv->tab_cont); |
6901 accessibility_obj = gtk_widget_get_accessible(gtkconv->tab_cont); |
| 6870 if (im != NULL && |
6902 if (im != NULL && |
| 6871 purple_conv_im_get_typing_state(im) == PURPLE_TYPING) { |
6903 purple_conv_im_get_typing_state(im) == PURPLE_TYPING) { |
| 7236 static gboolean |
7268 static gboolean |
| 7237 pidgin_conv_xy_to_right_infopane(PidginWindow *win, int x, int y) |
7269 pidgin_conv_xy_to_right_infopane(PidginWindow *win, int x, int y) |
| 7238 { |
7270 { |
| 7239 gint pane_x, pane_y, x_rel; |
7271 gint pane_x, pane_y, x_rel; |
| 7240 PidginConversation *gtkconv; |
7272 PidginConversation *gtkconv; |
| 7241 |
7273 GtkAllocation allocation; |
| 7242 gdk_window_get_origin(win->notebook->window, &pane_x, &pane_y); |
7274 |
| |
7275 gtk_widget_get_allocation(gtkconv->infopane, &allocation); |
| |
7276 gdk_window_get_origin(gtk_widget_get_window(win->notebook), |
| |
7277 &pane_x, &pane_y); |
| 7243 x_rel = x - pane_x; |
7278 x_rel = x - pane_x; |
| 7244 gtkconv = pidgin_conv_window_get_active_gtkconv(win); |
7279 gtkconv = pidgin_conv_window_get_active_gtkconv(win); |
| 7245 return (x_rel > gtkconv->infopane->allocation.x + gtkconv->infopane->allocation.width / 2); |
7280 return (x_rel > allocation.x + allocation.width / 2); |
| 7246 } |
7281 } |
| 7247 |
7282 |
| 7248 int |
7283 int |
| 7249 pidgin_conv_get_tab_at_xy(PidginWindow *win, int x, int y, gboolean *to_right) |
7284 pidgin_conv_get_tab_at_xy(PidginWindow *win, int x, int y, gboolean *to_right) |
| 7250 { |
7285 { |
| 7258 if (to_right) |
7293 if (to_right) |
| 7259 *to_right = FALSE; |
7294 *to_right = FALSE; |
| 7260 |
7295 |
| 7261 notebook = GTK_NOTEBOOK(win->notebook); |
7296 notebook = GTK_NOTEBOOK(win->notebook); |
| 7262 |
7297 |
| 7263 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); |
7298 gdk_window_get_origin(gtk_widget_get_window(win->notebook), &nb_x, &nb_y); |
| 7264 x_rel = x - nb_x; |
7299 x_rel = x - nb_x; |
| 7265 y_rel = y - nb_y; |
7300 y_rel = y - nb_y; |
| 7266 |
7301 |
| 7267 horiz = (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || |
7302 horiz = (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || |
| 7268 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM); |
7303 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM); |
| 7269 |
7304 |
| 7270 count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); |
7305 count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); |
| 7271 |
7306 |
| 7272 for (i = 0; i < count; i++) { |
7307 for (i = 0; i < count; i++) { |
| 7273 |
7308 GtkAllocation allocation; |
| |
7309 |
| |
7310 gtk_widget_get_allocation(tab, &allocation); |
| 7274 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i); |
7311 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i); |
| 7275 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), page); |
7312 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), page); |
| 7276 |
7313 |
| 7277 /* Make sure the tab is not hidden beyond an arrow */ |
7314 /* Make sure the tab is not hidden beyond an arrow */ |
| 7278 if (!GTK_WIDGET_DRAWABLE(tab) && gtk_notebook_get_show_tabs(notebook)) |
7315 if (!gtk_widget_is_drawable(tab) && gtk_notebook_get_show_tabs(notebook)) |
| 7279 continue; |
7316 continue; |
| 7280 |
7317 |
| 7281 if (horiz) { |
7318 if (horiz) { |
| 7282 if (x_rel >= tab->allocation.x - PIDGIN_HIG_BOX_SPACE && |
7319 if (x_rel >= allocation.x - PIDGIN_HIG_BOX_SPACE && |
| 7283 x_rel <= tab->allocation.x + tab->allocation.width + PIDGIN_HIG_BOX_SPACE) { |
7320 x_rel <= allocation.x + allocation.width + PIDGIN_HIG_BOX_SPACE) { |
| 7284 page_num = i; |
7321 page_num = i; |
| 7285 |
7322 |
| 7286 if (to_right && x_rel >= tab->allocation.x + tab->allocation.width/2) |
7323 if (to_right && x_rel >= allocation.x + allocation.width/2) |
| 7287 *to_right = TRUE; |
7324 *to_right = TRUE; |
| 7288 |
7325 |
| 7289 break; |
7326 break; |
| 7290 } |
7327 } |
| 7291 } else { |
7328 } else { |
| 7292 if (y_rel >= tab->allocation.y - PIDGIN_HIG_BOX_SPACE && |
7329 if (y_rel >= allocation.y - PIDGIN_HIG_BOX_SPACE && |
| 7293 y_rel <= tab->allocation.y + tab->allocation.height + PIDGIN_HIG_BOX_SPACE) { |
7330 y_rel <= allocation.y + allocation.height + PIDGIN_HIG_BOX_SPACE) { |
| 7294 page_num = i; |
7331 page_num = i; |
| 7295 |
7332 |
| 7296 if (to_right && y_rel >= tab->allocation.y + tab->allocation.height/2) |
7333 if (to_right && y_rel >= allocation.y + allocation.height/2) |
| 7297 *to_right = TRUE; |
7334 *to_right = TRUE; |
| 7298 |
7335 |
| 7299 break; |
7336 break; |
| 7300 } |
7337 } |
| 7301 } |
7338 } |
| 8381 GTK_RESPONSE_OK); |
8418 GTK_RESPONSE_OK); |
| 8382 |
8419 |
| 8383 gtk_container_set_border_width(GTK_CONTAINER(warn_close_dialog), |
8420 gtk_container_set_border_width(GTK_CONTAINER(warn_close_dialog), |
| 8384 6); |
8421 6); |
| 8385 gtk_window_set_resizable(GTK_WINDOW(warn_close_dialog), FALSE); |
8422 gtk_window_set_resizable(GTK_WINDOW(warn_close_dialog), FALSE); |
| 8386 gtk_dialog_set_has_separator(GTK_DIALOG(warn_close_dialog), |
8423 |
| |
8424 /* TODO: figure out how to set no separator in GTK+ 3.0 */ |
| |
8425 /* |
| |
8426 gtk_dialog_set_has_separator(GTK_DIALOG(warn_close_dialog), |
| 8387 FALSE); |
8427 FALSE); |
| 8388 |
8428 */ |
| |
8429 |
| 8389 /* Setup the outside spacing. */ |
8430 /* Setup the outside spacing. */ |
| 8390 vbox = GTK_DIALOG(warn_close_dialog)->vbox; |
8431 vbox = gtk_dialog_get_content_area(GTK_DIALOG(warn_close_dialog)); |
| 8391 |
8432 |
| 8392 gtk_box_set_spacing(GTK_BOX(vbox), 12); |
8433 gtk_box_set_spacing(GTK_BOX(vbox), 12); |
| 8393 gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); |
8434 gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); |
| 8394 |
8435 |
| 8395 img = gtk_image_new_from_stock(PIDGIN_STOCK_DIALOG_WARNING, |
8436 img = gtk_image_new_from_stock(PIDGIN_STOCK_DIALOG_WARNING, |
| 8539 #ifndef _WIN32 |
8580 #ifndef _WIN32 |
| 8540 /* Currently for win32 GTK+ (as of 2.2.1), gdk_pointer_is_grabbed will |
8581 /* Currently for win32 GTK+ (as of 2.2.1), gdk_pointer_is_grabbed will |
| 8541 always be true after a button press. */ |
8582 always be true after a button press. */ |
| 8542 if (!gdk_pointer_is_grabbed()) |
8583 if (!gdk_pointer_is_grabbed()) |
| 8543 #endif |
8584 #endif |
| 8544 gdk_pointer_grab(gtkwin->notebook->window, FALSE, |
8585 gdk_pointer_grab(gtk_widget_get_window(gtkwin->notebook), FALSE, |
| 8545 GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, |
8586 GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, |
| 8546 NULL, cursor, GDK_CURRENT_TIME); |
8587 NULL, cursor, GDK_CURRENT_TIME); |
| 8547 } |
8588 } |
| 8548 |
8589 |
| 8549 static gboolean |
8590 static gboolean |
| 8659 if (e->type != GDK_BUTTON_PRESS) |
8700 if (e->type != GDK_BUTTON_PRESS) |
| 8660 return FALSE; |
8701 return FALSE; |
| 8661 |
8702 |
| 8662 if (e->button == 1) { |
8703 if (e->button == 1) { |
| 8663 int nb_x, nb_y; |
8704 int nb_x, nb_y; |
| 8664 |
8705 GtkAllocation allocation; |
| |
8706 |
| |
8707 gtk_widget_get_allocation(gtkconv->infopane_hbox, &allocation); |
| |
8708 |
| 8665 if (gtkconv->win->in_drag) |
8709 if (gtkconv->win->in_drag) |
| 8666 return TRUE; |
8710 return TRUE; |
| 8667 |
8711 |
| 8668 gtkconv->win->in_predrag = TRUE; |
8712 gtkconv->win->in_predrag = TRUE; |
| 8669 gtkconv->win->drag_tab = gtk_notebook_page_num(GTK_NOTEBOOK(gtkconv->win->notebook), gtkconv->tab_cont); |
8713 gtkconv->win->drag_tab = gtk_notebook_page_num(GTK_NOTEBOOK(gtkconv->win->notebook), gtkconv->tab_cont); |
| 8670 |
8714 |
| 8671 gdk_window_get_origin(gtkconv->infopane_hbox->window, &nb_x, &nb_y); |
8715 gdk_window_get_origin(gtk_widget_get_window(gtkconv->infopane_hbox), &nb_x, &nb_y); |
| 8672 |
8716 |
| 8673 gtkconv->win->drag_min_x = gtkconv->infopane_hbox->allocation.x + nb_x; |
8717 gtkconv->win->drag_min_x = allocation.x + nb_x; |
| 8674 gtkconv->win->drag_min_y = gtkconv->infopane_hbox->allocation.y + nb_y; |
8718 gtkconv->win->drag_min_y = allocation.y + nb_y; |
| 8675 gtkconv->win->drag_max_x = gtkconv->infopane_hbox->allocation.width + gtkconv->win->drag_min_x; |
8719 gtkconv->win->drag_max_x = allocation.width + gtkconv->win->drag_min_x; |
| 8676 gtkconv->win->drag_max_y = gtkconv->infopane_hbox->allocation.height + gtkconv->win->drag_min_y; |
8720 gtkconv->win->drag_max_y = allocation.height + gtkconv->win->drag_min_y; |
| 8677 |
8721 |
| 8678 gtkconv->win->drag_motion_signal = g_signal_connect(G_OBJECT(gtkconv->win->notebook), "motion_notify_event", |
8722 gtkconv->win->drag_motion_signal = g_signal_connect(G_OBJECT(gtkconv->win->notebook), "motion_notify_event", |
| 8679 G_CALLBACK(notebook_motion_cb), gtkconv->win); |
8723 G_CALLBACK(notebook_motion_cb), gtkconv->win); |
| 8680 gtkconv->win->drag_leave_signal = g_signal_connect(G_OBJECT(gtkconv->win->notebook), "leave_notify_event", |
8724 gtkconv->win->drag_leave_signal = g_signal_connect(G_OBJECT(gtkconv->win->notebook), "leave_notify_event", |
| 8681 G_CALLBACK(notebook_leave_cb), gtkconv->win); |
8725 G_CALLBACK(notebook_leave_cb), gtkconv->win); |
| 8751 |
8796 |
| 8752 /* |
8797 /* |
| 8753 * Get the relative position of the press event, with regards to |
8798 * Get the relative position of the press event, with regards to |
| 8754 * the position of the notebook. |
8799 * the position of the notebook. |
| 8755 */ |
8800 */ |
| 8756 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); |
8801 gdk_window_get_origin(gtk_widget_get_window(win->notebook), &nb_x, &nb_y); |
| 8757 |
8802 |
| 8758 /* Reset the min/max x/y */ |
8803 /* Reset the min/max x/y */ |
| 8759 win->drag_min_x = 0; |
8804 win->drag_min_x = 0; |
| 8760 win->drag_min_y = 0; |
8805 win->drag_min_y = 0; |
| 8761 win->drag_max_x = 0; |
8806 win->drag_max_x = 0; |
| 8763 |
8808 |
| 8764 /* Find out which tab was dragged. */ |
8809 /* Find out which tab was dragged. */ |
| 8765 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), tab_clicked); |
8810 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), tab_clicked); |
| 8766 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(win->notebook), page); |
8811 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(win->notebook), page); |
| 8767 |
8812 |
| 8768 win->drag_min_x = tab->allocation.x + nb_x; |
8813 gtk_widget_get_allocation(tab, &allocation); |
| 8769 win->drag_min_y = tab->allocation.y + nb_y; |
8814 |
| 8770 win->drag_max_x = tab->allocation.width + win->drag_min_x; |
8815 win->drag_min_x = allocation.x + nb_x; |
| 8771 win->drag_max_y = tab->allocation.height + win->drag_min_y; |
8816 win->drag_min_y = allocation.y + nb_y; |
| |
8817 win->drag_max_x = allocation.width + win->drag_min_x; |
| |
8818 win->drag_max_y = allocation.height + win->drag_min_y; |
| 8772 |
8819 |
| 8773 /* Make sure the click occurred in the tab. */ |
8820 /* Make sure the click occurred in the tab. */ |
| 8774 if (e->x_root < win->drag_min_x || |
8821 if (e->x_root < win->drag_min_x || |
| 8775 e->x_root >= win->drag_max_x || |
8822 e->x_root >= win->drag_max_x || |
| 8776 e->y_root < win->drag_min_y || |
8823 e->y_root < win->drag_min_y || |
| 9003 |
9050 |
| 9004 if (gtkconv) |
9051 if (gtkconv) |
| 9005 close_conv_cb(NULL, gtkconv); |
9052 close_conv_cb(NULL, gtkconv); |
| 9006 } |
9053 } |
| 9007 |
9054 |
| |
9055 /* TODO: I don't know if this doable in GTK+ 3.0 */ |
| |
9056 #if 0 |
| 9008 static gboolean |
9057 static gboolean |
| 9009 right_click_menu_cb(GtkNotebook *notebook, GdkEventButton *event, PidginWindow *win) |
9058 right_click_menu_cb(GtkNotebook *notebook, GdkEventButton *event, PidginWindow *win) |
| 9010 { |
9059 { |
| 9011 GtkWidget *item, *menu; |
9060 GtkWidget *item; |
| 9012 PidginConversation *gtkconv; |
9061 PidginConversation *gtkconv; |
| 9013 |
9062 GtkWidget *menu = gtk_notebook_get_menu |
| |
9063 |
| 9014 if (event->type != GDK_BUTTON_PRESS || event->button != 3) |
9064 if (event->type != GDK_BUTTON_PRESS || event->button != 3) |
| 9015 return FALSE; |
9065 return FALSE; |
| 9016 |
9066 |
| 9017 gtkconv = pidgin_conv_window_get_gtkconv_at_index(win, |
9067 gtkconv = pidgin_conv_window_get_gtkconv_at_index(win, |
| 9018 pidgin_conv_get_tab_at_xy(win, event->x_root, event->y_root, NULL)); |
9068 pidgin_conv_get_tab_at_xy(win, event->x_root, event->y_root, NULL)); |
| 9054 g_signal_connect(G_OBJECT(item), "activate", |
9104 g_signal_connect(G_OBJECT(item), "activate", |
| 9055 G_CALLBACK(close_tab_cb), menu); |
9105 G_CALLBACK(close_tab_cb), menu); |
| 9056 |
9106 |
| 9057 return FALSE; |
9107 return FALSE; |
| 9058 } |
9108 } |
| |
9109 #endif |
| 9059 |
9110 |
| 9060 static void |
9111 static void |
| 9061 remove_edit_entry(PidginConversation *gtkconv, GtkWidget *entry) |
9112 remove_edit_entry(PidginConversation *gtkconv, GtkWidget *entry) |
| 9062 { |
9113 { |
| 9063 g_signal_handlers_disconnect_matched(G_OBJECT(entry), G_SIGNAL_MATCH_DATA, |
9114 g_signal_handlers_disconnect_matched(G_OBJECT(entry), G_SIGNAL_MATCH_DATA, |
| 9120 { |
9171 { |
| 9121 GtkWidget *entry = NULL; |
9172 GtkWidget *entry = NULL; |
| 9122 PurpleConversation *conv = gtkconv->active_conv; |
9173 PurpleConversation *conv = gtkconv->active_conv; |
| 9123 const char *text = NULL; |
9174 const char *text = NULL; |
| 9124 |
9175 |
| 9125 if (!GTK_WIDGET_VISIBLE(gtkconv->infopane)) { |
9176 if (!gtk_widget_get_visible(gtkconv->infopane)) { |
| 9126 /* There's already an entry for alias. Let's not create another one. */ |
9177 /* There's already an entry for alias. Let's not create another one. */ |
| 9127 return FALSE; |
9178 return FALSE; |
| 9128 } |
9179 } |
| 9129 |
9180 |
| 9130 if (!purple_account_is_connected(gtkconv->active_conv->account)) { |
9181 if (!purple_account_is_connected(gtkconv->active_conv->account)) { |
| 9282 } |
9333 } |
| 9283 |
9334 |
| 9284 static gboolean gtk_conv_configure_cb(GtkWidget *w, GdkEventConfigure *event, gpointer data) { |
9335 static gboolean gtk_conv_configure_cb(GtkWidget *w, GdkEventConfigure *event, gpointer data) { |
| 9285 int x, y; |
9336 int x, y; |
| 9286 |
9337 |
| 9287 if (GTK_WIDGET_VISIBLE(w)) |
9338 if (gtk_widget_get_visible(w)) |
| 9288 gtk_window_get_position(GTK_WINDOW(w), &x, &y); |
9339 gtk_window_get_position(GTK_WINDOW(w), &x, &y); |
| 9289 else |
9340 else |
| 9290 return FALSE; /* carry on normally */ |
9341 return FALSE; /* carry on normally */ |
| 9291 |
9342 |
| 9292 /* Workaround for GTK+ bug # 169811 - "configure_event" is fired |
9343 /* Workaround for GTK+ bug # 169811 - "configure_event" is fired |
| 9293 * when the window is being maximized */ |
9344 * when the window is being maximized */ |
| 9294 if (gdk_window_get_state(w->window) & GDK_WINDOW_STATE_MAXIMIZED) |
9345 if (gdk_window_get_state(gtk_widget_get_window(w)) & GDK_WINDOW_STATE_MAXIMIZED) |
| 9295 return FALSE; |
9346 return FALSE; |
| 9296 |
9347 |
| 9297 /* don't save off-screen positioning */ |
9348 /* don't save off-screen positioning */ |
| 9298 if (x + event->width < 0 || |
9349 if (x + event->width < 0 || |
| 9299 y + event->height < 0 || |
9350 y + event->height < 0 || |
| 9317 int conv_width, int conv_height) |
9368 int conv_width, int conv_height) |
| 9318 { |
9369 { |
| 9319 /* if the window exists, is hidden, we're saving positions, and the |
9370 /* if the window exists, is hidden, we're saving positions, and the |
| 9320 * position is sane... */ |
9371 * position is sane... */ |
| 9321 if (win && win->window && |
9372 if (win && win->window && |
| 9322 !GTK_WIDGET_VISIBLE(win->window) && conv_width != 0) { |
9373 !gtk_widget_get_visible(win->window) && conv_width != 0) { |
| 9323 |
9374 |
| 9324 #ifdef _WIN32 /* only override window manager placement on Windows */ |
9375 #ifdef _WIN32 /* only override window manager placement on Windows */ |
| 9325 /* ...check position is on screen... */ |
9376 /* ...check position is on screen... */ |
| 9326 if (conv_x >= gdk_screen_width()) |
9377 if (conv_x >= gdk_screen_width()) |
| 9327 conv_x = gdk_screen_width() - 100; |
9378 conv_x = gdk_screen_width() - 100; |
| 9402 gtk_notebook_set_scrollable(GTK_NOTEBOOK(win->notebook), TRUE); |
9453 gtk_notebook_set_scrollable(GTK_NOTEBOOK(win->notebook), TRUE); |
| 9403 gtk_notebook_popup_enable(GTK_NOTEBOOK(win->notebook)); |
9454 gtk_notebook_popup_enable(GTK_NOTEBOOK(win->notebook)); |
| 9404 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), FALSE); |
9455 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), FALSE); |
| 9405 gtk_notebook_set_show_border(GTK_NOTEBOOK(win->notebook), TRUE); |
9456 gtk_notebook_set_show_border(GTK_NOTEBOOK(win->notebook), TRUE); |
| 9406 |
9457 |
| |
9458 /* TODO: figure out how to add custom stuff to the right-click menu in |
| |
9459 GtkNotebook in GTK+ 3.0 */ |
| |
9460 /* |
| 9407 g_signal_connect(G_OBJECT(win->notebook), "button-press-event", |
9461 g_signal_connect(G_OBJECT(win->notebook), "button-press-event", |
| 9408 G_CALLBACK(right_click_menu_cb), win); |
9462 G_CALLBACK(right_click_menu_cb), win); |
| 9409 |
9463 */ |
| |
9464 |
| 9410 gtk_widget_show(win->notebook); |
9465 gtk_widget_show(win->notebook); |
| 9411 |
9466 |
| 9412 g_signal_connect(G_OBJECT(win->notebook), "switch_page", |
9467 g_signal_connect(G_OBJECT(win->notebook), "switch_page", |
| 9413 G_CALLBACK(before_switch_conv_cb), win); |
9468 G_CALLBACK(before_switch_conv_cb), win); |
| 9414 g_signal_connect_after(G_OBJECT(win->notebook), "switch_page", |
9469 g_signal_connect_after(G_OBJECT(win->notebook), "switch_page", |
| 9670 gtk_event_box_set_visible_window(GTK_EVENT_BOX(ebox), FALSE); |
9725 gtk_event_box_set_visible_window(GTK_EVENT_BOX(ebox), FALSE); |
| 9671 gtk_container_add(GTK_CONTAINER(ebox), gtkconv->tabby); |
9726 gtk_container_add(GTK_CONTAINER(ebox), gtkconv->tabby); |
| 9672 g_signal_connect(G_OBJECT(ebox), "enter-notify-event", |
9727 g_signal_connect(G_OBJECT(ebox), "enter-notify-event", |
| 9673 G_CALLBACK(gtkconv_tab_set_tip), gtkconv); |
9728 G_CALLBACK(gtkconv_tab_set_tip), gtkconv); |
| 9674 |
9729 |
| 9675 if (gtkconv->tab_label->parent == NULL) { |
9730 if (gtk_widget_get_parent(gtkconv->tab_label) == NULL) { |
| 9676 /* Pack if it's a new widget */ |
9731 /* Pack if it's a new widget */ |
| 9677 gtk_box_pack_start(GTK_BOX(gtkconv->tabby), first, FALSE, FALSE, 0); |
9732 gtk_box_pack_start(GTK_BOX(gtkconv->tabby), first, FALSE, FALSE, 0); |
| 9678 gtk_box_pack_start(GTK_BOX(gtkconv->tabby), gtkconv->tab_label, TRUE, TRUE, 0); |
9733 gtk_box_pack_start(GTK_BOX(gtkconv->tabby), gtkconv->tab_label, TRUE, TRUE, 0); |
| 9679 gtk_box_pack_start(GTK_BOX(gtkconv->tabby), third, FALSE, FALSE, 0); |
9734 gtk_box_pack_start(GTK_BOX(gtkconv->tabby), third, FALSE, FALSE, 0); |
| 9680 |
9735 |
| 9691 |
9746 |
| 9692 /* Reset the tabs label to the new version */ |
9747 /* Reset the tabs label to the new version */ |
| 9693 gtk_notebook_set_tab_label(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, ebox); |
9748 gtk_notebook_set_tab_label(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, ebox); |
| 9694 } |
9749 } |
| 9695 |
9750 |
| 9696 gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, |
9751 g_object_set(G_OBJECT(win->notebook), "expand", !tabs_side && !angle, |
| 9697 !tabs_side && !angle, |
9752 "fill", TRUE, NULL); |
| 9698 TRUE, GTK_PACK_START); |
|
| 9699 |
9753 |
| 9700 if (pidgin_conv_window_get_gtkconv_count(win) == 1) |
9754 if (pidgin_conv_window_get_gtkconv_count(win) == 1) |
| 9701 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), |
9755 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), |
| 9702 purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/tabs") && |
9756 purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/tabs") && |
| 9703 (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/im/show_buddy_icons") || |
9757 (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/im/show_buddy_icons") || |
| 9927 { |
9981 { |
| 9928 int x, y; |
9982 int x, y; |
| 9929 PurpleConversationType type = purple_conversation_get_type(conv->active_conv); |
9983 PurpleConversationType type = purple_conversation_get_type(conv->active_conv); |
| 9930 GList *all; |
9984 GList *all; |
| 9931 |
9985 |
| 9932 if (GTK_WIDGET_VISIBLE(w)) |
9986 if (gtk_widget_get_visible(w)) |
| 9933 gtk_window_get_position(GTK_WINDOW(w), &x, &y); |
9987 gtk_window_get_position(GTK_WINDOW(w), &x, &y); |
| 9934 else |
9988 else |
| 9935 return FALSE; /* carry on normally */ |
9989 return FALSE; /* carry on normally */ |
| 9936 |
9990 |
| 9937 /* Workaround for GTK+ bug # 169811 - "configure_event" is fired |
9991 /* Workaround for GTK+ bug # 169811 - "configure_event" is fired |
| 9938 * when the window is being maximized */ |
9992 * when the window is being maximized */ |
| 9939 if (gdk_window_get_state(w->window) & GDK_WINDOW_STATE_MAXIMIZED) |
9993 if (gdk_window_get_state(gtk_widget_get_window(w)) & GDK_WINDOW_STATE_MAXIMIZED) |
| 9940 return FALSE; |
9994 return FALSE; |
| 9941 |
9995 |
| 9942 /* don't save off-screen positioning */ |
9996 /* don't save off-screen positioning */ |
| 9943 if (x + event->width < 0 || |
9997 if (x + event->width < 0 || |
| 9944 y + event->height < 0 || |
9998 y + event->height < 0 || |