Fri, 24 Jul 2009 01:18:07 +0000
Webkit Message views.
This commit is a squashed commit of the series of commits from my git repository which I was using for development.
(git://github.com/tdrhq/pidgin-clone.git, branch webkit)
| 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); | |
|
32439
2c681e5daeeb
Webkit Message views.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
25888
diff
changeset
|
273 | 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
|
274 | |
| 10295 | 275 | if (theme->list) |
| 276 | list->next = child; | |
| 277 | else | |
| 278 | 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
|
279 | /* 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
|
280 | 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
|
281 | list->smileys = g_slist_reverse(list->smileys); |
| 10295 | 282 | list = child; |
| 283 | } else if (!g_ascii_strncasecmp(i, "Name=", strlen("Name="))) { | |
| 15338 | 284 | int len; |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13625
diff
changeset
|
285 | 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
|
286 | theme->name = g_strdup(i + strlen("Name=")); |
| 15338 | 287 | len = strlen(theme->name); |
| 288 | theme->name[len-1] = 0; | |
| 289 | if(len > 2 && theme->name[len-2] == '\r') | |
| 290 | theme->name[len-2] = 0; | |
| 10295 | 291 | } else if (!g_ascii_strncasecmp(i, "Description=", strlen("Description="))) { |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13625
diff
changeset
|
292 | g_free(theme->desc); |
| 10295 | 293 | theme->desc = g_strdup(i + strlen("Description=")); |
| 294 | theme->desc[strlen(theme->desc)-1] = 0; | |
| 295 | } else if (!g_ascii_strncasecmp(i, "Icon=", strlen("Icon="))) { | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13625
diff
changeset
|
296 | g_free(theme->icon); |
| 10295 | 297 | theme->icon = g_build_filename(dirname, i + strlen("Icon="), NULL); |
| 298 | theme->icon[strlen(theme->icon)-1] = 0; | |
| 299 | } else if (!g_ascii_strncasecmp(i, "Author=", strlen("Author="))) { | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13625
diff
changeset
|
300 | g_free(theme->author); |
| 10295 | 301 | theme->author = g_strdup(i + strlen("Author=")); |
| 302 | theme->author[strlen(theme->author)-1] = 0; | |
| 303 | } else if (load && list) { | |
| 304 | gboolean hidden = FALSE; | |
| 305 | char *sfile = NULL; | |
| 306 | ||
| 307 | if (*i == '!' && *(i + 1) == ' ') { | |
| 308 | hidden = TRUE; | |
| 309 | i = i + 2; | |
| 310 | } | |
| 311 | while (*i) { | |
| 312 | char l[64]; | |
| 313 | int li = 0; | |
|
13134
e5898f2191a4
[gaim-migrate @ 15495]
Christophe Chapuis <tofe2tofe@users.sourceforge.net>
parents:
12915
diff
changeset
|
314 | while (!isspace(*i) && li < sizeof(l) - 1) { |
|
e5898f2191a4
[gaim-migrate @ 15495]
Christophe Chapuis <tofe2tofe@users.sourceforge.net>
parents:
12915
diff
changeset
|
315 | 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
|
316 | i++; |
| 10295 | 317 | l[li++] = *(i++); |
|
12915
d3efd3201aec
[gaim-migrate @ 15268]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11557
diff
changeset
|
318 | } |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22443
diff
changeset
|
319 | l[li] = 0; |
| 10295 | 320 | if (!sfile) { |
| 321 | sfile = g_build_filename(dirname, l, NULL); | |
| 322 | } 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
|
323 | 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
|
324 | list->smileys = g_slist_prepend(list->smileys, smiley); |
|
32439
2c681e5daeeb
Webkit Message views.
Arnold Noronha <tdrhq@soc.pidgin.im>
parents:
25888
diff
changeset
|
325 | g_hash_table_insert (list->files, g_strdup(l), g_strdup(sfile)); |
| 10295 | 326 | } |
| 327 | while (isspace(*i)) | |
| 328 | i++; | |
| 329 | ||
| 330 | } | |
|
16458
e0e45bccd8e2
Fix #273 (Emoticons appearing in reverse order).
Daniel Atallah <datallah@pidgin.im>
parents:
16263
diff
changeset
|
331 | |
|
e0e45bccd8e2
Fix #273 (Emoticons appearing in reverse order).
Daniel Atallah <datallah@pidgin.im>
parents:
16263
diff
changeset
|
332 | |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22443
diff
changeset
|
333 | g_free(sfile); |
| 10295 | 334 | } |
| 335 | } | |
| 336 | ||
|
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
|
337 | /* 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
|
338 | 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
|
339 | 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
|
340 | |
|
13587
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
341 | g_free(dirname); |
|
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
342 | fclose(f); |
|
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
343 | |
|
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
344 | if (!theme->name || !theme->desc || !theme->author) { |
| 15884 | 345 | 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
|
346 | |
|
18535
360f2b11f562
Eliminate some duplicate code.
Richard Laager <rlaager@pidgin.im>
parents:
18348
diff
changeset
|
347 | pidgin_themes_destroy_smiley_theme(theme); |
|
13587
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
348 | return; |
|
fb0245a7ccab
[gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents:
13134
diff
changeset
|
349 | } |
|
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 | 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
|
352 | smiley_themes = g_slist_prepend(smiley_themes, theme); |
|
13587
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 | } |