Tue, 01 Apr 2014 02:11:17 +0200
PidginSmileyTheme: working implementation for gtkprefs
| 10295 | 1 | /* |
| 15918 | 2 | * Themes for Pidgin |
| 10295 | 3 | * |
| 15918 | 4 | * Pidgin is the legal property of its developers, whose names are too numerous |
| 10295 | 5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 6 | * source distribution. | |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
7 | * |
| 10295 | 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18535
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 10295 | 21 | * |
| 22 | */ | |
| 23 | #include "internal.h" | |
| 15577 | 24 | #include "pidgin.h" |
| 10295 | 25 | |
| 26 | #include "conversation.h" | |
| 27 | #include "debug.h" | |
| 28 | #include "prpl.h" | |
| 29 | #include "util.h" | |
| 30 | ||
| 31 | #include "gtkconv.h" | |
| 32 | #include "gtkdialogs.h" | |
|
22443
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
33 | #include "gtksmiley.h" |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
34 | #include "gtkthemes.h" |
|
33263
be88fa13ff7d
Change smiley theme stuff to use GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
35 | #include "gtkwebview.h" |
| 10295 | 36 | |
|
35708
8903e6402d5b
PidginSmileyTheme: working implementation for gtkprefs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35500
diff
changeset
|
37 | struct PidginSmileyTheme { |
|
8903e6402d5b
PidginSmileyTheme: working implementation for gtkprefs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35500
diff
changeset
|
38 | char *path; |
|
8903e6402d5b
PidginSmileyTheme: working implementation for gtkprefs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35500
diff
changeset
|
39 | char *name; |
|
8903e6402d5b
PidginSmileyTheme: working implementation for gtkprefs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35500
diff
changeset
|
40 | char *desc; |
|
8903e6402d5b
PidginSmileyTheme: working implementation for gtkprefs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35500
diff
changeset
|
41 | char *icon; |
|
8903e6402d5b
PidginSmileyTheme: working implementation for gtkprefs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35500
diff
changeset
|
42 | char *author; |
|
8903e6402d5b
PidginSmileyTheme: working implementation for gtkprefs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35500
diff
changeset
|
43 | |
|
8903e6402d5b
PidginSmileyTheme: working implementation for gtkprefs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35500
diff
changeset
|
44 | struct PidginSmileyList *list; |
|
8903e6402d5b
PidginSmileyTheme: working implementation for gtkprefs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35500
diff
changeset
|
45 | }; |
|
8903e6402d5b
PidginSmileyTheme: working implementation for gtkprefs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35500
diff
changeset
|
46 | |
| 10295 | 47 | GSList *smiley_themes = NULL; |
|
35500
ae6432ea326f
Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents:
35086
diff
changeset
|
48 | struct PidginSmileyTheme *current_smiley_theme; |
| 10295 | 49 | |
|
35500
ae6432ea326f
Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents:
35086
diff
changeset
|
50 | static void pidgin_themes_destroy_smiley_theme_smileys(struct PidginSmileyTheme *theme); |
|
17481
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
51 | |
|
16263
27e0ef0f38e6
Word on the street is that we don't want things named pidginfoo_bar(), but
Richard Laager <rlaager@pidgin.im>
parents:
16212
diff
changeset
|
52 | gboolean pidgin_themes_smileys_disabled() |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
53 | { |
|
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
54 | if (!current_smiley_theme) |
|
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
55 | return 1; |
|
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
56 | |
|
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
57 | return strcmp(current_smiley_theme->name, "none") == 0; |
|
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
58 | } |
|
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
59 | |
|
17481
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
60 | static void |
|
35500
ae6432ea326f
Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents:
35086
diff
changeset
|
61 | pidgin_themes_destroy_smiley_theme(struct PidginSmileyTheme *theme) |
|
18535
360f2b11f562
Eliminate some duplicate code.
Richard Laager <rlaager@pidgin.im>
parents:
18348
diff
changeset
|
62 | { |
|
360f2b11f562
Eliminate some duplicate code.
Richard Laager <rlaager@pidgin.im>
parents:
18348
diff
changeset
|
63 | pidgin_themes_destroy_smiley_theme_smileys(theme); |
|
17481
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
64 | |
|
18535
360f2b11f562
Eliminate some duplicate code.
Richard Laager <rlaager@pidgin.im>
parents:
18348
diff
changeset
|
65 | g_free(theme->name); |
|
360f2b11f562
Eliminate some duplicate code.
Richard Laager <rlaager@pidgin.im>
parents:
18348
diff
changeset
|
66 | g_free(theme->desc); |
|
360f2b11f562
Eliminate some duplicate code.
Richard Laager <rlaager@pidgin.im>
parents:
18348
diff
changeset
|
67 | g_free(theme->author); |
|
360f2b11f562
Eliminate some duplicate code.
Richard Laager <rlaager@pidgin.im>
parents:
18348
diff
changeset
|
68 | g_free(theme->icon); |
|
360f2b11f562
Eliminate some duplicate code.
Richard Laager <rlaager@pidgin.im>
parents:
18348
diff
changeset
|
69 | g_free(theme->path); |
|
360f2b11f562
Eliminate some duplicate code.
Richard Laager <rlaager@pidgin.im>
parents:
18348
diff
changeset
|
70 | g_free(theme); |
|
17481
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
71 | } |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
72 | |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
73 | static void pidgin_themes_remove_theme_dir(const char *theme_dir_name) |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
74 | { |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
75 | GString *str = NULL; |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
76 | const char *file_name = NULL; |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
77 | GDir *theme_dir = NULL; |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
78 | |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
79 | if ((theme_dir = g_dir_open(theme_dir_name, 0, NULL)) != NULL) { |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
80 | if ((str = g_string_new(theme_dir_name)) != NULL) { |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
81 | while ((file_name = g_dir_read_name(theme_dir)) != NULL) { |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
82 | g_string_printf(str, "%s%s%s", theme_dir_name, G_DIR_SEPARATOR_S, file_name); |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
83 | g_unlink(str->str); |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
84 | } |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
85 | g_string_free(str, TRUE); |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
86 | } |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
87 | g_dir_close(theme_dir); |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
88 | g_rmdir(theme_dir_name); |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
89 | } |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
90 | } |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
91 | |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
92 | void pidgin_themes_remove_smiley_theme(const char *file) |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
93 | { |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
94 | char *theme_dir = NULL, *last_slash = NULL; |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
95 | g_return_if_fail(NULL != file); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
96 | |
|
17481
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
97 | if (!g_file_test(file, G_FILE_TEST_EXISTS)) return; |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
98 | if ((theme_dir = g_strdup(file)) == NULL) return ; |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
99 | |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
100 | if ((last_slash = g_strrstr(theme_dir, G_DIR_SEPARATOR_S)) != NULL) { |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
101 | GSList *iter = NULL; |
|
35500
ae6432ea326f
Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents:
35086
diff
changeset
|
102 | struct PidginSmileyTheme *theme = NULL, *new_theme = NULL; |
|
17481
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
103 | |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
104 | *last_slash = 0; |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
105 | |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
106 | /* Delete files on disk */ |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
107 | pidgin_themes_remove_theme_dir(theme_dir); |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
108 | |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
109 | /* Find theme in themes list and remove it */ |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
110 | for (iter = smiley_themes ; iter ; iter = iter->next) { |
|
35500
ae6432ea326f
Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents:
35086
diff
changeset
|
111 | theme = ((struct PidginSmileyTheme *)(iter->data)); |
|
17481
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
112 | if (!strcmp(theme->path, file)) |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
113 | break ; |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
114 | } |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
115 | if (iter) { |
|
17482
d4bbeba47e82
Figured out how to keep reflecting current smiley theme after remove.
Gabriel Schulhof <nix@go-nix.ca>
parents:
17481
diff
changeset
|
116 | if (theme == current_smiley_theme) { |
|
35500
ae6432ea326f
Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents:
35086
diff
changeset
|
117 | new_theme = ((struct PidginSmileyTheme *)(NULL == iter->next ? (smiley_themes == iter ? NULL : smiley_themes->data) : iter->next->data)); |
|
17482
d4bbeba47e82
Figured out how to keep reflecting current smiley theme after remove.
Gabriel Schulhof <nix@go-nix.ca>
parents:
17481
diff
changeset
|
118 | if (new_theme) |
|
d4bbeba47e82
Figured out how to keep reflecting current smiley theme after remove.
Gabriel Schulhof <nix@go-nix.ca>
parents:
17481
diff
changeset
|
119 | purple_prefs_set_string(PIDGIN_PREFS_ROOT "/smileys/theme", new_theme->name); |
|
d4bbeba47e82
Figured out how to keep reflecting current smiley theme after remove.
Gabriel Schulhof <nix@go-nix.ca>
parents:
17481
diff
changeset
|
120 | else |
|
d4bbeba47e82
Figured out how to keep reflecting current smiley theme after remove.
Gabriel Schulhof <nix@go-nix.ca>
parents:
17481
diff
changeset
|
121 | current_smiley_theme = NULL; |
|
d4bbeba47e82
Figured out how to keep reflecting current smiley theme after remove.
Gabriel Schulhof <nix@go-nix.ca>
parents:
17481
diff
changeset
|
122 | } |
|
17481
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
123 | smiley_themes = g_slist_delete_link(smiley_themes, iter); |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
124 | |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
125 | /* Destroy theme structure */ |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
126 | pidgin_themes_destroy_smiley_theme(theme); |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
127 | } |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
128 | } |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
129 | |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
130 | g_free(theme_dir); |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
131 | } |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
132 | |
|
33263
be88fa13ff7d
Change smiley theme stuff to use GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
133 | static void _pidgin_themes_smiley_themeize(GtkWidget *webview, gboolean custom) |
| 10295 | 134 | { |
|
35500
ae6432ea326f
Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents:
35086
diff
changeset
|
135 | struct PidginSmileyList *list; |
| 10295 | 136 | if (!current_smiley_theme) |
| 137 | return; | |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
138 | |
|
35500
ae6432ea326f
Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents:
35086
diff
changeset
|
139 | pidgin_webview_remove_smileys(PIDGIN_WEBVIEW(webview)); |
| 10295 | 140 | list = current_smiley_theme->list; |
| 141 | while (list) { | |
| 142 | char *sml = !strcmp(list->sml, "default") ? NULL : list->sml; | |
| 143 | GSList *icons = list->smileys; | |
| 144 | while (icons) { | |
|
35500
ae6432ea326f
Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents:
35086
diff
changeset
|
145 | pidgin_webview_associate_smiley(PIDGIN_WEBVIEW(webview), sml, icons->data); |
| 10295 | 146 | icons = icons->next; |
| 147 | } | |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22443
diff
changeset
|
148 | |
|
22443
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
149 | if (custom == TRUE) { |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
150 | icons = pidgin_smileys_get_all(); |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
151 | |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
152 | while (icons) { |
|
35500
ae6432ea326f
Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents:
35086
diff
changeset
|
153 | pidgin_webview_associate_smiley(PIDGIN_WEBVIEW(webview), sml, icons->data); |
|
22443
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
154 | icons = icons->next; |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
155 | } |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
156 | } |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
157 | |
| 10295 | 158 | list = list->next; |
| 159 | } | |
| 160 | } | |
| 161 | ||
|
33263
be88fa13ff7d
Change smiley theme stuff to use GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
162 | void |
|
be88fa13ff7d
Change smiley theme stuff to use GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
163 | pidgin_themes_smiley_themeize(GtkWidget *webview) |
|
22443
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
164 | { |
|
33263
be88fa13ff7d
Change smiley theme stuff to use GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
165 | _pidgin_themes_smiley_themeize(webview, FALSE); |
|
22443
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
166 | } |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
167 | |
|
33263
be88fa13ff7d
Change smiley theme stuff to use GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
168 | void |
|
be88fa13ff7d
Change smiley theme stuff to use GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
169 | pidgin_themes_smiley_themeize_custom(GtkWidget *webview) |
|
22443
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
170 | { |
|
33263
be88fa13ff7d
Change smiley theme stuff to use GtkWebView.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32577
diff
changeset
|
171 | _pidgin_themes_smiley_themeize(webview, TRUE); |
|
22443
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
172 | } |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
173 | |
|
16195
4e158cbe65cd
Pull out the same block of code from two places and put it into
Mark Doliner <markdoliner@pidgin.im>
parents:
16194
diff
changeset
|
174 | static void |
|
35500
ae6432ea326f
Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents:
35086
diff
changeset
|
175 | pidgin_themes_destroy_smiley_theme_smileys(struct PidginSmileyTheme *theme) |
|
16195
4e158cbe65cd
Pull out the same block of code from two places and put it into
Mark Doliner <markdoliner@pidgin.im>
parents:
16194
diff
changeset
|
176 | { |
|
35500
ae6432ea326f
Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents:
35086
diff
changeset
|
177 | struct PidginSmileyList *wer; |
|
16195
4e158cbe65cd
Pull out the same block of code from two places and put it into
Mark Doliner <markdoliner@pidgin.im>
parents:
16194
diff
changeset
|
178 | |
|
16211
670c6b68f7c5
Change a g_slist_append() to a g_slist_prepend() in one place, and
Mark Doliner <markdoliner@pidgin.im>
parents:
16195
diff
changeset
|
179 | for (wer = theme->list; wer != NULL; wer = theme->list) { |
|
16195
4e158cbe65cd
Pull out the same block of code from two places and put it into
Mark Doliner <markdoliner@pidgin.im>
parents:
16194
diff
changeset
|
180 | while (wer->smileys) { |
|
35500
ae6432ea326f
Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents:
35086
diff
changeset
|
181 | PidginWebViewSmiley *uio = wer->smileys->data; |
|
ae6432ea326f
Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents:
35086
diff
changeset
|
182 | pidgin_webview_smiley_destroy(uio); |
|
28077
c2b493e058f1
Don't use pointers (even opaquely) once they're freed. Closes #9822.
Paul Aurich <darkrain42@pidgin.im>
parents:
28075
diff
changeset
|
183 | wer->smileys = g_slist_delete_link(wer->smileys, wer->smileys); |
|
16195
4e158cbe65cd
Pull out the same block of code from two places and put it into
Mark Doliner <markdoliner@pidgin.im>
parents:
16194
diff
changeset
|
184 | } |
|
16211
670c6b68f7c5
Change a g_slist_append() to a g_slist_prepend() in one place, and
Mark Doliner <markdoliner@pidgin.im>
parents:
16195
diff
changeset
|
185 | theme->list = wer->next; |
|
16195
4e158cbe65cd
Pull out the same block of code from two places and put it into
Mark Doliner <markdoliner@pidgin.im>
parents:
16194
diff
changeset
|
186 | g_free(wer->sml); |
|
4e158cbe65cd
Pull out the same block of code from two places and put it into
Mark Doliner <markdoliner@pidgin.im>
parents:
16194
diff
changeset
|
187 | g_free(wer); |
|
4e158cbe65cd
Pull out the same block of code from two places and put it into
Mark Doliner <markdoliner@pidgin.im>
parents:
16194
diff
changeset
|
188 | } |
|
16211
670c6b68f7c5
Change a g_slist_append() to a g_slist_prepend() in one place, and
Mark Doliner <markdoliner@pidgin.im>
parents:
16195
diff
changeset
|
189 | theme->list = NULL; |
|
16195
4e158cbe65cd
Pull out the same block of code from two places and put it into
Mark Doliner <markdoliner@pidgin.im>
parents:
16194
diff
changeset
|
190 | } |
|
4e158cbe65cd
Pull out the same block of code from two places and put it into
Mark Doliner <markdoliner@pidgin.im>
parents:
16194
diff
changeset
|
191 | |
| 17521 | 192 | static void |
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
193 | pidgin_smiley_themes_remove_non_existing(void) |
| 17521 | 194 | { |
|
35500
ae6432ea326f
Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents:
35086
diff
changeset
|
195 | static struct PidginSmileyTheme *theme = NULL; |
| 17521 | 196 | GSList *iter = NULL; |
| 197 | ||
| 198 | if (!smiley_themes) return ; | |
| 199 | ||
| 200 | for (iter = smiley_themes ; iter ; iter = iter->next) { | |
|
35500
ae6432ea326f
Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents:
35086
diff
changeset
|
201 | theme = ((struct PidginSmileyTheme *)(iter->data)); |
| 17521 | 202 | if (!g_file_test(theme->path, G_FILE_TEST_EXISTS)) { |
| 203 | if (theme == current_smiley_theme) | |
|
35500
ae6432ea326f
Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents:
35086
diff
changeset
|
204 | current_smiley_theme = ((struct PidginSmileyTheme *)(NULL == iter->next ? NULL : iter->next->data)); |
|
18535
360f2b11f562
Eliminate some duplicate code.
Richard Laager <rlaager@pidgin.im>
parents:
18348
diff
changeset
|
205 | pidgin_themes_destroy_smiley_theme(theme); |
| 17521 | 206 | iter->data = NULL; |
| 207 | } | |
| 208 | } | |
| 209 | /* Remove all elements whose data is NULL */ | |
| 210 | smiley_themes = g_slist_remove_all(smiley_themes, NULL); | |
| 211 | ||
| 17522 | 212 | if (!current_smiley_theme && smiley_themes) { |
|
35500
ae6432ea326f
Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents:
35086
diff
changeset
|
213 | struct PidginSmileyTheme *smile = g_slist_last(smiley_themes)->data; |
| 17522 | 214 | pidgin_themes_load_smiley_theme(smile->path, TRUE); |
| 215 | } | |
| 17521 | 216 | } |
| 217 | ||
|
16263
27e0ef0f38e6
Word on the street is that we don't want things named pidginfoo_bar(), but
Richard Laager <rlaager@pidgin.im>
parents:
16212
diff
changeset
|
218 | void pidgin_themes_load_smiley_theme(const char *file, gboolean load) |
| 10295 | 219 | { |
|
34515
93d7461ccc1c
Read theme file as binary (to avoid windows messing with line endings and stuff
Daniel Atallah <datallah@pidgin.im>
parents:
34514
diff
changeset
|
220 | FILE *f = g_fopen(file, "rb"); |
| 10295 | 221 | char buf[256]; |
| 222 | char *i; | |
|
34514
46ba9c764edc
Fix handling of multibyte utf-8 characters in smiley theme files. Fixes #15756.
Daniel Atallah <datallah@pidgin.im>
parents:
31294
diff
changeset
|
223 | gsize line_nbr = 0; |
|
35500
ae6432ea326f
Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents:
35086
diff
changeset
|
224 | struct PidginSmileyTheme *theme=NULL; |
|
ae6432ea326f
Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents:
35086
diff
changeset
|
225 | struct PidginSmileyList *list = NULL; |
| 10295 | 226 | GSList *lst = smiley_themes; |
| 227 | char *dirname; | |
| 228 | ||
|
35708
8903e6402d5b
PidginSmileyTheme: working implementation for gtkprefs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35500
diff
changeset
|
229 | if (file == NULL) { |
|
8903e6402d5b
PidginSmileyTheme: working implementation for gtkprefs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35500
diff
changeset
|
230 | if (current_smiley_theme) |
|
8903e6402d5b
PidginSmileyTheme: working implementation for gtkprefs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35500
diff
changeset
|
231 | pidgin_themes_destroy_smiley_theme_smileys(current_smiley_theme); |
|
8903e6402d5b
PidginSmileyTheme: working implementation for gtkprefs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35500
diff
changeset
|
232 | current_smiley_theme = NULL; |
|
8903e6402d5b
PidginSmileyTheme: working implementation for gtkprefs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35500
diff
changeset
|
233 | return; |
|
8903e6402d5b
PidginSmileyTheme: working implementation for gtkprefs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35500
diff
changeset
|
234 | } |
|
8903e6402d5b
PidginSmileyTheme: working implementation for gtkprefs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35500
diff
changeset
|
235 | |
| 10295 | 236 | if (!f) |
| 237 | return; | |
| 238 | ||
| 239 | while (lst) { | |
|
35500
ae6432ea326f
Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents:
35086
diff
changeset
|
240 | struct PidginSmileyTheme *thm = lst->data; |
| 10295 | 241 | if (!strcmp(thm->path, file)) { |
| 242 | theme = thm; | |
| 243 | break; | |
| 244 | } | |
| 245 | lst = lst->next; | |
| 246 | } | |
| 247 | ||
|
28078
5f3cb020eb74
Oops, fix loading smiley themes.
Paul Aurich <darkrain42@pidgin.im>
parents:
28077
diff
changeset
|
248 | if (theme != NULL && theme == current_smiley_theme) { |
|
13587
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
249 | /* Don't reload the theme if it is already loaded */ |
|
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
250 | fclose(f); |
|
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
251 | return; |
| 10295 | 252 | } |
| 253 | ||
|
28075
2d472ed937db
Clarify load_smiley_theme a little. Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents:
25888
diff
changeset
|
254 | if (theme == NULL) { |
|
35500
ae6432ea326f
Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents:
35086
diff
changeset
|
255 | theme = g_new0(struct PidginSmileyTheme, 1); |
|
28075
2d472ed937db
Clarify load_smiley_theme a little. Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents:
25888
diff
changeset
|
256 | theme->path = g_strdup(file); |
|
2d472ed937db
Clarify load_smiley_theme a little. Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents:
25888
diff
changeset
|
257 | smiley_themes = g_slist_prepend(smiley_themes, theme); |
|
2d472ed937db
Clarify load_smiley_theme a little. Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents:
25888
diff
changeset
|
258 | } |
|
2d472ed937db
Clarify load_smiley_theme a little. Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents:
25888
diff
changeset
|
259 | |
| 10295 | 260 | dirname = g_path_get_dirname(file); |
| 261 | ||
| 262 | while (!feof(f)) { | |
| 263 | if (!fgets(buf, sizeof(buf), f)) { | |
| 264 | break; | |
| 265 | } | |
|
34514
46ba9c764edc
Fix handling of multibyte utf-8 characters in smiley theme files. Fixes #15756.
Daniel Atallah <datallah@pidgin.im>
parents:
31294
diff
changeset
|
266 | line_nbr++; |
| 10295 | 267 | |
| 268 | if (buf[0] == '#' || buf[0] == '\0') | |
| 269 | continue; | |
| 29252 | 270 | else { |
| 271 | int len = strlen(buf); | |
| 272 | while (len && (buf[len - 1] == '\r' || buf[len - 1] == '\n')) | |
| 273 | buf[--len] = '\0'; | |
| 274 | if (len == 0) | |
| 275 | continue; | |
| 276 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29252
diff
changeset
|
277 | |
|
34514
46ba9c764edc
Fix handling of multibyte utf-8 characters in smiley theme files. Fixes #15756.
Daniel Atallah <datallah@pidgin.im>
parents:
31294
diff
changeset
|
278 | if (! g_utf8_validate(buf, -1, NULL)) { |
| 35086 | 279 | purple_debug_error("gtkthemes", "%s:%" G_GSIZE_FORMAT " is invalid UTF-8\n", file, line_nbr); |
|
34514
46ba9c764edc
Fix handling of multibyte utf-8 characters in smiley theme files. Fixes #15756.
Daniel Atallah <datallah@pidgin.im>
parents:
31294
diff
changeset
|
280 | continue; |
|
46ba9c764edc
Fix handling of multibyte utf-8 characters in smiley theme files. Fixes #15756.
Daniel Atallah <datallah@pidgin.im>
parents:
31294
diff
changeset
|
281 | } |
|
46ba9c764edc
Fix handling of multibyte utf-8 characters in smiley theme files. Fixes #15756.
Daniel Atallah <datallah@pidgin.im>
parents:
31294
diff
changeset
|
282 | |
| 10295 | 283 | i = buf; |
| 284 | while (isspace(*i)) | |
| 285 | i++; | |
| 286 | ||
| 287 | if (*i == '[' && strchr(i, ']') && load) { | |
|
35500
ae6432ea326f
Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents:
35086
diff
changeset
|
288 | struct PidginSmileyList *child = g_new0(struct PidginSmileyList, 1); |
| 10295 | 289 | child->sml = g_strndup(i+1, strchr(i, ']') - i - 1); |
|
32439
2c681e5daeeb
Webkit Message views.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
25888
diff
changeset
|
290 | child->files = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); |
|
2c681e5daeeb
Webkit Message views.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
25888
diff
changeset
|
291 | |
| 10295 | 292 | if (theme->list) |
| 293 | list->next = child; | |
| 294 | else | |
| 295 | theme->list = child; | |
|
17534
609ab183a700
Reverse the smiley list only after reading the whole list of smileys in.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17474
diff
changeset
|
296 | /* Reverse the Smiley list since it was built in reverse order for efficiency reasons */ |
|
609ab183a700
Reverse the smiley list only after reading the whole list of smileys in.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17474
diff
changeset
|
297 | if (list != NULL) |
|
609ab183a700
Reverse the smiley list only after reading the whole list of smileys in.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17474
diff
changeset
|
298 | list->smileys = g_slist_reverse(list->smileys); |
| 10295 | 299 | list = child; |
| 300 | } else if (!g_ascii_strncasecmp(i, "Name=", strlen("Name="))) { | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13625
diff
changeset
|
301 | g_free(theme->name); |
|
17474
a7f61acc10f6
A somewhat-Warmenhoved patch from tfujiwara to allow for the smiley theme
Richard Laager <rlaager@pidgin.im>
parents:
16458
diff
changeset
|
302 | theme->name = g_strdup(i + strlen("Name=")); |
| 10295 | 303 | } else if (!g_ascii_strncasecmp(i, "Description=", strlen("Description="))) { |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13625
diff
changeset
|
304 | g_free(theme->desc); |
| 10295 | 305 | theme->desc = g_strdup(i + strlen("Description=")); |
| 306 | } else if (!g_ascii_strncasecmp(i, "Icon=", strlen("Icon="))) { | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13625
diff
changeset
|
307 | g_free(theme->icon); |
| 10295 | 308 | theme->icon = g_build_filename(dirname, i + strlen("Icon="), NULL); |
| 309 | } else if (!g_ascii_strncasecmp(i, "Author=", strlen("Author="))) { | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13625
diff
changeset
|
310 | g_free(theme->author); |
| 10295 | 311 | theme->author = g_strdup(i + strlen("Author=")); |
| 312 | } else if (load && list) { | |
| 313 | gboolean hidden = FALSE; | |
| 314 | char *sfile = NULL; | |
| 315 | ||
| 316 | if (*i == '!' && *(i + 1) == ' ') { | |
| 317 | hidden = TRUE; | |
| 318 | i = i + 2; | |
| 319 | } | |
| 320 | while (*i) { | |
| 321 | char l[64]; | |
|
34308
cdb187c27360
Fix the rest of Pidgin's warnings about -Wsign-compare; remove -Wno-sign-compare from cflags
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33263
diff
changeset
|
322 | gsize li = 0; |
|
34514
46ba9c764edc
Fix handling of multibyte utf-8 characters in smiley theme files. Fixes #15756.
Daniel Atallah <datallah@pidgin.im>
parents:
31294
diff
changeset
|
323 | char *next; |
|
29246
544942e54b98
Look for non-null before processing theme input. Closes #10521 (again).
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29241
diff
changeset
|
324 | while (*i && !isspace(*i) && li < sizeof(l) - 1) { |
| 29252 | 325 | if (*i == '\\' && *(i+1) != '\0') |
|
12915
d3efd3201aec
[gaim-migrate @ 15268]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11557
diff
changeset
|
326 | i++; |
|
34514
46ba9c764edc
Fix handling of multibyte utf-8 characters in smiley theme files. Fixes #15756.
Daniel Atallah <datallah@pidgin.im>
parents:
31294
diff
changeset
|
327 | next = g_utf8_next_char(i); |
| 35086 | 328 | if ((gsize)(next - i) > (sizeof(l) - li -1)) { |
|
34514
46ba9c764edc
Fix handling of multibyte utf-8 characters in smiley theme files. Fixes #15756.
Daniel Atallah <datallah@pidgin.im>
parents:
31294
diff
changeset
|
329 | break; |
|
46ba9c764edc
Fix handling of multibyte utf-8 characters in smiley theme files. Fixes #15756.
Daniel Atallah <datallah@pidgin.im>
parents:
31294
diff
changeset
|
330 | } |
|
46ba9c764edc
Fix handling of multibyte utf-8 characters in smiley theme files. Fixes #15756.
Daniel Atallah <datallah@pidgin.im>
parents:
31294
diff
changeset
|
331 | while (i != next) |
|
46ba9c764edc
Fix handling of multibyte utf-8 characters in smiley theme files. Fixes #15756.
Daniel Atallah <datallah@pidgin.im>
parents:
31294
diff
changeset
|
332 | l[li++] = *(i++); |
|
12915
d3efd3201aec
[gaim-migrate @ 15268]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11557
diff
changeset
|
333 | } |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22443
diff
changeset
|
334 | l[li] = 0; |
| 10295 | 335 | if (!sfile) { |
| 336 | sfile = g_build_filename(dirname, l, NULL); | |
| 337 | } else { | |
|
35500
ae6432ea326f
Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents:
35086
diff
changeset
|
338 | PidginWebViewSmiley *smiley = pidgin_webview_smiley_create(sfile, l, hidden, 0); |
|
16211
670c6b68f7c5
Change a g_slist_append() to a g_slist_prepend() in one place, and
Mark Doliner <markdoliner@pidgin.im>
parents:
16195
diff
changeset
|
339 | list->smileys = g_slist_prepend(list->smileys, smiley); |
|
32439
2c681e5daeeb
Webkit Message views.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
25888
diff
changeset
|
340 | g_hash_table_insert (list->files, g_strdup(l), g_strdup(sfile)); |
| 10295 | 341 | } |
| 342 | while (isspace(*i)) | |
| 343 | i++; | |
| 344 | ||
| 345 | } | |
|
16458
e0e45bccd8e2
Fix #273 (Emoticons appearing in reverse order).
Daniel Atallah <datallah@pidgin.im>
parents:
16263
diff
changeset
|
346 | |
|
e0e45bccd8e2
Fix #273 (Emoticons appearing in reverse order).
Daniel Atallah <datallah@pidgin.im>
parents:
16263
diff
changeset
|
347 | |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22443
diff
changeset
|
348 | g_free(sfile); |
| 10295 | 349 | } |
| 350 | } | |
| 351 | ||
|
17535
5f2b75cc8b92
We also need to reverse the last protocol's smiley list instead of only
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17534
diff
changeset
|
352 | /* Reverse the Smiley list since it was built in reverse order for efficiency reasons */ |
|
5f2b75cc8b92
We also need to reverse the last protocol's smiley list instead of only
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17534
diff
changeset
|
353 | if (list != NULL) |
|
5f2b75cc8b92
We also need to reverse the last protocol's smiley list instead of only
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17534
diff
changeset
|
354 | list->smileys = g_slist_reverse(list->smileys); |
|
5f2b75cc8b92
We also need to reverse the last protocol's smiley list instead of only
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17534
diff
changeset
|
355 | |
|
13587
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
356 | g_free(dirname); |
|
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
357 | fclose(f); |
|
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
358 | |
|
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
359 | if (!theme->name || !theme->desc || !theme->author) { |
| 15884 | 360 | purple_debug_error("gtkthemes", "Invalid file format, not loading smiley theme from '%s'\n", file); |
|
13587
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
361 | |
|
28075
2d472ed937db
Clarify load_smiley_theme a little. Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents:
25888
diff
changeset
|
362 | smiley_themes = g_slist_remove(smiley_themes, theme); |
|
18535
360f2b11f562
Eliminate some duplicate code.
Richard Laager <rlaager@pidgin.im>
parents:
18348
diff
changeset
|
363 | pidgin_themes_destroy_smiley_theme(theme); |
|
13587
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
364 | return; |
|
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
365 | } |
|
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
366 | |
| 10295 | 367 | if (load) { |
|
18122
9bf9970c1b6a
disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents:
18121
diff
changeset
|
368 | GList *cnv; |
| 10295 | 369 | |
|
16195
4e158cbe65cd
Pull out the same block of code from two places and put it into
Mark Doliner <markdoliner@pidgin.im>
parents:
16194
diff
changeset
|
370 | if (current_smiley_theme) |
|
17481
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
371 | pidgin_themes_destroy_smiley_theme_smileys(current_smiley_theme); |
|
13587
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
372 | current_smiley_theme = theme; |
|
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
373 | |
|
34655
6a939719ea98
Replaced purple_conversations_get() with purple_conversations_get_all(), similar to other purple entities
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
374 | for (cnv = purple_conversations_get_all(); cnv != NULL; cnv = cnv->next) { |
| 15884 | 375 | PurpleConversation *conv = cnv->data; |
| 10295 | 376 | |
|
15692
ecda27df58b9
Some more pidgininfication
Daniel Atallah <datallah@pidgin.im>
parents:
15577
diff
changeset
|
377 | if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) { |
|
22443
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
378 | /* We want to see our custom smileys on our entry if we write the shortcut */ |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
379 | pidgin_themes_smiley_themeize_custom(PIDGIN_CONVERSATION(conv)->entry); |
| 10295 | 380 | } |
| 381 | } | |
| 382 | } | |
| 383 | } | |
| 384 | ||
|
16263
27e0ef0f38e6
Word on the street is that we don't want things named pidginfoo_bar(), but
Richard Laager <rlaager@pidgin.im>
parents:
16212
diff
changeset
|
385 | void pidgin_themes_smiley_theme_probe() |
| 10295 | 386 | { |
| 387 | GDir *dir; | |
| 388 | const gchar *file; | |
| 17521 | 389 | gchar *path, *test_path; |
| 10295 | 390 | int l; |
| 17521 | 391 | char* probedirs[3]; |
| 10295 | 392 | |
| 17521 | 393 | pidgin_smiley_themes_remove_non_existing(); |
| 394 | ||
| 15918 | 395 | probedirs[0] = g_build_filename(DATADIR, "pixmaps", "pidgin", "emotes", NULL); |
| 15884 | 396 | probedirs[1] = g_build_filename(purple_user_dir(), "smileys", NULL); |
| 10295 | 397 | probedirs[2] = 0; |
| 398 | for (l=0; probedirs[l]; l++) { | |
| 399 | dir = g_dir_open(probedirs[l], 0, NULL); | |
| 400 | if (dir) { | |
| 401 | while ((file = g_dir_read_name(dir))) { | |
| 17521 | 402 | test_path = g_build_filename(probedirs[l], file, NULL); |
| 403 | if (g_file_test(test_path, G_FILE_TEST_IS_DIR)) { | |
| 404 | path = g_build_filename(probedirs[l], file, "theme", NULL); | |
| 10295 | 405 | |
| 17521 | 406 | /* Here we check to see that the theme has proper syntax. |
| 407 | * We set the second argument to FALSE so that it doesn't load | |
| 408 | * the theme yet. | |
| 409 | */ | |
| 410 | pidgin_themes_load_smiley_theme(path, FALSE); | |
| 411 | g_free(path); | |
| 412 | } | |
| 413 | g_free(test_path); | |
| 10295 | 414 | } |
| 415 | g_dir_close(dir); | |
| 416 | } else if (l == 1) { | |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
10295
diff
changeset
|
417 | g_mkdir(probedirs[l], S_IRUSR | S_IWUSR | S_IXUSR); |
| 10295 | 418 | } |
| 419 | g_free(probedirs[l]); | |
| 420 | } | |
| 17521 | 421 | |
| 17522 | 422 | if (!current_smiley_theme && smiley_themes) { |
|
35500
ae6432ea326f
Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents:
35086
diff
changeset
|
423 | struct PidginSmileyTheme *smile = smiley_themes->data; |
| 17522 | 424 | pidgin_themes_load_smiley_theme(smile->path, TRUE); |
| 425 | } | |
| 10295 | 426 | } |
| 427 | ||
|
16263
27e0ef0f38e6
Word on the street is that we don't want things named pidginfoo_bar(), but
Richard Laager <rlaager@pidgin.im>
parents:
16212
diff
changeset
|
428 | GSList *pidgin_themes_get_proto_smileys(const char *id) { |
| 15884 | 429 | PurplePlugin *proto; |
|
35500
ae6432ea326f
Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents:
35086
diff
changeset
|
430 | struct PidginSmileyList *list, *def; |
| 10295 | 431 | |
| 432 | if ((current_smiley_theme == NULL) || (current_smiley_theme->list == NULL)) | |
| 433 | return NULL; | |
| 434 | ||
| 435 | def = list = current_smiley_theme->list; | |
| 436 | ||
| 437 | if (id == NULL) | |
| 438 | return def->smileys; | |
| 439 | ||
| 15884 | 440 | proto = purple_find_prpl(id); |
| 10295 | 441 | |
| 442 | while (list) { | |
| 443 | if (!strcmp(list->sml, "default")) | |
| 444 | def = list; | |
| 445 | else if (proto && !strcmp(proto->info->name, list->sml)) | |
| 446 | break; | |
| 447 | ||
| 448 | list = list->next; | |
| 449 | } | |
| 450 | ||
| 451 | return list ? list->smileys : def->smileys; | |
| 452 | } | |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
453 | |
|
16263
27e0ef0f38e6
Word on the street is that we don't want things named pidginfoo_bar(), but
Richard Laager <rlaager@pidgin.im>
parents:
16212
diff
changeset
|
454 | void pidgin_themes_init() |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
455 | { |
|
11557
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
456 | GSList *l; |
|
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
457 | const char *current_theme = |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15918
diff
changeset
|
458 | purple_prefs_get_string(PIDGIN_PREFS_ROOT "/smileys/theme"); |
|
11557
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
459 | |
|
16263
27e0ef0f38e6
Word on the street is that we don't want things named pidginfoo_bar(), but
Richard Laager <rlaager@pidgin.im>
parents:
16212
diff
changeset
|
460 | pidgin_themes_smiley_theme_probe(); |
|
11557
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
461 | |
|
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
462 | for (l = smiley_themes; l; l = l->next) { |
|
35500
ae6432ea326f
Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents:
35086
diff
changeset
|
463 | struct PidginSmileyTheme *smile = l->data; |
|
11557
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
464 | if (smile->name && strcmp(current_theme, smile->name) == 0) { |
|
16263
27e0ef0f38e6
Word on the street is that we don't want things named pidginfoo_bar(), but
Richard Laager <rlaager@pidgin.im>
parents:
16212
diff
changeset
|
465 | pidgin_themes_load_smiley_theme(smile->path, TRUE); |
|
11557
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
466 | break; |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
467 | } |
|
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
468 | } |
|
11557
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
469 | |
|
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
470 | /* If we still don't have a smiley theme, choose the first one */ |
|
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
471 | if (!current_smiley_theme && smiley_themes) { |
|
35500
ae6432ea326f
Fixed namespace issues in Pidgin.
Ankit Vani <a@nevitus.org>
parents:
35086
diff
changeset
|
472 | struct PidginSmileyTheme *smile = smiley_themes->data; |
|
16263
27e0ef0f38e6
Word on the street is that we don't want things named pidginfoo_bar(), but
Richard Laager <rlaager@pidgin.im>
parents:
16212
diff
changeset
|
473 | pidgin_themes_load_smiley_theme(smile->path, TRUE); |
|
11557
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
474 | } |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
475 | } |