Thu, 31 May 2012 05:45:28 +0000
No need to search for accounts when we already have a list of them.
| 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" | |
| 33 | #include "gtkimhtml.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
|
34 | #include "gtksmiley.h" |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
35 | #include "gtkthemes.h" |
| 10295 | 36 | |
| 37 | GSList *smiley_themes = NULL; | |
| 38 | struct smiley_theme *current_smiley_theme; | |
| 39 | ||
|
17481
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
40 | static void pidgin_themes_destroy_smiley_theme_smileys(struct smiley_theme *theme); |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
41 | |
|
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
|
42 | gboolean pidgin_themes_smileys_disabled() |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
43 | { |
|
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
44 | if (!current_smiley_theme) |
|
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
45 | return 1; |
|
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
46 | |
|
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
47 | return strcmp(current_smiley_theme->name, "none") == 0; |
|
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
48 | } |
|
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
49 | |
|
17481
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
50 | static void |
|
18535
360f2b11f562
Eliminate some duplicate code.
Richard Laager <rlaager@pidgin.im>
parents:
18348
diff
changeset
|
51 | pidgin_themes_destroy_smiley_theme(struct smiley_theme *theme) |
|
360f2b11f562
Eliminate some duplicate code.
Richard Laager <rlaager@pidgin.im>
parents:
18348
diff
changeset
|
52 | { |
|
360f2b11f562
Eliminate some duplicate code.
Richard Laager <rlaager@pidgin.im>
parents:
18348
diff
changeset
|
53 | 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
|
54 | |
|
18535
360f2b11f562
Eliminate some duplicate code.
Richard Laager <rlaager@pidgin.im>
parents:
18348
diff
changeset
|
55 | g_free(theme->name); |
|
360f2b11f562
Eliminate some duplicate code.
Richard Laager <rlaager@pidgin.im>
parents:
18348
diff
changeset
|
56 | g_free(theme->desc); |
|
360f2b11f562
Eliminate some duplicate code.
Richard Laager <rlaager@pidgin.im>
parents:
18348
diff
changeset
|
57 | g_free(theme->author); |
|
360f2b11f562
Eliminate some duplicate code.
Richard Laager <rlaager@pidgin.im>
parents:
18348
diff
changeset
|
58 | g_free(theme->icon); |
|
360f2b11f562
Eliminate some duplicate code.
Richard Laager <rlaager@pidgin.im>
parents:
18348
diff
changeset
|
59 | g_free(theme->path); |
|
360f2b11f562
Eliminate some duplicate code.
Richard Laager <rlaager@pidgin.im>
parents:
18348
diff
changeset
|
60 | g_free(theme); |
|
17481
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
61 | } |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
62 | |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
63 | 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
|
64 | { |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
65 | GString *str = NULL; |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
66 | const char *file_name = NULL; |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
67 | GDir *theme_dir = NULL; |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
68 | |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
69 | 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
|
70 | 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
|
71 | 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
|
72 | 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
|
73 | g_unlink(str->str); |
|
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 | g_string_free(str, TRUE); |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
76 | } |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
77 | g_dir_close(theme_dir); |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
78 | g_rmdir(theme_dir_name); |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
79 | } |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
80 | } |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
81 | |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
82 | 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
|
83 | { |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
84 | 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
|
85 | g_return_if_fail(NULL != file); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
86 | |
|
17481
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
87 | 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
|
88 | 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
|
89 | |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
90 | 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
|
91 | GSList *iter = NULL; |
|
17482
d4bbeba47e82
Figured out how to keep reflecting current smiley theme after remove.
Gabriel Schulhof <nix@go-nix.ca>
parents:
17481
diff
changeset
|
92 | struct smiley_theme *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
|
93 | |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
94 | *last_slash = 0; |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
95 | |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
96 | /* Delete files on disk */ |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
97 | 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
|
98 | |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
99 | /* 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
|
100 | for (iter = smiley_themes ; iter ; iter = iter->next) { |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
101 | theme = ((struct smiley_theme *)(iter->data)); |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
102 | if (!strcmp(theme->path, file)) |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
103 | break ; |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
104 | } |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
105 | 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
|
106 | if (theme == current_smiley_theme) { |
|
d4bbeba47e82
Figured out how to keep reflecting current smiley theme after remove.
Gabriel Schulhof <nix@go-nix.ca>
parents:
17481
diff
changeset
|
107 | new_theme = ((struct smiley_theme *)(NULL == iter->next ? (smiley_themes == iter ? NULL : smiley_themes->data) : iter->next->data)); |
|
d4bbeba47e82
Figured out how to keep reflecting current smiley theme after remove.
Gabriel Schulhof <nix@go-nix.ca>
parents:
17481
diff
changeset
|
108 | 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
|
109 | 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
|
110 | else |
|
d4bbeba47e82
Figured out how to keep reflecting current smiley theme after remove.
Gabriel Schulhof <nix@go-nix.ca>
parents:
17481
diff
changeset
|
111 | 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
|
112 | } |
|
17481
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
113 | 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
|
114 | |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
115 | /* Destroy theme structure */ |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
116 | 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
|
117 | } |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
118 | } |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
119 | |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
120 | g_free(theme_dir); |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
121 | } |
|
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
122 | |
|
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
|
123 | static void _pidgin_themes_smiley_themeize(GtkWidget *imhtml, gboolean custom) |
| 10295 | 124 | { |
|
32577
e32ba7559843
Mark webkit-related missing functionality with "TODO WEBKIT" instead of
Mark Doliner <markdoliner@pidgin.im>
parents:
32533
diff
changeset
|
125 | /* TODO WEBKIT: move imhtml dependency to use webview. */ |
|
32533
24b9aa43f224
Workaround the bug that causes a crash when closing a gtkwindow.
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
32503
diff
changeset
|
126 | #if 0 |
| 10295 | 127 | struct smiley_list *list; |
| 128 | if (!current_smiley_theme) | |
| 129 | return; | |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
130 | |
| 10295 | 131 | gtk_imhtml_remove_smileys(GTK_IMHTML(imhtml)); |
| 132 | list = current_smiley_theme->list; | |
| 133 | while (list) { | |
| 134 | char *sml = !strcmp(list->sml, "default") ? NULL : list->sml; | |
| 135 | GSList *icons = list->smileys; | |
| 136 | while (icons) { | |
| 137 | gtk_imhtml_associate_smiley(GTK_IMHTML(imhtml), sml, icons->data); | |
| 138 | icons = icons->next; | |
| 139 | } | |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22443
diff
changeset
|
140 | |
|
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
|
141 | 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
|
142 | 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
|
143 | |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
144 | while (icons) { |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
145 | gtk_imhtml_associate_smiley(GTK_IMHTML(imhtml), sml, icons->data); |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
146 | 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
|
147 | } |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
148 | } |
|
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 | |
| 10295 | 150 | list = list->next; |
| 151 | } | |
|
32577
e32ba7559843
Mark webkit-related missing functionality with "TODO WEBKIT" instead of
Mark Doliner <markdoliner@pidgin.im>
parents:
32533
diff
changeset
|
152 | #endif /* if 0 */ |
| 10295 | 153 | } |
| 154 | ||
|
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
|
155 | void pidgin_themes_smiley_themeize(GtkWidget *imhtml) |
|
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 | _pidgin_themes_smiley_themeize(imhtml, FALSE); |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
158 | } |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
159 | |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
160 | void pidgin_themes_smiley_themeize_custom(GtkWidget *imhtml) |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
161 | { |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge VillaseƱo (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22104
diff
changeset
|
162 | _pidgin_themes_smiley_themeize(imhtml, 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
|
163 | } |
|
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 | |
|
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
|
165 | static void |
|
17481
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
166 | pidgin_themes_destroy_smiley_theme_smileys(struct smiley_theme *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
|
167 | { |
|
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
|
168 | GHashTable *already_freed; |
|
670c6b68f7c5
Change a g_slist_append() to a g_slist_prepend() in one place, and
Mark Doliner <markdoliner@pidgin.im>
parents:
16195
diff
changeset
|
169 | struct smiley_list *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
|
170 | |
|
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
|
171 | already_freed = g_hash_table_new(g_direct_hash, g_direct_equal); |
|
670c6b68f7c5
Change a g_slist_append() to a g_slist_prepend() in one place, and
Mark Doliner <markdoliner@pidgin.im>
parents:
16195
diff
changeset
|
172 | 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
|
173 | while (wer->smileys) { |
|
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 | GtkIMHtmlSmiley *uio = wer->smileys->data; |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
175 | |
|
24588
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
22655
diff
changeset
|
176 | if (uio->imhtml) { |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
22655
diff
changeset
|
177 | g_signal_handlers_disconnect_matched(uio->imhtml, G_SIGNAL_MATCH_DATA, |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
22655
diff
changeset
|
178 | 0, 0, NULL, NULL, uio); |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
22655
diff
changeset
|
179 | } |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
180 | |
|
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
|
181 | if (uio->icon) |
|
4e158cbe65cd
Pull out the same block of code from two places and put it into
Mark Doliner <markdoliner@pidgin.im>
parents:
16194
diff
changeset
|
182 | g_object_unref(uio->icon); |
|
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
|
183 | if (g_hash_table_lookup(already_freed, uio->file) == 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
|
184 | g_free(uio->file); |
|
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 | g_hash_table_insert(already_freed, uio->file, GINT_TO_POINTER(1)); |
|
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 | } |
|
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(uio->smile); |
|
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 | g_free(uio); |
|
28077
c2b493e058f1
Don't use pointers (even opaquely) once they're freed. Closes #9822.
Paul Aurich <darkrain42@pidgin.im>
parents:
28075
diff
changeset
|
189 | 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
|
190 | } |
|
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
|
191 | 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
|
192 | 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
|
193 | 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
|
194 | } |
|
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
|
195 | 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
|
196 | |
|
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
|
197 | g_hash_table_destroy(already_freed); |
|
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
|
198 | } |
|
4e158cbe65cd
Pull out the same block of code from two places and put it into
Mark Doliner <markdoliner@pidgin.im>
parents:
16194
diff
changeset
|
199 | |
| 17521 | 200 | 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
|
201 | pidgin_smiley_themes_remove_non_existing(void) |
| 17521 | 202 | { |
| 203 | static struct smiley_theme *theme = NULL; | |
| 204 | GSList *iter = NULL; | |
| 205 | ||
| 206 | if (!smiley_themes) return ; | |
| 207 | ||
| 208 | for (iter = smiley_themes ; iter ; iter = iter->next) { | |
| 209 | theme = ((struct smiley_theme *)(iter->data)); | |
| 210 | if (!g_file_test(theme->path, G_FILE_TEST_EXISTS)) { | |
| 211 | if (theme == current_smiley_theme) | |
| 212 | current_smiley_theme = ((struct smiley_theme *)(NULL == iter->next ? NULL : iter->next->data)); | |
|
18535
360f2b11f562
Eliminate some duplicate code.
Richard Laager <rlaager@pidgin.im>
parents:
18348
diff
changeset
|
213 | pidgin_themes_destroy_smiley_theme(theme); |
| 17521 | 214 | iter->data = NULL; |
| 215 | } | |
| 216 | } | |
| 217 | /* Remove all elements whose data is NULL */ | |
| 218 | smiley_themes = g_slist_remove_all(smiley_themes, NULL); | |
| 219 | ||
| 17522 | 220 | if (!current_smiley_theme && smiley_themes) { |
| 221 | struct smiley_theme *smile = g_slist_last(smiley_themes)->data; | |
| 222 | pidgin_themes_load_smiley_theme(smile->path, TRUE); | |
| 223 | } | |
| 17521 | 224 | } |
| 225 | ||
|
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
|
226 | void pidgin_themes_load_smiley_theme(const char *file, gboolean load) |
| 10295 | 227 | { |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
10295
diff
changeset
|
228 | FILE *f = g_fopen(file, "r"); |
| 10295 | 229 | char buf[256]; |
| 230 | char *i; | |
| 231 | struct smiley_theme *theme=NULL; | |
| 232 | struct smiley_list *list = NULL; | |
| 233 | GSList *lst = smiley_themes; | |
| 234 | char *dirname; | |
| 235 | ||
| 236 | if (!f) | |
| 237 | return; | |
| 238 | ||
| 239 | while (lst) { | |
| 240 | struct smiley_theme *thm = lst->data; | |
| 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) { |
|
2d472ed937db
Clarify load_smiley_theme a little. Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents:
25888
diff
changeset
|
255 | theme = g_new0(struct smiley_theme, 1); |
|
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 | } | |
| 266 | ||
| 267 | if (buf[0] == '#' || buf[0] == '\0') | |
| 268 | continue; | |
| 29252 | 269 | else { |
| 270 | int len = strlen(buf); | |
| 271 | while (len && (buf[len - 1] == '\r' || buf[len - 1] == '\n')) | |
| 272 | buf[--len] = '\0'; | |
| 273 | if (len == 0) | |
| 274 | continue; | |
| 275 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
29252
diff
changeset
|
276 | |
| 10295 | 277 | i = buf; |
| 278 | while (isspace(*i)) | |
| 279 | i++; | |
| 280 | ||
| 281 | if (*i == '[' && strchr(i, ']') && load) { | |
| 282 | struct smiley_list *child = g_new0(struct smiley_list, 1); | |
| 283 | 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
|
284 | 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
|
285 | |
| 10295 | 286 | if (theme->list) |
| 287 | list->next = child; | |
| 288 | else | |
| 289 | 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
|
290 | /* 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
|
291 | 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
|
292 | list->smileys = g_slist_reverse(list->smileys); |
| 10295 | 293 | list = child; |
| 294 | } else if (!g_ascii_strncasecmp(i, "Name=", strlen("Name="))) { | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13625
diff
changeset
|
295 | 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
|
296 | theme->name = g_strdup(i + strlen("Name=")); |
| 10295 | 297 | } else if (!g_ascii_strncasecmp(i, "Description=", strlen("Description="))) { |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13625
diff
changeset
|
298 | g_free(theme->desc); |
| 10295 | 299 | theme->desc = g_strdup(i + strlen("Description=")); |
| 300 | } else if (!g_ascii_strncasecmp(i, "Icon=", strlen("Icon="))) { | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13625
diff
changeset
|
301 | g_free(theme->icon); |
| 10295 | 302 | theme->icon = g_build_filename(dirname, i + strlen("Icon="), NULL); |
| 303 | } else if (!g_ascii_strncasecmp(i, "Author=", strlen("Author="))) { | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13625
diff
changeset
|
304 | g_free(theme->author); |
| 10295 | 305 | theme->author = g_strdup(i + strlen("Author=")); |
| 306 | } else if (load && list) { | |
| 307 | gboolean hidden = FALSE; | |
| 308 | char *sfile = NULL; | |
| 309 | ||
| 310 | if (*i == '!' && *(i + 1) == ' ') { | |
| 311 | hidden = TRUE; | |
| 312 | i = i + 2; | |
| 313 | } | |
| 314 | while (*i) { | |
| 315 | char l[64]; | |
| 316 | int li = 0; | |
|
29246
544942e54b98
Look for non-null before processing theme input. Closes #10521 (again).
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29241
diff
changeset
|
317 | while (*i && !isspace(*i) && li < sizeof(l) - 1) { |
| 29252 | 318 | if (*i == '\\' && *(i+1) != '\0') |
|
12915
d3efd3201aec
[gaim-migrate @ 15268]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11557
diff
changeset
|
319 | i++; |
| 10295 | 320 | l[li++] = *(i++); |
|
12915
d3efd3201aec
[gaim-migrate @ 15268]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11557
diff
changeset
|
321 | } |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22443
diff
changeset
|
322 | l[li] = 0; |
| 10295 | 323 | if (!sfile) { |
| 324 | sfile = g_build_filename(dirname, l, NULL); | |
| 325 | } else { | |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22443
diff
changeset
|
326 | GtkIMHtmlSmiley *smiley = gtk_imhtml_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
|
327 | list->smileys = g_slist_prepend(list->smileys, smiley); |
|
32439
2c681e5daeeb
Webkit Message views.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
25888
diff
changeset
|
328 | g_hash_table_insert (list->files, g_strdup(l), g_strdup(sfile)); |
| 10295 | 329 | } |
| 330 | while (isspace(*i)) | |
| 331 | i++; | |
| 332 | ||
| 333 | } | |
|
16458
e0e45bccd8e2
Fix #273 (Emoticons appearing in reverse order).
Daniel Atallah <datallah@pidgin.im>
parents:
16263
diff
changeset
|
334 | |
|
e0e45bccd8e2
Fix #273 (Emoticons appearing in reverse order).
Daniel Atallah <datallah@pidgin.im>
parents:
16263
diff
changeset
|
335 | |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22443
diff
changeset
|
336 | g_free(sfile); |
| 10295 | 337 | } |
| 338 | } | |
| 339 | ||
|
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
|
340 | /* 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
|
341 | 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
|
342 | 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
|
343 | |
|
13587
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
344 | g_free(dirname); |
|
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
345 | fclose(f); |
|
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
346 | |
|
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
347 | if (!theme->name || !theme->desc || !theme->author) { |
| 15884 | 348 | 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
|
349 | |
|
28075
2d472ed937db
Clarify load_smiley_theme a little. Refs #9822.
Paul Aurich <darkrain42@pidgin.im>
parents:
25888
diff
changeset
|
350 | smiley_themes = g_slist_remove(smiley_themes, theme); |
|
18535
360f2b11f562
Eliminate some duplicate code.
Richard Laager <rlaager@pidgin.im>
parents:
18348
diff
changeset
|
351 | pidgin_themes_destroy_smiley_theme(theme); |
|
13587
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
352 | return; |
|
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
353 | } |
|
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
354 | |
| 10295 | 355 | if (load) { |
|
18122
9bf9970c1b6a
disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents:
18121
diff
changeset
|
356 | GList *cnv; |
| 10295 | 357 | |
|
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
|
358 | if (current_smiley_theme) |
|
17481
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
359 | pidgin_themes_destroy_smiley_theme_smileys(current_smiley_theme); |
|
13587
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
360 | current_smiley_theme = theme; |
|
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
361 | |
| 15884 | 362 | for (cnv = purple_get_conversations(); cnv != NULL; cnv = cnv->next) { |
| 363 | PurpleConversation *conv = cnv->data; | |
| 10295 | 364 | |
|
15692
ecda27df58b9
Some more pidgininfication
Daniel Atallah <datallah@pidgin.im>
parents:
15577
diff
changeset
|
365 | 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
|
366 | /* 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
|
367 | pidgin_themes_smiley_themeize_custom(PIDGIN_CONVERSATION(conv)->entry); |
| 10295 | 368 | } |
| 369 | } | |
| 370 | } | |
| 371 | } | |
| 372 | ||
|
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
|
373 | void pidgin_themes_smiley_theme_probe() |
| 10295 | 374 | { |
| 375 | GDir *dir; | |
| 376 | const gchar *file; | |
| 17521 | 377 | gchar *path, *test_path; |
| 10295 | 378 | int l; |
| 17521 | 379 | char* probedirs[3]; |
| 10295 | 380 | |
| 17521 | 381 | pidgin_smiley_themes_remove_non_existing(); |
| 382 | ||
| 15918 | 383 | probedirs[0] = g_build_filename(DATADIR, "pixmaps", "pidgin", "emotes", NULL); |
| 15884 | 384 | probedirs[1] = g_build_filename(purple_user_dir(), "smileys", NULL); |
| 10295 | 385 | probedirs[2] = 0; |
| 386 | for (l=0; probedirs[l]; l++) { | |
| 387 | dir = g_dir_open(probedirs[l], 0, NULL); | |
| 388 | if (dir) { | |
| 389 | while ((file = g_dir_read_name(dir))) { | |
| 17521 | 390 | test_path = g_build_filename(probedirs[l], file, NULL); |
| 391 | if (g_file_test(test_path, G_FILE_TEST_IS_DIR)) { | |
| 392 | path = g_build_filename(probedirs[l], file, "theme", NULL); | |
| 10295 | 393 | |
| 17521 | 394 | /* Here we check to see that the theme has proper syntax. |
| 395 | * We set the second argument to FALSE so that it doesn't load | |
| 396 | * the theme yet. | |
| 397 | */ | |
| 398 | pidgin_themes_load_smiley_theme(path, FALSE); | |
| 399 | g_free(path); | |
| 400 | } | |
| 401 | g_free(test_path); | |
| 10295 | 402 | } |
| 403 | g_dir_close(dir); | |
| 404 | } else if (l == 1) { | |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
10295
diff
changeset
|
405 | g_mkdir(probedirs[l], S_IRUSR | S_IWUSR | S_IXUSR); |
| 10295 | 406 | } |
| 407 | g_free(probedirs[l]); | |
| 408 | } | |
| 17521 | 409 | |
| 17522 | 410 | if (!current_smiley_theme && smiley_themes) { |
| 411 | struct smiley_theme *smile = smiley_themes->data; | |
| 412 | pidgin_themes_load_smiley_theme(smile->path, TRUE); | |
| 413 | } | |
| 10295 | 414 | } |
| 415 | ||
|
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
|
416 | GSList *pidgin_themes_get_proto_smileys(const char *id) { |
| 15884 | 417 | PurplePlugin *proto; |
| 10295 | 418 | struct smiley_list *list, *def; |
| 419 | ||
| 420 | if ((current_smiley_theme == NULL) || (current_smiley_theme->list == NULL)) | |
| 421 | return NULL; | |
| 422 | ||
| 423 | def = list = current_smiley_theme->list; | |
| 424 | ||
| 425 | if (id == NULL) | |
| 426 | return def->smileys; | |
| 427 | ||
| 15884 | 428 | proto = purple_find_prpl(id); |
| 10295 | 429 | |
| 430 | while (list) { | |
| 431 | if (!strcmp(list->sml, "default")) | |
| 432 | def = list; | |
| 433 | else if (proto && !strcmp(proto->info->name, list->sml)) | |
| 434 | break; | |
| 435 | ||
| 436 | list = list->next; | |
| 437 | } | |
| 438 | ||
| 439 | return list ? list->smileys : def->smileys; | |
| 440 | } | |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
441 | |
|
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
|
442 | void pidgin_themes_init() |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
443 | { |
|
11557
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
444 | GSList *l; |
|
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
445 | 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
|
446 | purple_prefs_get_string(PIDGIN_PREFS_ROOT "/smileys/theme"); |
|
11557
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
447 | |
|
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
|
448 | pidgin_themes_smiley_theme_probe(); |
|
11557
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
449 | |
|
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
450 | for (l = smiley_themes; l; l = l->next) { |
|
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
451 | struct smiley_theme *smile = l->data; |
|
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
452 | 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
|
453 | pidgin_themes_load_smiley_theme(smile->path, TRUE); |
|
11557
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
454 | break; |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
455 | } |
|
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
456 | } |
|
11557
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
457 | |
|
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
458 | /* 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
|
459 | if (!current_smiley_theme && smiley_themes) { |
|
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
460 | struct smiley_theme *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
|
461 | pidgin_themes_load_smiley_theme(smile->path, TRUE); |
|
11557
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
462 | } |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
463 | } |