annotate pidgin/gtksmiley.c @ 24011:005649461c77

In our child DNS lookup processes, don't bother to use select to watch the pipe with our parent. These processes don't do anything else, and they only need to watch one fd, so we can just use a blocking read() call. I don't think this will negatively affect anything, and it seems to fix some kind of funky rare race condition where the libpurple client will block while trying to read() a response from the child. If you think we should continue using select here, or you notice some problems with this, please let me know (and maybe even revert this)
author Mark Doliner <mark@kingant.net>
date Wed, 10 Sep 2008 21:48:33 +0000
parents 64a4069e504e
children 305fac6af8f9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1 /**
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
2 * @file gtksmiley.c GTK+ Smiley Manager API
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
3 * @ingroup pidgin
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
4 */
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
5
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
6 /*
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
7 * pidgin
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
8 *
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
9 * Pidgin is the legal property of its developers, whose names are too numerous
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
10 * to list here. Please refer to the COPYRIGHT file distributed with this
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
11 * source distribution.
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
12 *
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
13 * This program is free software; you can redistribute it and/or modify
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
14 * it under the terms of the GNU General Public License as published by
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
15 * the Free Software Foundation; either version 2 of the License, or
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
16 * (at your option) any later version.
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
17 *
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
18 * This program is distributed in the hope that it will be useful,
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
21 * GNU General Public License for more details.
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
22 *
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
23 * You should have received a copy of the GNU General Public License
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
24 * along with this program; if not, write to the Free Software
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
26 */
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
27
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
28 #include "internal.h"
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
29 #include "pidgin.h"
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
30
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
31 #include "debug.h"
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
32 #include "notify.h"
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
33 #include "smiley.h"
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
34
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
35 #include "gtkimhtml.h"
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
36 #include "gtksmiley.h"
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
37 #include "gtkutils.h"
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
38 #include "pidginstock.h"
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
39
23143
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
40 #define PIDGIN_RESPONSE_EDIT 1000
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
41
23163
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
42 struct _PidginSmiley
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
43 {
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
44 PurpleSmiley *smiley;
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
45 GtkWidget *parent;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
46 GtkWidget *smile;
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
47 GtkWidget *smiley_image;
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
48 gchar *filename;
23163
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
49 GdkPixbuf *custom_pixbuf;
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
50 };
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
51
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
52 typedef struct
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
53 {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
54 GtkWidget *window;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
55
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
56 GtkWidget *treeview;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
57 GtkListStore *model;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
58 } SmileyManager;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
59
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
60 enum
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
61 {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
62 ICON,
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
63 SHORTCUT,
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
64 SMILEY,
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
65 N_COL
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
66 };
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
67
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
68 static SmileyManager *smiley_manager = NULL;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
69 static GSList *gtk_smileys = NULL;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
70
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
71 static void
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
72 pidgin_smiley_destroy(PidginSmiley *smiley)
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
73 {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
74 gtk_widget_destroy(smiley->parent);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
75 g_free(smiley->filename);
23163
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
76 if (smiley->custom_pixbuf)
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
77 gdk_pixbuf_unref(smiley->custom_pixbuf);
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
78 g_free(smiley);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
79 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
80
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
81 /******************************************************************************
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
82 * GtkIMHtmlSmileys stuff
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
83 *****************************************************************************/
23136
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
84 /* Perhaps these should be in gtkimhtml.c instead. -- sadrul */
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
85 static void add_gtkimhtml_to_list(GtkIMHtmlSmiley *gtksmiley)
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
86 {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
87 gtk_smileys = g_slist_prepend(gtk_smileys, gtksmiley);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
88
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
89 purple_debug_info("gtksmiley", "adding %s to gtk_smileys\n", gtksmiley->smile);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
90 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
91
23136
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
92 static void
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
93 shortcut_changed_cb(PurpleSmiley *smiley, gpointer dontcare, GtkIMHtmlSmiley *gtksmiley)
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
94 {
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
95 g_free(gtksmiley->smile);
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
96 gtksmiley->smile = g_strdup(purple_smiley_get_shortcut(smiley));
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
97 }
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
98
23235
bfbd2b038135 Update the smiley in the smiley dialog if the imagefile is changed.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23185
diff changeset
99 static void
bfbd2b038135 Update the smiley in the smiley dialog if the imagefile is changed.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23185
diff changeset
100 image_changed_cb(PurpleSmiley *smiley, gpointer dontcare, GtkIMHtmlSmiley *gtksmiley)
bfbd2b038135 Update the smiley in the smiley dialog if the imagefile is changed.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23185
diff changeset
101 {
bfbd2b038135 Update the smiley in the smiley dialog if the imagefile is changed.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23185
diff changeset
102 const char *file;
bfbd2b038135 Update the smiley in the smiley dialog if the imagefile is changed.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23185
diff changeset
103
bfbd2b038135 Update the smiley in the smiley dialog if the imagefile is changed.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23185
diff changeset
104 g_free(gtksmiley->file);
bfbd2b038135 Update the smiley in the smiley dialog if the imagefile is changed.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23185
diff changeset
105
bfbd2b038135 Update the smiley in the smiley dialog if the imagefile is changed.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23185
diff changeset
106 file = purple_imgstore_get_filename(purple_smiley_get_stored_image(smiley));
bfbd2b038135 Update the smiley in the smiley dialog if the imagefile is changed.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23185
diff changeset
107 gtksmiley->file = g_build_filename(purple_smileys_get_storing_dir(), file, NULL);
bfbd2b038135 Update the smiley in the smiley dialog if the imagefile is changed.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23185
diff changeset
108 gtk_imhtml_smiley_reload(gtksmiley);
bfbd2b038135 Update the smiley in the smiley dialog if the imagefile is changed.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23185
diff changeset
109 }
bfbd2b038135 Update the smiley in the smiley dialog if the imagefile is changed.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23185
diff changeset
110
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
111 static GtkIMHtmlSmiley *smiley_purple_to_gtkimhtml(PurpleSmiley *smiley)
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
112 {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
113 GtkIMHtmlSmiley *gtksmiley;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
114 gchar *filename;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
115 const gchar *file;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
116
22880
2ab289f312d0 Hide PurpleSmiley internals.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22878
diff changeset
117 file = purple_imgstore_get_filename(purple_smiley_get_stored_image(smiley));
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
118
23136
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
119 filename = g_build_filename(purple_smileys_get_storing_dir(), file, NULL);
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
120
22889
019052a807a3 Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22883
diff changeset
121 gtksmiley = gtk_imhtml_smiley_create(filename, purple_smiley_get_shortcut(smiley),
019052a807a3 Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22883
diff changeset
122 FALSE, GTK_IMHTML_SMILEY_CUSTOM);
019052a807a3 Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22883
diff changeset
123 g_free(filename);
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
124
23136
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
125 /* Make sure the shortcut for the GtkIMHtmlSmiley is updated with the PurpleSmiley */
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
126 g_signal_connect(G_OBJECT(smiley), "notify::shortcut",
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
127 G_CALLBACK(shortcut_changed_cb), gtksmiley);
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
128
23235
bfbd2b038135 Update the smiley in the smiley dialog if the imagefile is changed.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23185
diff changeset
129 /* And update the pixbuf too when the image is changed */
bfbd2b038135 Update the smiley in the smiley dialog if the imagefile is changed.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23185
diff changeset
130 g_signal_connect(G_OBJECT(smiley), "notify::image",
bfbd2b038135 Update the smiley in the smiley dialog if the imagefile is changed.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23185
diff changeset
131 G_CALLBACK(image_changed_cb), gtksmiley);
bfbd2b038135 Update the smiley in the smiley dialog if the imagefile is changed.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23185
diff changeset
132
23136
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
133 return gtksmiley;
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
134 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
135
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
136 void pidgin_smiley_del_from_list(PurpleSmiley *smiley)
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
137 {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
138 GSList *list = NULL;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
139 GtkIMHtmlSmiley *gtksmiley;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
140
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
141 if (gtk_smileys == NULL)
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
142 return;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
143
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
144 list = gtk_smileys;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
145
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
146 for (; list; list = list->next) {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
147 gtksmiley = (GtkIMHtmlSmiley*)list->data;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
148
22880
2ab289f312d0 Hide PurpleSmiley internals.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22878
diff changeset
149 if (strcmp(gtksmiley->smile, purple_smiley_get_shortcut(smiley)))
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
150 continue;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
151
22889
019052a807a3 Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22883
diff changeset
152 gtk_imhtml_smiley_destroy(gtksmiley);
23136
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
153 g_signal_handlers_disconnect_matched(G_OBJECT(smiley), G_SIGNAL_MATCH_DATA,
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
154 0, 0, NULL, NULL, gtksmiley);
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
155 break;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
156 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
157
22878
db31bbdf355b Make sure deleting one smiley doesn't accidentally delete a few others.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22874
diff changeset
158 if (list)
db31bbdf355b Make sure deleting one smiley doesn't accidentally delete a few others.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22874
diff changeset
159 gtk_smileys = g_slist_delete_link(gtk_smileys, list);
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
160 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
161
23136
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
162 void pidgin_smiley_add_to_list(PurpleSmiley *smiley)
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
163 {
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
164 GtkIMHtmlSmiley *gtksmiley;
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
165
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
166 gtksmiley = smiley_purple_to_gtkimhtml(smiley);
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
167 add_gtkimhtml_to_list(gtksmiley);
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
168 g_signal_connect(G_OBJECT(smiley), "destroy", G_CALLBACK(pidgin_smiley_del_from_list), NULL);
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
169 }
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
170
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
171 void pidgin_smileys_init(void)
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
172 {
22881
d1bcb54920f8 Fix a leak, and correct the docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22880
diff changeset
173 GList *smileys;
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
174 PurpleSmiley *smiley;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
175
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
176 if (gtk_smileys != NULL)
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
177 return;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
178
22881
d1bcb54920f8 Fix a leak, and correct the docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22880
diff changeset
179 smileys = purple_smileys_get_all();
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
180
22881
d1bcb54920f8 Fix a leak, and correct the docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22880
diff changeset
181 for (; smileys; smileys = g_list_delete_link(smileys, smileys)) {
d1bcb54920f8 Fix a leak, and correct the docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22880
diff changeset
182 smiley = (PurpleSmiley*)smileys->data;
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
183
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
184 pidgin_smiley_add_to_list(smiley);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
185 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
186 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
187
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
188 void pidgin_smileys_uninit(void)
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
189 {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
190 GSList *list;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
191 GtkIMHtmlSmiley *gtksmiley;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
192
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
193 list = gtk_smileys;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
194
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
195 if (list == NULL)
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
196 return;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
197
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
198 for (; list; list = g_slist_delete_link(list, list)) {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
199 gtksmiley = (GtkIMHtmlSmiley*)list->data;
22889
019052a807a3 Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22883
diff changeset
200 gtk_imhtml_smiley_destroy(gtksmiley);
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
201 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
202
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
203 gtk_smileys = NULL;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
204 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
205
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
206 GSList *pidgin_smileys_get_all(void)
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
207 {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
208 return gtk_smileys;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
209 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
210
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
211 /******************************************************************************
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
212 * Manager stuff
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
213 *****************************************************************************/
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
214
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
215 static void refresh_list(void);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
216
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
217 /******************************************************************************
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
218 * The Add dialog
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
219 ******************************************************************************/
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
220
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
221 static void do_add(GtkWidget *widget, PidginSmiley *s)
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
222 {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
223 const gchar *entry;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
224 PurpleSmiley *emoticon;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
225
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
226 entry = gtk_entry_get_text(GTK_ENTRY(s->smile));
23889
64a4069e504e Do not allow setting empty shortcut for a custom smiley.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23832
diff changeset
227 if (!entry || !*entry) {
64a4069e504e Do not allow setting empty shortcut for a custom smiley.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23832
diff changeset
228 purple_notify_error(s->parent, _("Custom Smiley"),
64a4069e504e Do not allow setting empty shortcut for a custom smiley.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23832
diff changeset
229 _("More Data needed"),
64a4069e504e Do not allow setting empty shortcut for a custom smiley.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23832
diff changeset
230 _("Please provide a shortcut to associate with the smiley."));
64a4069e504e Do not allow setting empty shortcut for a custom smiley.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23832
diff changeset
231 return;
64a4069e504e Do not allow setting empty shortcut for a custom smiley.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23832
diff changeset
232 }
64a4069e504e Do not allow setting empty shortcut for a custom smiley.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23832
diff changeset
233
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
234 emoticon = purple_smileys_find_by_shortcut(entry);
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
235 if (emoticon && emoticon != s->smiley) {
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
236 purple_notify_error(s->parent, _("Custom Smiley"),
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
237 _("Duplicate Shortcut"),
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
238 _("A custom smiley for the selected shortcut already exists. Please specify a different shortcut."));
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
239 return;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
240 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
241
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
242 if (s->smiley) {
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
243 if (s->filename) {
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
244 gchar *data = NULL;
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
245 size_t len;
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
246 GError *err = NULL;
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
247
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
248 if (!g_file_get_contents(s->filename, &data, &len, &err)) {
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
249 purple_debug_error("gtksmiley", "Error reading %s: %s\n",
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
250 s->filename, err->message);
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
251 g_error_free(err);
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
252
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
253 return;
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
254 }
23185
013ec6fabd3f Always store custom smileys with hashed filenames. Closes #5913.
Marcus Lundblad <ml@update.uu.se>
parents: 23163
diff changeset
255 purple_smiley_set_data(s->smiley, (guchar*)data, len);
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
256 }
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
257 purple_smiley_set_shortcut(s->smiley, entry);
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
258 } else {
23163
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
259 if ((s->filename == NULL && s->custom_pixbuf == NULL)
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
260 || *entry == 0) {
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
261 purple_notify_error(s->parent, _("Custom Smiley"),
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
262 _("More Data needed"),
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
263 s->filename ? _("Please provide a shortcut to associate with the smiley.")
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
264 : _("Please select an image for the smiley."));
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
265 return;
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
266 }
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
267
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
268 purple_debug_info("gtksmiley", "adding a new smiley\n");
23163
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
269
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
270 if (s->filename == NULL) {
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
271 /* Get the smiley from the custom pixbuf */
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
272 gchar *buffer = NULL;
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
273 gsize size = 0;
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
274 gchar *filename;
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
275
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
276 gdk_pixbuf_save_to_bufferv(s->custom_pixbuf, &buffer, &size,
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
277 "png", NULL, NULL, NULL);
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
278 filename = purple_util_get_image_filename(buffer, size);
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
279 s->filename = g_build_filename(purple_smileys_get_storing_dir(), filename, NULL);
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
280 purple_util_write_data_to_file_absolute(s->filename, buffer, size);
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
281 g_free(filename);
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
282 g_free(buffer);
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
283 }
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
284 emoticon = purple_smiley_new_from_file(entry, s->filename);
23682
21e591b55339 at least don't crash when we can't read whatever we are reading
Ka-Hing Cheung <khc@hxbc.us>
parents: 23235
diff changeset
285 if (emoticon)
21e591b55339 at least don't crash when we can't read whatever we are reading
Ka-Hing Cheung <khc@hxbc.us>
parents: 23235
diff changeset
286 pidgin_smiley_add_to_list(emoticon);
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
287 }
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
288
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
289 if (smiley_manager != NULL)
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
290 refresh_list();
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
291
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
292 gtk_widget_destroy(s->parent);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
293 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
294
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
295 static void do_add_select_cb(GtkWidget *widget, gint resp, PidginSmiley *s)
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
296 {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
297 switch (resp) {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
298 case GTK_RESPONSE_ACCEPT:
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
299 do_add(widget, s);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
300 break;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
301 case GTK_RESPONSE_DELETE_EVENT:
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
302 case GTK_RESPONSE_CANCEL:
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
303 gtk_widget_destroy(s->parent);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
304 break;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
305 default:
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
306 purple_debug_error("gtksmiley", "no valid response\n");
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
307 break;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
308 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
309 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
310
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
311 static void do_add_file_cb(const char *filename, gpointer data)
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
312 {
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
313 PidginSmiley *s = data;
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
314 GdkPixbuf *pixbuf;
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
315
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
316 if (!filename)
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
317 return;
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
318
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
319 g_free(s->filename);
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
320 s->filename = g_strdup(filename);
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
321 pixbuf = gdk_pixbuf_new_from_file_at_scale(filename, 64, 64, FALSE, NULL);
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
322 gtk_image_set_from_pixbuf(GTK_IMAGE(s->smiley_image), pixbuf);
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
323 if (pixbuf)
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
324 gdk_pixbuf_unref(pixbuf);
23140
b37b9e53a31b Some little usability changes in the custom smiley dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23136
diff changeset
325 gtk_widget_grab_focus(s->smile);
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
326 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
327
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
328 static void
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
329 open_image_selector(GtkWidget *widget, PidginSmiley *psmiley)
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
330 {
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
331 GtkWidget *file_chooser;
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
332 file_chooser = pidgin_buddy_icon_chooser_new(GTK_WINDOW(gtk_widget_get_toplevel(widget)),
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
333 do_add_file_cb, psmiley);
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
334 gtk_window_set_title(GTK_WINDOW(file_chooser), _("Custom Smiley"));
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
335 gtk_window_set_role(GTK_WINDOW(file_chooser), "file-selector-custom-smiley");
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
336 gtk_widget_show_all(file_chooser);
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
337 }
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
338
23163
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
339 PidginSmiley *
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
340 pidgin_smiley_edit(GtkWidget *widget, PurpleSmiley *smiley)
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
341 {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
342 GtkWidget *vbox;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
343 GtkWidget *hbox;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
344 GtkWidget *label;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
345 GtkWidget *filech;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
346 GtkWidget *window;
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
347 GdkPixbuf *pixbuf = NULL;
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
348 PurpleStoredImage *stored_img;
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
349
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
350 PidginSmiley *s = g_new0(PidginSmiley, 1);
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
351 s->smiley = smiley;
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
352
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
353 window = gtk_dialog_new_with_buttons(smiley ? _("Edit Smiley") : _("Add Smiley"),
23163
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
354 widget ? GTK_WINDOW(widget) : NULL,
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
355 GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
23889
64a4069e504e Do not allow setting empty shortcut for a custom smiley.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23832
diff changeset
356 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
357 smiley ? GTK_STOCK_SAVE : GTK_STOCK_ADD, GTK_RESPONSE_ACCEPT,
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
358 NULL);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
359 s->parent = window;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
360
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
361 gtk_container_set_border_width(GTK_CONTAINER(window), PIDGIN_HIG_BORDER);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
362
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
363 g_signal_connect(window, "response", G_CALLBACK(do_add_select_cb), s);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
364
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
365 /* The vbox */
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
366 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
367 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(window)->vbox), vbox);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
368 gtk_widget_show(vbox);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
369
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
370 /* The hbox */
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
371 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
372 gtk_container_add(GTK_CONTAINER(GTK_VBOX(vbox)), hbox);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
373
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
374 label = gtk_label_new_with_mnemonic(_("Smiley _Image"));
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
375 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
376 gtk_widget_show(label);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
377
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
378 filech = gtk_button_new();
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
379 gtk_box_pack_end(GTK_BOX(hbox), filech, FALSE, FALSE, 0);
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
380 pidgin_set_accessible_label(filech, label);
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
381
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
382 s->smiley_image = gtk_image_new();
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
383 gtk_container_add(GTK_CONTAINER(filech), s->smiley_image);
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
384 if (smiley && (stored_img = purple_smiley_get_stored_image(smiley))) {
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
385 pixbuf = pidgin_pixbuf_from_imgstore(stored_img);
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
386 purple_imgstore_unref(stored_img);
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
387 } else {
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
388 GtkIconSize icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_SMALL);
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
389 pixbuf = gtk_widget_render_icon(window, PIDGIN_STOCK_TOOLBAR_SELECT_AVATAR,
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
390 icon_size, "PidginSmiley");
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
391 }
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
392
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
393 gtk_image_set_from_pixbuf(GTK_IMAGE(s->smiley_image), pixbuf);
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
394 if (pixbuf != NULL)
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
395 g_object_unref(G_OBJECT(pixbuf));
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
396 g_signal_connect(G_OBJECT(filech), "clicked", G_CALLBACK(open_image_selector), s);
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
397
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
398 gtk_widget_show_all(hbox);
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
399
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
400 /* info */
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
401 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BORDER);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
402 gtk_container_add(GTK_CONTAINER(GTK_VBOX(vbox)),hbox);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
403
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
404 /* Smiley shortcut */
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
405 label = gtk_label_new_with_mnemonic(_("Smiley S_hortcut"));
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
406 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
407 gtk_widget_show(label);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
408
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
409 s->smile = gtk_entry_new();
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
410 gtk_entry_set_activates_default(GTK_ENTRY(s->smile), TRUE);
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
411 pidgin_set_accessible_label(s->smile, label);
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
412 if (smiley)
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
413 gtk_entry_set_text(GTK_ENTRY(s->smile), purple_smiley_get_shortcut(smiley));
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
414
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
415 g_signal_connect(s->smile, "activate", G_CALLBACK(do_add), s);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
416
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
417 gtk_box_pack_end(GTK_BOX(hbox), s->smile, FALSE, FALSE, 0);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
418 gtk_widget_show(s->smile);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
419
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
420 gtk_widget_show(hbox);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
421
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
422 gtk_widget_show(GTK_WIDGET(window));
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
423 g_signal_connect_swapped(G_OBJECT(window), "destroy", G_CALLBACK(pidgin_smiley_destroy), s);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
424 g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(purple_notify_close_with_handle), s);
23163
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
425
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
426 return s;
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
427 }
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
428
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
429 void
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
430 pidgin_smiley_editor_set_shortcut(PidginSmiley *editor, const gchar *shortcut)
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
431 {
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
432 gtk_entry_set_text(GTK_ENTRY(editor->smile), shortcut ? shortcut : "");
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
433 }
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
434
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
435 void
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
436 pidgin_smiley_editor_set_image(PidginSmiley *editor, GdkPixbuf *image)
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
437 {
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
438 if (editor->custom_pixbuf)
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
439 gdk_pixbuf_unref(editor->custom_pixbuf);
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
440 editor->custom_pixbuf = image ? gdk_pixbuf_ref(image) : NULL;
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
441 if (image)
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
442 gtk_image_set_from_pixbuf(GTK_IMAGE(editor->smiley_image), image);
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
443 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
444
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
445 /******************************************************************************
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
446 * Delete smiley
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
447 *****************************************************************************/
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
448 static void delete_foreach(GtkTreeModel *model, GtkTreePath *path,
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
449 GtkTreeIter *iter, gpointer data)
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
450 {
23136
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
451 PurpleSmiley *smiley = NULL;
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
452 SmileyManager *dialog;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
453
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
454 dialog = (SmileyManager*)data;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
455
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
456 gtk_tree_model_get(model, iter,
23136
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
457 SMILEY, &smiley,
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
458 -1);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
459
23136
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
460 if(smiley != NULL) {
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
461 g_object_unref(G_OBJECT(smiley));
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
462 pidgin_smiley_del_from_list(smiley);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
463 purple_smiley_delete(smiley);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
464 }
23136
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
465 }
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
466
23136
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
467 static void append_to_list(GtkTreeModel *model, GtkTreePath *path,
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
468 GtkTreeIter *iter, gpointer data)
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
469 {
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
470 GList **list = data;
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
471 *list = g_list_prepend(*list, gtk_tree_path_copy(path));
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
472 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
473
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
474 static void smiley_delete(SmileyManager *dialog)
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
475 {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
476 GtkTreeSelection *selection;
23136
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
477 GList *list = NULL;
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
478
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
479 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview));
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
480 gtk_tree_selection_selected_foreach(selection, delete_foreach, dialog);
23136
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
481 gtk_tree_selection_selected_foreach(selection, append_to_list, &list);
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
482
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
483 while (list) {
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
484 GtkTreeIter iter;
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
485 if (gtk_tree_model_get_iter(GTK_TREE_MODEL(dialog->model), &iter, list->data))
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
486 gtk_list_store_remove(GTK_LIST_STORE(dialog->model), &iter);
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
487 gtk_tree_path_free(list->data);
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
488 list = g_list_delete_link(list, list);
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
489 }
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
490 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
491 /******************************************************************************
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
492 * The Smiley Manager
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
493 *****************************************************************************/
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
494 static void add_columns(GtkWidget *treeview, SmileyManager *dialog)
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
495 {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
496 GtkCellRenderer *rend;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
497 GtkTreeViewColumn *column;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
498
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
499 /* Icon */
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
500 column = gtk_tree_view_column_new();
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
501 gtk_tree_view_column_set_title(column, _("Smiley"));
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
502 gtk_tree_view_column_set_resizable(column, TRUE);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
503 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
504
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
505 rend = gtk_cell_renderer_pixbuf_new();
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
506 gtk_tree_view_column_pack_start(column, rend, FALSE);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
507 gtk_tree_view_column_add_attribute(column, rend, "pixbuf", ICON);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
508
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
509 /* Shortcut */
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
510 column = gtk_tree_view_column_new();
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
511 gtk_tree_view_column_set_title(column, _("Shortcut"));
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
512 gtk_tree_view_column_set_resizable(column, TRUE);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
513 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
514
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
515 rend = gtk_cell_renderer_text_new();
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
516 gtk_tree_view_column_pack_start(column, rend, TRUE);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
517 gtk_tree_view_column_add_attribute(column, rend, "text", SHORTCUT);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
518 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
519
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
520 static void store_smiley_add(PurpleSmiley *smiley)
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
521 {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
522 GtkTreeIter iter;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
523 PurpleStoredImage *img;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
524 GdkPixbuf *sized_smiley = NULL;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
525
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
526 if (smiley_manager == NULL)
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
527 return;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
528
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
529 img = purple_smiley_get_stored_image(smiley);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
530
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
531 if (img != NULL) {
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
532 GdkPixbuf *smiley_image = pidgin_pixbuf_from_imgstore(img);
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
533 purple_imgstore_unref(img);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
534
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
535 if (smiley_image != NULL)
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
536 sized_smiley = gdk_pixbuf_scale_simple(smiley_image,
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
537 22, 22, GDK_INTERP_HYPER);
23132
9c0a47402f7a Unref some gdkpixbufs to plug some memory leaks. References #1187.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23130
diff changeset
538 g_object_unref(G_OBJECT(smiley_image));
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
539 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
540
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
541
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
542 gtk_list_store_append(smiley_manager->model, &iter);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
543
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
544 gtk_list_store_set(smiley_manager->model, &iter,
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
545 ICON, sized_smiley,
22880
2ab289f312d0 Hide PurpleSmiley internals.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22878
diff changeset
546 SHORTCUT, purple_smiley_get_shortcut(smiley),
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
547 SMILEY, smiley,
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
548 -1);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
549
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
550 if (sized_smiley != NULL)
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
551 g_object_unref(G_OBJECT(sized_smiley));
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
552 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
553
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
554 static void populate_smiley_list(SmileyManager *dialog)
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
555 {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
556 GList *list;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
557 PurpleSmiley *emoticon;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
558
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
559 gtk_list_store_clear(dialog->model);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
560
22881
d1bcb54920f8 Fix a leak, and correct the docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22880
diff changeset
561 for(list = purple_smileys_get_all(); list != NULL;
d1bcb54920f8 Fix a leak, and correct the docs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22880
diff changeset
562 list = g_list_delete_link(list, list)) {
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
563 emoticon = (PurpleSmiley*)list->data;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
564
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
565 store_smiley_add(emoticon);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
566 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
567 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
568
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
569 static void smile_selected_cb(GtkTreeSelection *sel, SmileyManager *dialog)
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
570 {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
571 gint selected;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
572
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
573 selected = gtk_tree_selection_count_selected_rows(sel);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
574
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
575 gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog->window),
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
576 GTK_RESPONSE_NO, selected > 0);
23143
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
577
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
578 gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog->window),
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
579 PIDGIN_RESPONSE_EDIT, selected > 0);
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
580 }
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
581
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
582 static void
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
583 smiley_edit_iter(SmileyManager *dialog, GtkTreeIter *iter)
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
584 {
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
585 PurpleSmiley *smiley = NULL;
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
586 gtk_tree_model_get(GTK_TREE_MODEL(dialog->model), iter, SMILEY, &smiley, -1);
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
587 pidgin_smiley_edit(gtk_widget_get_toplevel(GTK_WIDGET(dialog->treeview)), smiley);
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
588 g_object_unref(G_OBJECT(smiley));
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
589 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
590
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
591 static void smiley_edit_cb(GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data)
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
592 {
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
593 GtkTreeIter iter;
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
594 SmileyManager *dialog = data;
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
595
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
596 gtk_tree_model_get_iter(GTK_TREE_MODEL(dialog->model), &iter, path);
23143
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
597 smiley_edit_iter(dialog, &iter);
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
598 }
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
599
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
600 static void
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
601 edit_selected_cb(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
602 {
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
603 smiley_edit_iter(data, iter);
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
604 }
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
605
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
606 static GtkWidget *smiley_list_create(SmileyManager *dialog)
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
607 {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
608 GtkWidget *sw;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
609 GtkWidget *treeview;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
610 GtkTreeSelection *sel;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
611
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
612 sw = gtk_scrolled_window_new(NULL, NULL);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
613 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
614 GTK_POLICY_AUTOMATIC,
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
615 GTK_POLICY_AUTOMATIC);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
616 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
617 GTK_SHADOW_IN);
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
618 gtk_widget_show(sw);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
619
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
620 /* Create the list model */
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
621 dialog->model = gtk_list_store_new(N_COL,
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
622 GDK_TYPE_PIXBUF, /* ICON */
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
623 G_TYPE_STRING, /* SHORTCUT */
23136
6c4f47b9d201 Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23132
diff changeset
624 G_TYPE_OBJECT /* SMILEY */
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
625 );
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
626
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
627 /* the actual treeview */
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
628 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(dialog->model));
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
629 dialog->treeview = treeview;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
630 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE);
23130
a3b4a9061552 Fix a small leak. And sort the smileys alphabetically, as suggested by
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23129
diff changeset
631 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(dialog->model), SHORTCUT, GTK_SORT_ASCENDING);
a3b4a9061552 Fix a small leak. And sort the smileys alphabetically, as suggested by
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23129
diff changeset
632 g_object_unref(G_OBJECT(dialog->model));
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
633
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
634 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
635 gtk_tree_selection_set_mode(sel, GTK_SELECTION_MULTIPLE);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
636 gtk_container_add(GTK_CONTAINER(sw), treeview);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
637
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
638 g_signal_connect(G_OBJECT(sel), "changed", G_CALLBACK(smile_selected_cb), dialog);
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
639 g_signal_connect(G_OBJECT(treeview), "row_activated", G_CALLBACK(smiley_edit_cb), dialog);
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
640
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
641 gtk_widget_show(treeview);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
642
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
643 add_columns(treeview, dialog);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
644 populate_smiley_list(dialog);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
645
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
646 return sw;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
647 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
648
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
649 static void refresh_list()
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
650 {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
651 populate_smiley_list(smiley_manager);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
652 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
653
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
654 static void smiley_manager_select_cb(GtkWidget *widget, gint resp, SmileyManager *dialog)
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
655 {
23143
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
656 GtkTreeSelection *selection = NULL;
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
657
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
658 switch (resp) {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
659 case GTK_RESPONSE_YES:
23129
b70b4108799e Patch from Masca to use the buddy-icon selector to select a custom
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22889
diff changeset
660 pidgin_smiley_edit(dialog->window, NULL);
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
661 break;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
662 case GTK_RESPONSE_NO:
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
663 smiley_delete(dialog);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
664 break;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
665 case GTK_RESPONSE_DELETE_EVENT:
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
666 case GTK_RESPONSE_CLOSE:
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
667 gtk_widget_destroy(dialog->window);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
668 g_free(smiley_manager);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
669 smiley_manager = NULL;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
670 break;
23143
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
671 case PIDGIN_RESPONSE_EDIT:
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
672 /* Find smiley of selection... */
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
673 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview));
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
674 gtk_tree_selection_selected_foreach(selection, edit_selected_cb, dialog);
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
675 break;
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
676 default:
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
677 purple_debug_info("gtksmiley", "No valid selection\n");
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
678 break;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
679 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
680 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
681
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
682 void pidgin_smiley_manager_show(void)
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
683 {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
684 SmileyManager *dialog;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
685 GtkWidget *win;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
686 GtkWidget *sw;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
687 GtkWidget *vbox;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
688
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
689 if (smiley_manager) {
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
690 gtk_window_present(GTK_WINDOW(smiley_manager->window));
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
691 return;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
692 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
693
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
694 dialog = g_new0(SmileyManager, 1);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
695 smiley_manager = dialog;
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
696
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
697 dialog->window = win = gtk_dialog_new_with_buttons(
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
698 _("Custom Smiley Manager"),
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
699 NULL,
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
700 GTK_DIALOG_DESTROY_WITH_PARENT,
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
701 GTK_STOCK_ADD, GTK_RESPONSE_YES,
23832
4b8ec4f8a811 Fix compiling with gtk < 2.6
Stu Tomlinson <stu@nosnilmot.com>
parents: 23682
diff changeset
702 PIDGIN_STOCK_EDIT, PIDGIN_RESPONSE_EDIT,
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
703 GTK_STOCK_DELETE, GTK_RESPONSE_NO,
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
704 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
705 NULL);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
706
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
707 gtk_window_set_default_size(GTK_WINDOW(win), 50, 400);
23140
b37b9e53a31b Some little usability changes in the custom smiley dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23136
diff changeset
708 gtk_window_set_role(GTK_WINDOW(win), "custom_smiley_manager");
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
709 gtk_container_set_border_width(GTK_CONTAINER(win),PIDGIN_HIG_BORDER);
23140
b37b9e53a31b Some little usability changes in the custom smiley dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23136
diff changeset
710 gtk_dialog_set_response_sensitive(GTK_DIALOG(win), GTK_RESPONSE_NO, FALSE);
23143
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
711 gtk_dialog_set_response_sensitive(GTK_DIALOG(win), PIDGIN_RESPONSE_EDIT,
d0ee799828d1 Modified patch from malu to add an 'Edit' button in the smiley manager
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23140
diff changeset
712 FALSE);
23163
99ef50c8da91 Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23143
diff changeset
713
22874
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
714 g_signal_connect(win, "response", G_CALLBACK(smiley_manager_select_cb),
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
715 dialog);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
716
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
717 /* The vbox */
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
718 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
719 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(win)->vbox), vbox);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
720 gtk_widget_show(vbox);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
721
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
722 /* get the scrolled window with all stuff */
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
723 sw = smiley_list_create(dialog);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
724 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
725 gtk_widget_show(sw);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
726
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
727 gtk_widget_show(win);
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
728 }
02eda4bd2b22 Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
729