Mercurial > pidgin
comparison src/conversation.c @ 1573:3a8bd72f431f
[gaim-migrate @ 1583]
tabbed conversation window, optional. you can toggle it and it will work like you'd expect. i still think that was an evil hack.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Thu, 15 Mar 2001 12:58:06 +0000 |
parents | 249a770bebd7 |
children | 427e1409917c |
comparison
equal
deleted
inserted
replaced
1572:d60672672a13 | 1573:3a8bd72f431f |
---|---|
59 int state_lock = 0; | 59 int state_lock = 0; |
60 | 60 |
61 GdkPixmap *dark_icon_pm = NULL; | 61 GdkPixmap *dark_icon_pm = NULL; |
62 GdkBitmap *dark_icon_bm = NULL; | 62 GdkBitmap *dark_icon_bm = NULL; |
63 | 63 |
64 static GtkWidget *all_convos = NULL; | |
65 static GtkWidget *convo_notebook = NULL; | |
66 | |
64 char fontface[64]; | 67 char fontface[64]; |
65 int fontsize = 3; | 68 int fontsize = 3; |
66 extern GdkColor bgcolor; | 69 extern GdkColor bgcolor; |
67 extern GdkColor fgcolor; | 70 extern GdkColor fgcolor; |
68 | 71 |
128 } | 131 } |
129 | 132 |
130 if (connections) | 133 if (connections) |
131 c->gc = (struct gaim_connection *)connections->data; | 134 c->gc = (struct gaim_connection *)connections->data; |
132 c->history = g_string_new(""); | 135 c->history = g_string_new(""); |
136 conversations = g_list_append(conversations, c); | |
133 show_conv(c); | 137 show_conv(c); |
134 conversations = g_list_append(conversations, c); | |
135 plugin_event(event_new_conversation, name, 0, 0, 0); | 138 plugin_event(event_new_conversation, name, 0, 0, 0); |
136 return c; | 139 return c; |
137 } | 140 } |
138 | 141 |
139 | 142 |
174 if (cnv) { | 177 if (cnv) { |
175 if (!(logging_options & OPT_LOG_ALL)) | 178 if (!(logging_options & OPT_LOG_ALL)) |
176 g_snprintf(buf, sizeof(buf), CONVERSATION_TITLE, cnv->name); | 179 g_snprintf(buf, sizeof(buf), CONVERSATION_TITLE, cnv->name); |
177 else | 180 else |
178 g_snprintf(buf, sizeof(buf), LOG_CONVERSATION_TITLE, cnv->name); | 181 g_snprintf(buf, sizeof(buf), LOG_CONVERSATION_TITLE, cnv->name); |
179 gtk_window_set_title(GTK_WINDOW(cnv->window), buf); | 182 if (!(display_options & OPT_DISP_ONE_WINDOW)) |
183 gtk_window_set_title(GTK_WINDOW(cnv->window), buf); | |
180 } | 184 } |
181 } | 185 } |
182 | 186 |
183 struct log_conversation *find_log_info(char *name) | 187 struct log_conversation *find_log_info(char *name) |
184 { | 188 { |
381 debug_printf("conversation close callback\n"); | 385 debug_printf("conversation close callback\n"); |
382 | 386 |
383 if (general_options & OPT_GEN_CHECK_SPELLING) | 387 if (general_options & OPT_GEN_CHECK_SPELLING) |
384 gtkspell_detach(GTK_TEXT(c->entry)); | 388 gtkspell_detach(GTK_TEXT(c->entry)); |
385 | 389 |
386 if (c->window) | 390 if ((display_options & OPT_DISP_ONE_WINDOW) && (!c->is_chat)) { |
387 gtk_widget_destroy(c->window); | 391 if (g_list_length(conversations) > 1) { |
388 c->window = NULL; | 392 gtk_notebook_remove_page(GTK_NOTEBOOK(convo_notebook), |
393 g_list_index(conversations, c)); | |
394 } else { | |
395 if (c->window) | |
396 gtk_widget_destroy(c->window); | |
397 c->window = NULL; | |
398 all_convos = NULL; | |
399 } | |
400 } else { | |
401 if (c->window) | |
402 gtk_widget_destroy(c->window); | |
403 c->window = NULL; | |
404 } | |
389 | 405 |
390 if (c->fg_color_dialog) | 406 if (c->fg_color_dialog) |
391 gtk_widget_destroy(c->fg_color_dialog); | 407 gtk_widget_destroy(c->fg_color_dialog); |
392 c->fg_color_dialog = NULL; | 408 c->fg_color_dialog = NULL; |
393 if (c->bg_color_dialog) | 409 if (c->bg_color_dialog) |
443 surround(c->entry, pre_fontface, "</FONT>"); | 459 surround(c->entry, pre_fontface, "</FONT>"); |
444 gtk_widget_grab_focus(c->entry); | 460 gtk_widget_grab_focus(c->entry); |
445 | 461 |
446 if (alloc) | 462 if (alloc) |
447 g_free(pre_fontface); | 463 g_free(pre_fontface); |
464 } | |
465 | |
466 static gint delete_all_convo(GtkWidget *w, GdkEventAny *e, gpointer d) | |
467 { | |
468 while (conversations) { | |
469 struct conversation *c = conversations->data; | |
470 close_callback(c->close, c); | |
471 } | |
472 return FALSE; | |
448 } | 473 } |
449 | 474 |
450 static gint delete_event_convo(GtkWidget *w, GdkEventAny * e, struct conversation *c) | 475 static gint delete_event_convo(GtkWidget *w, GdkEventAny * e, struct conversation *c) |
451 { | 476 { |
452 delete_conversation(c); | 477 delete_conversation(c); |
1366 | 1391 |
1367 if ((c->is_chat && (general_options & OPT_GEN_POPUP_CHAT)) || | 1392 if ((c->is_chat && (general_options & OPT_GEN_POPUP_CHAT)) || |
1368 (!c->is_chat && (general_options & OPT_GEN_POPUP_WINDOWS))) | 1393 (!c->is_chat && (general_options & OPT_GEN_POPUP_WINDOWS))) |
1369 gdk_window_show(c->window->window); | 1394 gdk_window_show(c->window->window); |
1370 | 1395 |
1396 if ((flags & WFLAG_RECV) && !c->is_chat && (display_options & OPT_DISP_ONE_WINDOW) && | |
1397 (gtk_notebook_get_current_page(GTK_NOTEBOOK(convo_notebook)) | |
1398 != g_list_index(conversations, c))) { | |
1399 GtkWidget *label = gtk_notebook_get_tab_label(GTK_NOTEBOOK(convo_notebook), | |
1400 gtk_notebook_get_nth_page(GTK_NOTEBOOK(convo_notebook), | |
1401 g_list_index(conversations, c))); | |
1402 GtkStyle *style = gtk_style_new(); | |
1403 if (!GTK_WIDGET_REALIZED(label)) | |
1404 gtk_widget_realize(label); | |
1405 gdk_font_unref(style->font); | |
1406 style->font = label->style->font; | |
1407 style->fg[0].red = 0xcccc; | |
1408 style->fg[0].green = 0x0000; | |
1409 style->fg[0].blue = 0x0000; | |
1410 gtk_widget_set_style(label, style); | |
1411 gtk_style_unref(style); | |
1412 } | |
1413 | |
1371 g_free(smiley); | 1414 g_free(smiley); |
1372 g_free(buf); | 1415 g_free(buf); |
1373 } | 1416 } |
1374 | 1417 |
1375 | 1418 |
1757 else | 1800 else |
1758 gtk_widget_set_sensitive(c->invite, TRUE); | 1801 gtk_widget_set_sensitive(c->invite, TRUE); |
1759 } | 1802 } |
1760 } | 1803 } |
1761 | 1804 |
1805 static void convo_switch(GtkNotebook *notebook, GtkWidget *page, gint page_num, gpointer data) | |
1806 { | |
1807 GtkWidget *label = gtk_notebook_get_tab_label(GTK_NOTEBOOK(convo_notebook), | |
1808 gtk_notebook_get_nth_page(GTK_NOTEBOOK(convo_notebook), page_num)); | |
1809 GtkStyle *style; | |
1810 struct conversation *c = g_list_nth_data(conversations, page_num); | |
1811 if (c && c->window && c->entry) | |
1812 gtk_window_set_focus(GTK_WINDOW(c->window), c->entry); | |
1813 if (!GTK_WIDGET_REALIZED(label)) | |
1814 return; | |
1815 style = gtk_style_new(); | |
1816 gdk_font_unref(style->font); | |
1817 style->font = label->style->font; | |
1818 style->fg[0].red = 0x0000; | |
1819 style->fg[0].green = 0x0000; | |
1820 style->fg[0].blue = 0x0000; | |
1821 gtk_widget_set_style(label, style); | |
1822 gtk_style_unref(style); | |
1823 } | |
1824 | |
1762 | 1825 |
1763 void show_conv(struct conversation *c) | 1826 void show_conv(struct conversation *c) |
1764 { | 1827 { |
1765 GtkWidget *win; | 1828 GtkWidget *win; |
1829 GtkWidget *cont; | |
1766 char buf[256]; | 1830 char buf[256]; |
1767 GtkWidget *text; | 1831 GtkWidget *text; |
1768 GtkWidget *sw; | 1832 GtkWidget *sw; |
1769 GtkWidget *send; | 1833 GtkWidget *send; |
1770 GtkWidget *info; | 1834 GtkWidget *info; |
1795 c->bgcol = bgcolor; | 1859 c->bgcol = bgcolor; |
1796 c->hasbg = 0; | 1860 c->hasbg = 0; |
1797 c->fgcol = fgcolor; | 1861 c->fgcol = fgcolor; |
1798 c->hasfg = 0; | 1862 c->hasfg = 0; |
1799 | 1863 |
1800 win = gtk_window_new(GTK_WINDOW_TOPLEVEL); | 1864 if (display_options & OPT_DISP_ONE_WINDOW) { |
1801 c->window = win; | 1865 if (!all_convos) { |
1802 gtk_object_set_user_data(GTK_OBJECT(win), c); | 1866 win = all_convos = c->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
1803 gtk_window_set_wmclass(GTK_WINDOW(win), "conversation", "Gaim"); | 1867 gtk_window_set_wmclass(GTK_WINDOW(win), "conversation", "Gaim"); |
1804 gtk_window_set_policy(GTK_WINDOW(win), TRUE, TRUE, TRUE); | 1868 gtk_window_set_policy(GTK_WINDOW(win), TRUE, TRUE, TRUE); |
1805 gtk_container_border_width(GTK_CONTAINER(win), 10); | 1869 gtk_container_border_width(GTK_CONTAINER(win), 0); |
1806 gtk_widget_realize(win); | 1870 gtk_widget_realize(win); |
1807 aol_icon(win->window); | 1871 aol_icon(win->window); |
1808 if ((find_log_info(c->name)) || ((logging_options & OPT_LOG_ALL))) | 1872 gtk_window_set_title(GTK_WINDOW(win), _("Gaim - Conversations")); |
1809 g_snprintf(buf, sizeof(buf), LOG_CONVERSATION_TITLE, c->name); | 1873 gtk_signal_connect(GTK_OBJECT(win), "delete_event", |
1810 else | 1874 GTK_SIGNAL_FUNC(delete_all_convo), NULL); |
1811 g_snprintf(buf, sizeof(buf), CONVERSATION_TITLE, c->name); | 1875 |
1812 gtk_window_set_title(GTK_WINDOW(win), buf); | 1876 convo_notebook = gtk_notebook_new(); |
1813 gtk_signal_connect(GTK_OBJECT(win), "delete_event", GTK_SIGNAL_FUNC(delete_event_convo), c); | 1877 gtk_container_add(GTK_CONTAINER(win), convo_notebook); |
1878 gtk_signal_connect(GTK_OBJECT(convo_notebook), "switch-page", | |
1879 GTK_SIGNAL_FUNC(convo_switch), NULL); | |
1880 gtk_widget_show(convo_notebook); | |
1881 } else | |
1882 win = c->window = all_convos; | |
1883 | |
1884 cont = gtk_vbox_new(FALSE, 5); | |
1885 gtk_container_set_border_width(GTK_CONTAINER(cont), 5); | |
1886 gtk_notebook_append_page(GTK_NOTEBOOK(convo_notebook), cont, gtk_label_new(c->name)); | |
1887 gtk_widget_show(cont); | |
1888 } else { | |
1889 cont = win = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
1890 c->window = win; | |
1891 gtk_object_set_user_data(GTK_OBJECT(win), c); | |
1892 gtk_window_set_wmclass(GTK_WINDOW(win), "conversation", "Gaim"); | |
1893 gtk_window_set_policy(GTK_WINDOW(win), TRUE, TRUE, TRUE); | |
1894 gtk_container_border_width(GTK_CONTAINER(win), 10); | |
1895 gtk_widget_realize(win); | |
1896 aol_icon(win->window); | |
1897 if ((find_log_info(c->name)) || ((logging_options & OPT_LOG_ALL))) | |
1898 g_snprintf(buf, sizeof(buf), LOG_CONVERSATION_TITLE, c->name); | |
1899 else | |
1900 g_snprintf(buf, sizeof(buf), CONVERSATION_TITLE, c->name); | |
1901 gtk_window_set_title(GTK_WINDOW(win), buf); | |
1902 gtk_signal_connect(GTK_OBJECT(win), "delete_event", | |
1903 GTK_SIGNAL_FUNC(delete_event_convo), c); | |
1904 } | |
1814 | 1905 |
1815 paned = gtk_vpaned_new(); | 1906 paned = gtk_vpaned_new(); |
1816 gtk_paned_set_gutter_size(GTK_PANED(paned), 15); | 1907 gtk_paned_set_gutter_size(GTK_PANED(paned), 15); |
1817 gtk_container_add(GTK_CONTAINER(win), paned); | 1908 gtk_container_add(GTK_CONTAINER(cont), paned); |
1818 gtk_widget_show(paned); | 1909 gtk_widget_show(paned); |
1819 | 1910 |
1820 vbox = gtk_vbox_new(FALSE, 5); | 1911 vbox = gtk_vbox_new(FALSE, 5); |
1821 gtk_paned_pack1(GTK_PANED(paned), vbox, FALSE, TRUE); | 1912 gtk_paned_pack1(GTK_PANED(paned), vbox, FALSE, TRUE); |
1822 gtk_widget_show(vbox); | 1913 gtk_widget_show(vbox); |
1823 | 1914 |
1824 sw = gtk_scrolled_window_new(NULL, NULL); | 1915 sw = gtk_scrolled_window_new(NULL, NULL); |
1916 c->sw = sw; | |
1825 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); | 1917 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); |
1826 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); | 1918 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); |
1827 gtk_widget_set_usize(sw, 320, 175); | 1919 gtk_widget_set_usize(sw, 320, 175); |
1828 gtk_widget_show(sw); | 1920 gtk_widget_show(sw); |
1829 | 1921 |
2035 cht = cht->next; | 2127 cht = cht->next; |
2036 } | 2128 } |
2037 con = con->next; | 2129 con = con->next; |
2038 } | 2130 } |
2039 } | 2131 } |
2132 | |
2133 void tabize() | |
2134 { | |
2135 /* evil, evil i tell you! evil! */ | |
2136 if (display_options & OPT_DISP_ONE_WINDOW) { | |
2137 GList *x = conversations; | |
2138 while (x) { | |
2139 struct conversation *c = x->data; | |
2140 GtkWidget *imhtml, *win; | |
2141 | |
2142 imhtml = c->text; | |
2143 win = c->window; | |
2144 show_conv(c); | |
2145 gtk_widget_destroy(c->text); | |
2146 gtk_widget_reparent(imhtml, c->sw); | |
2147 c->text = imhtml; | |
2148 gtk_widget_destroy(win); | |
2149 | |
2150 x = x->next; | |
2151 } | |
2152 } else { | |
2153 GList *x, *m; | |
2154 x = m = conversations; | |
2155 conversations = NULL; | |
2156 while (x) { | |
2157 struct conversation *c = x->data; | |
2158 GtkWidget *imhtml; | |
2159 | |
2160 imhtml = c->text; | |
2161 show_conv(c); | |
2162 gtk_widget_destroy(c->text); | |
2163 gtk_widget_reparent(imhtml, c->sw); | |
2164 c->text = imhtml; | |
2165 | |
2166 x = x->next; | |
2167 } | |
2168 if (all_convos) | |
2169 gtk_widget_destroy(all_convos); | |
2170 all_convos = NULL; | |
2171 conversations = m; | |
2172 } | |
2173 } |