| 1531 |
1531 |
| 1532 return ret; |
1532 return ret; |
| 1533 } |
1533 } |
| 1534 |
1534 |
| 1535 static void |
1535 static void |
| 1536 formatting_toggle_cb(GtkWebView *webview, GtkWebViewButtons buttons, void *data) |
1536 formatting_toggle_cb(PidginWebView *webview, PidginWebViewButtons buttons, void *data) |
| 1537 { |
1537 { |
| 1538 gboolean bold, italic, uline, strike; |
1538 gboolean bold, italic, uline, strike; |
| 1539 |
1539 |
| 1540 gtk_webview_get_current_format(webview, &bold, &italic, &uline, &strike); |
1540 pidgin_webview_get_current_format(webview, &bold, &italic, &uline, &strike); |
| 1541 |
1541 |
| 1542 if (buttons & GTK_WEBVIEW_BOLD) |
1542 if (buttons & PIDGIN_WEBVIEW_BOLD) |
| 1543 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_bold", |
1543 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_bold", |
| 1544 bold); |
1544 bold); |
| 1545 if (buttons & GTK_WEBVIEW_ITALIC) |
1545 if (buttons & PIDGIN_WEBVIEW_ITALIC) |
| 1546 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_italic", |
1546 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_italic", |
| 1547 italic); |
1547 italic); |
| 1548 if (buttons & GTK_WEBVIEW_UNDERLINE) |
1548 if (buttons & PIDGIN_WEBVIEW_UNDERLINE) |
| 1549 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline", |
1549 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline", |
| 1550 uline); |
1550 uline); |
| 1551 if (buttons & GTK_WEBVIEW_STRIKE) |
1551 if (buttons & PIDGIN_WEBVIEW_STRIKE) |
| 1552 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_strike", |
1552 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_strike", |
| 1553 strike); |
1553 strike); |
| 1554 |
1554 |
| 1555 if (buttons & GTK_WEBVIEW_GROW || buttons & GTK_WEBVIEW_SHRINK) |
1555 if (buttons & PIDGIN_WEBVIEW_GROW || buttons & PIDGIN_WEBVIEW_SHRINK) |
| 1556 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/font_size", |
1556 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/font_size", |
| 1557 gtk_webview_get_current_fontsize(webview)); |
1557 pidgin_webview_get_current_fontsize(webview)); |
| 1558 if (buttons & GTK_WEBVIEW_FACE) { |
1558 if (buttons & PIDGIN_WEBVIEW_FACE) { |
| 1559 char *face = gtk_webview_get_current_fontface(webview); |
1559 char *face = pidgin_webview_get_current_fontface(webview); |
| 1560 |
1560 |
| 1561 if (face) |
1561 if (face) |
| 1562 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/font_face", face); |
1562 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/font_face", face); |
| 1563 else |
1563 else |
| 1564 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/font_face", ""); |
1564 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/font_face", ""); |
| 1565 |
1565 |
| 1566 g_free(face); |
1566 g_free(face); |
| 1567 } |
1567 } |
| 1568 |
1568 |
| 1569 if (buttons & GTK_WEBVIEW_FORECOLOR) { |
1569 if (buttons & PIDGIN_WEBVIEW_FORECOLOR) { |
| 1570 char *color = gtk_webview_get_current_forecolor(webview); |
1570 char *color = pidgin_webview_get_current_forecolor(webview); |
| 1571 |
1571 |
| 1572 if (color) |
1572 if (color) |
| 1573 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/fgcolor", color); |
1573 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/fgcolor", color); |
| 1574 else |
1574 else |
| 1575 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/fgcolor", ""); |
1575 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/fgcolor", ""); |
| 1576 |
1576 |
| 1577 g_free(color); |
1577 g_free(color); |
| 1578 } |
1578 } |
| 1579 |
1579 |
| 1580 if (buttons & GTK_WEBVIEW_BACKCOLOR) { |
1580 if (buttons & PIDGIN_WEBVIEW_BACKCOLOR) { |
| 1581 char *color = gtk_webview_get_current_backcolor(webview); |
1581 char *color = pidgin_webview_get_current_backcolor(webview); |
| 1582 |
1582 |
| 1583 if (color) |
1583 if (color) |
| 1584 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/bgcolor", color); |
1584 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/bgcolor", color); |
| 1585 else |
1585 else |
| 1586 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/bgcolor", ""); |
1586 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/conversations/bgcolor", ""); |
| 1588 g_free(color); |
1588 g_free(color); |
| 1589 } |
1589 } |
| 1590 } |
1590 } |
| 1591 |
1591 |
| 1592 static void |
1592 static void |
| 1593 formatting_clear_cb(GtkWebView *webview, void *data) |
1593 formatting_clear_cb(PidginWebView *webview, void *data) |
| 1594 { |
1594 { |
| 1595 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_bold", FALSE); |
1595 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_bold", FALSE); |
| 1596 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_italic", FALSE); |
1596 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_italic", FALSE); |
| 1597 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline", FALSE); |
1597 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline", FALSE); |
| 1598 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_strike", FALSE); |
1598 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/send_strike", FALSE); |
| 1931 |
1931 |
| 1932 frame = pidgin_create_webview(TRUE, &webview, NULL); |
1932 frame = pidgin_create_webview(TRUE, &webview, NULL); |
| 1933 gtk_widget_show(frame); |
1933 gtk_widget_show(frame); |
| 1934 gtk_widget_set_name(webview, "pidgin_prefs_font_webview"); |
1934 gtk_widget_set_name(webview, "pidgin_prefs_font_webview"); |
| 1935 gtk_widget_set_size_request(frame, 450, -1); |
1935 gtk_widget_set_size_request(frame, 450, -1); |
| 1936 gtk_webview_set_whole_buffer_formatting_only(GTK_WEBVIEW(webview), TRUE); |
1936 pidgin_webview_set_whole_buffer_formatting_only(PIDGIN_WEBVIEW(webview), TRUE); |
| 1937 gtk_webview_set_format_functions(GTK_WEBVIEW(webview), |
1937 pidgin_webview_set_format_functions(PIDGIN_WEBVIEW(webview), |
| 1938 GTK_WEBVIEW_BOLD | |
1938 PIDGIN_WEBVIEW_BOLD | |
| 1939 GTK_WEBVIEW_ITALIC | |
1939 PIDGIN_WEBVIEW_ITALIC | |
| 1940 GTK_WEBVIEW_UNDERLINE | |
1940 PIDGIN_WEBVIEW_UNDERLINE | |
| 1941 GTK_WEBVIEW_STRIKE | |
1941 PIDGIN_WEBVIEW_STRIKE | |
| 1942 GTK_WEBVIEW_GROW | |
1942 PIDGIN_WEBVIEW_GROW | |
| 1943 GTK_WEBVIEW_SHRINK | |
1943 PIDGIN_WEBVIEW_SHRINK | |
| 1944 GTK_WEBVIEW_FACE | |
1944 PIDGIN_WEBVIEW_FACE | |
| 1945 GTK_WEBVIEW_FORECOLOR | |
1945 PIDGIN_WEBVIEW_FORECOLOR | |
| 1946 GTK_WEBVIEW_BACKCOLOR); |
1946 PIDGIN_WEBVIEW_BACKCOLOR); |
| 1947 |
1947 |
| 1948 gtk_webview_append_html(GTK_WEBVIEW(webview), |
1948 pidgin_webview_append_html(PIDGIN_WEBVIEW(webview), |
| 1949 _("This is how your outgoing message text will " |
1949 _("This is how your outgoing message text will " |
| 1950 "appear when you use protocols that support " |
1950 "appear when you use protocols that support " |
| 1951 "formatting.")); |
1951 "formatting.")); |
| 1952 |
1952 |
| 1953 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
1953 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
| 1954 |
1954 |
| 1955 gtk_webview_setup_entry(GTK_WEBVIEW(webview), |
1955 pidgin_webview_setup_entry(PIDGIN_WEBVIEW(webview), |
| 1956 PURPLE_CONNECTION_FLAG_HTML | |
1956 PURPLE_CONNECTION_FLAG_HTML | |
| 1957 PURPLE_CONNECTION_FLAG_FORMATTING_WBFO); |
1957 PURPLE_CONNECTION_FLAG_FORMATTING_WBFO); |
| 1958 |
1958 |
| 1959 g_signal_connect_after(G_OBJECT(webview), "format-toggled", |
1959 g_signal_connect_after(G_OBJECT(webview), "format-toggled", |
| 1960 G_CALLBACK(formatting_toggle_cb), NULL); |
1960 G_CALLBACK(formatting_toggle_cb), NULL); |