comparison src/gtkconv.c @ 11614:f72607814e4a

[gaim-migrate @ 13888] sadrul fixed that dragging to the right of the tab in another window thing, and i modified it a little, because i'm picky or something committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Wed, 05 Oct 2005 02:08:23 +0000
parents d15a1d755417
children d09d94db1a89
comparison
equal deleted inserted replaced
11613:d15a1d755417 11614:f72607814e4a
115 static GtkWidget *warn_close_dialog = NULL; 115 static GtkWidget *warn_close_dialog = NULL;
116 116
117 static gboolean update_send_to_selection(GaimGtkWindow *win); 117 static gboolean update_send_to_selection(GaimGtkWindow *win);
118 static void generate_send_to_items(GaimGtkWindow *win); 118 static void generate_send_to_items(GaimGtkWindow *win);
119 119
120
121
122 /* Prototypes. <-- because Paco-Paco hates this comment. */ 120 /* Prototypes. <-- because Paco-Paco hates this comment. */
123 static void got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first); 121 static void got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first);
124 static void gray_stuff_out(GaimGtkConversation *gtkconv); 122 static void gray_stuff_out(GaimGtkConversation *gtkconv);
125 static GList *generate_invite_user_names(GaimConnection *gc); 123 static GList *generate_invite_user_names(GaimConnection *gc);
126 static void add_chat_buddy_common(GaimConversation *conv, const char *name, 124 static void add_chat_buddy_common(GaimConversation *conv, const char *name,
5190 if (win != NULL && gaim_gtk_conv_window_is_active_conversation(conv)) 5188 if (win != NULL && gaim_gtk_conv_window_is_active_conversation(conv))
5191 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); 5189 gray_stuff_out(GAIM_GTK_CONVERSATION(conv));
5192 } 5190 }
5193 5191
5194 int 5192 int
5195 gaim_gtkconv_get_tab_at_xy(GaimGtkWindow *win, int x, int y) 5193 gaim_gtkconv_get_tab_at_xy(GaimGtkWindow *win, int x, int y, gboolean *to_right)
5196 { 5194 {
5197 gint nb_x, nb_y, x_rel, y_rel; 5195 gint nb_x, nb_y, x_rel, y_rel;
5198 GtkNotebook *notebook; 5196 GtkNotebook *notebook;
5199 GtkWidget *page, *tab; 5197 GtkWidget *page, *tab;
5200 gint i, page_num = -1; 5198 gint i, page_num = -1;
5201 gint count; 5199 gint count;
5202 gboolean horiz; 5200 gboolean horiz;
5203 5201
5202 if (to_right)
5203 *to_right = FALSE;
5204
5204 notebook = GTK_NOTEBOOK(win->notebook); 5205 notebook = GTK_NOTEBOOK(win->notebook);
5205 5206
5206 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); 5207 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y);
5207 x_rel = x - nb_x; 5208 x_rel = x - nb_x;
5208 y_rel = y - nb_y; 5209 y_rel = y - nb_y;
5219 5220
5220 if (horiz) { 5221 if (horiz) {
5221 if (x_rel >= tab->allocation.x - GAIM_HIG_BOX_SPACE && 5222 if (x_rel >= tab->allocation.x - GAIM_HIG_BOX_SPACE &&
5222 x_rel <= tab->allocation.x + tab->allocation.width + GAIM_HIG_BOX_SPACE) { 5223 x_rel <= tab->allocation.x + tab->allocation.width + GAIM_HIG_BOX_SPACE) {
5223 page_num = i; 5224 page_num = i;
5225
5226 if (to_right && x_rel >= tab->allocation.x + tab->allocation.width/2)
5227 *to_right = TRUE;
5228
5224 break; 5229 break;
5225 } 5230 }
5226 } else { 5231 } else {
5227 if (y_rel >= tab->allocation.y - GAIM_HIG_BOX_SPACE && 5232 if (y_rel >= tab->allocation.y - GAIM_HIG_BOX_SPACE &&
5228 y_rel <= tab->allocation.y + tab->allocation.height + GAIM_HIG_BOX_SPACE) { 5233 y_rel <= tab->allocation.y + tab->allocation.height + GAIM_HIG_BOX_SPACE) {
5229 page_num = i; 5234 page_num = i;
5235
5236 if (to_right && y_rel >= tab->allocation.y + tab->allocation.height/2)
5237 *to_right = TRUE;
5238
5230 break; 5239 break;
5231 } 5240 }
5232 } 5241 }
5233 } 5242 }
5234 5243
5708 { 5717 {
5709 if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE) 5718 if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE)
5710 gtk_widget_set_state(widget, GTK_STATE_NORMAL); 5719 gtk_widget_set_state(widget, GTK_STATE_NORMAL);
5711 } 5720 }
5712 5721
5713
5714
5715
5716 static void 5722 static void
5717 notebook_init_grab(GaimGtkWindow *gtkwin, GtkWidget *widget) 5723 notebook_init_grab(GaimGtkWindow *gtkwin, GtkWidget *widget)
5718 { 5724 {
5719 static GdkCursor *cursor = NULL; 5725 static GdkCursor *cursor = NULL;
5720 5726
5764 GtkNotebook *dest_notebook; 5770 GtkNotebook *dest_notebook;
5765 GtkWidget *tab; 5771 GtkWidget *tab;
5766 gint nb_x, nb_y, page_num; 5772 gint nb_x, nb_y, page_num;
5767 gint arrow1_x, arrow1_y, arrow2_x, arrow2_y; 5773 gint arrow1_x, arrow1_y, arrow2_x, arrow2_y;
5768 gboolean horiz_tabs = FALSE; 5774 gboolean horiz_tabs = FALSE;
5775 GaimGtkConversation *gtkconv;
5776 gboolean to_right = FALSE;
5769 5777
5770 /* Get the window that the cursor is over. */ 5778 /* Get the window that the cursor is over. */
5771 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); 5779 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root);
5772 5780
5773 if (dest_win == NULL) { 5781 if (dest_win == NULL) {
5774 dnd_hints_hide_all(); 5782 dnd_hints_hide_all();
5775 5783
5776 return TRUE; 5784 return TRUE;
5777 } 5785 }
5778 5786
5779
5780 dest_notebook = GTK_NOTEBOOK(dest_win->notebook); 5787 dest_notebook = GTK_NOTEBOOK(dest_win->notebook);
5781 5788
5782 gdk_window_get_origin(GTK_WIDGET(dest_notebook)->window, &nb_x, &nb_y); 5789 gdk_window_get_origin(GTK_WIDGET(dest_notebook)->window, &nb_x, &nb_y);
5783 5790
5784 arrow1_x = arrow2_x = nb_x; 5791 arrow1_x = arrow2_x = nb_x;
5785 arrow1_y = arrow2_y = nb_y; 5792 arrow1_y = arrow2_y = nb_y;
5786 5793
5787 page_num = gaim_gtkconv_get_tab_at_xy(dest_win, 5794 page_num = gaim_gtkconv_get_tab_at_xy(dest_win,
5788 e->x_root, e->y_root); 5795 e->x_root, e->y_root, &to_right);
5796 to_right = to_right && (win != dest_win);
5789 5797
5790 if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP || 5798 if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP ||
5791 gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) { 5799 gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) {
5792 5800
5793 horiz_tabs = TRUE; 5801 horiz_tabs = TRUE;
5794 } 5802 }
5795 5803
5796 tab = gaim_gtk_conv_window_get_gtkconv_at_index(dest_win, page_num)->tabby; 5804 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(dest_win, page_num);
5805 tab = gtkconv->tabby;
5797 5806
5798 if (horiz_tabs) { 5807 if (horiz_tabs) {
5799 arrow1_x = arrow2_x = nb_x + tab->allocation.x; 5808 arrow1_x = arrow2_x = nb_x + tab->allocation.x;
5800 5809
5801 if ((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) { 5810 if (((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) || to_right) {
5802 arrow1_x += tab->allocation.width; 5811 arrow1_x += tab->allocation.width;
5803 arrow2_x += tab->allocation.width; 5812 arrow2_x += tab->allocation.width;
5804 } 5813 }
5805 5814
5806 arrow1_y = nb_y + tab->allocation.y; 5815 arrow1_y = nb_y + tab->allocation.y;
5871 5880
5872 /* 5881 /*
5873 * Make sure a tab was actually clicked. The arrow buttons 5882 * Make sure a tab was actually clicked. The arrow buttons
5874 * mess things up. 5883 * mess things up.
5875 */ 5884 */
5876 tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root); 5885 tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root, NULL);
5877 5886
5878 if (tab_clicked == -1) 5887 if (tab_clicked == -1)
5879 return FALSE; 5888 return FALSE;
5880 5889
5881 /* 5890 /*
5932 GaimGtkWindow *dest_win; 5941 GaimGtkWindow *dest_win;
5933 GaimConversation *conv; 5942 GaimConversation *conv;
5934 GaimGtkConversation *gtkconv; 5943 GaimGtkConversation *gtkconv;
5935 gint dest_page_num = 0; 5944 gint dest_page_num = 0;
5936 gboolean new_window = FALSE; 5945 gboolean new_window = FALSE;
5946 gboolean to_right = FALSE;
5937 5947
5938 /* 5948 /*
5939 * Don't check to make sure that the event's window matches the 5949 * Don't check to make sure that the event's window matches the
5940 * widget's, because we may be getting an event passed on from the 5950 * widget's, because we may be getting an event passed on from the
5941 * close button. 5951 * close button.
6004 "conversation-dragging", win, dest_win); 6014 "conversation-dragging", win, dest_win);
6005 6015
6006 /* Get the destination page number. */ 6016 /* Get the destination page number. */
6007 if (!new_window) 6017 if (!new_window)
6008 dest_page_num = gaim_gtkconv_get_tab_at_xy(dest_win, 6018 dest_page_num = gaim_gtkconv_get_tab_at_xy(dest_win,
6009 e->x_root, e->y_root); 6019 e->x_root, e->y_root, &to_right);
6010 6020
6011 gtkconv = GAIM_GTK_CONVERSATION(conv); 6021 gtkconv = GAIM_GTK_CONVERSATION(conv);
6012 6022
6013 if (win == dest_win) { 6023 if (win == dest_win) {
6014 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, dest_page_num); 6024 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, dest_page_num);
6015 } else { 6025 } else {
6016 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); 6026 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv);
6017 gaim_gtk_conv_window_add_gtkconv(dest_win, gtkconv); 6027 gaim_gtk_conv_window_add_gtkconv(dest_win, gtkconv);
6018 gtk_notebook_reorder_child(GTK_NOTEBOOK(dest_win->notebook), gtkconv->tab_cont, dest_page_num); 6028 gtk_notebook_reorder_child(GTK_NOTEBOOK(dest_win->notebook), gtkconv->tab_cont, dest_page_num + to_right);
6019 gaim_gtk_conv_window_switch_gtkconv(dest_win, gtkconv); 6029 gaim_gtk_conv_window_switch_gtkconv(dest_win, gtkconv);
6020 if (new_window) { 6030 if (new_window) {
6021 gint win_width, win_height; 6031 gint win_width, win_height;
6022 6032
6023 gtk_window_get_size(GTK_WINDOW(dest_win->window), 6033 gtk_window_get_size(GTK_WINDOW(dest_win->window),