Mercurial > pidgin
comparison plugins/spellchk.c @ 12602:317d1dfedeed
[gaim-migrate @ 14937]
Adding a case sensitive option as per SF #1387378.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Wed, 21 Dec 2005 20:59:16 +0000 |
parents | e856f985a0b9 |
children | 022bf81f4087 |
comparison
equal
deleted
inserted
replaced
12601:e63fb8e9f4ac | 12602:317d1dfedeed |
---|---|
55 | 55 |
56 enum { | 56 enum { |
57 BAD_COLUMN, | 57 BAD_COLUMN, |
58 GOOD_COLUMN, | 58 GOOD_COLUMN, |
59 WORD_ONLY_COLUMN, | 59 WORD_ONLY_COLUMN, |
60 CASE_SENSITIVE_COLUMN, | |
60 N_COLUMNS | 61 N_COLUMNS |
61 }; | 62 }; |
62 | 63 |
63 struct _spellchk { | 64 struct _spellchk { |
64 GtkTextView *view; | 65 GtkTextView *view; |
208 foldedword = g_utf8_casefold(word, -1); | 209 foldedword = g_utf8_casefold(word, -1); |
209 | 210 |
210 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) { | 211 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) { |
211 do { | 212 do { |
212 GValue val1; | 213 GValue val1; |
214 gboolean case_sensitive; | |
213 const char *bad; | 215 const char *bad; |
214 gchar *tmpbad = NULL; | 216 gchar *tmpbad = NULL; |
215 | 217 |
216 val1.g_type = 0; | 218 val1.g_type = 0; |
217 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &iter, WORD_ONLY_COLUMN, &val1); | 219 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &iter, WORD_ONLY_COLUMN, &val1); |
219 g_value_unset(&val1); | 221 g_value_unset(&val1); |
220 continue; | 222 continue; |
221 } | 223 } |
222 g_value_unset(&val1); | 224 g_value_unset(&val1); |
223 | 225 |
226 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &iter, CASE_SENSITIVE_COLUMN, &val1); | |
227 case_sensitive = g_value_get_boolean(&val1); | |
228 g_value_unset(&val1); | |
229 | |
224 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &iter, BAD_COLUMN, &val1); | 230 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &iter, BAD_COLUMN, &val1); |
225 bad = g_value_get_string(&val1); | 231 bad = g_value_get_string(&val1); |
226 | 232 |
227 if (!strcmp(bad, lowerword) || | 233 if ((case_sensitive && !strcmp(bad, word)) || |
228 (!is_word_lowercase(bad) && | 234 (!case_sensitive && (!strcmp(bad, lowerword) || |
229 !strcmp((tmpbad = g_utf8_casefold(bad, -1)), foldedword))) | 235 (!is_word_lowercase(bad) && |
236 !strcmp((tmpbad = g_utf8_casefold(bad, -1)), foldedword))))) | |
230 { | 237 { |
231 GValue val2; | 238 GValue val2; |
232 const char *good; | 239 const char *good; |
233 | 240 |
234 g_free(tmpbad); | 241 g_free(tmpbad); |
235 | 242 |
236 val2.g_type = 0; | 243 val2.g_type = 0; |
237 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &iter, GOOD_COLUMN, &val2); | 244 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &iter, GOOD_COLUMN, &val2); |
238 good = g_value_get_string(&val2); | 245 good = g_value_get_string(&val2); |
239 | 246 |
240 if (is_word_lowercase(bad) && is_word_lowercase(good)) | 247 if (!case_sensitive && is_word_lowercase(bad) && is_word_lowercase(good)) |
241 { | 248 { |
242 if (is_word_uppercase(word)) | 249 if (is_word_uppercase(word)) |
243 outword = g_utf8_strup(good, -1); | 250 outword = g_utf8_strup(good, -1); |
244 else if (is_word_proper(word)) | 251 else if (is_word_proper(word)) |
245 outword = make_word_proper(good); | 252 outword = make_word_proper(good); |
1683 char bad[82] = ""; | 1690 char bad[82] = ""; |
1684 char good[256] = ""; | 1691 char good[256] = ""; |
1685 int pnt = 0; | 1692 int pnt = 0; |
1686 gsize size; | 1693 gsize size; |
1687 gboolean complete = TRUE; | 1694 gboolean complete = TRUE; |
1695 gboolean case_sensitive = FALSE; | |
1688 | 1696 |
1689 buf = g_build_filename(gaim_user_dir(), "dict", NULL); | 1697 buf = g_build_filename(gaim_user_dir(), "dict", NULL); |
1690 g_file_get_contents(buf, &ibuf, &size, NULL); | 1698 g_file_get_contents(buf, &ibuf, &size, NULL); |
1691 g_free(buf); | 1699 g_free(buf); |
1692 if (!ibuf) { | 1700 if (!ibuf) { |
1693 ibuf = g_strdup(defaultconf); | 1701 ibuf = g_strdup(defaultconf); |
1694 size = strlen(defaultconf); | 1702 size = strlen(defaultconf); |
1695 } | 1703 } |
1696 | 1704 |
1697 model = gtk_list_store_new((gint)N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN); | 1705 model = gtk_list_store_new((gint)N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN); |
1698 hashes = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); | 1706 hashes = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); |
1699 | 1707 |
1700 while (buf_get_line(ibuf, &buf, &pnt, size)) { | 1708 while (buf_get_line(ibuf, &buf, &pnt, size)) { |
1701 if (*buf != '#') { | 1709 if (*buf != '#') { |
1702 if (!strncasecmp(buf, "BAD ", 4)) | 1710 if (!strncasecmp(buf, "BAD ", 4)) |
1703 { | 1711 { |
1704 strncpy(bad, buf + 4, 81); | 1712 strncpy(bad, buf + 4, 81); |
1713 } | |
1714 else if(!strncasecmp(buf, "CASE ", 5)) | |
1715 { | |
1716 case_sensitive = *(buf+5) == '0' ? FALSE : TRUE; | |
1705 } | 1717 } |
1706 else if(!strncasecmp(buf, "COMPLETE ", 9)) | 1718 else if(!strncasecmp(buf, "COMPLETE ", 9)) |
1707 { | 1719 { |
1708 complete = *(buf+9) == '0' ? FALSE : TRUE; | 1720 complete = *(buf+9) == '0' ? FALSE : TRUE; |
1709 } | 1721 } |
1718 * hash is just being used to eliminate duplicate bad strings. | 1730 * hash is just being used to eliminate duplicate bad strings. |
1719 * The value has to be non-NULL so the lookup above will work. | 1731 * The value has to be non-NULL so the lookup above will work. |
1720 */ | 1732 */ |
1721 g_hash_table_insert(hashes, g_strdup(bad), GINT_TO_POINTER(1)); | 1733 g_hash_table_insert(hashes, g_strdup(bad), GINT_TO_POINTER(1)); |
1722 | 1734 |
1735 if (!complete) | |
1736 case_sensitive = TRUE; | |
1737 | |
1723 gtk_list_store_append(model, &iter); | 1738 gtk_list_store_append(model, &iter); |
1724 gtk_list_store_set(model, &iter, | 1739 gtk_list_store_set(model, &iter, |
1725 0, bad, | 1740 BAD_COLUMN, bad, |
1726 1, good, | 1741 GOOD_COLUMN, good, |
1727 2, complete, | 1742 WORD_ONLY_COLUMN, complete, |
1743 CASE_SENSITIVE_COLUMN, case_sensitive, | |
1728 -1); | 1744 -1); |
1729 } | 1745 } |
1730 bad[0] = '\0'; | 1746 bad[0] = '\0'; |
1731 complete = TRUE; | 1747 complete = TRUE; |
1748 case_sensitive = FALSE; | |
1732 } | 1749 } |
1733 } | 1750 } |
1734 } | 1751 } |
1735 g_free(ibuf); | 1752 g_free(ibuf); |
1736 g_hash_table_destroy(hashes); | 1753 g_hash_table_destroy(hashes); |
1741 | 1758 |
1742 static GtkWidget *tree; | 1759 static GtkWidget *tree; |
1743 static GtkWidget *bad_entry; | 1760 static GtkWidget *bad_entry; |
1744 static GtkWidget *good_entry; | 1761 static GtkWidget *good_entry; |
1745 static GtkWidget *complete_toggle; | 1762 static GtkWidget *complete_toggle; |
1763 static GtkWidget *case_toggle; | |
1746 | 1764 |
1747 static void save_list(void); | 1765 static void save_list(void); |
1748 | 1766 |
1749 static void on_edited(GtkCellRendererText *cellrenderertext, | 1767 static void on_edited(GtkCellRendererText *cellrenderertext, |
1750 gchar *path, gchar *arg2, gpointer data) | 1768 gchar *path, gchar *arg2, gpointer data) |
1767 } | 1785 } |
1768 g_value_unset(&val); | 1786 g_value_unset(&val); |
1769 } | 1787 } |
1770 | 1788 |
1771 | 1789 |
1772 static void on_toggled(GtkCellRendererToggle *cellrenderertoggle, | 1790 static void word_only_toggled(GtkCellRendererToggle *cellrenderertoggle, |
1773 gchar *path, gpointer data){ | 1791 gchar *path, gpointer data){ |
1774 GtkTreeIter iter; | 1792 GtkTreeIter iter; |
1775 gboolean enabled; | 1793 gboolean enabled; |
1776 | 1794 |
1777 g_return_if_fail(gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(model), &iter, path)); | 1795 g_return_if_fail(gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(model), &iter, path)); |
1779 WORD_ONLY_COLUMN, &enabled, | 1797 WORD_ONLY_COLUMN, &enabled, |
1780 -1); | 1798 -1); |
1781 | 1799 |
1782 gtk_list_store_set(GTK_LIST_STORE(model), &iter, | 1800 gtk_list_store_set(GTK_LIST_STORE(model), &iter, |
1783 WORD_ONLY_COLUMN, !enabled, | 1801 WORD_ONLY_COLUMN, !enabled, |
1802 -1); | |
1803 | |
1804 /* I want to be sure that the above change has happened to the GtkTreeView first. */ | |
1805 gtk_list_store_set(GTK_LIST_STORE(model), &iter, | |
1806 CASE_SENSITIVE_COLUMN, enabled, | |
1807 -1); | |
1808 | |
1809 save_list(); | |
1810 } | |
1811 | |
1812 static void case_sensitive_toggled(GtkCellRendererToggle *cellrenderertoggle, | |
1813 gchar *path, gpointer data){ | |
1814 GtkTreeIter iter; | |
1815 gboolean enabled; | |
1816 | |
1817 g_return_if_fail(gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(model), &iter, path)); | |
1818 | |
1819 /* Prevent the case sensitive column from changing on non-whole word replacements. | |
1820 * Ideally, the column would be set insensitive in the word_only_toggled callback. */ | |
1821 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, | |
1822 WORD_ONLY_COLUMN, &enabled, | |
1823 -1); | |
1824 if (!enabled) | |
1825 return; | |
1826 | |
1827 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, | |
1828 CASE_SENSITIVE_COLUMN, &enabled, | |
1829 -1); | |
1830 | |
1831 gtk_list_store_set(GTK_LIST_STORE(model), &iter, | |
1832 CASE_SENSITIVE_COLUMN, !enabled, | |
1784 -1); | 1833 -1); |
1785 | 1834 |
1786 save_list(); | 1835 save_list(); |
1787 } | 1836 } |
1788 | 1837 |
1824 gtk_list_store_append(model, &iter); | 1873 gtk_list_store_append(model, &iter); |
1825 gtk_list_store_set(model, &iter, | 1874 gtk_list_store_set(model, &iter, |
1826 BAD_COLUMN, gtk_entry_get_text(GTK_ENTRY(bad_entry)), | 1875 BAD_COLUMN, gtk_entry_get_text(GTK_ENTRY(bad_entry)), |
1827 GOOD_COLUMN, gtk_entry_get_text(GTK_ENTRY(good_entry)), | 1876 GOOD_COLUMN, gtk_entry_get_text(GTK_ENTRY(good_entry)), |
1828 WORD_ONLY_COLUMN, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(complete_toggle)), | 1877 WORD_ONLY_COLUMN, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(complete_toggle)), |
1878 CASE_SENSITIVE_COLUMN, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(case_toggle)), | |
1829 -1); | 1879 -1); |
1830 | 1880 |
1831 gtk_editable_delete_text(GTK_EDITABLE(bad_entry), 0, -1); | 1881 gtk_editable_delete_text(GTK_EDITABLE(bad_entry), 0, -1); |
1832 gtk_editable_delete_text(GTK_EDITABLE(good_entry), 0, -1); | 1882 gtk_editable_delete_text(GTK_EDITABLE(good_entry), 0, -1); |
1833 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(complete_toggle), TRUE); | 1883 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(complete_toggle), TRUE); |
1884 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(complete_toggle), FALSE); | |
1834 gtk_widget_grab_focus(bad_entry); | 1885 gtk_widget_grab_focus(bad_entry); |
1835 | 1886 |
1836 save_list(); | 1887 save_list(); |
1837 } | 1888 } |
1838 | 1889 |
1885 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) { | 1936 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) { |
1886 do { | 1937 do { |
1887 GValue val0; | 1938 GValue val0; |
1888 GValue val1; | 1939 GValue val1; |
1889 GValue val2; | 1940 GValue val2; |
1941 GValue val3; | |
1890 | 1942 |
1891 val0.g_type = 0; | 1943 val0.g_type = 0; |
1892 val1.g_type = 0; | 1944 val1.g_type = 0; |
1893 val2.g_type = 0; | 1945 val2.g_type = 0; |
1946 val3.g_type = 0; | |
1894 | 1947 |
1895 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &iter, BAD_COLUMN, &val0); | 1948 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &iter, BAD_COLUMN, &val0); |
1896 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &iter, GOOD_COLUMN, &val1); | 1949 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &iter, GOOD_COLUMN, &val1); |
1897 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &iter, WORD_ONLY_COLUMN, &val2); | 1950 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &iter, WORD_ONLY_COLUMN, &val2); |
1898 | 1951 gtk_tree_model_get_value(GTK_TREE_MODEL(model), &iter, CASE_SENSITIVE_COLUMN, &val3); |
1899 g_string_append_printf(data, "COMPLETE %d\nBAD %s\nGOOD %s\n\n", g_value_get_boolean(&val2), g_value_get_string(&val0), g_value_get_string(&val1)); | 1952 |
1953 g_string_append_printf(data, "COMPLETE %d\nCASE %d\nBAD %s\nGOOD %s\n\n", | |
1954 g_value_get_boolean(&val2), | |
1955 g_value_get_boolean(&val3), | |
1956 g_value_get_string(&val0), | |
1957 g_value_get_string(&val1)); | |
1900 | 1958 |
1901 g_value_unset(&val0); | 1959 g_value_unset(&val0); |
1902 g_value_unset(&val1); | 1960 g_value_unset(&val1); |
1903 g_value_unset(&val2); | 1961 g_value_unset(&val2); |
1962 g_value_unset(&val3); | |
1904 | 1963 |
1905 } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter)); | 1964 } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter)); |
1906 } | 1965 } |
1907 | 1966 |
1908 gaim_util_write_data_to_file("dict", data->str, -1); | 1967 gaim_util_write_data_to_file("dict", data->str, -1); |
1973 { | 2032 { |
1974 spellchk_detach((GaimConversation *)convs->data); | 2033 spellchk_detach((GaimConversation *)convs->data); |
1975 } | 2034 } |
1976 | 2035 |
1977 return TRUE; | 2036 return TRUE; |
2037 } | |
2038 | |
2039 static void whole_words_button_toggled(GtkToggleButton *complete_toggle, GtkToggleButton *case_toggle) | |
2040 { | |
2041 gboolean enabled = gtk_toggle_button_get_active(complete_toggle); | |
2042 | |
2043 gtk_toggle_button_set_active(case_toggle, !enabled); | |
2044 gtk_widget_set_sensitive(GTK_WIDGET(case_toggle), enabled); | |
1978 } | 2045 } |
1979 | 2046 |
1980 static GtkWidget * | 2047 static GtkWidget * |
1981 get_config_frame(GaimPlugin *plugin) | 2048 get_config_frame(GaimPlugin *plugin) |
1982 { | 2049 { |
1991 ret = gtk_vbox_new(FALSE, 18); | 2058 ret = gtk_vbox_new(FALSE, 18); |
1992 gtk_container_set_border_width (GTK_CONTAINER(ret), 12); | 2059 gtk_container_set_border_width (GTK_CONTAINER(ret), 12); |
1993 | 2060 |
1994 vbox = gaim_gtk_make_frame(ret, _("Text Replacements")); | 2061 vbox = gaim_gtk_make_frame(ret, _("Text Replacements")); |
1995 gtk_container_set_border_width(GTK_CONTAINER(vbox), 4); | 2062 gtk_container_set_border_width(GTK_CONTAINER(vbox), 4); |
1996 gtk_widget_set_size_request(vbox, 445, -1); | |
1997 gtk_widget_show(vbox); | 2063 gtk_widget_show(vbox); |
1998 | 2064 |
1999 win = gtk_scrolled_window_new(0, 0); | 2065 win = gtk_scrolled_window_new(0, 0); |
2000 gtk_container_add(GTK_CONTAINER(vbox), win); | 2066 gtk_box_pack_start(GTK_BOX(vbox), win, TRUE, TRUE, 0); |
2001 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(win), | 2067 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(win), |
2002 GTK_SHADOW_IN); | 2068 GTK_SHADOW_IN); |
2003 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(win), | 2069 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(win), |
2004 GTK_POLICY_AUTOMATIC, | 2070 GTK_POLICY_NEVER, |
2005 GTK_POLICY_AUTOMATIC); | 2071 GTK_POLICY_ALWAYS); |
2006 gtk_widget_show(win); | 2072 gtk_widget_show(win); |
2007 | 2073 |
2008 tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model)); | 2074 tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model)); |
2009 /* gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tree), TRUE); */ | 2075 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tree), TRUE); |
2010 gtk_widget_set_size_request(tree, 445, 200); | 2076 gtk_widget_set_size_request(tree, -1, 200); |
2011 | 2077 |
2012 renderer = gtk_cell_renderer_text_new(); | 2078 renderer = gtk_cell_renderer_text_new(); |
2013 g_object_set(G_OBJECT(renderer), | 2079 g_object_set(G_OBJECT(renderer), |
2014 "editable", TRUE, | 2080 "editable", TRUE, |
2015 NULL); | 2081 NULL); |
2016 g_signal_connect(G_OBJECT(renderer), "edited", | 2082 g_signal_connect(G_OBJECT(renderer), "edited", |
2017 G_CALLBACK(on_edited), GINT_TO_POINTER(0)); | 2083 G_CALLBACK(on_edited), GINT_TO_POINTER(0)); |
2018 column = gtk_tree_view_column_new_with_attributes(_("You type"), | 2084 column = gtk_tree_view_column_new_with_attributes(_("You type"), renderer, |
2019 renderer, "text", BAD_COLUMN, NULL); | 2085 "text", BAD_COLUMN, |
2086 NULL); | |
2020 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); | 2087 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); |
2021 gtk_tree_view_column_set_fixed_width(column, 130); | 2088 gtk_tree_view_column_set_fixed_width(column, 150); |
2022 /* gtk_tree_view_column_set_resizable(column, TRUE); */ | 2089 gtk_tree_view_column_set_resizable(column, TRUE); |
2023 gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); | 2090 gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); |
2091 | |
2024 renderer = gtk_cell_renderer_text_new(); | 2092 renderer = gtk_cell_renderer_text_new(); |
2025 g_object_set(G_OBJECT(renderer), | 2093 g_object_set(G_OBJECT(renderer), |
2026 "editable", TRUE, | 2094 "editable", TRUE, |
2027 NULL); | 2095 NULL); |
2028 g_signal_connect(G_OBJECT(renderer), "edited", | 2096 g_signal_connect(G_OBJECT(renderer), "edited", |
2029 G_CALLBACK(on_edited), GINT_TO_POINTER(1)); | 2097 G_CALLBACK(on_edited), GINT_TO_POINTER(1)); |
2030 column = gtk_tree_view_column_new_with_attributes(_("You send"), | 2098 column = gtk_tree_view_column_new_with_attributes(_("You send"), renderer, |
2031 renderer, "text", GOOD_COLUMN, NULL); | 2099 "text", GOOD_COLUMN, |
2100 NULL); | |
2032 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); | 2101 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); |
2033 gtk_tree_view_column_set_fixed_width(column, 150); | 2102 gtk_tree_view_column_set_fixed_width(column, 150); |
2034 /* gtk_tree_view_column_set_resizable(column, TRUE); */ | 2103 gtk_tree_view_column_set_resizable(column, TRUE); |
2035 gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); | 2104 gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); |
2105 | |
2036 renderer = gtk_cell_renderer_toggle_new(); | 2106 renderer = gtk_cell_renderer_toggle_new(); |
2037 g_object_set(G_OBJECT(renderer), | 2107 g_object_set(G_OBJECT(renderer), |
2038 "activatable", TRUE, | 2108 "activatable", TRUE, |
2039 NULL); | 2109 NULL); |
2040 g_signal_connect(G_OBJECT(renderer), "toggled", | 2110 g_signal_connect(G_OBJECT(renderer), "toggled", |
2041 G_CALLBACK(on_toggled), GINT_TO_POINTER(2)); | 2111 G_CALLBACK(word_only_toggled), NULL); |
2042 column = gtk_tree_view_column_new_with_attributes(_("Whole words only"), | 2112 column = gtk_tree_view_column_new_with_attributes(_("Whole words only"), renderer, |
2043 renderer, "active", WORD_ONLY_COLUMN, NULL); | 2113 "active", WORD_ONLY_COLUMN, |
2044 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); | 2114 NULL); |
2045 gtk_tree_view_column_set_fixed_width(column, 130); | 2115 gtk_tree_view_column_set_resizable(column, TRUE); |
2046 /* gtk_tree_view_column_set_resizable(column, TRUE); */ | |
2047 gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); | 2116 gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); |
2117 | |
2118 renderer = gtk_cell_renderer_toggle_new(); | |
2119 g_object_set(G_OBJECT(renderer), | |
2120 "activatable", TRUE, | |
2121 NULL); | |
2122 g_signal_connect(G_OBJECT(renderer), "toggled", | |
2123 G_CALLBACK(case_sensitive_toggled), NULL); | |
2124 column = gtk_tree_view_column_new_with_attributes(_("Case sensitive"), renderer, | |
2125 "active", CASE_SENSITIVE_COLUMN, | |
2126 NULL); | |
2127 gtk_tree_view_column_set_resizable(column, TRUE); | |
2128 gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); | |
2129 | |
2048 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)), | 2130 gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)), |
2049 GTK_SELECTION_MULTIPLE); | 2131 GTK_SELECTION_MULTIPLE); |
2050 gtk_container_add(GTK_CONTAINER(win), tree); | 2132 gtk_container_add(GTK_CONTAINER(win), tree); |
2051 gtk_widget_show(tree); | 2133 gtk_widget_show(tree); |
2052 | 2134 |
2064 "changed", G_CALLBACK(on_selection_changed), button); | 2146 "changed", G_CALLBACK(on_selection_changed), button); |
2065 | 2147 |
2066 gtk_widget_show(button); | 2148 gtk_widget_show(button); |
2067 | 2149 |
2068 vbox = gaim_gtk_make_frame(ret, _("Add a new text replacement")); | 2150 vbox = gaim_gtk_make_frame(ret, _("Add a new text replacement")); |
2069 gtk_widget_set_size_request(vbox, 300, -1); | |
2070 | 2151 |
2071 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | 2152 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
2072 sg2 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | 2153 sg2 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
2073 | 2154 |
2074 hbox = gtk_hbox_new(FALSE, 2); | 2155 hbox = gtk_hbox_new(FALSE, 2); |
2079 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | 2160 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
2080 gtk_size_group_add_widget(sg, label); | 2161 gtk_size_group_add_widget(sg, label); |
2081 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | 2162 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
2082 | 2163 |
2083 bad_entry = gtk_entry_new(); | 2164 bad_entry = gtk_entry_new(); |
2084 gtk_entry_set_max_length(GTK_ENTRY(bad_entry), 40); | 2165 /* Set a minimum size. Since they're in a size group, the other entry will match up. */ |
2166 gtk_widget_set_size_request(bad_entry, 350, -1); | |
2085 gtk_box_pack_start(GTK_BOX(hbox), bad_entry, TRUE, TRUE, 0); | 2167 gtk_box_pack_start(GTK_BOX(hbox), bad_entry, TRUE, TRUE, 0); |
2086 gtk_size_group_add_widget(sg2, bad_entry); | 2168 gtk_size_group_add_widget(sg2, bad_entry); |
2087 gtk_label_set_mnemonic_widget(GTK_LABEL(label), bad_entry); | 2169 gtk_label_set_mnemonic_widget(GTK_LABEL(label), bad_entry); |
2088 gtk_widget_show(bad_entry); | 2170 gtk_widget_show(bad_entry); |
2089 | 2171 |
2095 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | 2177 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
2096 gtk_size_group_add_widget(sg, label); | 2178 gtk_size_group_add_widget(sg, label); |
2097 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | 2179 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
2098 | 2180 |
2099 good_entry = gtk_entry_new(); | 2181 good_entry = gtk_entry_new(); |
2100 gtk_entry_set_max_length(GTK_ENTRY(good_entry), 255); | |
2101 gtk_box_pack_start(GTK_BOX(hbox), good_entry, TRUE, TRUE, 0); | 2182 gtk_box_pack_start(GTK_BOX(hbox), good_entry, TRUE, TRUE, 0); |
2102 gtk_size_group_add_widget(sg2, good_entry); | 2183 gtk_size_group_add_widget(sg2, good_entry); |
2103 gtk_label_set_mnemonic_widget(GTK_LABEL(label), good_entry); | 2184 gtk_label_set_mnemonic_widget(GTK_LABEL(label), good_entry); |
2104 gtk_widget_show(good_entry); | 2185 gtk_widget_show(good_entry); |
2105 | 2186 |
2187 /* Created here so it can be passed to whole_words_button_toggled. */ | |
2188 case_toggle = gtk_check_button_new_with_mnemonic(_("_Exact case match (uncheck for automatic case handling)")); | |
2189 | |
2106 complete_toggle = gtk_check_button_new_with_mnemonic(_("Only replace _whole words")); | 2190 complete_toggle = gtk_check_button_new_with_mnemonic(_("Only replace _whole words")); |
2107 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(complete_toggle), TRUE); | 2191 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(complete_toggle), TRUE); |
2192 g_signal_connect(G_OBJECT(complete_toggle), "clicked", | |
2193 G_CALLBACK(whole_words_button_toggled), case_toggle); | |
2108 gtk_widget_show(complete_toggle); | 2194 gtk_widget_show(complete_toggle); |
2109 gtk_box_pack_start(GTK_BOX(vbox), complete_toggle, FALSE, FALSE, 0); | 2195 gtk_box_pack_start(GTK_BOX(vbox), complete_toggle, FALSE, FALSE, 0); |
2196 | |
2197 /* The button is created above so it can be passed to whole_words_button_toggled. */ | |
2198 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(case_toggle), FALSE); | |
2199 gtk_widget_show(case_toggle); | |
2200 gtk_box_pack_start(GTK_BOX(vbox), case_toggle, FALSE, FALSE, 0); | |
2110 | 2201 |
2111 hbox = gtk_hbutton_box_new(); | 2202 hbox = gtk_hbutton_box_new(); |
2112 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | 2203 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
2113 button = gtk_button_new_from_stock(GTK_STOCK_ADD); | 2204 button = gtk_button_new_from_stock(GTK_STOCK_ADD); |
2114 g_signal_connect(G_OBJECT(button), "clicked", | 2205 g_signal_connect(G_OBJECT(button), "clicked", |