Tue, 07 Jul 2009 17:44:13 +0000
Plug a leak of an account dropdown selection dialog or two.
The optmenu was being assigned to the wrong field, meaning it would be
created twice (the latter when pidgin_request_fields hits that field). On
top of that, the dropdown was being created even when the field isn't
visible (which, in the case of one active account and the New IM dialog,
it isn't).
Fixes a bunch of failed assertions in the debug log like:
g_log: purple_request_field_account_set_value: assertion `field->type == PURPLE_REQUEST_FIELD_ACCOUNT' failed
| 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 | { |
| 125 | struct smiley_list *list; | |
| 126 | if (!current_smiley_theme) | |
| 127 | return; | |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
128 | |
| 10295 | 129 | gtk_imhtml_remove_smileys(GTK_IMHTML(imhtml)); |
| 130 | list = current_smiley_theme->list; | |
| 131 | while (list) { | |
| 132 | char *sml = !strcmp(list->sml, "default") ? NULL : list->sml; | |
| 133 | GSList *icons = list->smileys; | |
| 134 | while (icons) { | |
| 135 | gtk_imhtml_associate_smiley(GTK_IMHTML(imhtml), sml, icons->data); | |
| 136 | icons = icons->next; | |
| 137 | } | |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22443
diff
changeset
|
138 | |
|
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
|
139 | 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
|
140 | 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
|
141 | |
|
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 | 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
|
143 | 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
|
144 | 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
|
145 | } |
|
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 | } |
|
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 | |
| 10295 | 148 | list = list->next; |
| 149 | } | |
| 150 | } | |
| 151 | ||
|
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
|
152 | 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
|
153 | { |
|
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 | _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
|
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 | 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
|
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 | _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
|
160 | } |
|
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 | |
|
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
|
162 | static void |
|
17481
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
163 | 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
|
164 | { |
|
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
|
165 | 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
|
166 | 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
|
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 | 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
|
169 | 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
|
170 | 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
|
171 | GtkIMHtmlSmiley *uio = wer->smileys->data; |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
172 | |
|
24588
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
22655
diff
changeset
|
173 | if (uio->imhtml) { |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
22655
diff
changeset
|
174 | 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
|
175 | 0, 0, NULL, NULL, uio); |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
22655
diff
changeset
|
176 | } |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
177 | |
|
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 | 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
|
179 | 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
|
180 | 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
|
181 | 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
|
182 | 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
|
183 | } |
|
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->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
|
185 | g_free(uio); |
|
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 | wer->smileys = g_slist_remove(wer->smileys, uio); |
|
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 | } |
|
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
|
188 | 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
|
189 | 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
|
190 | 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
|
191 | } |
|
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
|
192 | 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
|
193 | |
|
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
|
194 | 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
|
195 | } |
|
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 | |
| 17521 | 197 | 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
|
198 | pidgin_smiley_themes_remove_non_existing(void) |
| 17521 | 199 | { |
| 200 | static struct smiley_theme *theme = NULL; | |
| 201 | GSList *iter = NULL; | |
| 202 | ||
| 203 | if (!smiley_themes) return ; | |
| 204 | ||
| 205 | for (iter = smiley_themes ; iter ; iter = iter->next) { | |
| 206 | theme = ((struct smiley_theme *)(iter->data)); | |
| 207 | if (!g_file_test(theme->path, G_FILE_TEST_EXISTS)) { | |
| 208 | if (theme == current_smiley_theme) | |
| 209 | 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
|
210 | pidgin_themes_destroy_smiley_theme(theme); |
| 17521 | 211 | iter->data = NULL; |
| 212 | } | |
| 213 | } | |
| 214 | /* Remove all elements whose data is NULL */ | |
| 215 | smiley_themes = g_slist_remove_all(smiley_themes, NULL); | |
| 216 | ||
| 17522 | 217 | if (!current_smiley_theme && smiley_themes) { |
| 218 | struct smiley_theme *smile = g_slist_last(smiley_themes)->data; | |
| 219 | pidgin_themes_load_smiley_theme(smile->path, TRUE); | |
| 220 | } | |
| 17521 | 221 | } |
| 222 | ||
|
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
|
223 | void pidgin_themes_load_smiley_theme(const char *file, gboolean load) |
| 10295 | 224 | { |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
10295
diff
changeset
|
225 | FILE *f = g_fopen(file, "r"); |
| 10295 | 226 | char buf[256]; |
| 227 | char *i; | |
| 228 | struct smiley_theme *theme=NULL; | |
| 229 | struct smiley_list *list = NULL; | |
| 230 | GSList *lst = smiley_themes; | |
| 231 | char *dirname; | |
|
13587
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
232 | gboolean new_theme = FALSE; |
| 10295 | 233 | |
| 234 | if (!f) | |
| 235 | return; | |
| 236 | ||
| 237 | while (lst) { | |
| 238 | struct smiley_theme *thm = lst->data; | |
| 239 | if (!strcmp(thm->path, file)) { | |
| 240 | theme = thm; | |
| 241 | break; | |
| 242 | } | |
| 243 | lst = lst->next; | |
| 244 | } | |
| 245 | ||
| 246 | if (!theme) { | |
|
13587
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
247 | new_theme = TRUE; |
| 10295 | 248 | theme = g_new0(struct smiley_theme, 1); |
| 249 | theme->path = g_strdup(file); | |
|
13587
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
250 | } else if (theme == current_smiley_theme) { |
|
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
251 | /* Don't reload the theme if it is already loaded */ |
|
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
252 | fclose(f); |
|
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
253 | return; |
| 10295 | 254 | } |
| 255 | ||
| 256 | dirname = g_path_get_dirname(file); | |
| 257 | ||
| 258 | while (!feof(f)) { | |
| 259 | if (!fgets(buf, sizeof(buf), f)) { | |
| 260 | break; | |
| 261 | } | |
| 262 | ||
| 263 | if (buf[0] == '#' || buf[0] == '\0') | |
| 264 | continue; | |
| 265 | ||
| 266 | i = buf; | |
| 267 | while (isspace(*i)) | |
| 268 | i++; | |
| 269 | ||
| 270 | if (*i == '[' && strchr(i, ']') && load) { | |
| 271 | struct smiley_list *child = g_new0(struct smiley_list, 1); | |
| 272 | child->sml = g_strndup(i+1, strchr(i, ']') - i - 1); | |
| 273 | if (theme->list) | |
| 274 | list->next = child; | |
| 275 | else | |
| 276 | 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
|
277 | /* 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
|
278 | 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
|
279 | list->smileys = g_slist_reverse(list->smileys); |
| 10295 | 280 | list = child; |
| 281 | } else if (!g_ascii_strncasecmp(i, "Name=", strlen("Name="))) { | |
| 15338 | 282 | int len; |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13625
diff
changeset
|
283 | 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
|
284 | theme->name = g_strdup(i + strlen("Name=")); |
| 15338 | 285 | len = strlen(theme->name); |
| 286 | theme->name[len-1] = 0; | |
| 287 | if(len > 2 && theme->name[len-2] == '\r') | |
| 288 | theme->name[len-2] = 0; | |
| 10295 | 289 | } else if (!g_ascii_strncasecmp(i, "Description=", strlen("Description="))) { |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13625
diff
changeset
|
290 | g_free(theme->desc); |
| 10295 | 291 | theme->desc = g_strdup(i + strlen("Description=")); |
| 292 | theme->desc[strlen(theme->desc)-1] = 0; | |
| 293 | } else if (!g_ascii_strncasecmp(i, "Icon=", strlen("Icon="))) { | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13625
diff
changeset
|
294 | g_free(theme->icon); |
| 10295 | 295 | theme->icon = g_build_filename(dirname, i + strlen("Icon="), NULL); |
| 296 | theme->icon[strlen(theme->icon)-1] = 0; | |
| 297 | } else if (!g_ascii_strncasecmp(i, "Author=", strlen("Author="))) { | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13625
diff
changeset
|
298 | g_free(theme->author); |
| 10295 | 299 | theme->author = g_strdup(i + strlen("Author=")); |
| 300 | theme->author[strlen(theme->author)-1] = 0; | |
| 301 | } else if (load && list) { | |
| 302 | gboolean hidden = FALSE; | |
| 303 | char *sfile = NULL; | |
| 304 | ||
| 305 | if (*i == '!' && *(i + 1) == ' ') { | |
| 306 | hidden = TRUE; | |
| 307 | i = i + 2; | |
| 308 | } | |
| 309 | while (*i) { | |
| 310 | char l[64]; | |
| 311 | int li = 0; | |
|
13134
e5898f2191a4
[gaim-migrate @ 15495]
Christophe Chapuis <tofe2tofe@users.sourceforge.net>
parents:
12915
diff
changeset
|
312 | while (!isspace(*i) && li < sizeof(l) - 1) { |
|
e5898f2191a4
[gaim-migrate @ 15495]
Christophe Chapuis <tofe2tofe@users.sourceforge.net>
parents:
12915
diff
changeset
|
313 | if (*i == '\\' && *(i+1) != '\0' && *(i+1) != '\n' && *(i+1) != '\r') |
|
12915
d3efd3201aec
[gaim-migrate @ 15268]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11557
diff
changeset
|
314 | i++; |
| 10295 | 315 | l[li++] = *(i++); |
|
12915
d3efd3201aec
[gaim-migrate @ 15268]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11557
diff
changeset
|
316 | } |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22443
diff
changeset
|
317 | l[li] = 0; |
| 10295 | 318 | if (!sfile) { |
| 319 | sfile = g_build_filename(dirname, l, NULL); | |
| 320 | } 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
|
321 | 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
|
322 | list->smileys = g_slist_prepend(list->smileys, smiley); |
| 10295 | 323 | } |
| 324 | while (isspace(*i)) | |
| 325 | i++; | |
| 326 | ||
| 327 | } | |
|
16458
e0e45bccd8e2
Fix #273 (Emoticons appearing in reverse order).
Daniel Atallah <datallah@pidgin.im>
parents:
16263
diff
changeset
|
328 | |
|
e0e45bccd8e2
Fix #273 (Emoticons appearing in reverse order).
Daniel Atallah <datallah@pidgin.im>
parents:
16263
diff
changeset
|
329 | |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22443
diff
changeset
|
330 | g_free(sfile); |
| 10295 | 331 | } |
| 332 | } | |
| 333 | ||
|
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
|
334 | /* 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
|
335 | 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
|
336 | 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
|
337 | |
|
13587
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
338 | g_free(dirname); |
|
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
339 | fclose(f); |
|
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
340 | |
|
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
341 | if (!theme->name || !theme->desc || !theme->author) { |
| 15884 | 342 | 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
|
343 | |
|
18535
360f2b11f562
Eliminate some duplicate code.
Richard Laager <rlaager@pidgin.im>
parents:
18348
diff
changeset
|
344 | pidgin_themes_destroy_smiley_theme(theme); |
|
13587
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
345 | return; |
|
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 | |
|
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
348 | if (new_theme) { |
|
16212
50ef047fed38
Change another 'append' to 'prepend', since the ordering doesn't matter
Mark Doliner <markdoliner@pidgin.im>
parents:
16211
diff
changeset
|
349 | smiley_themes = g_slist_prepend(smiley_themes, theme); |
|
13587
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
350 | } |
|
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
351 | |
| 10295 | 352 | if (load) { |
|
18122
9bf9970c1b6a
disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents:
18121
diff
changeset
|
353 | GList *cnv; |
| 10295 | 354 | |
|
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
|
355 | if (current_smiley_theme) |
|
17481
0187dfe85231
Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents:
17480
diff
changeset
|
356 | pidgin_themes_destroy_smiley_theme_smileys(current_smiley_theme); |
|
13587
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
357 | current_smiley_theme = theme; |
|
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
358 | |
| 15884 | 359 | for (cnv = purple_get_conversations(); cnv != NULL; cnv = cnv->next) { |
| 360 | PurpleConversation *conv = cnv->data; | |
| 10295 | 361 | |
|
15692
ecda27df58b9
Some more pidgininfication
Daniel Atallah <datallah@pidgin.im>
parents:
15577
diff
changeset
|
362 | 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
|
363 | /* We want to see our custom smileys on our entry if we write the shortcut */ |
|
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
|
364 | pidgin_themes_smiley_themeize(PIDGIN_CONVERSATION(conv)->imhtml); |
|
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
|
365 | pidgin_themes_smiley_themeize_custom(PIDGIN_CONVERSATION(conv)->entry); |
| 10295 | 366 | } |
| 367 | } | |
| 368 | } | |
| 369 | } | |
| 370 | ||
|
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
|
371 | void pidgin_themes_smiley_theme_probe() |
| 10295 | 372 | { |
| 373 | GDir *dir; | |
| 374 | const gchar *file; | |
| 17521 | 375 | gchar *path, *test_path; |
| 10295 | 376 | int l; |
| 17521 | 377 | char* probedirs[3]; |
| 10295 | 378 | |
| 17521 | 379 | pidgin_smiley_themes_remove_non_existing(); |
| 380 | ||
| 15918 | 381 | probedirs[0] = g_build_filename(DATADIR, "pixmaps", "pidgin", "emotes", NULL); |
| 15884 | 382 | probedirs[1] = g_build_filename(purple_user_dir(), "smileys", NULL); |
| 10295 | 383 | probedirs[2] = 0; |
| 384 | for (l=0; probedirs[l]; l++) { | |
| 385 | dir = g_dir_open(probedirs[l], 0, NULL); | |
| 386 | if (dir) { | |
| 387 | while ((file = g_dir_read_name(dir))) { | |
| 17521 | 388 | test_path = g_build_filename(probedirs[l], file, NULL); |
| 389 | if (g_file_test(test_path, G_FILE_TEST_IS_DIR)) { | |
| 390 | path = g_build_filename(probedirs[l], file, "theme", NULL); | |
| 10295 | 391 | |
| 17521 | 392 | /* Here we check to see that the theme has proper syntax. |
| 393 | * We set the second argument to FALSE so that it doesn't load | |
| 394 | * the theme yet. | |
| 395 | */ | |
| 396 | pidgin_themes_load_smiley_theme(path, FALSE); | |
| 397 | g_free(path); | |
| 398 | } | |
| 399 | g_free(test_path); | |
| 10295 | 400 | } |
| 401 | g_dir_close(dir); | |
| 402 | } else if (l == 1) { | |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
10295
diff
changeset
|
403 | g_mkdir(probedirs[l], S_IRUSR | S_IWUSR | S_IXUSR); |
| 10295 | 404 | } |
| 405 | g_free(probedirs[l]); | |
| 406 | } | |
| 17521 | 407 | |
| 17522 | 408 | if (!current_smiley_theme && smiley_themes) { |
| 409 | struct smiley_theme *smile = smiley_themes->data; | |
| 410 | pidgin_themes_load_smiley_theme(smile->path, TRUE); | |
| 411 | } | |
| 10295 | 412 | } |
| 413 | ||
|
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
|
414 | GSList *pidgin_themes_get_proto_smileys(const char *id) { |
| 15884 | 415 | PurplePlugin *proto; |
| 10295 | 416 | struct smiley_list *list, *def; |
| 417 | ||
| 418 | if ((current_smiley_theme == NULL) || (current_smiley_theme->list == NULL)) | |
| 419 | return NULL; | |
| 420 | ||
| 421 | def = list = current_smiley_theme->list; | |
| 422 | ||
| 423 | if (id == NULL) | |
| 424 | return def->smileys; | |
| 425 | ||
| 15884 | 426 | proto = purple_find_prpl(id); |
| 10295 | 427 | |
| 428 | while (list) { | |
| 429 | if (!strcmp(list->sml, "default")) | |
| 430 | def = list; | |
| 431 | else if (proto && !strcmp(proto->info->name, list->sml)) | |
| 432 | break; | |
| 433 | ||
| 434 | list = list->next; | |
| 435 | } | |
| 436 | ||
| 437 | return list ? list->smileys : def->smileys; | |
| 438 | } | |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
439 | |
|
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
|
440 | void pidgin_themes_init() |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
441 | { |
|
11557
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
442 | GSList *l; |
|
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
443 | 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
|
444 | purple_prefs_get_string(PIDGIN_PREFS_ROOT "/smileys/theme"); |
|
11557
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
445 | |
|
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
|
446 | pidgin_themes_smiley_theme_probe(); |
|
11557
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
447 | |
|
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
448 | for (l = smiley_themes; l; l = l->next) { |
|
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
449 | struct smiley_theme *smile = l->data; |
|
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
450 | 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
|
451 | pidgin_themes_load_smiley_theme(smile->path, TRUE); |
|
11557
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
452 | break; |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
453 | } |
|
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
454 | } |
|
11557
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
455 | |
|
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
456 | /* 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
|
457 | if (!current_smiley_theme && smiley_themes) { |
|
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
458 | 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
|
459 | pidgin_themes_load_smiley_theme(smile->path, TRUE); |
|
11557
7a20e7fb7915
[gaim-migrate @ 13819]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
460 | } |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
10589
diff
changeset
|
461 | } |