Mercurial > pidgin.yaz
comparison src/gtkimhtml.c @ 2541:8229710b343b
[gaim-migrate @ 2554]
fun stuff.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Thu, 18 Oct 2001 20:56:59 +0000 |
parents | 4ab2903f28a1 |
children | e284ab2882bd |
comparison
equal
deleted
inserted
replaced
2540:42e8c40247f5 | 2541:8229710b343b |
---|---|
17 * along with this program; if not, write to the Free Software | 17 * along with this program; if not, write to the Free Software |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 * | 19 * |
20 */ | 20 */ |
21 | 21 |
22 #ifdef HAVE_CONFIG_H | |
23 #include <config.h> | |
24 #endif | |
22 #include "gtkimhtml.h" | 25 #include "gtkimhtml.h" |
23 #include <X11/Xlib.h> | 26 #include <X11/Xlib.h> |
24 #include <gdk/gdkx.h> | 27 #include <gdk/gdkx.h> |
25 #include <gtk/gtk.h> | 28 #include <gtk/gtk.h> |
26 #include <string.h> | 29 #include <string.h> |
27 #include <ctype.h> | 30 #include <ctype.h> |
28 #include <stdio.h> | 31 #include <stdio.h> |
29 #include <math.h> | 32 #include <math.h> |
33 #ifdef HAVE_LANGINFO_CODESET | |
34 #include <langinfo.h> | |
35 #include <locale.h> | |
36 #endif | |
30 | 37 |
31 #include "pixmaps/angel.xpm" | 38 #include "pixmaps/angel.xpm" |
32 #include "pixmaps/bigsmile.xpm" | 39 #include "pixmaps/bigsmile.xpm" |
33 #include "pixmaps/burp.xpm" | 40 #include "pixmaps/burp.xpm" |
34 #include "pixmaps/crossedlips.xpm" | 41 #include "pixmaps/crossedlips.xpm" |
76 struct _GtkSmileyTree { | 83 struct _GtkSmileyTree { |
77 GString *values; | 84 GString *values; |
78 GtkSmileyTree **children; | 85 GtkSmileyTree **children; |
79 gchar **image; | 86 gchar **image; |
80 }; | 87 }; |
88 | |
89 static gchar* getcharset() | |
90 { | |
91 static gchar charset[64]; | |
92 #ifdef HAVE_LANGINFO_CODESET | |
93 gchar *ch = nl_langinfo(CODESET); | |
94 if (strncasecmp(ch, "iso-", 4) == 0) | |
95 g_snprintf(charset, sizeof(charset), "iso%s", ch + 4); | |
96 else | |
97 g_snprintf(charset, sizeof(charset), ch); | |
98 #else | |
99 g_snprintf(charset, sizeof(charset), "iso8859-*"); | |
100 #endif | |
101 return charset; | |
102 } | |
81 | 103 |
82 static GtkSmileyTree* | 104 static GtkSmileyTree* |
83 gtk_smiley_tree_new () | 105 gtk_smiley_tree_new () |
84 { | 106 { |
85 return g_new0 (GtkSmileyTree, 1); | 107 return g_new0 (GtkSmileyTree, 1); |
346 gtk_widget_destroy (imhtml->tip_window); | 368 gtk_widget_destroy (imhtml->tip_window); |
347 imhtml->tip_window = NULL; | 369 imhtml->tip_window = NULL; |
348 } | 370 } |
349 imhtml->tip_bit = NULL; | 371 imhtml->tip_bit = NULL; |
350 | 372 |
351 gdk_font_unref (imhtml->default_font); | 373 if (imhtml->default_font) |
352 gdk_color_free (imhtml->default_fg_color); | 374 gdk_font_unref (imhtml->default_font); |
353 gdk_color_free (imhtml->default_bg_color); | 375 if (imhtml->default_fg_color) |
376 gdk_color_free (imhtml->default_fg_color); | |
377 if (imhtml->default_bg_color) | |
378 gdk_color_free (imhtml->default_bg_color); | |
354 | 379 |
355 gdk_cursor_destroy (imhtml->hand_cursor); | 380 gdk_cursor_destroy (imhtml->hand_cursor); |
356 gdk_cursor_destroy (imhtml->arrow_cursor); | 381 gdk_cursor_destroy (imhtml->arrow_cursor); |
357 | 382 |
358 gtk_smiley_tree_destroy (imhtml->smiley_data); | 383 gtk_smiley_tree_destroy (imhtml->smiley_data); |
404 | 429 |
405 widget->style = gtk_style_attach (widget->style, widget->window); | 430 widget->style = gtk_style_attach (widget->style, widget->window); |
406 | 431 |
407 gdk_window_set_cursor (widget->window, imhtml->arrow_cursor); | 432 gdk_window_set_cursor (widget->window, imhtml->arrow_cursor); |
408 | 433 |
434 imhtml->default_font = gdk_font_ref (GTK_WIDGET (imhtml)->style->font); | |
435 | |
409 gdk_window_set_background (widget->window, &widget->style->base [GTK_STATE_NORMAL]); | 436 gdk_window_set_background (widget->window, &widget->style->base [GTK_STATE_NORMAL]); |
410 gdk_window_set_background (GTK_LAYOUT (imhtml)->bin_window, | 437 gdk_window_set_background (GTK_LAYOUT (imhtml)->bin_window, |
411 &widget->style->base [GTK_STATE_NORMAL]); | 438 &widget->style->base [GTK_STATE_NORMAL]); |
439 | |
440 imhtml->default_fg_color = gdk_color_copy (>K_WIDGET (imhtml)->style->fg [GTK_STATE_NORMAL]); | |
441 imhtml->default_bg_color = gdk_color_copy (>K_WIDGET (imhtml)->style->base [GTK_STATE_NORMAL]); | |
412 | 442 |
413 gdk_window_show (GTK_LAYOUT (imhtml)->bin_window); | 443 gdk_window_show (GTK_LAYOUT (imhtml)->bin_window); |
414 } | 444 } |
415 | 445 |
416 static gboolean | 446 static gboolean |
1779 if (imhtml->default_font) | 1809 if (imhtml->default_font) |
1780 return gdk_font_ref (imhtml->default_font); | 1810 return gdk_font_ref (imhtml->default_font); |
1781 return gdk_fontset_load ("-*-*-*-*-*-*-*-*-*-*-*-*-*-*,*"); | 1811 return gdk_fontset_load ("-*-*-*-*-*-*-*-*-*-*-*-*-*-*,*"); |
1782 } | 1812 } |
1783 | 1813 |
1784 g_snprintf (buf, sizeof (buf), "-*-%s-%s-%c-*-*-*-%d-*-*-*-*-iso8859-*", | 1814 g_snprintf (buf, sizeof (buf), "-*-%s-%s-%c-*-*-*-%d-*-*-*-*-%s", |
1785 choice, | 1815 choice, |
1786 bold ? "bold" : "medium", | 1816 bold ? "bold" : "medium", |
1787 italics ? 'i' : 'r', | 1817 italics ? 'i' : 'r', |
1788 size); | 1818 size, |
1819 getcharset()); | |
1789 font = gdk_font_load (buf); | 1820 font = gdk_font_load (buf); |
1790 | 1821 |
1791 if (!font && italics) { | 1822 if (!font && italics) { |
1792 g_snprintf (buf, sizeof (buf), "-*-%s-%s-o-*-*-*-%d-*-*-*-*-iso8859-*", | 1823 g_snprintf (buf, sizeof (buf), "-*-%s-%s-o-*-*-*-%d-*-*-*-*-%s", |
1793 choice, | 1824 choice, |
1794 bold ? "bold" : "medium", | 1825 bold ? "bold" : "medium", |
1795 size); | 1826 size, |
1827 getcharset()); | |
1796 font = gdk_font_load (buf); | 1828 font = gdk_font_load (buf); |
1797 } | 1829 } |
1798 | 1830 |
1799 if (!font) { | 1831 if (!font) { |
1800 g_snprintf (buf, sizeof (buf), "-*-%s-%s-%c-*-*-*-*-*-*-*-*-iso8859-*", | 1832 g_snprintf (buf, sizeof (buf), "-*-%s-%s-%c-*-*-*-*-*-*-*-*-%s", |
1801 choice, | 1833 choice, |
1802 bold ? "bold" : "medium", | 1834 bold ? "bold" : "medium", |
1803 italics ? 'i' : 'r'); | 1835 italics ? 'i' : 'r', |
1836 getcharset()); | |
1804 font = gdk_font_load (buf); | 1837 font = gdk_font_load (buf); |
1805 } | 1838 } |
1806 | 1839 |
1807 if (!font && italics) { | 1840 if (!font && italics) { |
1808 g_snprintf (buf, sizeof (buf), "-*-%s-%s-o-*-*-*-*-*-*-*-*-iso8859-*", | 1841 g_snprintf (buf, sizeof (buf), "-*-%s-%s-o-*-*-*-*-*-*-*-*-%s", |
1809 choice, | 1842 choice, |
1810 bold ? "bold" : "medium"); | 1843 bold ? "bold" : "medium", |
1844 getcharset()); | |
1811 font = gdk_font_load (buf); | 1845 font = gdk_font_load (buf); |
1812 } | 1846 } |
1813 | 1847 |
1814 if (!font) { | 1848 if (!font) { |
1815 g_snprintf (buf, sizeof (buf), "-*-%s-*-%c-*-*-*-*-*-*-*-*-iso8859-*", | 1849 g_snprintf (buf, sizeof (buf), "-*-%s-*-%c-*-*-*-*-*-*-*-*-%s", |
1816 choice, | 1850 choice, |
1817 italics ? 'i' : 'r'); | 1851 italics ? 'i' : 'r', |
1852 getcharset()); | |
1818 font = gdk_font_load (buf); | 1853 font = gdk_font_load (buf); |
1819 } | 1854 } |
1820 | 1855 |
1821 if (!font) { | 1856 if (!font) { |
1822 g_snprintf (buf, sizeof (buf), "-*-%s-*-%c-*-*-*-*-*-*-*-*-iso8859-*", | 1857 g_snprintf (buf, sizeof (buf), "-*-%s-*-%c-*-*-*-*-*-*-*-*-%s", |
1823 choice, | 1858 choice, |
1824 italics ? 'o' : '*'); | 1859 italics ? 'o' : '*', |
1860 getcharset()); | |
1825 font = gdk_font_load (buf); | 1861 font = gdk_font_load (buf); |
1826 } | 1862 } |
1827 | 1863 |
1828 if (!font && italics) { | 1864 if (!font && italics) { |
1829 g_snprintf (buf, sizeof (buf), "-*-%s-*-*-*-*-*-*-*-*-*-*-iso8859-*", | 1865 g_snprintf (buf, sizeof (buf), "-*-%s-*-*-*-*-*-*-*-*-*-*-%s", |
1830 choice); | 1866 choice, |
1867 getcharset()); | |
1831 font = gdk_font_load (buf); | 1868 font = gdk_font_load (buf); |
1832 } | 1869 } |
1833 | 1870 |
1834 if (!font) { | 1871 if (!font) { |
1835 g_snprintf (buf, sizeof (buf), "-*-%s-%s-%c-*-*-*-%d-*-*-*-*-*-*", | 1872 g_snprintf (buf, sizeof (buf), "-*-%s-%s-%c-*-*-*-%d-*-*-*-*-*-*", |
1912 { "STRING", 0, TARGET_STRING }, | 1949 { "STRING", 0, TARGET_STRING }, |
1913 { "TEXT", 0, TARGET_TEXT }, | 1950 { "TEXT", 0, TARGET_TEXT }, |
1914 { "COMPOUND_TEXT", 0, TARGET_COMPOUND_TEXT } | 1951 { "COMPOUND_TEXT", 0, TARGET_COMPOUND_TEXT } |
1915 }; | 1952 }; |
1916 | 1953 |
1917 imhtml->default_font = gdk_font_ref (GTK_WIDGET (imhtml)->style->font); | 1954 imhtml->default_font = gtk_imhtml_font_load (imhtml, DEFAULT_FONT_NAME, FALSE, FALSE, 0); |
1918 imhtml->default_fg_color = gdk_color_copy (>K_WIDGET (imhtml)->style->fg [GTK_STATE_NORMAL]); | |
1919 imhtml->default_bg_color = gdk_color_copy (>K_WIDGET (imhtml)->style->base [GTK_STATE_NORMAL]); | |
1920 imhtml->hand_cursor = gdk_cursor_new (GDK_HAND2); | 1955 imhtml->hand_cursor = gdk_cursor_new (GDK_HAND2); |
1921 imhtml->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); | 1956 imhtml->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); |
1922 | 1957 |
1923 GTK_WIDGET_SET_FLAGS (GTK_WIDGET (imhtml), GTK_CAN_FOCUS); | 1958 GTK_WIDGET_SET_FLAGS (GTK_WIDGET (imhtml), GTK_CAN_FOCUS); |
1924 gtk_selection_add_targets (GTK_WIDGET (imhtml), GDK_SELECTION_PRIMARY, targets, 3); | 1959 gtk_selection_add_targets (GTK_WIDGET (imhtml), GDK_SELECTION_PRIMARY, targets, 3); |