annotate pidgin/gtkthemes.c @ 30385:6c148063fdfd

applied changes from bf4b720f9231b395fb51bf1e27440328d46bceb5 through 5d1cd42e92b6d03e3c1556c107bf4e6174743813
author Evan Schoenberg <evan.s@dreskin.net>
date Tue, 18 May 2010 04:28:41 +0000
parents 508b73ce9b14
children a8cc50c2279f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
15858
e4805a4be652 Fix smileys
Sean Egan <seanegan@gmail.com>
parents: 15823
diff changeset
2 * Themes for Pidgin
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
15858
e4805a4be652 Fix smileys
Sean Egan <seanegan@gmail.com>
parents: 15823
diff changeset
4 * Pidgin is the legal property of its developers, whose names are too numerous
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 * source distribution.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
19680
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 18376
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 #include "internal.h"
15514
535f002e7b0f More pidgin changes
Sean Egan <seanegan@gmail.com>
parents: 15501
diff changeset
24 #include "pidgin.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #include "conversation.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include "debug.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "prpl.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "util.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "gtkconv.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include "gtkdialogs.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #include "gtkimhtml.h"
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
34 #include "gtksmiley.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 #include "gtkthemes.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 GSList *smiley_themes = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 struct smiley_theme *current_smiley_theme;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39
17483
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
40 static void pidgin_themes_destroy_smiley_theme_smileys(struct smiley_theme *theme);
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
41
16202
0973688f4b74 Word on the street is that we don't want things named pidginfoo_bar(), but
Richard Laager <rlaager@wiktel.com>
parents: 16151
diff changeset
42 gboolean pidgin_themes_smileys_disabled()
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 if (!current_smiley_theme)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 return 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 return strcmp(current_smiley_theme->name, "none") == 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49
17483
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
50 static void
18376
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
51 pidgin_themes_destroy_smiley_theme(struct smiley_theme *theme)
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
52 {
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
53 pidgin_themes_destroy_smiley_theme_smileys(theme);
17483
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
54
18376
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
55 g_free(theme->name);
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
56 g_free(theme->desc);
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
57 g_free(theme->author);
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
58 g_free(theme->icon);
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
59 g_free(theme->path);
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
60 g_free(theme);
17483
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
61 }
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
62
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
63 static void pidgin_themes_remove_theme_dir(const char *theme_dir_name)
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
64 {
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
65 GString *str = NULL;
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
66 const char *file_name = NULL;
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
67 GDir *theme_dir = NULL;
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
68
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
69 if ((theme_dir = g_dir_open(theme_dir_name, 0, NULL)) != NULL) {
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
70 if ((str = g_string_new(theme_dir_name)) != NULL) {
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
71 while ((file_name = g_dir_read_name(theme_dir)) != NULL) {
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
72 g_string_printf(str, "%s%s%s", theme_dir_name, G_DIR_SEPARATOR_S, file_name);
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
73 g_unlink(str->str);
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
74 }
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
75 g_string_free(str, TRUE);
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
76 }
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
77 g_dir_close(theme_dir);
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
78 g_rmdir(theme_dir_name);
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
79 }
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
80 }
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
81
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
82 void pidgin_themes_remove_smiley_theme(const char *file)
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
83 {
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
84 char *theme_dir = NULL, *last_slash = NULL;
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
85 g_return_if_fail(NULL != file);
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 24311
diff changeset
86
17483
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
87 if (!g_file_test(file, G_FILE_TEST_EXISTS)) return;
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
88 if ((theme_dir = g_strdup(file)) == NULL) return ;
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
89
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
90 if ((last_slash = g_strrstr(theme_dir, G_DIR_SEPARATOR_S)) != NULL) {
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
91 GSList *iter = NULL;
17484
7055885b1b70 Figured out how to keep reflecting current smiley theme after remove.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17483
diff changeset
92 struct smiley_theme *theme = NULL, *new_theme = NULL;
17483
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
93
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
94 *last_slash = 0;
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
95
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
96 /* Delete files on disk */
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
97 pidgin_themes_remove_theme_dir(theme_dir);
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
98
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
99 /* Find theme in themes list and remove it */
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
100 for (iter = smiley_themes ; iter ; iter = iter->next) {
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
101 theme = ((struct smiley_theme *)(iter->data));
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
102 if (!strcmp(theme->path, file))
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
103 break ;
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
104 }
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
105 if (iter) {
17484
7055885b1b70 Figured out how to keep reflecting current smiley theme after remove.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17483
diff changeset
106 if (theme == current_smiley_theme) {
7055885b1b70 Figured out how to keep reflecting current smiley theme after remove.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17483
diff changeset
107 new_theme = ((struct smiley_theme *)(NULL == iter->next ? (smiley_themes == iter ? NULL : smiley_themes->data) : iter->next->data));
7055885b1b70 Figured out how to keep reflecting current smiley theme after remove.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17483
diff changeset
108 if (new_theme)
7055885b1b70 Figured out how to keep reflecting current smiley theme after remove.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17483
diff changeset
109 purple_prefs_set_string(PIDGIN_PREFS_ROOT "/smileys/theme", new_theme->name);
7055885b1b70 Figured out how to keep reflecting current smiley theme after remove.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17483
diff changeset
110 else
7055885b1b70 Figured out how to keep reflecting current smiley theme after remove.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17483
diff changeset
111 current_smiley_theme = NULL;
7055885b1b70 Figured out how to keep reflecting current smiley theme after remove.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17483
diff changeset
112 }
17483
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
113 smiley_themes = g_slist_delete_link(smiley_themes, iter);
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
114
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
115 /* Destroy theme structure */
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
116 pidgin_themes_destroy_smiley_theme(theme);
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
117 }
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
118 }
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
119
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
120 g_free(theme_dir);
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
121 }
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
122
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
123 static void _pidgin_themes_smiley_themeize(GtkWidget *imhtml, gboolean custom)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 {
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;
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 24311
diff changeset
172
24311
9ea84135db24 Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <ml@update.uu.se>
parents: 22889
diff changeset
173 if (uio->imhtml) {
9ea84135db24 Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <ml@update.uu.se>
parents: 22889
diff changeset
174 g_signal_handlers_disconnect_matched(uio->imhtml, G_SIGNAL_MATCH_DATA,
9ea84135db24 Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <ml@update.uu.se>
parents: 22889
diff changeset
175 0, 0, NULL, NULL, uio);
9ea84135db24 Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <ml@update.uu.se>
parents: 22889
diff changeset
176 }
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 24311
diff changeset
177
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
178 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
179 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
180 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
181 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
182 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
183 }
019092f88c43 Pull out the same block of code from two places and put it into
Mark Doliner <mark@kingant.net>
parents: 16132
diff changeset
184 g_free(uio->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
185 g_free(uio);
28138
deecc1d663c4 Don't use pointers (even opaquely) once they're freed. Closes #9822.
Paul Aurich <paul@darkrain42.org>
parents: 28136
diff changeset
186 wer->smileys = g_slist_delete_link(wer->smileys, wer->smileys);
16133
019092f88c43 Pull out the same block of code from two places and put it into
Mark Doliner <mark@kingant.net>
parents: 16132
diff changeset
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 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
189 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
190 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
191 }
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
192 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
193
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
194 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
195 }
019092f88c43 Pull out the same block of code from two places and put it into
Mark Doliner <mark@kingant.net>
parents: 16132
diff changeset
196
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
197 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
198 pidgin_smiley_themes_remove_non_existing(void)
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
199 {
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
200 static struct smiley_theme *theme = NULL;
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
201 GSList *iter = NULL;
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
202
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
203 if (!smiley_themes) return ;
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
204
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
205 for (iter = smiley_themes ; iter ; iter = iter->next) {
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
206 theme = ((struct smiley_theme *)(iter->data));
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
207 if (!g_file_test(theme->path, G_FILE_TEST_EXISTS)) {
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
208 if (theme == current_smiley_theme)
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
209 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
210 pidgin_themes_destroy_smiley_theme(theme);
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
211 iter->data = NULL;
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
212 }
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
213 }
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
214 /* Remove all elements whose data is NULL */
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
215 smiley_themes = g_slist_remove_all(smiley_themes, NULL);
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
216
17654
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
217 if (!current_smiley_theme && smiley_themes) {
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
218 struct smiley_theme *smile = g_slist_last(smiley_themes)->data;
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
219 pidgin_themes_load_smiley_theme(smile->path, TRUE);
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
220 }
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
221 }
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
222
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
223 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
224 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 FILE *f = g_fopen(file, "r");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 char buf[256];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227 char *i;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 struct smiley_theme *theme=NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 struct smiley_list *list = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 GSList *lst = smiley_themes;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 char *dirname;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 if (!f)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 return;
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 while (lst) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 struct smiley_theme *thm = lst->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238 if (!strcmp(thm->path, file)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 theme = thm;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242 lst = lst->next;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244
28139
5b21007cf503 Oops, fix loading smiley themes.
Paul Aurich <paul@darkrain42.org>
parents: 28138
diff changeset
245 if (theme != NULL && theme == current_smiley_theme) {
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246 /* 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
247 fclose(f);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248 return;
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
28136
c91832e94473 Clarify load_smiley_theme a little. Refs #9822.
Paul Aurich <paul@darkrain42.org>
parents: 25415
diff changeset
251 if (theme == NULL) {
c91832e94473 Clarify load_smiley_theme a little. Refs #9822.
Paul Aurich <paul@darkrain42.org>
parents: 25415
diff changeset
252 theme = g_new0(struct smiley_theme, 1);
c91832e94473 Clarify load_smiley_theme a little. Refs #9822.
Paul Aurich <paul@darkrain42.org>
parents: 25415
diff changeset
253 theme->path = g_strdup(file);
c91832e94473 Clarify load_smiley_theme a little. Refs #9822.
Paul Aurich <paul@darkrain42.org>
parents: 25415
diff changeset
254 smiley_themes = g_slist_prepend(smiley_themes, theme);
c91832e94473 Clarify load_smiley_theme a little. Refs #9822.
Paul Aurich <paul@darkrain42.org>
parents: 25415
diff changeset
255 }
c91832e94473 Clarify load_smiley_theme a little. Refs #9822.
Paul Aurich <paul@darkrain42.org>
parents: 25415
diff changeset
256
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 dirname = g_path_get_dirname(file);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259 while (!feof(f)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 if (!fgets(buf, sizeof(buf), f)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262 }
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 (buf[0] == '#' || buf[0] == '\0')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
265 continue;
29320
508b73ce9b14 Fix merge.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29319
diff changeset
266 else {
508b73ce9b14 Fix merge.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29319
diff changeset
267 int len = strlen(buf);
508b73ce9b14 Fix merge.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29319
diff changeset
268 while (len && (buf[len - 1] == '\r' || buf[len - 1] == '\n'))
508b73ce9b14 Fix merge.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29319
diff changeset
269 buf[--len] = '\0';
508b73ce9b14 Fix merge.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29319
diff changeset
270 if (len == 0)
508b73ce9b14 Fix merge.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29319
diff changeset
271 continue;
508b73ce9b14 Fix merge.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29319
diff changeset
272 }
508b73ce9b14 Fix merge.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29319
diff changeset
273
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274 i = buf;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275 while (isspace(*i))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276 i++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 if (*i == '[' && strchr(i, ']') && load) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279 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
280 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
281 if (theme->list)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282 list->next = child;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284 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
285 /* 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
286 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
287 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
288 list = child;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 } 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
290 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
291 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
292 } 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
293 g_free(theme->desc);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294 theme->desc = g_strdup(i + strlen("Description="));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295 } 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
296 g_free(theme->icon);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
297 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
298 } 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
299 g_free(theme->author);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
300 theme->author = g_strdup(i + strlen("Author="));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
301 } else if (load && list) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
302 gboolean hidden = FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303 char *sfile = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
305 if (*i == '!' && *(i + 1) == ' ') {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
306 hidden = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
307 i = i + 2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
308 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
309 while (*i) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
310 char l[64];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
311 int li = 0;
29318
ed93baed53c2 Look for non-null before processing theme input. Closes #10521 (again).
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29308
diff changeset
312 while (*i && !isspace(*i) && li < sizeof(l) - 1) {
29320
508b73ce9b14 Fix merge.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29319
diff changeset
313 if (*i == '\\' && *(i+1) != '\0')
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
314 i++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
315 l[li++] = *(i++);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
316 }
22889
019052a807a3 Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22874
diff changeset
317 l[li] = 0;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
318 if (!sfile) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319 sfile = g_build_filename(dirname, l, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320 } 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
321 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
322 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
323 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
324 while (isspace(*i))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325 i++;
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 }
16361
4d2201900a35 Fix #273 (Emoticons appearing in reverse order).
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16202
diff changeset
328
4d2201900a35 Fix #273 (Emoticons appearing in reverse order).
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16202
diff changeset
329
22889
019052a807a3 Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22874
diff changeset
330 g_free(sfile);
15374
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 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333
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
334 /* 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
335 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
336 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
337
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338 g_free(dirname);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339 fclose(f);
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 if (!theme->name || !theme->desc || !theme->author) {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15632
diff changeset
342 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
343
28136
c91832e94473 Clarify load_smiley_theme a little. Refs #9822.
Paul Aurich <paul@darkrain42.org>
parents: 25415
diff changeset
344 smiley_themes = g_slist_remove(smiley_themes, theme);
18376
e56531865ea5 Eliminate some duplicate code.
Richard Laager <rlaager@wiktel.com>
parents: 18295
diff changeset
345 pidgin_themes_destroy_smiley_theme(theme);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346 return;
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 if (load) {
18063
926ccb104da0 disapproval of revision '1411afd7660760db59966c3a9f18e2adab8eb27e'
Richard Laager <rlaager@wiktel.com>
parents: 18058
diff changeset
350 GList *cnv;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351
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
352 if (current_smiley_theme)
17483
cf6b7aeae062 Need help reflecting selected smiley theme after remove
Gabriel Schulhof <nix@go-nix.ca>
parents: 17482
diff changeset
353 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
354 current_smiley_theme = theme;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15632
diff changeset
356 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
357 PurpleConversation *conv = cnv->data;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
358
15632
a830f9756f23 Some more pidgininfication
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15514
diff changeset
359 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
360 /* 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
361 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
362 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
363 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
364 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
365 }
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
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
368 void pidgin_themes_smiley_theme_probe()
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
369 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
370 GDir *dir;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
371 const gchar *file;
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
372 gchar *path, *test_path;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373 int l;
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
374 char* probedirs[3];
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
376 pidgin_smiley_themes_remove_non_existing();
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
377
15858
e4805a4be652 Fix smileys
Sean Egan <seanegan@gmail.com>
parents: 15823
diff changeset
378 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
379 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
380 probedirs[2] = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
381 for (l=0; probedirs[l]; l++) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
382 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
383 if (dir) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
384 while ((file = g_dir_read_name(dir))) {
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
385 test_path = g_build_filename(probedirs[l], file, NULL);
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
386 if (g_file_test(test_path, G_FILE_TEST_IS_DIR)) {
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
387 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
388
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
389 /* Here we check to see that the theme has proper syntax.
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
390 * 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
391 * the theme yet.
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 pidgin_themes_load_smiley_theme(path, FALSE);
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
394 g_free(path);
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
395 }
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
396 g_free(test_path);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
397 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
398 g_dir_close(dir);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
399 } else if (l == 1) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
400 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
401 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
402 g_free(probedirs[l]);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403 }
17653
76066eb86611 Weirdness ...
Gabriel Schulhof <nix@go-nix.ca>
parents: 17484
diff changeset
404
17654
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
405 if (!current_smiley_theme && smiley_themes) {
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
406 struct smiley_theme *smile = smiley_themes->data;
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
407 pidgin_themes_load_smiley_theme(smile->path, TRUE);
6c9c16275868 Aaaaaaaah!
Gabriel Schulhof <nix@go-nix.ca>
parents: 17653
diff changeset
408 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
409 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
410
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
411 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
412 PurplePlugin *proto;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
413 struct smiley_list *list, *def;
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 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
416 return NULL;
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 def = list = current_smiley_theme->list;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
419
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420 if (id == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
421 return def->smileys;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
422
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15632
diff changeset
423 proto = purple_find_prpl(id);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
424
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
425 while (list) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
426 if (!strcmp(list->sml, "default"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
427 def = list;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
428 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
429 break;
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 list = list->next;
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 return list ? list->smileys : def->smileys;
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
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
437 void pidgin_themes_init()
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
438 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
439 GSList *l;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
440 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
441 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
442
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
443 pidgin_themes_smiley_theme_probe();
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
444
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
445 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
446 struct smiley_theme *smile = l->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
447 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
448 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
449 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
450 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
451 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
452
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
453 /* 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
454 if (!current_smiley_theme && smiley_themes) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
455 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
456 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
457 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
458 }