annotate pidgin/gtkthemes.c @ 23483:748308865dbf

Changed how the prefs handle themes
author Justin Rodriguez <ffdragon@soc.pidgin.im>
date Wed, 23 Jul 2008 05:32:00 +0000
parents 019052a807a3
children 9ea84135db24
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);
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
86
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 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 struct smiley_list *list;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 if (!current_smiley_theme)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 gtk_imhtml_remove_smileys(GTK_IMHTML(imhtml));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 list = current_smiley_theme->list;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131 while (list) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 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
133 GSList *icons = list->smileys;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 while (icons) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 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
136 icons = icons->next;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 }
22889
019052a807a3 Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22874
diff changeset
138
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
139 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
140 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
141
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
142 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
143 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
144 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
145 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
146 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
147
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148 list = list->next;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
152 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
153 {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
154 _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
155 }
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 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
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 _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
160 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
161
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
162 static void
17483
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
163 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
164 {
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
165 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
166 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
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 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
169 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
170 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
171 GtkIMHtmlSmiley *uio = wer->smileys->data;
019092f88c43 Pull out the same block of code from two places and put it into
Mark Doliner <mark@kingant.net>
parents: 16132
diff changeset
172 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
173 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
174 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
175 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
176 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
177 }
019092f88c43 Pull out the same block of code from two places and put it into
Mark Doliner <mark@kingant.net>
parents: 16132
diff changeset
178 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
179 g_free(uio);
019092f88c43 Pull out the same block of code from two places and put it into
Mark Doliner <mark@kingant.net>
parents: 16132
diff changeset
180 wer->smileys = g_slist_remove(wer->smileys, uio);
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 }
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
182 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
183 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
184 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
185 }
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
186 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
187
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
188 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
189 }
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
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
191 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
192 pidgin_smiley_themes_remove_non_existing(void)
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
193 {
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
194 static struct smiley_theme *theme = NULL;
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
195 GSList *iter = NULL;
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
196
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
197 if (!smiley_themes) return ;
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
198
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
199 for (iter = smiley_themes ; iter ; iter = iter->next) {
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
200 theme = ((struct smiley_theme *)(iter->data));
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
201 if (!g_file_test(theme->path, G_FILE_TEST_EXISTS)) {
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
202 if (theme == current_smiley_theme)
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
203 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
204 pidgin_themes_destroy_smiley_theme(theme);
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
205 iter->data = NULL;
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
206 }
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 /* Remove all elements whose data is NULL */
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
209 smiley_themes = g_slist_remove_all(smiley_themes, NULL);
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
210
17654
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
211 if (!current_smiley_theme && smiley_themes) {
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
212 struct smiley_theme *smile = g_slist_last(smiley_themes)->data;
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
213 pidgin_themes_load_smiley_theme(smile->path, TRUE);
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
214 }
17653
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
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
217 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
218 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 FILE *f = g_fopen(file, "r");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 char buf[256];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 char *i;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222 struct smiley_theme *theme=NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 struct smiley_list *list = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 GSList *lst = smiley_themes;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 char *dirname;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 gboolean new_theme = FALSE;
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 if (!f)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 while (lst) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 struct smiley_theme *thm = lst->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 if (!strcmp(thm->path, file)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 theme = thm;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 lst = lst->next;
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240 if (!theme) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 new_theme = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242 theme = g_new0(struct smiley_theme, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 theme->path = g_strdup(file);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244 } else if (theme == current_smiley_theme) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 /* 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
246 fclose(f);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250 dirname = g_path_get_dirname(file);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252 while (!feof(f)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 if (!fgets(buf, sizeof(buf), f)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
255 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 if (buf[0] == '#' || buf[0] == '\0')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 i = buf;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261 while (isspace(*i))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262 i++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264 if (*i == '[' && strchr(i, ']') && load) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
265 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
266 child->sml = g_strndup(i+1, strchr(i, ']') - i - 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267 if (theme->list)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268 list->next = child;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270 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
271 /* 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
272 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
273 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
274 list = child;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275 } 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
276 int len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277 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
278 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
279 len = strlen(theme->name);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280 theme->name[len-1] = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281 if(len > 2 && theme->name[len-2] == '\r')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282 theme->name[len-2] = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283 } 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
284 g_free(theme->desc);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285 theme->desc = g_strdup(i + strlen("Description="));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286 theme->desc[strlen(theme->desc)-1] = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287 } 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
288 g_free(theme->icon);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 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
290 theme->icon[strlen(theme->icon)-1] = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291 } 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
292 g_free(theme->author);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293 theme->author = g_strdup(i + strlen("Author="));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294 theme->author[strlen(theme->author)-1] = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295 } else if (load && list) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296 gboolean hidden = FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
297 char *sfile = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
299 if (*i == '!' && *(i + 1) == ' ') {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
300 hidden = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
301 i = i + 2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
302 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303 while (*i) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304 char l[64];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
305 int li = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
306 while (!isspace(*i) && li < sizeof(l) - 1) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
307 if (*i == '\\' && *(i+1) != '\0' && *(i+1) != '\n' && *(i+1) != '\r')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
308 i++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
309 l[li++] = *(i++);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
310 }
22889
019052a807a3 Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22874
diff changeset
311 l[li] = 0;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
312 if (!sfile) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313 sfile = g_build_filename(dirname, l, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
314 } 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
315 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
316 list->smileys = g_slist_prepend(list->smileys, smiley);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
317 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
318 while (isspace(*i))
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321 }
16361
4d2201900a35 Fix #273 (Emoticons appearing in reverse order).
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16202
diff changeset
322
4d2201900a35 Fix #273 (Emoticons appearing in reverse order).
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16202
diff changeset
323
22889
019052a807a3 Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22874
diff changeset
324 g_free(sfile);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
326 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
327
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
328 /* 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
329 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
330 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
331
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332 g_free(dirname);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333 fclose(f);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
335 if (!theme->name || !theme->desc || !theme->author) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15632
diff changeset
336 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
337
18376
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
338 pidgin_themes_destroy_smiley_theme(theme);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
340 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
342 if (new_theme) {
16151
c0dc6225a1d7 Change another 'append' to 'prepend', since the ordering doesn't matter
Mark Doliner <mark@kingant.net>
parents: 16150
diff changeset
343 smiley_themes = g_slist_prepend(smiley_themes, theme);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
344 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346 if (load) {
18063
926ccb104da0 disapproval of revision '1411afd7660760db59966c3a9f18e2adab8eb27e'
Richard Laager <rlaager@wiktel.com>
parents: 18058
diff changeset
347 GList *cnv;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
348
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
349 if (current_smiley_theme)
17483
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
350 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
351 current_smiley_theme = theme;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15632
diff changeset
353 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
354 PurpleConversation *conv = cnv->data;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355
15632
a830f9756f23 Some more pidgininfication
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15514
diff changeset
356 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
357 /* We want to see our custom smileys on our entry if we write the shortcut */
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
358 pidgin_themes_smiley_themeize(PIDGIN_CONVERSATION(conv)->imhtml);
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
359 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
360 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
361 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
362 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
364
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
365 void pidgin_themes_smiley_theme_probe()
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
367 GDir *dir;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
368 const gchar *file;
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
369 gchar *path, *test_path;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
370 int l;
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
371 char* probedirs[3];
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
372
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
373 pidgin_smiley_themes_remove_non_existing();
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
374
15858
e4805a4be652 Fix smileys
Sean Egan <seanegan@gmail.com>
parents: 15823
diff changeset
375 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
376 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
377 probedirs[2] = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
378 for (l=0; probedirs[l]; l++) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
379 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
380 if (dir) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
381 while ((file = g_dir_read_name(dir))) {
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
382 test_path = g_build_filename(probedirs[l], file, NULL);
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
383 if (g_file_test(test_path, G_FILE_TEST_IS_DIR)) {
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
384 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
385
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
386 /* Here we check to see that the theme has proper syntax.
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
387 * 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
388 * the theme yet.
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
389 */
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
390 pidgin_themes_load_smiley_theme(path, FALSE);
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
391 g_free(path);
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
392 }
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
393 g_free(test_path);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
394 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
395 g_dir_close(dir);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
396 } else if (l == 1) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
397 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
398 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
399 g_free(probedirs[l]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
400 }
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
401
17654
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
402 if (!current_smiley_theme && smiley_themes) {
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
403 struct smiley_theme *smile = smiley_themes->data;
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
404 pidgin_themes_load_smiley_theme(smile->path, TRUE);
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
405 }
15374
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
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
408 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
409 PurplePlugin *proto;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
410 struct smiley_list *list, *def;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
411
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
412 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
413 return NULL;
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 def = list = current_smiley_theme->list;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
416
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
417 if (id == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
418 return def->smileys;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
419
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15632
diff changeset
420 proto = purple_find_prpl(id);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
421
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
422 while (list) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
423 if (!strcmp(list->sml, "default"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
424 def = list;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
425 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
426 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
427
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
428 list = list->next;
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
431 return list ? list->smileys : def->smileys;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
432 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
433
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
434 void pidgin_themes_init()
15374
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 GSList *l;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
437 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
438 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
439
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
440 pidgin_themes_smiley_theme_probe();
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
441
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
442 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
443 struct smiley_theme *smile = l->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
444 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
445 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
446 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
447 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
448 }
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 /* 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
451 if (!current_smiley_theme && smiley_themes) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
452 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
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 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
455 }