annotate pidgin/gtkthemes.c @ 18804:b839f427cbb2

More minor leak fixes and cleanup to bonjour.
author Daniel Atallah <daniel.atallah@gmail.com>
date Mon, 06 Aug 2007 00:12:52 +0000
parents e56531865ea5
children 44b4e8bd759b
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 #include "gtkthemes.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 GSList *smiley_themes = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 struct smiley_theme *current_smiley_theme;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38
17483
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
39 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
40
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
41 gboolean pidgin_themes_smileys_disabled()
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 if (!current_smiley_theme)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 return 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 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
47 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48
17483
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
49 static void
18376
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
50 pidgin_themes_destroy_smiley_theme(struct smiley_theme *theme)
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
51 {
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
52 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
53
18376
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
54 g_free(theme->name);
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
55 g_free(theme->desc);
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
56 g_free(theme->author);
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
57 g_free(theme->icon);
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
58 g_free(theme->path);
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
59 g_free(theme);
17483
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
60 }
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 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
63 {
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
64 GString *str = NULL;
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
65 const char *file_name = NULL;
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
66 GDir *theme_dir = NULL;
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
67
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
68 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
69 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
70 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
71 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
72 g_unlink(str->str);
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
73 }
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
74 g_string_free(str, TRUE);
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
75 }
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
76 g_dir_close(theme_dir);
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
77 g_rmdir(theme_dir_name);
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
78 }
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 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
82 {
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
83 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
84 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
85
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
86 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
87 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
88
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
89 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
90 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
91 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
92
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
93 *last_slash = 0;
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
94
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
95 /* Delete files on disk */
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
96 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
97
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
98 /* 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
99 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
100 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
101 if (!strcmp(theme->path, file))
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
102 break ;
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
103 }
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
104 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
105 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
106 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
107 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
108 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
109 else
7055885b1b70 Figured out how to keep reflecting current smiley theme after remove.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17483
diff changeset
110 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
111 }
17483
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
112 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
113
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
114 /* Destroy theme structure */
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
115 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
116 }
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 g_free(theme_dir);
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
120 }
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
121
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
122 void pidgin_themes_smiley_themeize(GtkWidget *imhtml)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 struct smiley_list *list;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 if (!current_smiley_theme)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 gtk_imhtml_remove_smileys(GTK_IMHTML(imhtml));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 list = current_smiley_theme->list;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 while (list) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131 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
132 GSList *icons = list->smileys;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 while (icons) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 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
135 icons = icons->next;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 list = list->next;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140
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
141 static void
17483
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
142 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
143 {
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
144 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
145 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
146
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
147 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
148 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
149 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
150 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
151 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
152 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
153 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
154 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
155 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
156 }
019092f88c43 Pull out the same block of code from two places and put it into
Mark Doliner <mark@kingant.net>
parents: 16132
diff changeset
157 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
158 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
159 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
160 }
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
161 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
162 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
163 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
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 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
166
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
167 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
168 }
019092f88c43 Pull out the same block of code from two places and put it into
Mark Doliner <mark@kingant.net>
parents: 16132
diff changeset
169
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
170 static void
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
171 pidgin_smiley_themes_remove_non_existing()
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
172 {
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
173 static struct smiley_theme *theme = NULL;
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
174 GSList *iter = NULL;
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
175
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
176 if (!smiley_themes) return ;
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
177
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
178 for (iter = smiley_themes ; iter ; iter = iter->next) {
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
179 theme = ((struct smiley_theme *)(iter->data));
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
180 if (!g_file_test(theme->path, G_FILE_TEST_EXISTS)) {
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
181 if (theme == current_smiley_theme)
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
182 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
183 pidgin_themes_destroy_smiley_theme(theme);
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
184 iter->data = NULL;
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
185 }
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
186 }
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
187 /* Remove all elements whose data is NULL */
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
188 smiley_themes = g_slist_remove_all(smiley_themes, NULL);
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
189
17654
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
190 if (!current_smiley_theme && smiley_themes) {
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
191 struct smiley_theme *smile = g_slist_last(smiley_themes)->data;
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
192 pidgin_themes_load_smiley_theme(smile->path, TRUE);
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
193 }
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
194 }
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
195
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
196 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
197 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198 FILE *f = g_fopen(file, "r");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199 char buf[256];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 char *i;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201 struct smiley_theme *theme=NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202 struct smiley_list *list = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 GSList *lst = smiley_themes;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 char *dirname;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 gboolean new_theme = FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 if (!f)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 while (lst) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 struct smiley_theme *thm = lst->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 if (!strcmp(thm->path, file)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 theme = thm;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 lst = lst->next;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 }
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 if (!theme) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 new_theme = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 theme = g_new0(struct smiley_theme, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222 theme->path = g_strdup(file);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 } else if (theme == current_smiley_theme) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 /* 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
225 fclose(f);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 return;
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 dirname = g_path_get_dirname(file);
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 (!feof(f)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 if (!fgets(buf, sizeof(buf), f)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 }
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 (buf[0] == '#' || buf[0] == '\0')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 continue;
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 i = buf;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240 while (isspace(*i))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 i++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 if (*i == '[' && strchr(i, ']') && load) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244 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
245 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
246 if (theme->list)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247 list->next = child;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249 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
250 /* 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
251 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
252 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
253 list = child;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254 } 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
255 int len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256 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
257 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
258 len = strlen(theme->name);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259 theme->name[len-1] = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 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
261 theme->name[len-2] = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262 } 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
263 g_free(theme->desc);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264 theme->desc = g_strdup(i + strlen("Description="));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
265 theme->desc[strlen(theme->desc)-1] = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266 } 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
267 g_free(theme->icon);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268 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
269 theme->icon[strlen(theme->icon)-1] = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270 } 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
271 g_free(theme->author);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
272 theme->author = g_strdup(i + strlen("Author="));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273 theme->author[strlen(theme->author)-1] = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274 } else if (load && list) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275 gboolean hidden = FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276 char *sfile = NULL;
16132
9699941af4c4 Fix a memory leak that occurs when a smiley theme lists a filename,
Mark Doliner <mark@kingant.net>
parents: 16062
diff changeset
277 gboolean have_used_sfile = FALSE;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279 if (*i == '!' && *(i + 1) == ' ') {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280 hidden = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281 i = i + 2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283 while (*i) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284 char l[64];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285 int li = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286 while (!isspace(*i) && li < sizeof(l) - 1) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287 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
288 i++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 l[li++] = *(i++);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291 if (!sfile) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
292 l[li] = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293 sfile = g_build_filename(dirname, l, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295 GtkIMHtmlSmiley *smiley = g_new0(GtkIMHtmlSmiley, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296 l[li] = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
297 smiley->file = sfile;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298 smiley->smile = g_strdup(l);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
299 smiley->hidden = hidden;
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
300 list->smileys = g_slist_prepend(list->smileys, smiley);
16132
9699941af4c4 Fix a memory leak that occurs when a smiley theme lists a filename,
Mark Doliner <mark@kingant.net>
parents: 16062
diff changeset
301 have_used_sfile = TRUE;
15374
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 (isspace(*i))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304 i++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
305
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
306 }
16361
4d2201900a35 Fix #273 (Emoticons appearing in reverse order).
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16202
diff changeset
307
4d2201900a35 Fix #273 (Emoticons appearing in reverse order).
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16202
diff changeset
308
16132
9699941af4c4 Fix a memory leak that occurs when a smiley theme lists a filename,
Mark Doliner <mark@kingant.net>
parents: 16062
diff changeset
309 if (!have_used_sfile)
9699941af4c4 Fix a memory leak that occurs when a smiley theme lists a filename,
Mark Doliner <mark@kingant.net>
parents: 16062
diff changeset
310 g_free(sfile);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
311 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
312 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313
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
314 /* 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
315 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
316 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
317
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
318 g_free(dirname);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319 fclose(f);
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 if (!theme->name || !theme->desc || !theme->author) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15632
diff changeset
322 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
323
18376
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
324 pidgin_themes_destroy_smiley_theme(theme);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325 return;
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328 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
329 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
330 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332 if (load) {
18063
926ccb104da0 disapproval of revision '1411afd7660760db59966c3a9f18e2adab8eb27e'
Richard Laager <rlaager@wiktel.com>
parents: 18058
diff changeset
333 GList *cnv;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334
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
335 if (current_smiley_theme)
17483
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
336 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
337 current_smiley_theme = theme;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15632
diff changeset
339 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
340 PurpleConversation *conv = cnv->data;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341
15632
a830f9756f23 Some more pidgininfication
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15514
diff changeset
342 if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) {
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
343 pidgin_themes_smiley_themeize(PIDGIN_CONVERSATION(conv)->imhtml);
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
344 pidgin_themes_smiley_themeize(PIDGIN_CONVERSATION(conv)->entry);
15374
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 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
348 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349
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
350 void pidgin_themes_smiley_theme_probe()
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352 GDir *dir;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353 const gchar *file;
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
354 gchar *path, *test_path;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355 int l;
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
356 char* probedirs[3];
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
357
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
358 pidgin_smiley_themes_remove_non_existing();
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
359
15858
e4805a4be652 Fix smileys
Sean Egan <seanegan@gmail.com>
parents: 15823
diff changeset
360 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
361 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
362 probedirs[2] = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363 for (l=0; probedirs[l]; l++) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
364 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
365 if (dir) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366 while ((file = g_dir_read_name(dir))) {
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
367 test_path = g_build_filename(probedirs[l], file, NULL);
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
368 if (g_file_test(test_path, G_FILE_TEST_IS_DIR)) {
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
369 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
370
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
371 /* Here we check to see that the theme has proper syntax.
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
372 * 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
373 * the theme yet.
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
374 */
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
375 pidgin_themes_load_smiley_theme(path, FALSE);
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
376 g_free(path);
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
377 }
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
378 g_free(test_path);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
379 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
380 g_dir_close(dir);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
381 } else if (l == 1) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
382 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
383 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
384 g_free(probedirs[l]);
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
17654
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
387 if (!current_smiley_theme && smiley_themes) {
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
388 struct smiley_theme *smile = smiley_themes->data;
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
389 pidgin_themes_load_smiley_theme(smile->path, TRUE);
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
390 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
391 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
392
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
393 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
394 PurplePlugin *proto;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
395 struct smiley_list *list, *def;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
396
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
397 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
398 return NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
399
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
400 def = list = current_smiley_theme->list;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
401
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
402 if (id == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403 return def->smileys;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
404
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15632
diff changeset
405 proto = purple_find_prpl(id);
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 while (list) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
408 if (!strcmp(list->sml, "default"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
409 def = list;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
410 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
411 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
412
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
413 list = list->next;
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
416 return list ? list->smileys : def->smileys;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
417 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
418
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
419 void pidgin_themes_init()
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
421 GSList *l;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
422 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
423 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
424
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
425 pidgin_themes_smiley_theme_probe();
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
426
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
427 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
428 struct smiley_theme *smile = l->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
429 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
430 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
431 break;
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 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
434
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
435 /* 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
436 if (!current_smiley_theme && smiley_themes) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
437 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
438 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
439 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
440 }