annotate pidgin/gtkthemes.c @ 32827:4a34689eeb33 default tip

merged from im.pidgin.pidgin
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Sat, 19 Nov 2011 14:42:54 +0900
parents 68fe7b5211a7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
15858
e4805a4be652 Fix smileys
Sean Egan <seanegan@gmail.com>
parents: 15823
diff changeset
2 * Themes for Pidgin
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
15858
e4805a4be652 Fix smileys
Sean Egan <seanegan@gmail.com>
parents: 15823
diff changeset
4 * Pidgin is the legal property of its developers, whose names are too numerous
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 * source distribution.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
19680
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 18376
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 #include "internal.h"
15514
535f002e7b0f More pidgin changes
Sean Egan <seanegan@gmail.com>
parents: 15501
diff changeset
24 #include "pidgin.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #include "conversation.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include "debug.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "prpl.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "util.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "gtkconv.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include "gtkdialogs.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #include "gtkimhtml.h"
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
34 #include "gtksmiley.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 #include "gtkthemes.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 GSList *smiley_themes = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 struct smiley_theme *current_smiley_theme;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39
17483
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
40 static void pidgin_themes_destroy_smiley_theme_smileys(struct smiley_theme *theme);
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
41
16202
0973688f4b74 Word on the street is that we don't want things named pidginfoo_bar(), but
Richard Laager <rlaager@wiktel.com>
parents: 16151
diff changeset
42 gboolean pidgin_themes_smileys_disabled()
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 if (!current_smiley_theme)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 return 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 return strcmp(current_smiley_theme->name, "none") == 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49
17483
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
50 static void
18376
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
51 pidgin_themes_destroy_smiley_theme(struct smiley_theme *theme)
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
52 {
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
53 pidgin_themes_destroy_smiley_theme_smileys(theme);
17483
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
54
18376
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
55 g_free(theme->name);
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
56 g_free(theme->desc);
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
57 g_free(theme->author);
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
58 g_free(theme->icon);
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
59 g_free(theme->path);
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
60 g_free(theme);
17483
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
61 }
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
62
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
63 static void pidgin_themes_remove_theme_dir(const char *theme_dir_name)
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
64 {
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
65 GString *str = NULL;
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
66 const char *file_name = NULL;
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
67 GDir *theme_dir = NULL;
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
68
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
69 if ((theme_dir = g_dir_open(theme_dir_name, 0, NULL)) != NULL) {
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
70 if ((str = g_string_new(theme_dir_name)) != NULL) {
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
71 while ((file_name = g_dir_read_name(theme_dir)) != NULL) {
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
72 g_string_printf(str, "%s%s%s", theme_dir_name, G_DIR_SEPARATOR_S, file_name);
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
73 g_unlink(str->str);
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
74 }
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
75 g_string_free(str, TRUE);
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
76 }
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
77 g_dir_close(theme_dir);
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
78 g_rmdir(theme_dir_name);
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
79 }
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
80 }
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
81
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
82 void pidgin_themes_remove_smiley_theme(const char *file)
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
83 {
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
84 char *theme_dir = NULL, *last_slash = NULL;
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
85 g_return_if_fail(NULL != file);
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 24311
diff changeset
86
17483
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
87 if (!g_file_test(file, G_FILE_TEST_EXISTS)) return;
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
88 if ((theme_dir = g_strdup(file)) == NULL) return ;
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
89
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
90 if ((last_slash = g_strrstr(theme_dir, G_DIR_SEPARATOR_S)) != NULL) {
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
91 GSList *iter = NULL;
17484
7055885b1b70 Figured out how to keep reflecting current smiley theme after remove.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17483
diff changeset
92 struct smiley_theme *theme = NULL, *new_theme = NULL;
17483
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
93
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
94 *last_slash = 0;
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
95
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
96 /* Delete files on disk */
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
97 pidgin_themes_remove_theme_dir(theme_dir);
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
98
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
99 /* Find theme in themes list and remove it */
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
100 for (iter = smiley_themes ; iter ; iter = iter->next) {
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
101 theme = ((struct smiley_theme *)(iter->data));
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
102 if (!strcmp(theme->path, file))
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
103 break ;
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
104 }
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
105 if (iter) {
17484
7055885b1b70 Figured out how to keep reflecting current smiley theme after remove.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17483
diff changeset
106 if (theme == current_smiley_theme) {
7055885b1b70 Figured out how to keep reflecting current smiley theme after remove.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17483
diff changeset
107 new_theme = ((struct smiley_theme *)(NULL == iter->next ? (smiley_themes == iter ? NULL : smiley_themes->data) : iter->next->data));
7055885b1b70 Figured out how to keep reflecting current smiley theme after remove.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17483
diff changeset
108 if (new_theme)
7055885b1b70 Figured out how to keep reflecting current smiley theme after remove.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17483
diff changeset
109 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/smileys/theme", new_theme->name);
7055885b1b70 Figured out how to keep reflecting current smiley theme after remove.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17483
diff changeset
110 else
7055885b1b70 Figured out how to keep reflecting current smiley theme after remove.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17483
diff changeset
111 current_smiley_theme = NULL;
7055885b1b70 Figured out how to keep reflecting current smiley theme after remove.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17483
diff changeset
112 }
17483
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
113 smiley_themes = g_slist_delete_link(smiley_themes, iter);
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
114
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
115 /* Destroy theme structure */
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
116 pidgin_themes_destroy_smiley_theme(theme);
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
117 }
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
118 }
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
119
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
120 g_free(theme_dir);
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
121 }
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
122
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
123 static void _pidgin_themes_smiley_themeize(GtkWidget *imhtml, gboolean custom)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 {
32660
68fe7b5211a7 Mark webkit-related missing functionality with "TODO WEBKIT" instead of
Mark Doliner <mark@kingant.net>
parents: 32616
diff changeset
125 /* TODO WEBKIT: move imhtml dependency to use webview. */
32616
6eb0a2a860b3 Workaround the bug that causes a crash when closing a gtkwindow.
masca@cpw.pidgin.im
parents: 32584
diff changeset
126 #if 0
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 struct smiley_list *list;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 if (!current_smiley_theme)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131 gtk_imhtml_remove_smileys(GTK_IMHTML(imhtml));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 list = current_smiley_theme->list;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 while (list) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 char *sml = !strcmp(list->sml, "default") ? NULL : list->sml;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 GSList *icons = list->smileys;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 while (icons) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 gtk_imhtml_associate_smiley(GTK_IMHTML(imhtml), sml, icons->data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 icons = icons->next;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 }
22889
019052a807a3 Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22874
diff changeset
140
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
141 if (custom == TRUE) {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
142 icons = pidgin_smileys_get_all();
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
143
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
144 while (icons) {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
145 gtk_imhtml_associate_smiley(GTK_IMHTML(imhtml), sml, icons->data);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
146 icons = icons->next;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
147 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
148 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
149
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 list = list->next;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 }
32660
68fe7b5211a7 Mark webkit-related missing functionality with "TODO WEBKIT" instead of
Mark Doliner <mark@kingant.net>
parents: 32616
diff changeset
152 #endif /* if 0 */
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
155 void pidgin_themes_smiley_themeize(GtkWidget *imhtml)
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
156 {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
157 _pidgin_themes_smiley_themeize(imhtml, FALSE);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
158 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
159
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
160 void pidgin_themes_smiley_themeize_custom(GtkWidget *imhtml)
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
161 {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
162 _pidgin_themes_smiley_themeize(imhtml, TRUE);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
163 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
164
16133
019092f88c43 Pull out the same block of code from two places and put it into
Mark Doliner <mark@kingant.net>
parents: 16132
diff changeset
165 static void
17483
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
166 pidgin_themes_destroy_smiley_theme_smileys(struct smiley_theme *theme)
16133
019092f88c43 Pull out the same block of code from two places and put it into
Mark Doliner <mark@kingant.net>
parents: 16132
diff changeset
167 {
16150
218818f96b93 Change a g_slist_append() to a g_slist_prepend() in one place, and
Mark Doliner <mark@kingant.net>
parents: 16133
diff changeset
168 GHashTable *already_freed;
218818f96b93 Change a g_slist_append() to a g_slist_prepend() in one place, and
Mark Doliner <mark@kingant.net>
parents: 16133
diff changeset
169 struct smiley_list *wer;
16133
019092f88c43 Pull out the same block of code from two places and put it into
Mark Doliner <mark@kingant.net>
parents: 16132
diff changeset
170
16150
218818f96b93 Change a g_slist_append() to a g_slist_prepend() in one place, and
Mark Doliner <mark@kingant.net>
parents: 16133
diff changeset
171 already_freed = g_hash_table_new(g_direct_hash, g_direct_equal);
218818f96b93 Change a g_slist_append() to a g_slist_prepend() in one place, and
Mark Doliner <mark@kingant.net>
parents: 16133
diff changeset
172 for (wer = theme->list; wer != NULL; wer = theme->list) {
16133
019092f88c43 Pull out the same block of code from two places and put it into
Mark Doliner <mark@kingant.net>
parents: 16132
diff changeset
173 while (wer->smileys) {
019092f88c43 Pull out the same block of code from two places and put it into
Mark Doliner <mark@kingant.net>
parents: 16132
diff changeset
174 GtkIMHtmlSmiley *uio = wer->smileys->data;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 24311
diff changeset
175
24311
9ea84135db24 Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <ml@update.uu.se>
parents: 22889
diff changeset
176 if (uio->imhtml) {
9ea84135db24 Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <ml@update.uu.se>
parents: 22889
diff changeset
177 g_signal_handlers_disconnect_matched(uio->imhtml, G_SIGNAL_MATCH_DATA,
9ea84135db24 Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <ml@update.uu.se>
parents: 22889
diff changeset
178 0, 0, NULL, NULL, uio);
9ea84135db24 Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <ml@update.uu.se>
parents: 22889
diff changeset
179 }
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 24311
diff changeset
180
16133
019092f88c43 Pull out the same block of code from two places and put it into
Mark Doliner <mark@kingant.net>
parents: 16132
diff changeset
181 if (uio->icon)
019092f88c43 Pull out the same block of code from two places and put it into
Mark Doliner <mark@kingant.net>
parents: 16132
diff changeset
182 g_object_unref(uio->icon);
16150
218818f96b93 Change a g_slist_append() to a g_slist_prepend() in one place, and
Mark Doliner <mark@kingant.net>
parents: 16133
diff changeset
183 if (g_hash_table_lookup(already_freed, uio->file) == NULL) {
16133
019092f88c43 Pull out the same block of code from two places and put it into
Mark Doliner <mark@kingant.net>
parents: 16132
diff changeset
184 g_free(uio->file);
16150
218818f96b93 Change a g_slist_append() to a g_slist_prepend() in one place, and
Mark Doliner <mark@kingant.net>
parents: 16133
diff changeset
185 g_hash_table_insert(already_freed, uio->file, GINT_TO_POINTER(1));
16133
019092f88c43 Pull out the same block of code from two places and put it into
Mark Doliner <mark@kingant.net>
parents: 16132
diff changeset
186 }
019092f88c43 Pull out the same block of code from two places and put it into
Mark Doliner <mark@kingant.net>
parents: 16132
diff changeset
187 g_free(uio->smile);
019092f88c43 Pull out the same block of code from two places and put it into
Mark Doliner <mark@kingant.net>
parents: 16132
diff changeset
188 g_free(uio);
28138
deecc1d663c4 Don't use pointers (even opaquely) once they're freed. Closes #9822.
Paul Aurich <paul@darkrain42.org>
parents: 28136
diff changeset
189 wer->smileys = g_slist_delete_link(wer->smileys, wer->smileys);
16133
019092f88c43 Pull out the same block of code from two places and put it into
Mark Doliner <mark@kingant.net>
parents: 16132
diff changeset
190 }
16150
218818f96b93 Change a g_slist_append() to a g_slist_prepend() in one place, and
Mark Doliner <mark@kingant.net>
parents: 16133
diff changeset
191 theme->list = wer->next;
16133
019092f88c43 Pull out the same block of code from two places and put it into
Mark Doliner <mark@kingant.net>
parents: 16132
diff changeset
192 g_free(wer->sml);
019092f88c43 Pull out the same block of code from two places and put it into
Mark Doliner <mark@kingant.net>
parents: 16132
diff changeset
193 g_free(wer);
019092f88c43 Pull out the same block of code from two places and put it into
Mark Doliner <mark@kingant.net>
parents: 16132
diff changeset
194 }
16150
218818f96b93 Change a g_slist_append() to a g_slist_prepend() in one place, and
Mark Doliner <mark@kingant.net>
parents: 16133
diff changeset
195 theme->list = NULL;
16133
019092f88c43 Pull out the same block of code from two places and put it into
Mark Doliner <mark@kingant.net>
parents: 16132
diff changeset
196
16150
218818f96b93 Change a g_slist_append() to a g_slist_prepend() in one place, and
Mark Doliner <mark@kingant.net>
parents: 16133
diff changeset
197 g_hash_table_destroy(already_freed);
16133
019092f88c43 Pull out the same block of code from two places and put it into
Mark Doliner <mark@kingant.net>
parents: 16132
diff changeset
198 }
019092f88c43 Pull out the same block of code from two places and put it into
Mark Doliner <mark@kingant.net>
parents: 16132
diff changeset
199
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
200 static void
22007
c38d72677c8a Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@wiktel.com>
parents: 19680
diff changeset
201 pidgin_smiley_themes_remove_non_existing(void)
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
202 {
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
203 static struct smiley_theme *theme = NULL;
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
204 GSList *iter = NULL;
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
205
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
206 if (!smiley_themes) return ;
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
207
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
208 for (iter = smiley_themes ; iter ; iter = iter->next) {
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
209 theme = ((struct smiley_theme *)(iter->data));
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
210 if (!g_file_test(theme->path, G_FILE_TEST_EXISTS)) {
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
211 if (theme == current_smiley_theme)
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
212 current_smiley_theme = ((struct smiley_theme *)(NULL == iter->next ? NULL : iter->next->data));
18376
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
213 pidgin_themes_destroy_smiley_theme(theme);
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
214 iter->data = NULL;
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
215 }
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
216 }
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
217 /* Remove all elements whose data is NULL */
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
218 smiley_themes = g_slist_remove_all(smiley_themes, NULL);
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
219
17654
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
220 if (!current_smiley_theme && smiley_themes) {
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
221 struct smiley_theme *smile = g_slist_last(smiley_themes)->data;
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
222 pidgin_themes_load_smiley_theme(smile->path, TRUE);
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
223 }
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
224 }
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
225
16202
0973688f4b74 Word on the street is that we don't want things named pidginfoo_bar(), but
Richard Laager <rlaager@wiktel.com>
parents: 16151
diff changeset
226 void pidgin_themes_load_smiley_theme(const char *file, gboolean load)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 FILE *f = g_fopen(file, "r");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 char buf[256];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 char *i;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 struct smiley_theme *theme=NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 struct smiley_list *list = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 GSList *lst = smiley_themes;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 char *dirname;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 if (!f)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 while (lst) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240 struct smiley_theme *thm = lst->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 if (!strcmp(thm->path, file)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242 theme = thm;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 lst = lst->next;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247
28139
5b21007cf503 Oops, fix loading smiley themes.
Paul Aurich <paul@darkrain42.org>
parents: 28138
diff changeset
248 if (theme != NULL && theme == current_smiley_theme) {
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249 /* Don't reload the theme if it is already loaded */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250 fclose(f);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253
28136
c91832e94473 Clarify load_smiley_theme a little. Refs #9822.
Paul Aurich <paul@darkrain42.org>
parents: 25415
diff changeset
254 if (theme == NULL) {
c91832e94473 Clarify load_smiley_theme a little. Refs #9822.
Paul Aurich <paul@darkrain42.org>
parents: 25415
diff changeset
255 theme = g_new0(struct smiley_theme, 1);
c91832e94473 Clarify load_smiley_theme a little. Refs #9822.
Paul Aurich <paul@darkrain42.org>
parents: 25415
diff changeset
256 theme->path = g_strdup(file);
c91832e94473 Clarify load_smiley_theme a little. Refs #9822.
Paul Aurich <paul@darkrain42.org>
parents: 25415
diff changeset
257 smiley_themes = g_slist_prepend(smiley_themes, theme);
c91832e94473 Clarify load_smiley_theme a little. Refs #9822.
Paul Aurich <paul@darkrain42.org>
parents: 25415
diff changeset
258 }
c91832e94473 Clarify load_smiley_theme a little. Refs #9822.
Paul Aurich <paul@darkrain42.org>
parents: 25415
diff changeset
259
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 dirname = g_path_get_dirname(file);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262 while (!feof(f)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263 if (!fgets(buf, sizeof(buf), f)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
265 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267 if (buf[0] == '#' || buf[0] == '\0')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268 continue;
29320
508b73ce9b14 Fix merge.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29319
diff changeset
269 else {
508b73ce9b14 Fix merge.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29319
diff changeset
270 int len = strlen(buf);
508b73ce9b14 Fix merge.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29319
diff changeset
271 while (len && (buf[len - 1] == '\r' || buf[len - 1] == '\n'))
508b73ce9b14 Fix merge.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29319
diff changeset
272 buf[--len] = '\0';
508b73ce9b14 Fix merge.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29319
diff changeset
273 if (len == 0)
508b73ce9b14 Fix merge.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29319
diff changeset
274 continue;
508b73ce9b14 Fix merge.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29319
diff changeset
275 }
31534
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 29320
diff changeset
276
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277 i = buf;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 while (isspace(*i))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279 i++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281 if (*i == '[' && strchr(i, ']') && load) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282 struct smiley_list *child = g_new0(struct smiley_list, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283 child->sml = g_strndup(i+1, strchr(i, ']') - i - 1);
32520
fe75cd926073 Webkit Message views.
tdrhq@soc.pidgin.im
parents: 25415
diff changeset
284 child->files = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
fe75cd926073 Webkit Message views.
tdrhq@soc.pidgin.im
parents: 25415
diff changeset
285
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286 if (theme->list)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287 list->next = child;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 theme->list = child;
17666
fe5a89474e6d Reverse the smiley list only after reading the whole list of smileys in.
Stu Tomlinson <stu@nosnilmot.com>
parents: 17476
diff changeset
290 /* Reverse the Smiley list since it was built in reverse order for efficiency reasons */
fe5a89474e6d Reverse the smiley list only after reading the whole list of smileys in.
Stu Tomlinson <stu@nosnilmot.com>
parents: 17476
diff changeset
291 if (list != NULL)
fe5a89474e6d Reverse the smiley list only after reading the whole list of smileys in.
Stu Tomlinson <stu@nosnilmot.com>
parents: 17476
diff changeset
292 list->smileys = g_slist_reverse(list->smileys);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293 list = child;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294 } else if (!g_ascii_strncasecmp(i, "Name=", strlen("Name="))) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295 g_free(theme->name);
17476
92821180bded A somewhat-Warmenhoved patch from tfujiwara to allow for the smiley theme
Richard Laager <rlaager@wiktel.com>
parents: 16361
diff changeset
296 theme->name = g_strdup(i + strlen("Name="));
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
297 } else if (!g_ascii_strncasecmp(i, "Description=", strlen("Description="))) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298 g_free(theme->desc);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
299 theme->desc = g_strdup(i + strlen("Description="));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
300 } else if (!g_ascii_strncasecmp(i, "Icon=", strlen("Icon="))) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
301 g_free(theme->icon);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
302 theme->icon = g_build_filename(dirname, i + strlen("Icon="), NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303 } else if (!g_ascii_strncasecmp(i, "Author=", strlen("Author="))) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304 g_free(theme->author);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
305 theme->author = g_strdup(i + strlen("Author="));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
306 } else if (load && list) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
307 gboolean hidden = FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
308 char *sfile = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
309
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
310 if (*i == '!' && *(i + 1) == ' ') {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
311 hidden = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
312 i = i + 2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
314 while (*i) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
315 char l[64];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
316 int li = 0;
29318
ed93baed53c2 Look for non-null before processing theme input. Closes #10521 (again).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29308
diff changeset
317 while (*i && !isspace(*i) && li < sizeof(l) - 1) {
29320
508b73ce9b14 Fix merge.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29319
diff changeset
318 if (*i == '\\' && *(i+1) != '\0')
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319 i++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320 l[li++] = *(i++);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321 }
22889
019052a807a3 Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22874
diff changeset
322 l[li] = 0;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
323 if (!sfile) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
324 sfile = g_build_filename(dirname, l, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325 } else {
22889
019052a807a3 Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22874
diff changeset
326 GtkIMHtmlSmiley *smiley = gtk_imhtml_smiley_create(sfile, l, hidden, 0);
16150
218818f96b93 Change a g_slist_append() to a g_slist_prepend() in one place, and
Mark Doliner <mark@kingant.net>
parents: 16133
diff changeset
327 list->smileys = g_slist_prepend(list->smileys, smiley);
32520
fe75cd926073 Webkit Message views.
tdrhq@soc.pidgin.im
parents: 25415
diff changeset
328 g_hash_table_insert (list->files, g_strdup(l), g_strdup(sfile));
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 while (isspace(*i))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331 i++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333 }
16361
4d2201900a35 Fix #273 (Emoticons appearing in reverse order).
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16202
diff changeset
334
4d2201900a35 Fix #273 (Emoticons appearing in reverse order).
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16202
diff changeset
335
22889
019052a807a3 Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22874
diff changeset
336 g_free(sfile);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
337 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339
17667
98f27c7f0ef5 We also need to reverse the last protocol's smiley list instead of only
Stu Tomlinson <stu@nosnilmot.com>
parents: 17666
diff changeset
340 /* Reverse the Smiley list since it was built in reverse order for efficiency reasons */
98f27c7f0ef5 We also need to reverse the last protocol's smiley list instead of only
Stu Tomlinson <stu@nosnilmot.com>
parents: 17666
diff changeset
341 if (list != NULL)
98f27c7f0ef5 We also need to reverse the last protocol's smiley list instead of only
Stu Tomlinson <stu@nosnilmot.com>
parents: 17666
diff changeset
342 list->smileys = g_slist_reverse(list->smileys);
98f27c7f0ef5 We also need to reverse the last protocol's smiley list instead of only
Stu Tomlinson <stu@nosnilmot.com>
parents: 17666
diff changeset
343
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
344 g_free(dirname);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345 fclose(f);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347 if (!theme->name || !theme->desc || !theme->author) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15632
diff changeset
348 purple_debug_error("gtkthemes", "Invalid file format, not loading smiley theme from '%s'\n", file);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349
28136
c91832e94473 Clarify load_smiley_theme a little. Refs #9822.
Paul Aurich <paul@darkrain42.org>
parents: 25415
diff changeset
350 smiley_themes = g_slist_remove(smiley_themes, theme);
18376
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
351 pidgin_themes_destroy_smiley_theme(theme);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
354
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355 if (load) {
18063
926ccb104da0 disapproval of revision '1411afd7660760db59966c3a9f18e2adab8eb27e'
Richard Laager <rlaager@wiktel.com>
parents: 18058
diff changeset
356 GList *cnv;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
357
16133
019092f88c43 Pull out the same block of code from two places and put it into
Mark Doliner <mark@kingant.net>
parents: 16132
diff changeset
358 if (current_smiley_theme)
17483
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
359 pidgin_themes_destroy_smiley_theme_smileys(current_smiley_theme);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360 current_smiley_theme = theme;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
361
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15632
diff changeset
362 for (cnv = purple_get_conversations(); cnv != NULL; cnv = cnv->next) {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15632
diff changeset
363 PurpleConversation *conv = cnv->data;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
364
15632
a830f9756f23 Some more pidgininfication
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15514
diff changeset
365 if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) {
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
366 /* We want to see our custom smileys on our entry if we write the shortcut */
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
367 pidgin_themes_smiley_themeize_custom(PIDGIN_CONVERSATION(conv)->entry);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
368 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
369 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
370 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
371 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
372
16202
0973688f4b74 Word on the street is that we don't want things named pidginfoo_bar(), but
Richard Laager <rlaager@wiktel.com>
parents: 16151
diff changeset
373 void pidgin_themes_smiley_theme_probe()
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375 GDir *dir;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
376 const gchar *file;
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
377 gchar *path, *test_path;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
378 int l;
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
379 char* probedirs[3];
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
380
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
381 pidgin_smiley_themes_remove_non_existing();
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
382
15858
e4805a4be652 Fix smileys
Sean Egan <seanegan@gmail.com>
parents: 15823
diff changeset
383 probedirs[0] = g_build_filename(DATADIR, "pixmaps", "pidgin", "emotes", NULL);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15632
diff changeset
384 probedirs[1] = g_build_filename(purple_user_dir(), "smileys", NULL);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
385 probedirs[2] = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
386 for (l=0; probedirs[l]; l++) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
387 dir = g_dir_open(probedirs[l], 0, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
388 if (dir) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
389 while ((file = g_dir_read_name(dir))) {
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
390 test_path = g_build_filename(probedirs[l], file, NULL);
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
391 if (g_file_test(test_path, G_FILE_TEST_IS_DIR)) {
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
392 path = g_build_filename(probedirs[l], file, "theme", NULL);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
393
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
394 /* Here we check to see that the theme has proper syntax.
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
395 * We set the second argument to FALSE so that it doesn't load
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
396 * the theme yet.
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
397 */
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
398 pidgin_themes_load_smiley_theme(path, FALSE);
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
399 g_free(path);
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
400 }
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
401 g_free(test_path);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
402 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403 g_dir_close(dir);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
404 } else if (l == 1) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
405 g_mkdir(probedirs[l], S_IRUSR | S_IWUSR | S_IXUSR);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
406 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
407 g_free(probedirs[l]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
408 }
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
409
17654
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
410 if (!current_smiley_theme && smiley_themes) {
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
411 struct smiley_theme *smile = smiley_themes->data;
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
412 pidgin_themes_load_smiley_theme(smile->path, TRUE);
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
413 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
414 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
415
16202
0973688f4b74 Word on the street is that we don't want things named pidginfoo_bar(), but
Richard Laager <rlaager@wiktel.com>
parents: 16151
diff changeset
416 GSList *pidgin_themes_get_proto_smileys(const char *id) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15632
diff changeset
417 PurplePlugin *proto;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
418 struct smiley_list *list, *def;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
419
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420 if ((current_smiley_theme == NULL) || (current_smiley_theme->list == NULL))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
421 return NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
422
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
423 def = list = current_smiley_theme->list;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
424
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
425 if (id == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
426 return def->smileys;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
427
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15632
diff changeset
428 proto = purple_find_prpl(id);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
429
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
430 while (list) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
431 if (!strcmp(list->sml, "default"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
432 def = list;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
433 else if (proto && !strcmp(proto->info->name, list->sml))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
434 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
435
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
436 list = list->next;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
437 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
438
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
439 return list ? list->smileys : def->smileys;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
440 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
441
16202
0973688f4b74 Word on the street is that we don't want things named pidginfoo_bar(), but
Richard Laager <rlaager@wiktel.com>
parents: 16151
diff changeset
442 void pidgin_themes_init()
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
443 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
444 GSList *l;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
445 const char *current_theme =
16062
07554cc5d090 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents: 15858
diff changeset
446 purple_prefs_get_string(PIDGIN_PREFS_ROOT "/smileys/theme");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
447
16202
0973688f4b74 Word on the street is that we don't want things named pidginfoo_bar(), but
Richard Laager <rlaager@wiktel.com>
parents: 16151
diff changeset
448 pidgin_themes_smiley_theme_probe();
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
449
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
450 for (l = smiley_themes; l; l = l->next) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
451 struct smiley_theme *smile = l->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
452 if (smile->name && strcmp(current_theme, smile->name) == 0) {
16202
0973688f4b74 Word on the street is that we don't want things named pidginfoo_bar(), but
Richard Laager <rlaager@wiktel.com>
parents: 16151
diff changeset
453 pidgin_themes_load_smiley_theme(smile->path, TRUE);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
454 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
455 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
456 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
457
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
458 /* If we still don't have a smiley theme, choose the first one */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
459 if (!current_smiley_theme && smiley_themes) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
460 struct smiley_theme *smile = smiley_themes->data;
16202
0973688f4b74 Word on the street is that we don't want things named pidginfoo_bar(), but
Richard Laager <rlaager@wiktel.com>
parents: 16151
diff changeset
461 pidgin_themes_load_smiley_theme(smile->path, TRUE);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
462 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
463 }