comparison src/gtkconv.c @ 8582:d7c85220c685

[gaim-migrate @ 9332] Added a conversation-drag-ended signal. Patch by Etan Reisner. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Mon, 05 Apr 2004 06:52:02 +0000
parents 7dcd6f26e4a7
children 82357fa4e6b8
comparison
equal deleted inserted replaced
8581:2714e30991db 8582:d7c85220c685
1891 if (gaim_conv_window_get_conversation_count(win) < 2) 1891 if (gaim_conv_window_get_conversation_count(win) < 2)
1892 return FALSE; 1892 return FALSE;
1893 1893
1894 if (gaim_conv_window_get_conversation_count(win) > 1) { 1894 if (gaim_conv_window_get_conversation_count(win) > 1) {
1895 /* Make a new window to stick this to. */ 1895 /* Make a new window to stick this to. */
1896 GaimConvWindow *new_win;
1897 GaimGtkWindow *new_gtkwin;
1898 GaimGtkConversation *gtkconv; 1896 GaimGtkConversation *gtkconv;
1899 gint win_width, win_height; 1897 gint win_width, win_height;
1900 1898
1901 gtkconv = GAIM_GTK_CONVERSATION(conv); 1899 gtkconv = GAIM_GTK_CONVERSATION(conv);
1902 1900
1903 new_win = gaim_conv_window_new(); 1901 dest_win = gaim_conv_window_new();
1904 1902
1905 gaim_conv_window_add_conversation(new_win, 1903 gaim_conv_window_add_conversation(dest_win,
1906 gaim_conv_window_remove_conversation(win, 1904 gaim_conv_window_remove_conversation(win,
1907 gaim_conversation_get_index(conv))); 1905 gaim_conversation_get_index(conv)));
1908 1906
1909 new_gtkwin = GAIM_GTK_WINDOW(new_win); 1907 dest_gtkwin = GAIM_GTK_WINDOW(dest_win);
1910 1908
1911 gtk_window_get_size(GTK_WINDOW(new_gtkwin->window), 1909 gtk_window_get_size(GTK_WINDOW(dest_gtkwin->window),
1912 &win_width, &win_height); 1910 &win_width, &win_height);
1913 1911
1914 gtk_window_move(GTK_WINDOW(new_gtkwin->window), 1912 gtk_window_move(GTK_WINDOW(dest_gtkwin->window),
1915 e->x_root - (win_width / 2), 1913 e->x_root - (win_width / 2),
1916 e->y_root - (win_height / 2)); 1914 e->y_root - (win_height / 2));
1917 1915
1918 gaim_conv_window_show(new_win); 1916 gaim_conv_window_show(dest_win);
1919 } 1917 }
1920 1918 } else {
1921 return TRUE; 1919 dest_gtkwin = GAIM_GTK_WINDOW(dest_win);
1922 } 1920
1923 1921 /* Get the destination notebook. */
1924 dest_gtkwin = GAIM_GTK_WINDOW(dest_win); 1922 dest_notebook = GTK_NOTEBOOK(gtkwin->notebook);
1925 1923
1926 /* Get the destination notebook. */ 1924 /* Get the destination page number. */
1927 dest_notebook = GTK_NOTEBOOK(gtkwin->notebook); 1925 dest_page_num = gaim_gtkconv_get_dest_tab_at_xy(dest_win,
1928 1926 e->x_root, e->y_root);
1929 /* Get the destination page number. */ 1927
1930 dest_page_num = gaim_gtkconv_get_dest_tab_at_xy(dest_win, 1928 if (win == dest_win) {
1931 e->x_root, e->y_root); 1929 gaim_conv_window_move_conversation(win,
1932 1930 gaim_conversation_get_index(conv), dest_page_num);
1933 if (win == dest_win) { 1931 }
1934 gaim_conv_window_move_conversation(win, 1932 else {
1935 gaim_conversation_get_index(conv), dest_page_num); 1933 size_t pos;
1936 } 1934
1937 else { 1935 gaim_conv_window_remove_conversation(win,
1938 size_t pos; 1936 gaim_conversation_get_index(conv));
1939 1937
1940 gaim_conv_window_remove_conversation(win, 1938 pos = gaim_conv_window_add_conversation(dest_win, conv);
1941 gaim_conversation_get_index(conv)); 1939
1942 1940 if (pos != dest_page_num)
1943 pos = gaim_conv_window_add_conversation(dest_win, conv); 1941 gaim_conv_window_move_conversation(dest_win, pos, dest_page_num);
1944 1942
1945 if (pos != dest_page_num) 1943 gaim_conv_window_switch_conversation(dest_win, dest_page_num);
1946 gaim_conv_window_move_conversation(dest_win, pos, dest_page_num); 1944 }
1947 1945
1948 gaim_conv_window_switch_conversation(dest_win, dest_page_num); 1946 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry);
1949 } 1947 }
1950 1948
1951 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); 1949 gaim_signal_emit(gaim_gtk_conversations_get_handle(), "conversation-drag-ended",
1950 win, dest_win);
1952 1951
1953 return TRUE; 1952 return TRUE;
1954 } 1953 }
1955 1954
1956 /************************************************************************** 1955 /**************************************************************************
5726 return; 5725 return;
5727 5726
5728 gaim_conv_placement_set_current_func(func); 5727 gaim_conv_placement_set_current_func(func);
5729 } 5728 }
5730 5729
5730 void *
5731 gaim_gtk_conversations_get_handle(void)
5732 {
5733 static int handle;
5734
5735 return &handle;
5736 }
5737
5731 void 5738 void
5732 gaim_gtk_conversations_init(void) 5739 gaim_gtk_conversations_init(void)
5733 { 5740 {
5741 void *handle = gaim_gtk_conversations_get_handle();
5742
5734 /* Conversations */ 5743 /* Conversations */
5735 gaim_prefs_add_none("/gaim/gtk/conversations"); 5744 gaim_prefs_add_none("/gaim/gtk/conversations");
5736 gaim_prefs_add_bool("/gaim/gtk/conversations/icons_on_tabs", TRUE); 5745 gaim_prefs_add_bool("/gaim/gtk/conversations/icons_on_tabs", TRUE);
5737 gaim_prefs_add_bool("/gaim/gtk/conversations/close_on_tabs", TRUE); 5746 gaim_prefs_add_bool("/gaim/gtk/conversations/close_on_tabs", TRUE);
5738 gaim_prefs_add_bool("/gaim/gtk/conversations/ctrl_enter_sends", FALSE); 5747 gaim_prefs_add_bool("/gaim/gtk/conversations/ctrl_enter_sends", FALSE);
5826 5835
5827 5836
5828 /* Chat callbacks */ 5837 /* Chat callbacks */
5829 gaim_prefs_connect_callback("/gaim/gtk/conversations/chat/button_type", 5838 gaim_prefs_connect_callback("/gaim/gtk/conversations/chat/button_type",
5830 chat_button_type_pref_cb, NULL); 5839 chat_button_type_pref_cb, NULL);
5831 } 5840
5841 /**********************************************************************
5842 * Register signals
5843 **********************************************************************/
5844 gaim_signal_register(handle, "conversation-drag-ended",
5845 gaim_marshal_VOID__POINTER_POINTER, NULL, 2,
5846 gaim_value_new(GAIM_TYPE_SUBTYPE,
5847 GAIM_SUBTYPE_CONV_WINDOW),
5848 gaim_value_new(GAIM_TYPE_SUBTYPE,
5849 GAIM_SUBTYPE_CONV_WINDOW));
5850 }
5851
5852 void
5853 gaim_gtk_conversations_uninit(void)
5854 {
5855 gaim_signals_unregister_by_instance(gaim_gtk_conversations_get_handle());
5856 }