annotate pidgin/gtkutils.c @ 32305:2ec94166be43

On the way to hiding the PurpleConnection struct. * Added purple_connection_get_flags() and purple_connection_set_flags() * Use purple_connection_ accessor functions.
author andrew.victor@mxit.com
date Tue, 18 Oct 2011 18:47:48 +0000
parents 308519b40f50
children b6276b10cb10
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /**
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * @file gtkutils.c GTK+ utility functions
16193
247e421c4fa6 Rename the Doxygen group from gtkui to pidgin.
Richard Laager <rlaager@wiktel.com>
parents: 16062
diff changeset
3 * @ingroup pidgin
20074
6bf32c9e15a7 remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents: 20028
diff changeset
4 */
6bf32c9e15a7 remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents: 20028
diff changeset
5
6bf32c9e15a7 remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents: 20028
diff changeset
6 /* pidgin
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 *
15870
66dff3dfdea6 Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents: 15822
diff changeset
8 * Pidgin is the legal property of its developers, whose names are too numerous
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * to list here. Please refer to the COPYRIGHT file distributed with this
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * source distribution.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * This program is free software; you can redistribute it and/or modify
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * it under the terms of the GNU General Public License as published by
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * This program is distributed in the hope that it will be useful,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 * along with this program; if not, write to the Free Software
19681
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19367
diff changeset
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 */
24350
8282911d5e17 Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@wiktel.com>
parents: 23358
diff changeset
26 #define _PIDGIN_GTKUTILS_C_
8282911d5e17 Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@wiktel.com>
parents: 23358
diff changeset
27
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "internal.h"
15513
535f002e7b0f More pidgin changes
Sean Egan <seanegan@gmail.com>
parents: 15506
diff changeset
29 #include "pidgin.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #ifndef _WIN32
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 # include <X11/Xlib.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 # ifdef small
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 # undef small
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 # endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 #endif /*_WIN32*/
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 #ifdef USE_GTKSPELL
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 # include <gtkspell/gtkspell.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 # ifdef _WIN32
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 # include "wspell.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 # endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 #include <gdk/gdkkeysyms.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 #include "conversation.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 #include "debug.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 #include "desktopitem.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 #include "imgstore.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 #include "notify.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 #include "prefs.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 #include "prpl.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 #include "request.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 #include "signals.h"
27435
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
57 #include "sound.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 #include "util.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59
25142
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
60 #include "gtkaccount.h"
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
61 #include "gtkprefs.h"
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
62
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 #include "gtkconv.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 #include "gtkdialogs.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 #include "gtkimhtml.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 #include "gtkimhtmltoolbar.h"
15821
84b0f9b23ede According to etags, pidgin/ should be completely clean of references to 'gaim' as a client
Sean Egan <seanegan@gmail.com>
parents: 15820
diff changeset
67 #include "pidginstock.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 #include "gtkthemes.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 #include "gtkutils.h"
32138
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
70 #include "gtkwebview.h"
21402
9fef5d307a27 Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <will.thompson@collabora.co.uk>
parents: 21399
diff changeset
71 #include "pidgin/minidialog.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72
17110
f93dcfab772d Formatting changes.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17109
diff changeset
73 typedef struct {
17169
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
74 GtkWidget *menu;
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
75 gint default_item;
17176
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
76 } AopMenu;
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
77
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 static guint accels_save_timer = 0;
28403
3fdad8b715c7 Fix the win32 URIs to only linkify if the protocol is followed by a colon.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28379
diff changeset
79 static GSList *registered_url_handlers = NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 static gboolean
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 url_clicked_idle_cb(gpointer data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
84 purple_notify_uri(NULL, data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85 g_free(data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 return FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88
25142
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
89 static gboolean
25197
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
90 url_clicked_cb(GtkIMHtml *unused, GtkIMHtmlLink *link)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 {
25197
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
92 const char *uri = gtk_imhtml_link_get_url(link);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 g_idle_add(url_clicked_idle_cb, g_strdup(uri));
25142
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
94 return TRUE;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 static GtkIMHtmlFuncs gtkimhtml_cbs = {
16375
391a79778f89 Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents: 16255
diff changeset
98 (GtkIMHtmlGetImageFunc)purple_imgstore_find_by_id,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
99 (GtkIMHtmlGetImageDataFunc)purple_imgstore_get_data,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
100 (GtkIMHtmlGetImageSizeFunc)purple_imgstore_get_size,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
101 (GtkIMHtmlGetImageFilenameFunc)purple_imgstore_get_filename,
16375
391a79778f89 Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents: 16255
diff changeset
102 purple_imgstore_ref_by_id,
391a79778f89 Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents: 16255
diff changeset
103 purple_imgstore_unref_by_id,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 void
15506
311315e979f7 gtkutils changes
Sean Egan <seanegan@gmail.com>
parents: 15500
diff changeset
107 pidgin_setup_imhtml(GtkWidget *imhtml)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 g_return_if_fail(imhtml != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 g_return_if_fail(GTK_IS_IMHTML(imhtml));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111
16202
0973688f4b74 Word on the street is that we don't want things named pidginfoo_bar(), but
Richard Laager <rlaager@wiktel.com>
parents: 16193
diff changeset
112 pidgin_themes_smiley_themeize(imhtml);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 gtk_imhtml_set_funcs(GTK_IMHTML(imhtml), &gtkimhtml_cbs);
15444
154b8d8643a2 GNOME has a 'document font' setting that we should use when running on GNOME. This does the gconftool-2 spawning trick to get it
Sean Egan <seanegan@gmail.com>
parents: 15435
diff changeset
115
28581
b027d1d97edb I *think* this properly adds back the font preference stuff I axed earlier, but
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 28558
diff changeset
116 #ifdef _WIN32
17406
747e5fd970e6 Reluctantly, I've added a preference for overriding the GTK+ default theme in GtkIMHtml widgets. There is support for this feature in the GNOME HIG and in other GTK+ (including GNOME) applications. This fixes #494. This is a GTK+ 2.4-only feature. I don't update the fonts in existing gtkimhtml's yet, only in new ones. Someone else may want to take care of that
Sean Egan <seanegan@gmail.com>
parents: 17341
diff changeset
117 if (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/use_theme_font")) {
29038
f6cc97902049 Make the conversation text preview section dynamically update as the win32-only font override changes. Fixes #11168
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28924
diff changeset
118 PangoFontDescription *desc;
17406
747e5fd970e6 Reluctantly, I've added a preference for overriding the GTK+ default theme in GtkIMHtml widgets. There is support for this feature in the GNOME HIG and in other GTK+ (including GNOME) applications. This fixes #494. This is a GTK+ 2.4-only feature. I don't update the fonts in existing gtkimhtml's yet, only in new ones. Someone else may want to take care of that
Sean Egan <seanegan@gmail.com>
parents: 17341
diff changeset
119 const char *font = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/custom_font");
747e5fd970e6 Reluctantly, I've added a preference for overriding the GTK+ default theme in GtkIMHtml widgets. There is support for this feature in the GNOME HIG and in other GTK+ (including GNOME) applications. This fixes #494. This is a GTK+ 2.4-only feature. I don't update the fonts in existing gtkimhtml's yet, only in new ones. Someone else may want to take care of that
Sean Egan <seanegan@gmail.com>
parents: 17341
diff changeset
120 desc = pango_font_description_from_string(font);
29038
f6cc97902049 Make the conversation text preview section dynamically update as the win32-only font override changes. Fixes #11168
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28924
diff changeset
121 if (desc) {
f6cc97902049 Make the conversation text preview section dynamically update as the win32-only font override changes. Fixes #11168
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28924
diff changeset
122 gtk_widget_modify_font(imhtml, desc);
f6cc97902049 Make the conversation text preview section dynamically update as the win32-only font override changes. Fixes #11168
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28924
diff changeset
123 pango_font_description_free(desc);
f6cc97902049 Make the conversation text preview section dynamically update as the win32-only font override changes. Fixes #11168
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28924
diff changeset
124 }
17406
747e5fd970e6 Reluctantly, I've added a preference for overriding the GTK+ default theme in GtkIMHtml widgets. There is support for this feature in the GNOME HIG and in other GTK+ (including GNOME) applications. This fixes #494. This is a GTK+ 2.4-only feature. I don't update the fonts in existing gtkimhtml's yet, only in new ones. Someone else may want to take care of that
Sean Egan <seanegan@gmail.com>
parents: 17341
diff changeset
125 }
28581
b027d1d97edb I *think* this properly adds back the font preference stuff I axed earlier, but
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 28558
diff changeset
126 #endif
20805
e0ce7124d2d4 Fix CID 353
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20660
diff changeset
127
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129
21646
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
130 static
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
131 void pidgin_window_init(GtkWindow *wnd, const char *title, guint border_width, const char *role, gboolean resizable)
17720
92c3c2eeba87 Added to gtkutils.c:
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
132 {
92c3c2eeba87 Added to gtkutils.c:
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
133 if (title)
92c3c2eeba87 Added to gtkutils.c:
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
134 gtk_window_set_title(wnd, title);
18643
3bf2e6cb8e35 Prevent some more window titles from being "pidgin.exe" on Windows. Fixes #1767
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18464
diff changeset
135 #ifdef _WIN32
3bf2e6cb8e35 Prevent some more window titles from being "pidgin.exe" on Windows. Fixes #1767
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18464
diff changeset
136 else
3bf2e6cb8e35 Prevent some more window titles from being "pidgin.exe" on Windows. Fixes #1767
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18464
diff changeset
137 gtk_window_set_title(wnd, PIDGIN_ALERT_TITLE);
3bf2e6cb8e35 Prevent some more window titles from being "pidgin.exe" on Windows. Fixes #1767
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18464
diff changeset
138 #endif
17720
92c3c2eeba87 Added to gtkutils.c:
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
139 gtk_container_set_border_width(GTK_CONTAINER(wnd), border_width);
92c3c2eeba87 Added to gtkutils.c:
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
140 if (role)
92c3c2eeba87 Added to gtkutils.c:
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
141 gtk_window_set_role(wnd, role);
92c3c2eeba87 Added to gtkutils.c:
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
142 gtk_window_set_resizable(wnd, resizable);
21646
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
143 }
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
144
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
145 GtkWidget *
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
146 pidgin_create_window(const char *title, guint border_width, const char *role, gboolean resizable)
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
147 {
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
148 GtkWindow *wnd = NULL;
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
149
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
150 wnd = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
151 pidgin_window_init(wnd, title, border_width, role, resizable);
17720
92c3c2eeba87 Added to gtkutils.c:
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
152
92c3c2eeba87 Added to gtkutils.c:
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
153 return GTK_WIDGET(wnd);
92c3c2eeba87 Added to gtkutils.c:
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
154 }
92c3c2eeba87 Added to gtkutils.c:
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
155
92c3c2eeba87 Added to gtkutils.c:
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
156 GtkWidget *
29615
97005a2e99d7 Use a small GtkButton instead of the custom "X" for close in various
Kosta Arvanitis <karvanitis@hotmail.com>
parents: 29413
diff changeset
157 pidgin_create_small_button(GtkWidget *image)
97005a2e99d7 Use a small GtkButton instead of the custom "X" for close in various
Kosta Arvanitis <karvanitis@hotmail.com>
parents: 29413
diff changeset
158 {
97005a2e99d7 Use a small GtkButton instead of the custom "X" for close in various
Kosta Arvanitis <karvanitis@hotmail.com>
parents: 29413
diff changeset
159 GtkWidget *button;
97005a2e99d7 Use a small GtkButton instead of the custom "X" for close in various
Kosta Arvanitis <karvanitis@hotmail.com>
parents: 29413
diff changeset
160
97005a2e99d7 Use a small GtkButton instead of the custom "X" for close in various
Kosta Arvanitis <karvanitis@hotmail.com>
parents: 29413
diff changeset
161 button = gtk_button_new();
97005a2e99d7 Use a small GtkButton instead of the custom "X" for close in various
Kosta Arvanitis <karvanitis@hotmail.com>
parents: 29413
diff changeset
162 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
97005a2e99d7 Use a small GtkButton instead of the custom "X" for close in various
Kosta Arvanitis <karvanitis@hotmail.com>
parents: 29413
diff changeset
163
97005a2e99d7 Use a small GtkButton instead of the custom "X" for close in various
Kosta Arvanitis <karvanitis@hotmail.com>
parents: 29413
diff changeset
164 /* don't allow focus on the close button */
97005a2e99d7 Use a small GtkButton instead of the custom "X" for close in various
Kosta Arvanitis <karvanitis@hotmail.com>
parents: 29413
diff changeset
165 gtk_button_set_focus_on_click(GTK_BUTTON(button), FALSE);
97005a2e99d7 Use a small GtkButton instead of the custom "X" for close in various
Kosta Arvanitis <karvanitis@hotmail.com>
parents: 29413
diff changeset
166
29617
7ed0ddbdd2a8 Use an inline RC style to get rid of some other padding to make the small
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29615
diff changeset
167 /* set style to make it as small as possible */
7ed0ddbdd2a8 Use an inline RC style to get rid of some other padding to make the small
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29615
diff changeset
168 gtk_widget_set_name(button, "pidgin-small-close-button");
29615
97005a2e99d7 Use a small GtkButton instead of the custom "X" for close in various
Kosta Arvanitis <karvanitis@hotmail.com>
parents: 29413
diff changeset
169
97005a2e99d7 Use a small GtkButton instead of the custom "X" for close in various
Kosta Arvanitis <karvanitis@hotmail.com>
parents: 29413
diff changeset
170 gtk_widget_show(image);
97005a2e99d7 Use a small GtkButton instead of the custom "X" for close in various
Kosta Arvanitis <karvanitis@hotmail.com>
parents: 29413
diff changeset
171
97005a2e99d7 Use a small GtkButton instead of the custom "X" for close in various
Kosta Arvanitis <karvanitis@hotmail.com>
parents: 29413
diff changeset
172 gtk_container_add(GTK_CONTAINER(button), image);
97005a2e99d7 Use a small GtkButton instead of the custom "X" for close in various
Kosta Arvanitis <karvanitis@hotmail.com>
parents: 29413
diff changeset
173
97005a2e99d7 Use a small GtkButton instead of the custom "X" for close in various
Kosta Arvanitis <karvanitis@hotmail.com>
parents: 29413
diff changeset
174 return button;
97005a2e99d7 Use a small GtkButton instead of the custom "X" for close in various
Kosta Arvanitis <karvanitis@hotmail.com>
parents: 29413
diff changeset
175 }
97005a2e99d7 Use a small GtkButton instead of the custom "X" for close in various
Kosta Arvanitis <karvanitis@hotmail.com>
parents: 29413
diff changeset
176
97005a2e99d7 Use a small GtkButton instead of the custom "X" for close in various
Kosta Arvanitis <karvanitis@hotmail.com>
parents: 29413
diff changeset
177 GtkWidget *
21646
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
178 pidgin_create_dialog(const char *title, guint border_width, const char *role, gboolean resizable)
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
179 {
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
180 GtkWindow *wnd = NULL;
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
181
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
182 wnd = GTK_WINDOW(gtk_dialog_new());
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
183 pidgin_window_init(wnd, title, border_width, role, resizable);
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
184 g_object_set(G_OBJECT(wnd), "has-separator", FALSE, NULL);
17720
92c3c2eeba87 Added to gtkutils.c:
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
185
92c3c2eeba87 Added to gtkutils.c:
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
186 return GTK_WIDGET(wnd);
92c3c2eeba87 Added to gtkutils.c:
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
187 }
92c3c2eeba87 Added to gtkutils.c:
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
188
92c3c2eeba87 Added to gtkutils.c:
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
189 GtkWidget *
21646
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
190 pidgin_dialog_get_vbox_with_properties(GtkDialog *dialog, gboolean homogeneous, gint spacing)
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
191 {
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
192 GtkBox *vbox = GTK_BOX(GTK_DIALOG(dialog)->vbox);
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
193 gtk_box_set_homogeneous(vbox, homogeneous);
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
194 gtk_box_set_spacing(vbox, spacing);
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
195 return GTK_WIDGET(vbox);
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
196 }
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
197
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
198 GtkWidget *pidgin_dialog_get_vbox(GtkDialog *dialog)
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
199 {
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
200 return GTK_DIALOG(dialog)->vbox;
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
201 }
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
202
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
203 GtkWidget *pidgin_dialog_get_action_area(GtkDialog *dialog)
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
204 {
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
205 return GTK_DIALOG(dialog)->action_area;
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
206 }
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
207
21652
eb2d5ba2a50d Add a utility function pidgin_dialog_add_button to add buttons to a dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21646
diff changeset
208 GtkWidget *pidgin_dialog_add_button(GtkDialog *dialog, const char *label,
eb2d5ba2a50d Add a utility function pidgin_dialog_add_button to add buttons to a dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21646
diff changeset
209 GCallback callback, gpointer callbackdata)
eb2d5ba2a50d Add a utility function pidgin_dialog_add_button to add buttons to a dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21646
diff changeset
210 {
eb2d5ba2a50d Add a utility function pidgin_dialog_add_button to add buttons to a dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21646
diff changeset
211 GtkWidget *button = gtk_button_new_from_stock(label);
eb2d5ba2a50d Add a utility function pidgin_dialog_add_button to add buttons to a dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21646
diff changeset
212 GtkWidget *bbox = pidgin_dialog_get_action_area(dialog);
eb2d5ba2a50d Add a utility function pidgin_dialog_add_button to add buttons to a dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21646
diff changeset
213 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
eb2d5ba2a50d Add a utility function pidgin_dialog_add_button to add buttons to a dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21646
diff changeset
214 if (callback)
eb2d5ba2a50d Add a utility function pidgin_dialog_add_button to add buttons to a dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21646
diff changeset
215 g_signal_connect(G_OBJECT(button), "clicked", callback, callbackdata);
eb2d5ba2a50d Add a utility function pidgin_dialog_add_button to add buttons to a dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21646
diff changeset
216 gtk_widget_show(button);
eb2d5ba2a50d Add a utility function pidgin_dialog_add_button to add buttons to a dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21646
diff changeset
217 return button;
eb2d5ba2a50d Add a utility function pidgin_dialog_add_button to add buttons to a dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21646
diff changeset
218 }
eb2d5ba2a50d Add a utility function pidgin_dialog_add_button to add buttons to a dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21646
diff changeset
219
21646
2a2496044eef Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21560
diff changeset
220 GtkWidget *
15500
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15444
diff changeset
221 pidgin_create_imhtml(gboolean editable, GtkWidget **imhtml_ret, GtkWidget **toolbar_ret, GtkWidget **sw_ret)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 GtkWidget *frame;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 GtkWidget *imhtml;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 GtkWidget *sep;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 GtkWidget *sw;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227 GtkWidget *toolbar = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 GtkWidget *vbox;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 frame = gtk_frame_new(NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 vbox = gtk_vbox_new(FALSE, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 gtk_container_add(GTK_CONTAINER(frame), vbox);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235 gtk_widget_show(vbox);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 if (editable) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238 toolbar = gtk_imhtmltoolbar_new();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240 gtk_widget_show(toolbar);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242 sep = gtk_hseparator_new();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244 g_signal_connect_swapped(G_OBJECT(toolbar), "show", G_CALLBACK(gtk_widget_show), sep);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 g_signal_connect_swapped(G_OBJECT(toolbar), "hide", G_CALLBACK(gtk_widget_hide), sep);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246 gtk_widget_show(sep);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249 imhtml = gtk_imhtml_new(NULL, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250 gtk_imhtml_set_editable(GTK_IMHTML(imhtml), editable);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 gtk_imhtml_set_format_functions(GTK_IMHTML(imhtml), GTK_IMHTML_ALL ^ GTK_IMHTML_IMAGE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(imhtml), GTK_WRAP_WORD_CHAR);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 #ifdef USE_GTKSPELL
16062
07554cc5d090 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents: 16010
diff changeset
254 if (editable && purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/spellcheck"))
15500
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15444
diff changeset
255 pidgin_setup_gtkspell(GTK_TEXT_VIEW(imhtml));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 gtk_widget_show(imhtml);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259 if (editable) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 gtk_imhtmltoolbar_attach(GTK_IMHTMLTOOLBAR(toolbar), imhtml);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(toolbar), "default");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262 }
15506
311315e979f7 gtkutils changes
Sean Egan <seanegan@gmail.com>
parents: 15500
diff changeset
263 pidgin_setup_imhtml(imhtml);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264
31367
917c597beb97 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31014
diff changeset
265 sw = pidgin_make_scrollable(imhtml, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC, GTK_SHADOW_NONE, -1, -1);
917c597beb97 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31014
diff changeset
266 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268 if (imhtml_ret != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269 *imhtml_ret = imhtml;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271 if (editable && (toolbar_ret != NULL))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
272 *toolbar_ret = toolbar;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274 if (sw_ret != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275 *sw_ret = sw;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277 return frame;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279
32138
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
280 GtkWidget *
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
281 pidgin_create_webview(gboolean editable, GtkWidget **webview_ret, GtkWidget **toolbar_ret, GtkWidget **sw_ret)
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
282 {
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
283 GtkWidget *frame;
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
284 GtkWidget *webview;
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
285 GtkWidget *sep;
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
286 GtkWidget *sw;
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
287 GtkWidget *toolbar = NULL;
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
288 GtkWidget *vbox;
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
289
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
290 frame = gtk_frame_new(NULL);
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
291 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
292
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
293 vbox = gtk_vbox_new(FALSE, 0);
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
294 gtk_container_add(GTK_CONTAINER(frame), vbox);
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
295 gtk_widget_show(vbox);
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
296
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
297 if (editable) {
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
298 toolbar = gtk_imhtmltoolbar_new();
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
299 gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
300 gtk_widget_show(toolbar);
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
301
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
302 sep = gtk_hseparator_new();
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
303 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0);
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
304 g_signal_connect_swapped(G_OBJECT(toolbar), "show", G_CALLBACK(gtk_widget_show), sep);
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
305 g_signal_connect_swapped(G_OBJECT(toolbar), "hide", G_CALLBACK(gtk_widget_hide), sep);
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
306 gtk_widget_show(sep);
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
307 }
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
308
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
309 webview = gtk_webview_new();
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
310 #if 0
32199
68fe7b5211a7 Mark webkit-related missing functionality with "TODO WEBKIT" instead of
Mark Doliner <mark@kingant.net>
parents: 32139
diff changeset
311 /* TODO WEBKIT: Don't have editable webview yet. */
32138
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
312 gtk_webview_set_editable(GTK_WEBVIEW(webview), editable);
32199
68fe7b5211a7 Mark webkit-related missing functionality with "TODO WEBKIT" instead of
Mark Doliner <mark@kingant.net>
parents: 32139
diff changeset
313 #endif /* if 0 */
32138
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
314 #ifdef USE_GTKSPELL
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
315 if (editable && purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/spellcheck"))
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
316 pidgin_setup_gtkspell(GTK_TEXT_VIEW(webview));
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
317 #endif
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
318 gtk_widget_show(webview);
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
319
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
320 if (editable) {
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
321 gtk_imhtmltoolbar_attach(GTK_IMHTMLTOOLBAR(toolbar), webview);
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
322 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(toolbar), "default");
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
323 }
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
324
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
325 sw = pidgin_make_scrollable(webview, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC, GTK_SHADOW_NONE, -1, -1);
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
326 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
327
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
328 gtk_webview_set_vadjustment(GTK_WEBVIEW(webview),
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
329 gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(sw)));
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
330
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
331 if (webview_ret != NULL)
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
332 *webview_ret = webview;
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
333
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
334 if (editable && (toolbar_ret != NULL))
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
335 *toolbar_ret = toolbar;
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
336
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
337 if (sw_ret != NULL)
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
338 *sw_ret = sw;
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
339
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
340 return frame;
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
341 }
d9cb56d33839 Add a pidgin_create_webview utility function, which acts similarly to
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 32005
diff changeset
342
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343 void
15500
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15444
diff changeset
344 pidgin_set_sensitive_if_input(GtkWidget *entry, GtkWidget *dialog)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346 const char *text = gtk_entry_get_text(GTK_ENTRY(entry));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347 gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), GTK_RESPONSE_OK,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
348 (*text != '\0'));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351 void
15500
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15444
diff changeset
352 pidgin_toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
354 gboolean sensitivity;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
356 if (to_toggle == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
357 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
358
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
359 sensitivity = GTK_WIDGET_IS_SENSITIVE(to_toggle);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
361 gtk_widget_set_sensitive(to_toggle, !sensitivity);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
362 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
364 void
15500
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15444
diff changeset
365 pidgin_toggle_sensitive_array(GtkWidget *w, GPtrArray *data)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
367 gboolean sensitivity;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
368 gpointer element;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
369 int i;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
370
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
371 for (i=0; i < data->len; i++) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
372 element = g_ptr_array_index(data,i);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373 if (element == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
376 sensitivity = GTK_WIDGET_IS_SENSITIVE(element);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
377
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
378 gtk_widget_set_sensitive(element, !sensitivity);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
379 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
380 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
381
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
382 void
15500
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15444
diff changeset
383 pidgin_toggle_showhide(GtkWidget *widget, GtkWidget *to_toggle)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
384 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
385 if (to_toggle == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
386 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
387
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
388 if (GTK_WIDGET_VISIBLE(to_toggle))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
389 gtk_widget_hide(to_toggle);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
390 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
391 gtk_widget_show(to_toggle);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
392 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
393
17749
5241d388f463 Change pidgin_separator to return the separator added to the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17082
diff changeset
394 GtkWidget *pidgin_separator(GtkWidget *menu)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
395 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
396 GtkWidget *menuitem;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
397
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
398 menuitem = gtk_separator_menu_item_new();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
399 gtk_widget_show(menuitem);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
400 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
17749
5241d388f463 Change pidgin_separator to return the separator added to the menu.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17082
diff changeset
401 return menuitem;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
402 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403
15506
311315e979f7 gtkutils changes
Sean Egan <seanegan@gmail.com>
parents: 15500
diff changeset
404 GtkWidget *pidgin_new_item(GtkWidget *menu, const char *str)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
405 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
406 GtkWidget *menuitem;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
407 GtkWidget *label;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
408
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
409 menuitem = gtk_menu_item_new();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
410 if (menu)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
411 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
412 gtk_widget_show(menuitem);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
413
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
414 label = gtk_label_new(str);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
415 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
416 gtk_label_set_pattern(GTK_LABEL(label), "_");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
417 gtk_container_add(GTK_CONTAINER(menuitem), label);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
418 gtk_widget_show(label);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
419 /* FIXME: Go back and fix this
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420 gtk_widget_add_accelerator(menuitem, "activate", accel, str[0],
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
421 GDK_MOD1_MASK, GTK_ACCEL_LOCKED);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
422 */
15506
311315e979f7 gtkutils changes
Sean Egan <seanegan@gmail.com>
parents: 15500
diff changeset
423 pidgin_set_accessible_label (menuitem, label);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
424 return menuitem;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
425 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
426
15506
311315e979f7 gtkutils changes
Sean Egan <seanegan@gmail.com>
parents: 15500
diff changeset
427 GtkWidget *pidgin_new_check_item(GtkWidget *menu, const char *str,
26624
4aa5400b1b99 Replace the deprecated GtkSignalFunc and GTK_SIGNAL_FUNC with GCallback and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26623
diff changeset
428 GCallback cb, gpointer data, gboolean checked)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
429 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
430 GtkWidget *menuitem;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
431 menuitem = gtk_check_menu_item_new_with_mnemonic(str);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
432
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
433 if (menu)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
434 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
435
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
436 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), checked);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
437
26624
4aa5400b1b99 Replace the deprecated GtkSignalFunc and GTK_SIGNAL_FUNC with GCallback and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26623
diff changeset
438 if (cb)
4aa5400b1b99 Replace the deprecated GtkSignalFunc and GTK_SIGNAL_FUNC with GCallback and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26623
diff changeset
439 g_signal_connect(G_OBJECT(menuitem), "activate", cb, data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
440
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
441 gtk_widget_show_all(menuitem);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
442
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
443 return menuitem;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
444 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
445
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
446 GtkWidget *
15506
311315e979f7 gtkutils changes
Sean Egan <seanegan@gmail.com>
parents: 15500
diff changeset
447 pidgin_pixbuf_toolbar_button_from_stock(const char *icon)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
448 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
449 GtkWidget *button, *image, *bbox;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
450
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
451 button = gtk_toggle_button_new();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
452 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
453
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
454 bbox = gtk_vbox_new(FALSE, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
455
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
456 gtk_container_add (GTK_CONTAINER(button), bbox);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
457
15559
442128853bdb toolbar/menu icons. reduce the imhtmltoolbar spacing. more gaimstock pruning
Sean Egan <seanegan@gmail.com>
parents: 15515
diff changeset
458 image = gtk_image_new_from_stock(icon, gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
459 gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
460
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
461 gtk_widget_show_all(bbox);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
462
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
463 return button;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
464 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
465
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
466 GtkWidget *
15506
311315e979f7 gtkutils changes
Sean Egan <seanegan@gmail.com>
parents: 15500
diff changeset
467 pidgin_pixbuf_button_from_stock(const char *text, const char *icon,
311315e979f7 gtkutils changes
Sean Egan <seanegan@gmail.com>
parents: 15500
diff changeset
468 PidginButtonOrientation style)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
469 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
470 GtkWidget *button, *image, *label, *bbox, *ibox, *lbox = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
471
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
472 button = gtk_button_new();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
473
15506
311315e979f7 gtkutils changes
Sean Egan <seanegan@gmail.com>
parents: 15500
diff changeset
474 if (style == PIDGIN_BUTTON_HORIZONTAL) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
475 bbox = gtk_hbox_new(FALSE, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
476 ibox = gtk_hbox_new(FALSE, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
477 if (text)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
478 lbox = gtk_hbox_new(FALSE, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
479 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
480 bbox = gtk_vbox_new(FALSE, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
481 ibox = gtk_vbox_new(FALSE, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
482 if (text)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
483 lbox = gtk_vbox_new(FALSE, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
484 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
485
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
486 gtk_container_add(GTK_CONTAINER(button), bbox);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
487
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
488 if (icon) {
29413
a4167f67d118 *** Plucked rev df5196ac4c45dfff9cad5768c27d4e1d46fbb2ab (qulogic@pidgin.im):
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29363
diff changeset
489 gtk_box_pack_start(GTK_BOX(bbox), ibox, TRUE, TRUE, 0);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
490 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_BUTTON);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
491 gtk_box_pack_end(GTK_BOX(ibox), image, FALSE, TRUE, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
492 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
493
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
494 if (text) {
29413
a4167f67d118 *** Plucked rev df5196ac4c45dfff9cad5768c27d4e1d46fbb2ab (qulogic@pidgin.im):
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29363
diff changeset
495 gtk_box_pack_start(GTK_BOX(bbox), lbox, TRUE, TRUE, 0);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
496 label = gtk_label_new(NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
497 gtk_label_set_text_with_mnemonic(GTK_LABEL(label), text);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
498 gtk_label_set_mnemonic_widget(GTK_LABEL(label), button);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
499 gtk_box_pack_start(GTK_BOX(lbox), label, FALSE, TRUE, 0);
15506
311315e979f7 gtkutils changes
Sean Egan <seanegan@gmail.com>
parents: 15500
diff changeset
500 pidgin_set_accessible_label (button, label);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
501 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
502
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
503 gtk_widget_show_all(bbox);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
504
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
505 return button;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
506 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
507
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
508
26624
4aa5400b1b99 Replace the deprecated GtkSignalFunc and GTK_SIGNAL_FUNC with GCallback and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26623
diff changeset
509 GtkWidget *pidgin_new_item_from_stock(GtkWidget *menu, const char *str, const char *icon, GCallback cb, gpointer data, guint accel_key, guint accel_mods, char *mod)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
510 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
511 GtkWidget *menuitem;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
512 /*
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
513 GtkWidget *hbox;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
514 GtkWidget *label;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
515 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
516 GtkWidget *image;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
517
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
518 if (icon == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
519 menuitem = gtk_menu_item_new_with_mnemonic(str);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
520 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
521 menuitem = gtk_image_menu_item_new_with_mnemonic(str);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
522
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
523 if (menu)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
524 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
525
26624
4aa5400b1b99 Replace the deprecated GtkSignalFunc and GTK_SIGNAL_FUNC with GCallback and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26623
diff changeset
526 if (cb)
4aa5400b1b99 Replace the deprecated GtkSignalFunc and GTK_SIGNAL_FUNC with GCallback and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26623
diff changeset
527 g_signal_connect(G_OBJECT(menuitem), "activate", cb, data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
528
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
529 if (icon != NULL) {
15559
442128853bdb toolbar/menu icons. reduce the imhtmltoolbar spacing. more gaimstock pruning
Sean Egan <seanegan@gmail.com>
parents: 15515
diff changeset
530 image = gtk_image_new_from_stock(icon, gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
531 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
532 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
533 /* FIXME: this isn't right
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
534 if (mod) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
535 label = gtk_label_new(mod);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
536 gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 2);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
537 gtk_widget_show(label);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
538 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
539 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
540 /*
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
541 if (accel_key) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
542 gtk_widget_add_accelerator(menuitem, "activate", accel, accel_key,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
543 accel_mods, GTK_ACCEL_LOCKED);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
544 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
545 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
546
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
547 gtk_widget_show_all(menuitem);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
548
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
549 return menuitem;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
550 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
551
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
552 GtkWidget *
15500
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15444
diff changeset
553 pidgin_make_frame(GtkWidget *parent, const char *title)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
554 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
555 GtkWidget *vbox, *label, *hbox;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
556 char *labeltitle;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
557
15820
cebfc6af3eb5 More Gaim to Pidgin stuff
Sean Egan <seanegan@gmail.com>
parents: 15737
diff changeset
558 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
559 gtk_box_pack_start(GTK_BOX(parent), vbox, FALSE, FALSE, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
560 gtk_widget_show(vbox);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
561
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
562 label = gtk_label_new(NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
563
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
564 labeltitle = g_strdup_printf("<span weight=\"bold\">%s</span>", title);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
565 gtk_label_set_markup(GTK_LABEL(label), labeltitle);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
566 g_free(labeltitle);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
567
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
568 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
569 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
570 gtk_widget_show(label);
15506
311315e979f7 gtkutils changes
Sean Egan <seanegan@gmail.com>
parents: 15500
diff changeset
571 pidgin_set_accessible_label (vbox, label);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
572
15820
cebfc6af3eb5 More Gaim to Pidgin stuff
Sean Egan <seanegan@gmail.com>
parents: 15737
diff changeset
573 hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
574 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
575 gtk_widget_show(hbox);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
576
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
577 label = gtk_label_new(" ");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
578 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
579 gtk_widget_show(label);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
580
15820
cebfc6af3eb5 More Gaim to Pidgin stuff
Sean Egan <seanegan@gmail.com>
parents: 15737
diff changeset
581 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
582 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
583 gtk_widget_show(vbox);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
584
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
585 return vbox;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
586 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
587
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
588 static gpointer
17110
f93dcfab772d Formatting changes.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17109
diff changeset
589 aop_option_menu_get_selected(GtkWidget *optmenu, GtkWidget **p_item)
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
590 {
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
591 GtkWidget *menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu));
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
592 GtkWidget *item = gtk_menu_get_active(GTK_MENU(menu));
17170
a8365d7615be Style changes in if statements.
Richard Laager <rlaager@wiktel.com>
parents: 17169
diff changeset
593 if (p_item)
17169
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
594 (*p_item) = item;
26975
fe1603ecf579 Avoid an assertion when nothing in dropdown is selected.
Paul Aurich <paul@darkrain42.org>
parents: 26729
diff changeset
595 return item ? g_object_get_data(G_OBJECT(item), "aop_per_item_data") : NULL;
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
596 }
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
597
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
598 static void
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
599 aop_menu_cb(GtkWidget *optmenu, GCallback cb)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
600 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
601 GtkWidget *item;
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
602 gpointer per_item_data;
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
603
17169
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
604 per_item_data = aop_option_menu_get_selected(optmenu, &item);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
605
17176
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
606 if (cb != NULL) {
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
607 ((void (*)(GtkWidget *, gpointer, gpointer))cb)(item, per_item_data, g_object_get_data(G_OBJECT(optmenu), "user_data"));
17172
c8f1748e5af9 Add some braces and clean up indentation.
Richard Laager <rlaager@wiktel.com>
parents: 17171
diff changeset
608 }
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
609 }
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
610
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
611 static GtkWidget *
17810
8bc2b7ec45c1 Make sure if some plugin used pidgin_protocol_option_menu_new, they continue
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17800
diff changeset
612 aop_menu_item_new(GtkSizeGroup *sg, GdkPixbuf *pixbuf, const char *lbl, gpointer per_item_data, const char *data)
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
613 {
17169
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
614 GtkWidget *item;
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
615 GtkWidget *hbox;
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
616 GtkWidget *image;
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
617 GtkWidget *label;
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
618
17176
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
619 item = gtk_menu_item_new();
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
620 gtk_widget_show(item);
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
621
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
622 hbox = gtk_hbox_new(FALSE, 4);
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
623 gtk_widget_show(hbox);
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
624
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
625 /* Create the image */
17173
662552c912b4 Fix a logic mistake I introduced during a cleanup.
Richard Laager <rlaager@wiktel.com>
parents: 17172
diff changeset
626 if (pixbuf == NULL)
17176
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
627 image = gtk_image_new();
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
628 else
17176
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
629 image = gtk_image_new_from_pixbuf(pixbuf);
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
630 gtk_widget_show(image);
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
631
17170
a8365d7615be Style changes in if statements.
Richard Laager <rlaager@wiktel.com>
parents: 17169
diff changeset
632 if (sg)
17169
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
633 gtk_size_group_add_widget(sg, image);
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
634
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
635 /* Create the label */
17176
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
636 label = gtk_label_new (lbl);
17181
45fcb1611bef Forgot an instance of g_object_new and some other changes are necessary, too.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17176
diff changeset
637 gtk_widget_show (label);
17176
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
638 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
17181
45fcb1611bef Forgot an instance of g_object_new and some other changes are necessary, too.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17176
diff changeset
639 gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
25924
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25881
diff changeset
640
17169
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
641 gtk_container_add(GTK_CONTAINER(item), hbox);
17176
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
642 gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
643 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
17169
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
644
17810
8bc2b7ec45c1 Make sure if some plugin used pidgin_protocol_option_menu_new, they continue
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17800
diff changeset
645 g_object_set_data(G_OBJECT (item), data, per_item_data);
17169
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
646 g_object_set_data(G_OBJECT (item), "aop_per_item_data", per_item_data);
17110
f93dcfab772d Formatting changes.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17109
diff changeset
647
f93dcfab772d Formatting changes.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17109
diff changeset
648 pidgin_set_accessible_label(item, label);
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
649
17169
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
650 return item;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
651 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
652
17758
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
653 static GdkPixbuf *
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
654 pidgin_create_prpl_icon_from_prpl(PurplePlugin *prpl, PidginPrplIconSize size, PurpleAccount *account)
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
655 {
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
656 PurplePluginProtocolInfo *prpl_info;
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
657 const char *protoname = NULL;
18144
1a282f3d8057 Use dynamic string manipulation to get rid of a MAXPATHLEN.
Richard Laager <rlaager@wiktel.com>
parents: 18121
diff changeset
658 char *tmp;
17758
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
659 char *filename = NULL;
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
660 GdkPixbuf *pixbuf;
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
661
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
662 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
663 if (prpl_info->list_icon == NULL)
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
664 return NULL;
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
665
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
666 protoname = prpl_info->list_icon(account, NULL);
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
667 if (protoname == NULL)
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
668 return NULL;
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
669
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
670 /*
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
671 * Status icons will be themeable too, and then it will look up
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
672 * protoname from the theme
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
673 */
18144
1a282f3d8057 Use dynamic string manipulation to get rid of a MAXPATHLEN.
Richard Laager <rlaager@wiktel.com>
parents: 18121
diff changeset
674 tmp = g_strconcat(protoname, ".png", NULL);
17758
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
675
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
676 filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "protocols",
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
677 size == PIDGIN_PRPL_ICON_SMALL ? "16" :
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
678 size == PIDGIN_PRPL_ICON_MEDIUM ? "22" : "48",
18144
1a282f3d8057 Use dynamic string manipulation to get rid of a MAXPATHLEN.
Richard Laager <rlaager@wiktel.com>
parents: 18121
diff changeset
679 tmp, NULL);
1a282f3d8057 Use dynamic string manipulation to get rid of a MAXPATHLEN.
Richard Laager <rlaager@wiktel.com>
parents: 18121
diff changeset
680 g_free(tmp);
1a282f3d8057 Use dynamic string manipulation to get rid of a MAXPATHLEN.
Richard Laager <rlaager@wiktel.com>
parents: 18121
diff changeset
681
31682
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
682 pixbuf = pidgin_pixbuf_new_from_file(filename);
17758
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
683 g_free(filename);
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
684
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
685 return pixbuf;
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
686 }
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
687
16960
5143cdd8ad79 disapproval of revision '4c87fc288fc11aefa6d7ff9c06f98a532e72d6fb'
Richard Laager <rlaager@wiktel.com>
parents: 16959
diff changeset
688 static GtkWidget *
17176
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
689 aop_option_menu_new(AopMenu *aop_menu, GCallback cb, gpointer user_data)
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
690 {
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
691 GtkWidget *optmenu;
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
692
17176
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
693 optmenu = gtk_option_menu_new();
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
694 gtk_widget_show(optmenu);
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
695 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), aop_menu->menu);
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
696
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
697 if (aop_menu->default_item != -1)
17169
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
698 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), aop_menu->default_item);
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
699
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
700 g_object_set_data_full(G_OBJECT(optmenu), "aop_menu", aop_menu, (GDestroyNotify)g_free);
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
701 g_object_set_data(G_OBJECT(optmenu), "user_data", user_data);
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
702
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
703 g_signal_connect(G_OBJECT(optmenu), "changed", G_CALLBACK(aop_menu_cb), cb);
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
704
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
705 return optmenu;
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
706 }
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
707
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
708 static void
17176
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
709 aop_option_menu_replace_menu(GtkWidget *optmenu, AopMenu *new_aop_menu)
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
710 {
17170
a8365d7615be Style changes in if statements.
Richard Laager <rlaager@wiktel.com>
parents: 17169
diff changeset
711 if (gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)))
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
712 gtk_option_menu_remove_menu(GTK_OPTION_MENU(optmenu));
17176
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
713
17169
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
714 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), new_aop_menu->menu);
17176
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
715
17170
a8365d7615be Style changes in if statements.
Richard Laager <rlaager@wiktel.com>
parents: 17169
diff changeset
716 if (new_aop_menu->default_item != -1)
17169
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
717 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), new_aop_menu->default_item);
17176
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
718
17169
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
719 g_object_set_data_full(G_OBJECT(optmenu), "aop_menu", new_aop_menu, (GDestroyNotify)g_free);
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
720 }
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
721
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
722 static void
17110
f93dcfab772d Formatting changes.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17109
diff changeset
723 aop_option_menu_select_by_data(GtkWidget *optmenu, gpointer data)
16960
5143cdd8ad79 disapproval of revision '4c87fc288fc11aefa6d7ff9c06f98a532e72d6fb'
Richard Laager <rlaager@wiktel.com>
parents: 16959
diff changeset
724 {
17169
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
725 guint idx;
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
726 GList *llItr = NULL;
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
727
17176
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
728 for (idx = 0, llItr = GTK_MENU_SHELL(gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)))->children;
17170
a8365d7615be Style changes in if statements.
Richard Laager <rlaager@wiktel.com>
parents: 17169
diff changeset
729 llItr != NULL;
17176
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
730 llItr = llItr->next, idx++) {
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
731 if (data == g_object_get_data(G_OBJECT(llItr->data), "aop_per_item_data")) {
17169
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
732 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), idx);
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
733 break;
17170
a8365d7615be Style changes in if statements.
Richard Laager <rlaager@wiktel.com>
parents: 17169
diff changeset
734 }
a8365d7615be Style changes in if statements.
Richard Laager <rlaager@wiktel.com>
parents: 17169
diff changeset
735 }
16960
5143cdd8ad79 disapproval of revision '4c87fc288fc11aefa6d7ff9c06f98a532e72d6fb'
Richard Laager <rlaager@wiktel.com>
parents: 16959
diff changeset
736 }
5143cdd8ad79 disapproval of revision '4c87fc288fc11aefa6d7ff9c06f98a532e72d6fb'
Richard Laager <rlaager@wiktel.com>
parents: 16959
diff changeset
737
17176
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
738 static AopMenu *
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
739 create_protocols_menu(const char *default_proto_id)
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
740 {
17176
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
741 AopMenu *aop_menu = NULL;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
742 PurplePlugin *plugin;
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
743 GdkPixbuf *pixbuf = NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
744 GtkSizeGroup *sg;
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
745 GList *p;
31014
695b6e57e255 UI hack ala Google Talk for Facebook.
Stu Tomlinson <stu@nosnilmot.com>
parents: 30430
diff changeset
746 const char *gtalk_name = NULL, *facebook_name = NULL;
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
747 int i;
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
748
17176
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
749 aop_menu = g_malloc0(sizeof(AopMenu));
17169
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
750 aop_menu->default_item = -1;
17176
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
751 aop_menu->menu = gtk_menu_new();
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
752 gtk_widget_show(aop_menu->menu);
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
753 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
17052
fdd1a73aa37e Only include Google Talk if we have XMPP.
Richard Laager <rlaager@wiktel.com>
parents: 17046
diff changeset
754
31014
695b6e57e255 UI hack ala Google Talk for Facebook.
Stu Tomlinson <stu@nosnilmot.com>
parents: 30430
diff changeset
755 if (purple_find_prpl("prpl-jabber")) {
17071
10c7c5d4ea25 Patch from Gabriel Schulhof to fix the Google-Talk selection.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17052
diff changeset
756 gtalk_name = _("Google Talk");
31014
695b6e57e255 UI hack ala Google Talk for Facebook.
Stu Tomlinson <stu@nosnilmot.com>
parents: 30430
diff changeset
757 facebook_name = _("Facebook (XMPP)");
695b6e57e255 UI hack ala Google Talk for Facebook.
Stu Tomlinson <stu@nosnilmot.com>
parents: 30430
diff changeset
758 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
759
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
760 for (p = purple_plugins_get_protocols(), i = 0;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
761 p != NULL;
17176
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
762 p = p->next, i++) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
763
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
764 plugin = (PurplePlugin *)p->data;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
765
17176
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
766 if (gtalk_name && strcmp(gtalk_name, plugin->info->name) < 0) {
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
767 char *filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "protocols",
17170
a8365d7615be Style changes in if statements.
Richard Laager <rlaager@wiktel.com>
parents: 17169
diff changeset
768 "16", "google-talk.png", NULL);
17810
8bc2b7ec45c1 Make sure if some plugin used pidgin_protocol_option_menu_new, they continue
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17800
diff changeset
769 GtkWidget *item;
8bc2b7ec45c1 Make sure if some plugin used pidgin_protocol_option_menu_new, they continue
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17800
diff changeset
770
31682
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
771 pixbuf = pidgin_pixbuf_new_from_file(filename);
17046
bc16e00f1f7d Sort Google Talk appropriately.
Richard Laager <rlaager@wiktel.com>
parents: 16990
diff changeset
772 g_free(filename);
bc16e00f1f7d Sort Google Talk appropriately.
Richard Laager <rlaager@wiktel.com>
parents: 16990
diff changeset
773
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
774 gtk_menu_shell_append(GTK_MENU_SHELL(aop_menu->menu),
17810
8bc2b7ec45c1 Make sure if some plugin used pidgin_protocol_option_menu_new, they continue
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17800
diff changeset
775 item = aop_menu_item_new(sg, pixbuf, gtalk_name, "prpl-jabber", "protocol"));
31014
695b6e57e255 UI hack ala Google Talk for Facebook.
Stu Tomlinson <stu@nosnilmot.com>
parents: 30430
diff changeset
776 g_object_set_data(G_OBJECT(item), "fakegoogle", GINT_TO_POINTER(1));
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
777
17170
a8365d7615be Style changes in if statements.
Richard Laager <rlaager@wiktel.com>
parents: 17169
diff changeset
778 if (pixbuf)
17169
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
779 g_object_unref(pixbuf);
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
780
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
781 gtalk_name = NULL;
17436
ff04387682ce Fix for the protocol type being off by one in modify account dialog
Stu Tomlinson <stu@nosnilmot.com>
parents: 17419
diff changeset
782 i++;
17046
bc16e00f1f7d Sort Google Talk appropriately.
Richard Laager <rlaager@wiktel.com>
parents: 16990
diff changeset
783 }
bc16e00f1f7d Sort Google Talk appropriately.
Richard Laager <rlaager@wiktel.com>
parents: 16990
diff changeset
784
31014
695b6e57e255 UI hack ala Google Talk for Facebook.
Stu Tomlinson <stu@nosnilmot.com>
parents: 30430
diff changeset
785 if (facebook_name && strcmp(facebook_name, plugin->info->name) < 0) {
695b6e57e255 UI hack ala Google Talk for Facebook.
Stu Tomlinson <stu@nosnilmot.com>
parents: 30430
diff changeset
786 char *filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "protocols",
695b6e57e255 UI hack ala Google Talk for Facebook.
Stu Tomlinson <stu@nosnilmot.com>
parents: 30430
diff changeset
787 "16", "facebook.png", NULL);
695b6e57e255 UI hack ala Google Talk for Facebook.
Stu Tomlinson <stu@nosnilmot.com>
parents: 30430
diff changeset
788 GtkWidget *item;
695b6e57e255 UI hack ala Google Talk for Facebook.
Stu Tomlinson <stu@nosnilmot.com>
parents: 30430
diff changeset
789
31682
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
790 pixbuf = pidgin_pixbuf_new_from_file(filename);
31014
695b6e57e255 UI hack ala Google Talk for Facebook.
Stu Tomlinson <stu@nosnilmot.com>
parents: 30430
diff changeset
791 g_free(filename);
695b6e57e255 UI hack ala Google Talk for Facebook.
Stu Tomlinson <stu@nosnilmot.com>
parents: 30430
diff changeset
792
695b6e57e255 UI hack ala Google Talk for Facebook.
Stu Tomlinson <stu@nosnilmot.com>
parents: 30430
diff changeset
793 gtk_menu_shell_append(GTK_MENU_SHELL(aop_menu->menu),
695b6e57e255 UI hack ala Google Talk for Facebook.
Stu Tomlinson <stu@nosnilmot.com>
parents: 30430
diff changeset
794 item = aop_menu_item_new(sg, pixbuf, facebook_name, "prpl-jabber", "protocol"));
695b6e57e255 UI hack ala Google Talk for Facebook.
Stu Tomlinson <stu@nosnilmot.com>
parents: 30430
diff changeset
795 g_object_set_data(G_OBJECT(item), "fakefacebook", GINT_TO_POINTER(1));
695b6e57e255 UI hack ala Google Talk for Facebook.
Stu Tomlinson <stu@nosnilmot.com>
parents: 30430
diff changeset
796
695b6e57e255 UI hack ala Google Talk for Facebook.
Stu Tomlinson <stu@nosnilmot.com>
parents: 30430
diff changeset
797 if (pixbuf)
695b6e57e255 UI hack ala Google Talk for Facebook.
Stu Tomlinson <stu@nosnilmot.com>
parents: 30430
diff changeset
798 g_object_unref(pixbuf);
695b6e57e255 UI hack ala Google Talk for Facebook.
Stu Tomlinson <stu@nosnilmot.com>
parents: 30430
diff changeset
799
695b6e57e255 UI hack ala Google Talk for Facebook.
Stu Tomlinson <stu@nosnilmot.com>
parents: 30430
diff changeset
800 facebook_name = NULL;
695b6e57e255 UI hack ala Google Talk for Facebook.
Stu Tomlinson <stu@nosnilmot.com>
parents: 30430
diff changeset
801 i++;
695b6e57e255 UI hack ala Google Talk for Facebook.
Stu Tomlinson <stu@nosnilmot.com>
parents: 30430
diff changeset
802 }
695b6e57e255 UI hack ala Google Talk for Facebook.
Stu Tomlinson <stu@nosnilmot.com>
parents: 30430
diff changeset
803
17758
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
804 pixbuf = pidgin_create_prpl_icon_from_prpl(plugin, PIDGIN_PRPL_ICON_SMALL, NULL);
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
805
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
806 gtk_menu_shell_append(GTK_MENU_SHELL(aop_menu->menu),
17810
8bc2b7ec45c1 Make sure if some plugin used pidgin_protocol_option_menu_new, they continue
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17800
diff changeset
807 aop_menu_item_new(sg, pixbuf, plugin->info->name, plugin->info->id, "protocol"));
17176
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
808
17170
a8365d7615be Style changes in if statements.
Richard Laager <rlaager@wiktel.com>
parents: 17169
diff changeset
809 if (pixbuf)
17169
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
810 g_object_unref(pixbuf);
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
811
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
812 if (default_proto_id != NULL && !strcmp(plugin->info->id, default_proto_id))
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
813 aop_menu->default_item = i;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
814 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
815
17169
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
816 g_object_unref(sg);
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
817
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
818 return aop_menu;
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
819 }
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
820
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
821 GtkWidget *
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
822 pidgin_protocol_option_menu_new(const char *id, GCallback cb,
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
823 gpointer user_data)
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
824 {
17169
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
825 return aop_option_menu_new(create_protocols_menu(id), cb, user_data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
826 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
827
18464
09b964413667 Patch from nix_nix, adds 'get prpl name from account menu' API
Sean Egan <seanegan@gmail.com>
parents: 18341
diff changeset
828 const char *
09b964413667 Patch from nix_nix, adds 'get prpl name from account menu' API
Sean Egan <seanegan@gmail.com>
parents: 18341
diff changeset
829 pidgin_protocol_option_menu_get_selected(GtkWidget *optmenu)
09b964413667 Patch from nix_nix, adds 'get prpl name from account menu' API
Sean Egan <seanegan@gmail.com>
parents: 18341
diff changeset
830 {
09b964413667 Patch from nix_nix, adds 'get prpl name from account menu' API
Sean Egan <seanegan@gmail.com>
parents: 18341
diff changeset
831 return (const char *)aop_option_menu_get_selected(optmenu, NULL);
09b964413667 Patch from nix_nix, adds 'get prpl name from account menu' API
Sean Egan <seanegan@gmail.com>
parents: 18341
diff changeset
832 }
09b964413667 Patch from nix_nix, adds 'get prpl name from account menu' API
Sean Egan <seanegan@gmail.com>
parents: 18341
diff changeset
833
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
834 PurpleAccount *
15500
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15444
diff changeset
835 pidgin_account_option_menu_get_selected(GtkWidget *optmenu)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
836 {
17169
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
837 return (PurpleAccount *)aop_option_menu_get_selected(optmenu, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
838 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
839
17176
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
840 static AopMenu *
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
841 create_account_menu(PurpleAccount *default_account,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
842 PurpleFilterAccountFunc filter_func, gboolean show_all)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
843 {
17176
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
844 AopMenu *aop_menu = NULL;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
845 PurpleAccount *account;
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
846 GdkPixbuf *pixbuf = NULL;
18063
926ccb104da0 disapproval of revision '1411afd7660760db59966c3a9f18e2adab8eb27e'
Richard Laager <rlaager@wiktel.com>
parents: 18058
diff changeset
847 GList *list;
926ccb104da0 disapproval of revision '1411afd7660760db59966c3a9f18e2adab8eb27e'
Richard Laager <rlaager@wiktel.com>
parents: 18058
diff changeset
848 GList *p;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
849 GtkSizeGroup *sg;
17169
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
850 int i;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
851 char buf[256];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
852
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
853 if (show_all)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
854 list = purple_accounts_get_all();
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
855 else
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
856 list = purple_connections_get_all();
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
857
17176
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
858 aop_menu = g_malloc0(sizeof(AopMenu));
17169
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
859 aop_menu->default_item = -1;
17181
45fcb1611bef Forgot an instance of g_object_new and some other changes are necessary, too.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17176
diff changeset
860 aop_menu->menu = gtk_menu_new();
45fcb1611bef Forgot an instance of g_object_new and some other changes are necessary, too.
Gabriel Schulhof <nix@go-nix.ca>
parents: 17176
diff changeset
861 gtk_widget_show(aop_menu->menu);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
862 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
863
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
864 for (p = list, i = 0; p != NULL; p = p->next, i++) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
865 if (show_all)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
866 account = (PurpleAccount *)p->data;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
867 else {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
868 PurpleConnection *gc = (PurpleConnection *)p->data;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
869
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
870 account = purple_connection_get_account(gc);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
871 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
872
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
873 if (filter_func && !filter_func(account)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
874 i--;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
875 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
876 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
877
17758
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
878 pixbuf = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_SMALL);
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
879
17799
2f8d77356268 merge of '2f10c41a04555ebc895ec5168c3c2996c738cbd9'
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17758 17341
diff changeset
880 if (pixbuf) {
17758
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
881 if (purple_account_is_disconnected(account) && show_all &&
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
882 purple_connections_get_all())
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
883 gdk_pixbuf_saturate_and_pixelate(pixbuf, pixbuf, 0.0, FALSE);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
884 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
885
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
886 if (purple_account_get_alias(account)) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
887 g_snprintf(buf, sizeof(buf), "%s (%s) (%s)",
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
888 purple_account_get_username(account),
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
889 purple_account_get_alias(account),
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
890 purple_account_get_protocol_name(account));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
891 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
892 g_snprintf(buf, sizeof(buf), "%s (%s)",
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
893 purple_account_get_username(account),
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
894 purple_account_get_protocol_name(account));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
895 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
896
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
897 gtk_menu_shell_append(GTK_MENU_SHELL(aop_menu->menu),
17810
8bc2b7ec45c1 Make sure if some plugin used pidgin_protocol_option_menu_new, they continue
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17800
diff changeset
898 aop_menu_item_new(sg, pixbuf, buf, account, "account"));
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
899
17170
a8365d7615be Style changes in if statements.
Richard Laager <rlaager@wiktel.com>
parents: 17169
diff changeset
900 if (pixbuf)
17169
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
901 g_object_unref(pixbuf);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
902
17176
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
903 if (default_account && account == default_account)
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
904 aop_menu->default_item = i;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
905 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
906
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
907 g_object_unref(sg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
908
17169
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
909 return aop_menu;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
910 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
911
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
912 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
913 regenerate_account_menu(GtkWidget *optmenu)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
914 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
915 gboolean show_all;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
916 PurpleAccount *account;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
917 PurpleFilterAccountFunc filter_func;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
918
17169
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
919 account = (PurpleAccount *)aop_option_menu_get_selected(optmenu, NULL);
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
920 show_all = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(optmenu), "show_all"));
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
921 filter_func = g_object_get_data(G_OBJECT(optmenu), "filter_func");
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
922
17169
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
923 aop_option_menu_replace_menu(optmenu, create_account_menu(account, filter_func, show_all));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
924 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
925
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
926 static void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
927 account_menu_sign_on_off_cb(PurpleConnection *gc, GtkWidget *optmenu)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
928 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
929 regenerate_account_menu(optmenu);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
930 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
931
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
932 static void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
933 account_menu_added_removed_cb(PurpleAccount *account, GtkWidget *optmenu)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
934 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
935 regenerate_account_menu(optmenu);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
936 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
937
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
938 static gboolean
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
939 account_menu_destroyed_cb(GtkWidget *optmenu, GdkEvent *event,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
940 void *user_data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
941 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
942 purple_signals_disconnect_by_handle(optmenu);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
943
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
944 return FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
945 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
946
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
947 void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
948 pidgin_account_option_menu_set_selected(GtkWidget *optmenu, PurpleAccount *account)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
949 {
17341
fe8a1051aa0a Casting things to gpointer isn't useful, unless they were previously const.
Richard Laager <rlaager@wiktel.com>
parents: 17181
diff changeset
950 aop_option_menu_select_by_data(optmenu, account);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
951 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
952
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
953 GtkWidget *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
954 pidgin_account_option_menu_new(PurpleAccount *default_account,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
955 gboolean show_all, GCallback cb,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
956 PurpleFilterAccountFunc filter_func,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
957 gpointer user_data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
958 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
959 GtkWidget *optmenu;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
960
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
961 /* Create the option menu */
17169
06aa5dd957c6 Style change: death to spaces before semi-colons.
Richard Laager <rlaager@wiktel.com>
parents: 17167
diff changeset
962 optmenu = aop_option_menu_new(create_account_menu(default_account, filter_func, show_all), cb, user_data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
963
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
964 g_signal_connect(G_OBJECT(optmenu), "destroy",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
965 G_CALLBACK(account_menu_destroyed_cb), NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
966
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
967 /* Register the purple sign on/off event callbacks. */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
968 purple_signal_connect(purple_connections_get_handle(), "signed-on",
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
969 optmenu, PURPLE_CALLBACK(account_menu_sign_on_off_cb),
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
970 optmenu);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
971 purple_signal_connect(purple_connections_get_handle(), "signed-off",
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
972 optmenu, PURPLE_CALLBACK(account_menu_sign_on_off_cb),
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
973 optmenu);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
974 purple_signal_connect(purple_accounts_get_handle(), "account-added",
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
975 optmenu, PURPLE_CALLBACK(account_menu_added_removed_cb),
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
976 optmenu);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
977 purple_signal_connect(purple_accounts_get_handle(), "account-removed",
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
978 optmenu, PURPLE_CALLBACK(account_menu_added_removed_cb),
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
979 optmenu);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
980
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
981 /* Set some data. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
982 g_object_set_data(G_OBJECT(optmenu), "user_data", user_data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
983 g_object_set_data(G_OBJECT(optmenu), "show_all", GINT_TO_POINTER(show_all));
17176
5e89c6d85d6e Coding style changes
Gabriel Schulhof <nix@go-nix.ca>
parents: 17173
diff changeset
984 g_object_set_data(G_OBJECT(optmenu), "filter_func", filter_func);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
985
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
986 return optmenu;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
987 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
988
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
989 void
15500
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15444
diff changeset
990 pidgin_setup_gtkspell(GtkTextView *textview)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
991 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
992 #ifdef USE_GTKSPELL
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
993 GError *error = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
994 char *locale = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
995
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
996 g_return_if_fail(textview != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
997 g_return_if_fail(GTK_IS_TEXT_VIEW(textview));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
998
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
999 if (gtkspell_new_attach(textview, locale, &error) == NULL && error)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1000 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1001 purple_debug_warning("gtkspell", "Failed to setup GtkSpell: %s\n",
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1002 error->message);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1003 g_error_free(error);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1004 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1005 #endif /* USE_GTKSPELL */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1006 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1007
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1008 void
15500
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15444
diff changeset
1009 pidgin_save_accels_cb(GtkAccelGroup *accel_group, guint arg1,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1010 GdkModifierType arg2, GClosure *arg3,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1011 gpointer data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1012 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1013 purple_debug(PURPLE_DEBUG_MISC, "accels",
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1014 "accel changed, scheduling save.\n");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1015
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1016 if (!accels_save_timer)
26531
b162300ab1e7 A patch from Arunan Balasubramaniam to use timeouts in seconds instead of
foss@abala.me
parents: 26243
diff changeset
1017 accels_save_timer = purple_timeout_add_seconds(5, pidgin_save_accels,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1018 NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1019 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1020
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1021 gboolean
15500
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15444
diff changeset
1022 pidgin_save_accels(gpointer data)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1023 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1024 char *filename = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1025
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1026 filename = g_build_filename(purple_user_dir(), G_DIR_SEPARATOR_S,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1027 "accels", NULL);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1028 purple_debug(PURPLE_DEBUG_MISC, "accels", "saving accels to %s\n", filename);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1029 gtk_accel_map_save(filename);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1030 g_free(filename);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1031
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1032 accels_save_timer = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1033 return FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1034 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1035
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1036 void
15500
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15444
diff changeset
1037 pidgin_load_accels()
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1038 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1039 char *filename = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1040
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1041 filename = g_build_filename(purple_user_dir(), G_DIR_SEPARATOR_S,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1042 "accels", NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1043 gtk_accel_map_load(filename);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1044 g_free(filename);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1045 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1046
18218
571e0ca28d6c Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18215
diff changeset
1047 static void
571e0ca28d6c Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18215
diff changeset
1048 show_retrieveing_info(PurpleConnection *conn, const char *name)
17800
8fe927fa0220 Fix the last merge.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17799
diff changeset
1049 {
8fe927fa0220 Fix the last merge.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17799
diff changeset
1050 PurpleNotifyUserInfo *info = purple_notify_user_info_new();
31904
3322201b446f I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <mark@kingant.net>
parents: 31864
diff changeset
1051 purple_notify_user_info_add_pair_plaintext(info, _("Information"), _("Retrieving..."));
17800
8fe927fa0220 Fix the last merge.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17799
diff changeset
1052 purple_notify_userinfo(conn, name, info, NULL, NULL);
8fe927fa0220 Fix the last merge.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17799
diff changeset
1053 purple_notify_user_info_destroy(info);
18218
571e0ca28d6c Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18215
diff changeset
1054 }
571e0ca28d6c Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18215
diff changeset
1055
571e0ca28d6c Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18215
diff changeset
1056 void pidgin_retrieve_user_info(PurpleConnection *conn, const char *name)
571e0ca28d6c Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18215
diff changeset
1057 {
571e0ca28d6c Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18215
diff changeset
1058 show_retrieveing_info(conn, name);
17800
8fe927fa0220 Fix the last merge.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17799
diff changeset
1059 serv_get_info(conn, name);
8fe927fa0220 Fix the last merge.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17799
diff changeset
1060 }
8fe927fa0220 Fix the last merge.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17799
diff changeset
1061
18218
571e0ca28d6c Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18215
diff changeset
1062 void pidgin_retrieve_user_info_in_chat(PurpleConnection *conn, const char *name, int chat)
571e0ca28d6c Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18215
diff changeset
1063 {
571e0ca28d6c Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18215
diff changeset
1064 char *who = NULL;
571e0ca28d6c Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18215
diff changeset
1065 PurplePluginProtocolInfo *prpl_info = NULL;
571e0ca28d6c Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18215
diff changeset
1066
571e0ca28d6c Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18215
diff changeset
1067 if (chat < 0) {
571e0ca28d6c Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18215
diff changeset
1068 pidgin_retrieve_user_info(conn, name);
571e0ca28d6c Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18215
diff changeset
1069 return;
571e0ca28d6c Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18215
diff changeset
1070 }
571e0ca28d6c Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18215
diff changeset
1071
32305
2ec94166be43 On the way to hiding the PurpleConnection struct.
andrew.victor@mxit.com
parents: 32241
diff changeset
1072 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(conn));
23358
da78db9f188f Pass the "real" chat username to the pidgin_retrieve_user_info function.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23195
diff changeset
1073 if (prpl_info != NULL && prpl_info->get_cb_real_name)
da78db9f188f Pass the "real" chat username to the pidgin_retrieve_user_info function.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23195
diff changeset
1074 who = prpl_info->get_cb_real_name(conn, chat, name);
18218
571e0ca28d6c Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18215
diff changeset
1075 if (prpl_info == NULL || prpl_info->get_cb_info == NULL) {
23358
da78db9f188f Pass the "real" chat username to the pidgin_retrieve_user_info function.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23195
diff changeset
1076 pidgin_retrieve_user_info(conn, who ? who : name);
da78db9f188f Pass the "real" chat username to the pidgin_retrieve_user_info function.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 23195
diff changeset
1077 g_free(who);
18218
571e0ca28d6c Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18215
diff changeset
1078 return;
571e0ca28d6c Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18215
diff changeset
1079 }
571e0ca28d6c Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18215
diff changeset
1080
571e0ca28d6c Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18215
diff changeset
1081 show_retrieveing_info(conn, who ? who : name);
571e0ca28d6c Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18215
diff changeset
1082 prpl_info->get_cb_info(conn, chat, name);
571e0ca28d6c Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18215
diff changeset
1083 g_free(who);
571e0ca28d6c Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18215
diff changeset
1084 }
571e0ca28d6c Show immediate feedback when getting information about someone in a chat.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18215
diff changeset
1085
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1086 gboolean
15500
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15444
diff changeset
1087 pidgin_parse_x_im_contact(const char *msg, gboolean all_accounts,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1088 PurpleAccount **ret_account, char **ret_protocol,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1089 char **ret_username, char **ret_alias)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1090 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1091 char *protocol = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1092 char *username = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1093 char *alias = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1094 char *str;
30413
7c871249318b Fix some "Dead nested assignment"s and then kill off some useless
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29770
diff changeset
1095 char *s;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1096 gboolean valid;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1097
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1098 g_return_val_if_fail(msg != NULL, FALSE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1099 g_return_val_if_fail(ret_protocol != NULL, FALSE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1100 g_return_val_if_fail(ret_username != NULL, FALSE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1101
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1102 s = str = g_strdup(msg);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1103
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1104 while (*s != '\r' && *s != '\n' && *s != '\0')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1105 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1106 char *key, *value;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1107
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1108 key = s;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1109
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1110 /* Grab the key */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1111 while (*s != '\r' && *s != '\n' && *s != '\0' && *s != ' ')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1112 s++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1113
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1114 if (*s == '\r') s++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1115
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1116 if (*s == '\n')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1117 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1118 s++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1119 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1120 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1121
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1122 if (*s != '\0') *s++ = '\0';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1123
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1124 /* Clear past any whitespace */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1125 while (*s != '\0' && *s == ' ')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1126 s++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1127
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1128 /* Now let's grab until the end of the line. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1129 value = s;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1130
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1131 while (*s != '\r' && *s != '\n' && *s != '\0')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1132 s++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1133
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1134 if (*s == '\r') *s++ = '\0';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1135 if (*s == '\n') *s++ = '\0';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1136
30413
7c871249318b Fix some "Dead nested assignment"s and then kill off some useless
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29770
diff changeset
1137 if (strchr(key, ':') != NULL)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1138 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1139 if (!g_ascii_strcasecmp(key, "X-IM-Username:"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1140 username = g_strdup(value);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1141 else if (!g_ascii_strcasecmp(key, "X-IM-Protocol:"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1142 protocol = g_strdup(value);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1143 else if (!g_ascii_strcasecmp(key, "X-IM-Alias:"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1144 alias = g_strdup(value);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1145 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1146 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1147
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1148 if (username != NULL && protocol != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1149 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1150 valid = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1151
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1152 *ret_username = username;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1153 *ret_protocol = protocol;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1154
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1155 if (ret_alias != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1156 *ret_alias = alias;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1157
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1158 /* Check for a compatible account. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1159 if (ret_account != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1160 {
18063
926ccb104da0 disapproval of revision '1411afd7660760db59966c3a9f18e2adab8eb27e'
Richard Laager <rlaager@wiktel.com>
parents: 18058
diff changeset
1161 GList *list;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1162 PurpleAccount *account = NULL;
18063
926ccb104da0 disapproval of revision '1411afd7660760db59966c3a9f18e2adab8eb27e'
Richard Laager <rlaager@wiktel.com>
parents: 18058
diff changeset
1163 GList *l;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1164 const char *protoname;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1165
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1166 if (all_accounts)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1167 list = purple_accounts_get_all();
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1168 else
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1169 list = purple_connections_get_all();
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1170
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1171 for (l = list; l != NULL; l = l->next)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1172 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1173 PurpleConnection *gc;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1174 PurplePluginProtocolInfo *prpl_info = NULL;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1175 PurplePlugin *plugin;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1176
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1177 if (all_accounts)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1178 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1179 account = (PurpleAccount *)l->data;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1180
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1181 plugin = purple_plugins_find_with_id(
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1182 purple_account_get_protocol_id(account));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1183
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1184 if (plugin == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1185 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1186 account = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1187
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1188 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1189 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1190
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1191 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1192 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1193 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1194 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1195 gc = (PurpleConnection *)l->data;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1196 account = purple_connection_get_account(gc);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1197
32305
2ec94166be43 On the way to hiding the PurpleConnection struct.
andrew.victor@mxit.com
parents: 32241
diff changeset
1198 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1199 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1200
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1201 protoname = prpl_info->list_icon(account, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1202
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1203 if (!strcmp(protoname, protocol))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1204 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1205
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1206 account = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1207 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1208
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1209 /* Special case for AIM and ICQ */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1210 if (account == NULL && (!strcmp(protocol, "aim") ||
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1211 !strcmp(protocol, "icq")))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1212 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1213 for (l = list; l != NULL; l = l->next)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1214 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1215 PurpleConnection *gc;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1216 PurplePluginProtocolInfo *prpl_info = NULL;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1217 PurplePlugin *plugin;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1218
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1219 if (all_accounts)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1220 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1221 account = (PurpleAccount *)l->data;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1222
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1223 plugin = purple_plugins_find_with_id(
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1224 purple_account_get_protocol_id(account));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1225
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1226 if (plugin == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1227 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1228 account = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1229
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1230 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1231 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1232
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1233 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1234 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1235 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1236 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1237 gc = (PurpleConnection *)l->data;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1238 account = purple_connection_get_account(gc);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1239
32305
2ec94166be43 On the way to hiding the PurpleConnection struct.
andrew.victor@mxit.com
parents: 32241
diff changeset
1240 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1241 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1242
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1243 protoname = prpl_info->list_icon(account, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1244
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1245 if (!strcmp(protoname, "aim") || !strcmp(protoname, "icq"))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1246 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1247
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1248 account = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1249 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1250 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1251
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1252 *ret_account = account;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1253 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1254 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1255 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1256 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1257 valid = FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1258
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1259 g_free(username);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1260 g_free(protocol);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1261 g_free(alias);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1262 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1263
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1264 g_free(str);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1265
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1266 return valid;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1267 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1268
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1269 void
15506
311315e979f7 gtkutils changes
Sean Egan <seanegan@gmail.com>
parents: 15500
diff changeset
1270 pidgin_set_accessible_label (GtkWidget *w, GtkWidget *l)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1271 {
19367
bf918749b375 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 18827
diff changeset
1272 AtkObject *acc;
bf918749b375 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 18827
diff changeset
1273 const gchar *label_text;
bf918749b375 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 18827
diff changeset
1274 const gchar *existing_name;
bf918749b375 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 18827
diff changeset
1275
bf918749b375 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 18827
diff changeset
1276 acc = gtk_widget_get_accessible (w);
bf918749b375 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 18827
diff changeset
1277
bf918749b375 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 18827
diff changeset
1278 /* If this object has no name, set it's name with the label text */
bf918749b375 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 18827
diff changeset
1279 existing_name = atk_object_get_name (acc);
bf918749b375 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 18827
diff changeset
1280 if (!existing_name) {
bf918749b375 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 18827
diff changeset
1281 label_text = gtk_label_get_text (GTK_LABEL(l));
bf918749b375 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 18827
diff changeset
1282 if (label_text)
bf918749b375 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 18827
diff changeset
1283 atk_object_set_name (acc, label_text);
bf918749b375 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 18827
diff changeset
1284 }
bf918749b375 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 18827
diff changeset
1285
bf918749b375 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 18827
diff changeset
1286 pidgin_set_accessible_relations(w, l);
bf918749b375 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 18827
diff changeset
1287 }
bf918749b375 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 18827
diff changeset
1288
bf918749b375 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 18827
diff changeset
1289 void
bf918749b375 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 18827
diff changeset
1290 pidgin_set_accessible_relations (GtkWidget *w, GtkWidget *l)
bf918749b375 Separate out setting up the labelled-by and label-for ATK relationships
Casey Harkins <charkins@pidgin.im>
parents: 18827
diff changeset
1291 {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1292 AtkObject *acc, *label;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1293 AtkObject *rel_obj[1];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1294 AtkRelationSet *set;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1295 AtkRelation *relation;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1296
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1297 acc = gtk_widget_get_accessible (w);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1298 label = gtk_widget_get_accessible (l);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1299
18287
44928d01ec8c Call gtk_label_set_mnemonic_widget() in pidgin_make_accessible_label. Closes #589
Sean Egan <seanegan@gmail.com>
parents: 18218
diff changeset
1300 /* Make sure mnemonics work */
20349
0484600ac434 applied changes from 29b2fc4762e2c5d03a7100c78f2a7b49237c5e80
Luke Schierer <lschiere@pidgin.im>
parents: 20342
diff changeset
1301 gtk_label_set_mnemonic_widget(GTK_LABEL(l), w);
0484600ac434 applied changes from 29b2fc4762e2c5d03a7100c78f2a7b49237c5e80
Luke Schierer <lschiere@pidgin.im>
parents: 20342
diff changeset
1302
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1303 /* Create the labeled-by relation */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1304 set = atk_object_ref_relation_set (acc);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1305 rel_obj[0] = label;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1306 relation = atk_relation_new (rel_obj, 1, ATK_RELATION_LABELLED_BY);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1307 atk_relation_set_add (set, relation);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1308 g_object_unref (relation);
20349
0484600ac434 applied changes from 29b2fc4762e2c5d03a7100c78f2a7b49237c5e80
Luke Schierer <lschiere@pidgin.im>
parents: 20342
diff changeset
1309 g_object_unref(set);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1310
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1311 /* Create the label-for relation */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1312 set = atk_object_ref_relation_set (label);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1313 rel_obj[0] = acc;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1314 relation = atk_relation_new (rel_obj, 1, ATK_RELATION_LABEL_FOR);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1315 atk_relation_set_add (set, relation);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1316 g_object_unref (relation);
20349
0484600ac434 applied changes from 29b2fc4762e2c5d03a7100c78f2a7b49237c5e80
Luke Schierer <lschiere@pidgin.im>
parents: 20342
diff changeset
1317 g_object_unref(set);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1318 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1319
18166
afeb35205669 Reduce code duplication and keep gtk 2.0 compatibility by making
Stu Tomlinson <stu@nosnilmot.com>
parents: 18144
diff changeset
1320 void
afeb35205669 Reduce code duplication and keep gtk 2.0 compatibility by making
Stu Tomlinson <stu@nosnilmot.com>
parents: 18144
diff changeset
1321 pidgin_menu_position_func_helper(GtkMenu *menu,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1322 gint *x,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1323 gint *y,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1324 gboolean *push_in,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1325 gpointer data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1326 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1327 GtkWidget *widget;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1328 GtkRequisition requisition;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1329 GdkScreen *screen;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1330 GdkRectangle monitor;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1331 gint monitor_num;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1332 gint space_left, space_right, space_above, space_below;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1333 gint needed_width;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1334 gint needed_height;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1335 gint xthickness;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1336 gint ythickness;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1337 gboolean rtl;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1338
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1339 g_return_if_fail(GTK_IS_MENU(menu));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1340
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1341 widget = GTK_WIDGET(menu);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1342 screen = gtk_widget_get_screen(widget);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1343 xthickness = widget->style->xthickness;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1344 ythickness = widget->style->ythickness;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1345 rtl = (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1346
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1347 /*
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1348 * We need the requisition to figure out the right place to
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1349 * popup the menu. In fact, we always need to ask here, since
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1350 * if a size_request was queued while we weren't popped up,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1351 * the requisition won't have been recomputed yet.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1352 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1353 gtk_widget_size_request (widget, &requisition);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1354
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1355 monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1356
31928
1f22e6ea1d2a It seems like there's a dereference missing here.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 31904
diff changeset
1357 *push_in = FALSE;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1358
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1359 /*
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1360 * The placement of popup menus horizontally works like this (with
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1361 * RTL in parentheses)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1362 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1363 * - If there is enough room to the right (left) of the mouse cursor,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1364 * position the menu there.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1365 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1366 * - Otherwise, if if there is enough room to the left (right) of the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1367 * mouse cursor, position the menu there.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1368 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1369 * - Otherwise if the menu is smaller than the monitor, position it
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1370 * on the side of the mouse cursor that has the most space available
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1371 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1372 * - Otherwise (if there is simply not enough room for the menu on the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1373 * monitor), position it as far left (right) as possible.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1374 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1375 * Positioning in the vertical direction is similar: first try below
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1376 * mouse cursor, then above.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1377 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1378 gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1379
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1380 space_left = *x - monitor.x;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1381 space_right = monitor.x + monitor.width - *x - 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1382 space_above = *y - monitor.y;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1383 space_below = monitor.y + monitor.height - *y - 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1384
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1385 /* position horizontally */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1386
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1387 /* the amount of space we need to position the menu. Note the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1388 * menu is offset "xthickness" pixels
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1389 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1390 needed_width = requisition.width - xthickness;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1391
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1392 if (needed_width <= space_left ||
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1393 needed_width <= space_right)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1394 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1395 if ((rtl && needed_width <= space_left) ||
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1396 (!rtl && needed_width > space_right))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1397 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1398 /* position left */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1399 *x = *x + xthickness - requisition.width + 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1400 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1401 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1402 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1403 /* position right */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1404 *x = *x - xthickness;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1405 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1406
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1407 /* x is clamped on-screen further down */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1408 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1409 else if (requisition.width <= monitor.width)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1410 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1411 /* the menu is too big to fit on either side of the mouse
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1412 * cursor, but smaller than the monitor. Position it on
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1413 * the side that has the most space
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1414 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1415 if (space_left > space_right)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1416 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1417 /* left justify */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1418 *x = monitor.x;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1419 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1420 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1421 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1422 /* right justify */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1423 *x = monitor.x + monitor.width - requisition.width;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1424 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1425 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1426 else /* menu is simply too big for the monitor */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1427 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1428 if (rtl)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1429 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1430 /* right justify */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1431 *x = monitor.x + monitor.width - requisition.width;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1432 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1433 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1434 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1435 /* left justify */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1436 *x = monitor.x;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1437 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1438 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1439
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1440 /* Position vertically. The algorithm is the same as above, but
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1441 * simpler because we don't have to take RTL into account.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1442 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1443 needed_height = requisition.height - ythickness;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1444
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1445 if (needed_height <= space_above ||
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1446 needed_height <= space_below)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1447 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1448 if (needed_height <= space_below)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1449 *y = *y - ythickness;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1450 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1451 *y = *y + ythickness - requisition.height + 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1452
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1453 *y = CLAMP (*y, monitor.y,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1454 monitor.y + monitor.height - requisition.height);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1455 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1456 else if (needed_height > space_below && needed_height > space_above)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1457 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1458 if (space_below >= space_above)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1459 *y = monitor.y + monitor.height - requisition.height;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1460 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1461 *y = monitor.y;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1462 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1463 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1464 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1465 *y = monitor.y;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1466 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1467 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1468
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1469
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1470 void
15500
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15444
diff changeset
1471 pidgin_treeview_popup_menu_position_func(GtkMenu *menu,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1472 gint *x,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1473 gint *y,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1474 gboolean *push_in,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1475 gpointer data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1476 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1477 GtkWidget *widget = GTK_WIDGET(data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1478 GtkTreeView *tv = GTK_TREE_VIEW(data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1479 GtkTreePath *path;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1480 GtkTreeViewColumn *col;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1481 GdkRectangle rect;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1482 gint ythickness = GTK_WIDGET(menu)->style->ythickness;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1483
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1484 gdk_window_get_origin (widget->window, x, y);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1485 gtk_tree_view_get_cursor (tv, &path, &col);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1486 gtk_tree_view_get_cell_area (tv, path, col, &rect);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1487
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1488 *x += rect.x+rect.width;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1489 *y += rect.y+rect.height+ythickness;
18166
afeb35205669 Reduce code duplication and keep gtk 2.0 compatibility by making
Stu Tomlinson <stu@nosnilmot.com>
parents: 18144
diff changeset
1490 pidgin_menu_position_func_helper(menu, x, y, push_in, data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1491 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1492
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1493 enum {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1494 DND_FILE_TRANSFER,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1495 DND_IM_IMAGE,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1496 DND_BUDDY_ICON
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1497 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1498
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1499 typedef struct {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1500 char *filename;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1501 PurpleAccount *account;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1502 char *who;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1503 } _DndData;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1504
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1505 static void dnd_image_ok_callback(_DndData *data, int choice)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1506 {
31156
85d5f1e37fdb When drag-dropping an image into an IM window and sending as an inline
Mark Doliner <mark@kingant.net>
parents: 31014
diff changeset
1507 const gchar *shortname;
23120
f6c57e6e8a89 Deprecate pidgin_set_custom_buddy_icon and update the places that use it to
Etan Reisner <pidgin@unreliablesource.net>
parents: 23119
diff changeset
1508 gchar *filedata;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1509 size_t size;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1510 struct stat st;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1511 GError *err = NULL;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1512 PurpleConversation *conv;
15500
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15444
diff changeset
1513 PidginConversation *gtkconv;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1514 GtkTextIter iter;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1515 int id;
23120
f6c57e6e8a89 Deprecate pidgin_set_custom_buddy_icon and update the places that use it to
Etan Reisner <pidgin@unreliablesource.net>
parents: 23119
diff changeset
1516 PurpleBuddy *buddy;
f6c57e6e8a89 Deprecate pidgin_set_custom_buddy_icon and update the places that use it to
Etan Reisner <pidgin@unreliablesource.net>
parents: 23119
diff changeset
1517 PurpleContact *contact;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1518 switch (choice) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1519 case DND_BUDDY_ICON:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1520 if (g_stat(data->filename, &st)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1521 char *str;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1522
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1523 str = g_strdup_printf(_("The following error has occurred loading %s: %s"),
21860
f23c41e65f63 Use g_sterror instead of strerror in two more places.
Mark Doliner <mark@kingant.net>
parents: 21778
diff changeset
1524 data->filename, g_strerror(errno));
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1525 purple_notify_error(NULL, NULL,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1526 _("Failed to load image"),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1527 str);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1528 g_free(str);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1529
26643
0011cd06990a Use stock-id in the status editor window too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26624
diff changeset
1530 break;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1531 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1532
23121
0ca259d5f928 Compile and de-warn.
Etan Reisner <pidgin@unreliablesource.net>
parents: 23120
diff changeset
1533 buddy = purple_find_buddy(data->account, data->who);
23120
f6c57e6e8a89 Deprecate pidgin_set_custom_buddy_icon and update the places that use it to
Etan Reisner <pidgin@unreliablesource.net>
parents: 23119
diff changeset
1534 if (!buddy) {
f6c57e6e8a89 Deprecate pidgin_set_custom_buddy_icon and update the places that use it to
Etan Reisner <pidgin@unreliablesource.net>
parents: 23119
diff changeset
1535 purple_debug_info("custom-icon", "You can only set custom icons for people on your buddylist.\n");
f6c57e6e8a89 Deprecate pidgin_set_custom_buddy_icon and update the places that use it to
Etan Reisner <pidgin@unreliablesource.net>
parents: 23119
diff changeset
1536 break;
f6c57e6e8a89 Deprecate pidgin_set_custom_buddy_icon and update the places that use it to
Etan Reisner <pidgin@unreliablesource.net>
parents: 23119
diff changeset
1537 }
f6c57e6e8a89 Deprecate pidgin_set_custom_buddy_icon and update the places that use it to
Etan Reisner <pidgin@unreliablesource.net>
parents: 23119
diff changeset
1538 contact = purple_buddy_get_contact(buddy);
f6c57e6e8a89 Deprecate pidgin_set_custom_buddy_icon and update the places that use it to
Etan Reisner <pidgin@unreliablesource.net>
parents: 23119
diff changeset
1539 purple_buddy_icons_node_set_custom_icon_from_file((PurpleBlistNode*)contact, data->filename);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1540 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1541 case DND_FILE_TRANSFER:
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1542 serv_send_file(purple_account_get_connection(data->account), data->who, data->filename);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1543 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1544 case DND_IM_IMAGE:
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1545 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, data->account, data->who);
15500
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15444
diff changeset
1546 gtkconv = PIDGIN_CONVERSATION(conv);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1547
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1548 if (!g_file_get_contents(data->filename, &filedata, &size,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1549 &err)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1550 char *str;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1551
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1552 str = g_strdup_printf(_("The following error has occurred loading %s: %s"), data->filename, err->message);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1553 purple_notify_error(NULL, NULL,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1554 _("Failed to load image"),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1555 str);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1556
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1557 g_error_free(err);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1558 g_free(str);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1559
26643
0011cd06990a Use stock-id in the status editor window too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26624
diff changeset
1560 break;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1561 }
31156
85d5f1e37fdb When drag-dropping an image into an IM window and sending as an inline
Mark Doliner <mark@kingant.net>
parents: 31014
diff changeset
1562 shortname = strrchr(data->filename, G_DIR_SEPARATOR);
85d5f1e37fdb When drag-dropping an image into an IM window and sending as an inline
Mark Doliner <mark@kingant.net>
parents: 31014
diff changeset
1563 shortname = shortname ? shortname + 1 : data->filename;
85d5f1e37fdb When drag-dropping an image into an IM window and sending as an inline
Mark Doliner <mark@kingant.net>
parents: 31014
diff changeset
1564 id = purple_imgstore_add_with_id(filedata, size, shortname);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1565
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1566 gtk_text_buffer_get_iter_at_mark(GTK_IMHTML(gtkconv->entry)->text_buffer, &iter,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1567 gtk_text_buffer_get_insert(GTK_IMHTML(gtkconv->entry)->text_buffer));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1568 gtk_imhtml_insert_image_at_iter(GTK_IMHTML(gtkconv->entry), id, &iter);
16375
391a79778f89 Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
Richard Laager <rlaager@wiktel.com>
parents: 16255
diff changeset
1569 purple_imgstore_unref_by_id(id);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1570
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1571 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1572 }
24719
5ec72dbdd28e Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <paul@darkrain42.org>
parents: 24600
diff changeset
1573 g_free(data->filename);
5ec72dbdd28e Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <paul@darkrain42.org>
parents: 24600
diff changeset
1574 g_free(data->who);
5ec72dbdd28e Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <paul@darkrain42.org>
parents: 24600
diff changeset
1575 g_free(data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1576 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1577
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1578 static void dnd_image_cancel_callback(_DndData *data, int choice)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1579 {
24719
5ec72dbdd28e Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <paul@darkrain42.org>
parents: 24600
diff changeset
1580 g_free(data->filename);
5ec72dbdd28e Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <paul@darkrain42.org>
parents: 24600
diff changeset
1581 g_free(data->who);
5ec72dbdd28e Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <paul@darkrain42.org>
parents: 24600
diff changeset
1582 g_free(data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1583 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1584
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1585 static void dnd_set_icon_ok_cb(_DndData *data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1586 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1587 dnd_image_ok_callback(data, DND_BUDDY_ICON);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1588 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1589
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1590 static void dnd_set_icon_cancel_cb(_DndData *data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1591 {
24719
5ec72dbdd28e Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <paul@darkrain42.org>
parents: 24600
diff changeset
1592 g_free(data->filename);
5ec72dbdd28e Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <paul@darkrain42.org>
parents: 24600
diff changeset
1593 g_free(data->who);
5ec72dbdd28e Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <paul@darkrain42.org>
parents: 24600
diff changeset
1594 g_free(data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1595 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1596
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1597 void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1598 pidgin_dnd_file_manage(GtkSelectionData *sd, PurpleAccount *account, const char *who)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1599 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1600 GdkPixbuf *pb;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1601 GList *files = purple_uri_list_extract_filenames((const gchar *)sd->data);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1602 PurpleConnection *gc = purple_account_get_connection(account);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1603 PurplePluginProtocolInfo *prpl_info = NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1604 #ifndef _WIN32
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1605 PurpleDesktopItem *item;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1606 #endif
28172
07718e5eb8ce Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <paul@darkrain42.org>
parents: 27958
diff changeset
1607 gchar *filename = NULL;
07718e5eb8ce Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <paul@darkrain42.org>
parents: 27958
diff changeset
1608 gchar *basename = NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1609
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1610 g_return_if_fail(account != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1611 g_return_if_fail(who != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1612
28172
07718e5eb8ce Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <paul@darkrain42.org>
parents: 27958
diff changeset
1613 for ( ; files; files = g_list_delete_link(files, files)) {
07718e5eb8ce Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <paul@darkrain42.org>
parents: 27958
diff changeset
1614 g_free(filename);
07718e5eb8ce Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <paul@darkrain42.org>
parents: 27958
diff changeset
1615 g_free(basename);
07718e5eb8ce Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <paul@darkrain42.org>
parents: 27958
diff changeset
1616
07718e5eb8ce Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <paul@darkrain42.org>
parents: 27958
diff changeset
1617 filename = files->data;
07718e5eb8ce Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <paul@darkrain42.org>
parents: 27958
diff changeset
1618 basename = g_path_get_basename(filename);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1619
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1620 /* XXX - Make ft API support creating a transfer with more than one file */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1621 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1622 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1623 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1624
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1625 /* XXX - make ft api suupport sending a directory */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1626 /* Are we dealing with a directory? */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1627 if (g_file_test(filename, G_FILE_TEST_IS_DIR)) {
16010
eae8e127e4fb make things cleaner for translators
Nathan Walp <nwalp@pidgin.im>
parents: 15924
diff changeset
1628 char *str, *str2;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1629
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1630 str = g_strdup_printf(_("Cannot send folder %s."), basename);
16921
b668951121d8 Change the PIDGIN_NAME stuff to allow translators to transliterate the
Richard Laager <rlaager@wiktel.com>
parents: 16625
diff changeset
1631 str2 = g_strdup_printf(_("%s cannot transfer a folder. You will need to send the files within individually."), PIDGIN_NAME);
16010
eae8e127e4fb make things cleaner for translators
Nathan Walp <nwalp@pidgin.im>
parents: 15924
diff changeset
1632
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1633 purple_notify_error(NULL, NULL,
16010
eae8e127e4fb make things cleaner for translators
Nathan Walp <nwalp@pidgin.im>
parents: 15924
diff changeset
1634 str, str2);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1635
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1636 g_free(str);
16010
eae8e127e4fb make things cleaner for translators
Nathan Walp <nwalp@pidgin.im>
parents: 15924
diff changeset
1637 g_free(str2);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1638 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1639 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1640
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1641 /* Are we dealing with an image? */
31682
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
1642 pb = pidgin_pixbuf_new_from_file(filename);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1643 if (pb) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1644 _DndData *data = g_malloc(sizeof(_DndData));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1645 gboolean ft = FALSE, im = FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1646
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1647 data->who = g_strdup(who);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1648 data->filename = g_strdup(filename);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1649 data->account = account;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1650
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1651 if (gc)
32305
2ec94166be43 On the way to hiding the PurpleConnection struct.
andrew.victor@mxit.com
parents: 32241
diff changeset
1652 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1653
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1654 if (prpl_info && prpl_info->options & OPT_PROTO_IM_IMAGE)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1655 im = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1656
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1657 if (prpl_info && prpl_info->can_receive_file)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1658 ft = prpl_info->can_receive_file(gc, who);
20900
f7b799e77c43 When drag-dropping an image onto a conversation, include 'Send image file' as
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20805
diff changeset
1659 else if (prpl_info && prpl_info->send_file)
f7b799e77c43 When drag-dropping an image onto a conversation, include 'Send image file' as
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20805
diff changeset
1660 ft = TRUE;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1661
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1662 if (im && ft)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1663 purple_request_choice(NULL, NULL,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1664 _("You have dragged an image"),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1665 _("You can send this image as a file transfer, "
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1666 "embed it into this message, or use it as the buddy icon for this user."),
28924
4931a24576bd Mark strings for translation.
Adi Roiban <adi@roiban.ro>
parents: 28882
diff changeset
1667 DND_FILE_TRANSFER, _("OK"), (GCallback)dnd_image_ok_callback,
4931a24576bd Mark strings for translation.
Adi Roiban <adi@roiban.ro>
parents: 28882
diff changeset
1668 _("Cancel"), (GCallback)dnd_image_cancel_callback,
16439
08db93bbd798 Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents: 16255
diff changeset
1669 account, who, NULL,
08db93bbd798 Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents: 16255
diff changeset
1670 data,
08db93bbd798 Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents: 16255
diff changeset
1671 _("Set as buddy icon"), DND_BUDDY_ICON,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1672 _("Send image file"), DND_FILE_TRANSFER,
16439
08db93bbd798 Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents: 16255
diff changeset
1673 _("Insert in message"), DND_IM_IMAGE,
08db93bbd798 Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents: 16255
diff changeset
1674 NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1675 else if (!(im || ft))
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1676 purple_request_yes_no(NULL, NULL, _("You have dragged an image"),
16439
08db93bbd798 Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents: 16255
diff changeset
1677 _("Would you like to set it as the buddy icon for this user?"),
22143
70fc60344317 A few more of those "default_action" fixes
Mark Doliner <mark@kingant.net>
parents: 22012
diff changeset
1678 PURPLE_DEFAULT_ACTION_NONE,
16439
08db93bbd798 Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents: 16255
diff changeset
1679 account, who, NULL,
08db93bbd798 Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents: 16255
diff changeset
1680 data, (GCallback)dnd_set_icon_ok_cb, (GCallback)dnd_set_icon_cancel_cb);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1681 else
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1682 purple_request_choice(NULL, NULL,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1683 _("You have dragged an image"),
17419
840ae0796048 Fix the "transfer file or embed image" message (it looks like it was copied and pasted incorrectly).
Daniel Atallah <daniel.atallah@gmail.com>
parents: 17406
diff changeset
1684 (ft ? _("You can send this image as a file transfer, or use it as the buddy icon for this user.") :
16439
08db93bbd798 Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents: 16255
diff changeset
1685 _("You can insert this image into this message, or use it as the buddy icon for this user")),
08db93bbd798 Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents: 16255
diff changeset
1686 (ft ? DND_FILE_TRANSFER : DND_IM_IMAGE),
28924
4931a24576bd Mark strings for translation.
Adi Roiban <adi@roiban.ro>
parents: 28882
diff changeset
1687 _("OK"), (GCallback)dnd_image_ok_callback,
4931a24576bd Mark strings for translation.
Adi Roiban <adi@roiban.ro>
parents: 28882
diff changeset
1688 _("Cancel"), (GCallback)dnd_image_cancel_callback,
16439
08db93bbd798 Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents: 16255
diff changeset
1689 account, who, NULL,
08db93bbd798 Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents: 16255
diff changeset
1690 data,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1691 _("Set as buddy icon"), DND_BUDDY_ICON,
16439
08db93bbd798 Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents: 16255
diff changeset
1692 (ft ? _("Send image file") : _("Insert in message")), (ft ? DND_FILE_TRANSFER : DND_IM_IMAGE),
08db93bbd798 Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents: 16255
diff changeset
1693 NULL);
26623
a3f7ade9e45b Use g_object_ref/unref instead of the deprecated versions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26531
diff changeset
1694 g_object_unref(G_OBJECT(pb));
28172
07718e5eb8ce Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <paul@darkrain42.org>
parents: 27958
diff changeset
1695
07718e5eb8ce Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <paul@darkrain42.org>
parents: 27958
diff changeset
1696 g_free(basename);
07718e5eb8ce Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <paul@darkrain42.org>
parents: 27958
diff changeset
1697 while (files) {
07718e5eb8ce Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <paul@darkrain42.org>
parents: 27958
diff changeset
1698 g_free(files->data);
07718e5eb8ce Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <paul@darkrain42.org>
parents: 27958
diff changeset
1699 files = g_list_delete_link(files, files);
07718e5eb8ce Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <paul@darkrain42.org>
parents: 27958
diff changeset
1700 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1701 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1702 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1703
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1704 #ifndef _WIN32
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1705 /* Are we trying to send a .desktop file? */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1706 else if (purple_str_has_suffix(basename, ".desktop") && (item = purple_desktop_item_new_from_file(filename))) {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1707 PurpleDesktopItemType dtype;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1708 char key[64];
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1709 const char *itemname = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1710
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1711 const char * const *langs;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1712 int i;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1713 langs = g_get_language_names();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1714 for (i = 0; langs[i]; i++) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1715 g_snprintf(key, sizeof(key), "Name[%s]", langs[i]);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1716 itemname = purple_desktop_item_get_string(item, key);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1717 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1718 }
29087
2dcff225172e Start of killing off unneeded GTK_CHECK_VERSION checks in pidgin. Refs #10024
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27958
diff changeset
1719
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1720 if (!itemname)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1721 itemname = purple_desktop_item_get_string(item, "Name");
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1722
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1723 dtype = purple_desktop_item_get_entry_type(item);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1724 switch (dtype) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1725 PurpleConversation *conv;
15500
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15444
diff changeset
1726 PidginConversation *gtkconv;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1727
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1728 case PURPLE_DESKTOP_ITEM_TYPE_LINK:
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1729 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, who);
15500
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15444
diff changeset
1730 gtkconv = PIDGIN_CONVERSATION(conv);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1731 gtk_imhtml_insert_link(GTK_IMHTML(gtkconv->entry),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1732 gtk_text_buffer_get_insert(GTK_IMHTML(gtkconv->entry)->text_buffer),
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1733 purple_desktop_item_get_string(item, "URL"), itemname);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1734 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1735 default:
29087
2dcff225172e Start of killing off unneeded GTK_CHECK_VERSION checks in pidgin. Refs #10024
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27958
diff changeset
1736 /* I don't know if we really want to do anything here. Most of
2dcff225172e Start of killing off unneeded GTK_CHECK_VERSION checks in pidgin. Refs #10024
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27958
diff changeset
1737 * the desktop item types are crap like "MIME Type" (I have no
2dcff225172e Start of killing off unneeded GTK_CHECK_VERSION checks in pidgin. Refs #10024
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27958
diff changeset
1738 * clue how that would be a desktop item) and "Comment"...
2dcff225172e Start of killing off unneeded GTK_CHECK_VERSION checks in pidgin. Refs #10024
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27958
diff changeset
1739 * nothing we can really send. The only logical one is
2dcff225172e Start of killing off unneeded GTK_CHECK_VERSION checks in pidgin. Refs #10024
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27958
diff changeset
1740 * "Application," but do we really want to send a binary and
2dcff225172e Start of killing off unneeded GTK_CHECK_VERSION checks in pidgin. Refs #10024
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27958
diff changeset
1741 * nothing else? Probably not. I'll just give an error and
2dcff225172e Start of killing off unneeded GTK_CHECK_VERSION checks in pidgin. Refs #10024
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27958
diff changeset
1742 * return. */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1743 /* The original patch sent the icon used by the launcher. That's probably wrong */
27284
73c8e1964eef A semi-random collection of English spelling and grammatical changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26975
diff changeset
1744 purple_notify_error(NULL, NULL, _("Cannot send launcher"),
73c8e1964eef A semi-random collection of English spelling and grammatical changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26975
diff changeset
1745 _("You dragged a desktop launcher. Most "
73c8e1964eef A semi-random collection of English spelling and grammatical changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26975
diff changeset
1746 "likely you wanted to send the target "
73c8e1964eef A semi-random collection of English spelling and grammatical changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26975
diff changeset
1747 "of this launcher instead of this "
73c8e1964eef A semi-random collection of English spelling and grammatical changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26975
diff changeset
1748 "launcher itself."));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1749 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1750 }
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1751 purple_desktop_item_unref(item);
28172
07718e5eb8ce Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <paul@darkrain42.org>
parents: 27958
diff changeset
1752 g_free(basename);
07718e5eb8ce Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <paul@darkrain42.org>
parents: 27958
diff changeset
1753 while (files) {
07718e5eb8ce Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <paul@darkrain42.org>
parents: 27958
diff changeset
1754 g_free(files->data);
07718e5eb8ce Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <paul@darkrain42.org>
parents: 27958
diff changeset
1755 files = g_list_delete_link(files, files);
07718e5eb8ce Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <paul@darkrain42.org>
parents: 27958
diff changeset
1756 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1757 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1758 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1759 #endif /* _WIN32 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1760
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1761 /* Everything is fine, let's send */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1762 serv_send_file(gc, who, filename);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1763 }
28172
07718e5eb8ce Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <paul@darkrain42.org>
parents: 27958
diff changeset
1764
07718e5eb8ce Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <paul@darkrain42.org>
parents: 27958
diff changeset
1765 g_free(filename);
07718e5eb8ce Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
Paul Aurich <paul@darkrain42.org>
parents: 27958
diff changeset
1766 g_free(basename);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1767 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1768
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1769 void pidgin_buddy_icon_get_scale_size(GdkPixbuf *buf, PurpleBuddyIconSpec *spec, PurpleIconScaleRules rules, int *width, int *height)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1770 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1771 *width = gdk_pixbuf_get_width(buf);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1772 *height = gdk_pixbuf_get_height(buf);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1773
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1774 if ((spec == NULL) || !(spec->scale_rules & rules))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1775 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1776
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1777 purple_buddy_icon_get_scale_size(spec, width, height);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1778
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1779 /* and now for some arbitrary sanity checks */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1780 if(*width > 100)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1781 *width = 100;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1782 if(*height > 100)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1783 *height = 100;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1784 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1785
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1786 GdkPixbuf * pidgin_create_status_icon(PurpleStatusPrimitive prim, GtkWidget *w, const char *size)
15737
20225df32b7e Change some old, busted status icon stuff to use the new hotness
Sean Egan <seanegan@gmail.com>
parents: 15583
diff changeset
1787 {
20225df32b7e Change some old, busted status icon stuff to use the new hotness
Sean Egan <seanegan@gmail.com>
parents: 15583
diff changeset
1788 GtkIconSize icon_size = gtk_icon_size_from_name(size);
20225df32b7e Change some old, busted status icon stuff to use the new hotness
Sean Egan <seanegan@gmail.com>
parents: 15583
diff changeset
1789 GdkPixbuf *pixbuf = NULL;
26644
18543445e929 Reduce code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26643
diff changeset
1790 const char *stock = pidgin_stock_id_from_status_primitive(prim);
18543445e929 Reduce code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26643
diff changeset
1791
18543445e929 Reduce code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26643
diff changeset
1792 pixbuf = gtk_widget_render_icon (w, stock ? stock : PIDGIN_STOCK_STATUS_AVAILABLE,
18543445e929 Reduce code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26643
diff changeset
1793 icon_size, "GtkWidget");
15737
20225df32b7e Change some old, busted status icon stuff to use the new hotness
Sean Egan <seanegan@gmail.com>
parents: 15583
diff changeset
1794 return pixbuf;
20225df32b7e Change some old, busted status icon stuff to use the new hotness
Sean Egan <seanegan@gmail.com>
parents: 15583
diff changeset
1795 }
20225df32b7e Change some old, busted status icon stuff to use the new hotness
Sean Egan <seanegan@gmail.com>
parents: 15583
diff changeset
1796
26729
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1797 static const char *
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1798 stock_id_from_status_primitive_idle(PurpleStatusPrimitive prim, gboolean idle)
26643
0011cd06990a Use stock-id in the status editor window too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26624
diff changeset
1799 {
0011cd06990a Use stock-id in the status editor window too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26624
diff changeset
1800 const char *stock = NULL;
0011cd06990a Use stock-id in the status editor window too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26624
diff changeset
1801 switch (prim) {
0011cd06990a Use stock-id in the status editor window too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26624
diff changeset
1802 case PURPLE_STATUS_UNSET:
0011cd06990a Use stock-id in the status editor window too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26624
diff changeset
1803 stock = NULL;
0011cd06990a Use stock-id in the status editor window too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26624
diff changeset
1804 break;
0011cd06990a Use stock-id in the status editor window too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26624
diff changeset
1805 case PURPLE_STATUS_UNAVAILABLE:
26729
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1806 stock = idle ? PIDGIN_STOCK_STATUS_BUSY_I : PIDGIN_STOCK_STATUS_BUSY;
26643
0011cd06990a Use stock-id in the status editor window too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26624
diff changeset
1807 break;
0011cd06990a Use stock-id in the status editor window too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26624
diff changeset
1808 case PURPLE_STATUS_AWAY:
26729
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1809 stock = idle ? PIDGIN_STOCK_STATUS_AWAY_I : PIDGIN_STOCK_STATUS_AWAY;
26643
0011cd06990a Use stock-id in the status editor window too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26624
diff changeset
1810 break;
0011cd06990a Use stock-id in the status editor window too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26624
diff changeset
1811 case PURPLE_STATUS_EXTENDED_AWAY:
26729
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1812 stock = idle ? PIDGIN_STOCK_STATUS_XA_I : PIDGIN_STOCK_STATUS_XA;
26643
0011cd06990a Use stock-id in the status editor window too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26624
diff changeset
1813 break;
0011cd06990a Use stock-id in the status editor window too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26624
diff changeset
1814 case PURPLE_STATUS_INVISIBLE:
0011cd06990a Use stock-id in the status editor window too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26624
diff changeset
1815 stock = PIDGIN_STOCK_STATUS_INVISIBLE;
0011cd06990a Use stock-id in the status editor window too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26624
diff changeset
1816 break;
0011cd06990a Use stock-id in the status editor window too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26624
diff changeset
1817 case PURPLE_STATUS_OFFLINE:
26729
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1818 stock = idle ? PIDGIN_STOCK_STATUS_OFFLINE_I : PIDGIN_STOCK_STATUS_OFFLINE;
26643
0011cd06990a Use stock-id in the status editor window too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26624
diff changeset
1819 break;
0011cd06990a Use stock-id in the status editor window too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26624
diff changeset
1820 default:
26729
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1821 stock = idle ? PIDGIN_STOCK_STATUS_AVAILABLE_I : PIDGIN_STOCK_STATUS_AVAILABLE;
26643
0011cd06990a Use stock-id in the status editor window too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26624
diff changeset
1822 break;
0011cd06990a Use stock-id in the status editor window too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26624
diff changeset
1823 }
0011cd06990a Use stock-id in the status editor window too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26624
diff changeset
1824 return stock;
0011cd06990a Use stock-id in the status editor window too.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26624
diff changeset
1825 }
15737
20225df32b7e Change some old, busted status icon stuff to use the new hotness
Sean Egan <seanegan@gmail.com>
parents: 15583
diff changeset
1826
26729
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1827 const char *
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1828 pidgin_stock_id_from_status_primitive(PurpleStatusPrimitive prim)
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1829 {
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1830 return stock_id_from_status_primitive_idle(prim, FALSE);
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1831 }
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1832
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1833 const char *
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1834 pidgin_stock_id_from_presence(PurplePresence *presence)
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1835 {
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1836 PurpleStatus *status;
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1837 PurpleStatusType *type;
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1838 PurpleStatusPrimitive prim;
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1839 gboolean idle;
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1840
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1841 g_return_val_if_fail(presence, NULL);
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1842
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1843 status = purple_presence_get_active_status(presence);
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1844 type = purple_status_get_type(status);
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1845 prim = purple_status_type_get_primitive(type);
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1846
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1847 idle = purple_presence_is_idle(presence);
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1848
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1849 return stock_id_from_status_primitive_idle(prim, idle);
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1850 }
89f613b16e2b New API to get the stock-id for a presence.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26654
diff changeset
1851
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1852 GdkPixbuf *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1853 pidgin_create_prpl_icon(PurpleAccount *account, PidginPrplIconSize size)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1854 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1855 PurplePlugin *prpl;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1856
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1857 g_return_val_if_fail(account != NULL, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1858
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1859 prpl = purple_find_prpl(purple_account_get_protocol_id(account));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1860 if (prpl == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1861 return NULL;
17758
012aaa301a30 Remove code duplication for prpl-icon creation.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17753
diff changeset
1862 return pidgin_create_prpl_icon_from_prpl(prpl, size, account);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1863 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1864
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1865 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1866 menu_action_cb(GtkMenuItem *item, gpointer object)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1867 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1868 gpointer data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1869 void (*callback)(gpointer, gpointer);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1870
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1871 callback = g_object_get_data(G_OBJECT(item), "purplecallback");
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1872 data = g_object_get_data(G_OBJECT(item), "purplecallbackdata");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1873
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1874 if (callback)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1875 callback(object, data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1876 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1877
17753
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1878 GtkWidget *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1879 pidgin_append_menu_action(GtkWidget *menu, PurpleMenuAction *act,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1880 gpointer object)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1881 {
17753
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1882 GtkWidget *menuitem;
32005
3b2ceeb8883b Hide-a-PurpleMenuAction.
masca@cpw.pidgin.im
parents: 31945
diff changeset
1883 GList *list;
17799
2f8d77356268 merge of '2f10c41a04555ebc895ec5168c3c2996c738cbd9'
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17758 17341
diff changeset
1884
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1885 if (act == NULL) {
17753
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1886 return pidgin_separator(menu);
17799
2f8d77356268 merge of '2f10c41a04555ebc895ec5168c3c2996c738cbd9'
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17758 17341
diff changeset
1887 }
17753
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1888
32005
3b2ceeb8883b Hide-a-PurpleMenuAction.
masca@cpw.pidgin.im
parents: 31945
diff changeset
1889 list = purple_menu_action_get_children(act);
3b2ceeb8883b Hide-a-PurpleMenuAction.
masca@cpw.pidgin.im
parents: 31945
diff changeset
1890 menuitem = gtk_menu_item_new_with_mnemonic(purple_menu_action_get_label(act));
3b2ceeb8883b Hide-a-PurpleMenuAction.
masca@cpw.pidgin.im
parents: 31945
diff changeset
1891
3b2ceeb8883b Hide-a-PurpleMenuAction.
masca@cpw.pidgin.im
parents: 31945
diff changeset
1892 if (list == NULL) {
3b2ceeb8883b Hide-a-PurpleMenuAction.
masca@cpw.pidgin.im
parents: 31945
diff changeset
1893 PurpleCallback callback;
3b2ceeb8883b Hide-a-PurpleMenuAction.
masca@cpw.pidgin.im
parents: 31945
diff changeset
1894
3b2ceeb8883b Hide-a-PurpleMenuAction.
masca@cpw.pidgin.im
parents: 31945
diff changeset
1895 callback = purple_menu_action_get_callback(act);
3b2ceeb8883b Hide-a-PurpleMenuAction.
masca@cpw.pidgin.im
parents: 31945
diff changeset
1896
3b2ceeb8883b Hide-a-PurpleMenuAction.
masca@cpw.pidgin.im
parents: 31945
diff changeset
1897 if (callback != NULL) {
17753
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1898 g_object_set_data(G_OBJECT(menuitem),
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1899 "purplecallback",
32005
3b2ceeb8883b Hide-a-PurpleMenuAction.
masca@cpw.pidgin.im
parents: 31945
diff changeset
1900 callback);
17753
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1901 g_object_set_data(G_OBJECT(menuitem),
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1902 "purplecallbackdata",
32005
3b2ceeb8883b Hide-a-PurpleMenuAction.
masca@cpw.pidgin.im
parents: 31945
diff changeset
1903 purple_menu_action_get_data(act));
17753
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1904 g_signal_connect(G_OBJECT(menuitem), "activate",
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1905 G_CALLBACK(menu_action_cb),
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1906 object);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1907 } else {
17753
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1908 gtk_widget_set_sensitive(menuitem, FALSE);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1909 }
17753
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1910
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1911 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1912 } else {
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1913 GList *l = NULL;
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1914 GtkWidget *submenu = NULL;
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1915 GtkAccelGroup *group;
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1916
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1917 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1918
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1919 submenu = gtk_menu_new();
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1920 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu);
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1921
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1922 group = gtk_menu_get_accel_group(GTK_MENU(menu));
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1923 if (group) {
32005
3b2ceeb8883b Hide-a-PurpleMenuAction.
masca@cpw.pidgin.im
parents: 31945
diff changeset
1924 char *path = g_strdup_printf("%s/%s", GTK_MENU_ITEM(menuitem)->accel_path,
3b2ceeb8883b Hide-a-PurpleMenuAction.
masca@cpw.pidgin.im
parents: 31945
diff changeset
1925 purple_menu_action_get_label(act));
17753
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1926 gtk_menu_set_accel_path(GTK_MENU(submenu), path);
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1927 g_free(path);
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1928 gtk_menu_set_accel_group(GTK_MENU(submenu), group);
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1929 }
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1930
32005
3b2ceeb8883b Hide-a-PurpleMenuAction.
masca@cpw.pidgin.im
parents: 31945
diff changeset
1931 for (l = list; l; l = l->next) {
17753
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1932 PurpleMenuAction *act = (PurpleMenuAction *)l->data;
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1933
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1934 pidgin_append_menu_action(submenu, act, object);
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1935 }
32005
3b2ceeb8883b Hide-a-PurpleMenuAction.
masca@cpw.pidgin.im
parents: 31945
diff changeset
1936 g_list_free(list);
3b2ceeb8883b Hide-a-PurpleMenuAction.
masca@cpw.pidgin.im
parents: 31945
diff changeset
1937 purple_menu_action_set_children(act, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1938 }
17753
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1939 purple_menu_action_free(act);
d48026a5f9dd Use purple_conversation_extended_menu to add items in the conversation
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17750
diff changeset
1940 return menuitem;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1941 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1942
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1943 typedef struct
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1944 {
18667
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
1945 GtkWidget *entry;
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
1946 GtkWidget *accountopt;
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
1947
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
1948 PidginFilterBuddyCompletionEntryFunc filter_func;
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
1949 gpointer filter_func_user_data;
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
1950
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
1951 GtkListStore *store;
15500
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15444
diff changeset
1952 } PidginCompletionData;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1953
25925
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
1954 static gboolean buddyname_completion_match_func(GtkEntryCompletion *completion,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1955 const gchar *key, GtkTreeIter *iter, gpointer user_data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1956 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1957 GtkTreeModel *model;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1958 GValue val1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1959 GValue val2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1960 const char *tmp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1961
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1962 model = gtk_entry_completion_get_model (completion);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1963
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1964 val1.g_type = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1965 gtk_tree_model_get_value(model, iter, 2, &val1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1966 tmp = g_value_get_string(&val1);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1967 if (tmp != NULL && purple_str_has_prefix(tmp, key))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1968 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1969 g_value_unset(&val1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1970 return TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1971 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1972 g_value_unset(&val1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1973
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1974 val2.g_type = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1975 gtk_tree_model_get_value(model, iter, 3, &val2);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1976 tmp = g_value_get_string(&val2);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1977 if (tmp != NULL && purple_str_has_prefix(tmp, key))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1978 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1979 g_value_unset(&val2);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1980 return TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1981 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1982 g_value_unset(&val2);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1983
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1984 return FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1985 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1986
25925
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
1987 static gboolean buddyname_completion_match_selected_cb(GtkEntryCompletion *completion,
18667
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
1988 GtkTreeModel *model, GtkTreeIter *iter, PidginCompletionData *data)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1989 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1990 GValue val;
18667
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
1991 GtkWidget *optmenu = data->accountopt;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
1992 PurpleAccount *account;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1993
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1994 val.g_type = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1995 gtk_tree_model_get_value(model, iter, 1, &val);
18667
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
1996 gtk_entry_set_text(GTK_ENTRY(data->entry), g_value_get_string(&val));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1997 g_value_unset(&val);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1998
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1999 gtk_tree_model_get_value(model, iter, 4, &val);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2000 account = g_value_get_pointer(&val);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2001 g_value_unset(&val);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2002
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2003 if (account == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2004 return TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2005
17109
7ca09df1ea55 aop_menu branch
Gabriel Schulhof <nix@go-nix.ca>
parents: 17071
diff changeset
2006 if (optmenu != NULL)
17341
fe8a1051aa0a Casting things to gpointer isn't useful, unless they were previously const.
Richard Laager <rlaager@wiktel.com>
parents: 17181
diff changeset
2007 aop_option_menu_select_by_data(optmenu, account);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2008
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2009 return TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2010 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2011
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2012 static void
25925
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2013 add_buddyname_autocomplete_entry(GtkListStore *store, const char *buddy_alias, const char *contact_alias,
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2014 const PurpleAccount *account, const char *buddyname)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2015 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2016 GtkTreeIter iter;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2017 gboolean completion_added = FALSE;
25925
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2018 gchar *normalized_buddyname;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2019 gchar *tmp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2020
25925
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2021 tmp = g_utf8_normalize(buddyname, -1, G_NORMALIZE_DEFAULT);
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2022 normalized_buddyname = g_utf8_casefold(tmp, -1);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2023 g_free(tmp);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2024
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2025 /* There's no sense listing things like: 'xxx "xxx"'
25925
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2026 when the name and buddy alias match. */
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2027 if (buddy_alias && strcmp(buddy_alias, buddyname)) {
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2028 char *completion_entry = g_strdup_printf("%s \"%s\"", buddyname, buddy_alias);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2029 char *tmp2 = g_utf8_normalize(buddy_alias, -1, G_NORMALIZE_DEFAULT);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2030
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2031 tmp = g_utf8_casefold(tmp2, -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2032 g_free(tmp2);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2033
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2034 gtk_list_store_append(store, &iter);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2035 gtk_list_store_set(store, &iter,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2036 0, completion_entry,
25925
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2037 1, buddyname,
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2038 2, normalized_buddyname,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2039 3, tmp,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2040 4, account,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2041 -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2042 g_free(completion_entry);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2043 g_free(tmp);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2044 completion_added = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2045 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2046
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2047 /* There's no sense listing things like: 'xxx "xxx"'
25925
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2048 when the name and contact alias match. */
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2049 if (contact_alias && strcmp(contact_alias, buddyname)) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2050 /* We don't want duplicates when the contact and buddy alias match. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2051 if (!buddy_alias || strcmp(contact_alias, buddy_alias)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2052 char *completion_entry = g_strdup_printf("%s \"%s\"",
25925
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2053 buddyname, contact_alias);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2054 char *tmp2 = g_utf8_normalize(contact_alias, -1, G_NORMALIZE_DEFAULT);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2055
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2056 tmp = g_utf8_casefold(tmp2, -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2057 g_free(tmp2);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2058
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2059 gtk_list_store_append(store, &iter);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2060 gtk_list_store_set(store, &iter,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2061 0, completion_entry,
25925
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2062 1, buddyname,
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2063 2, normalized_buddyname,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2064 3, tmp,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2065 4, account,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2066 -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2067 g_free(completion_entry);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2068 g_free(tmp);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2069 completion_added = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2070 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2071 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2072
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2073 if (completion_added == FALSE) {
25925
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2074 /* Add the buddy's name. */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2075 gtk_list_store_append(store, &iter);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2076 gtk_list_store_set(store, &iter,
25925
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2077 0, buddyname,
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2078 1, buddyname,
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2079 2, normalized_buddyname,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2080 3, NULL,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2081 4, account,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2082 -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2083 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2084
25925
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2085 g_free(normalized_buddyname);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2086 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2087
18667
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2088 static void get_log_set_name(PurpleLogSet *set, gpointer value, PidginCompletionData *data)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2089 {
18667
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2090 PidginFilterBuddyCompletionEntryFunc filter_func = data->filter_func;
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2091 gpointer user_data = data->filter_func_user_data;
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2092
25925
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2093 /* 1. Don't show buddies because we will have gotten them already.
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2094 * 2. The boxes that use this autocomplete code handle only IMs. */
18667
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2095 if (!set->buddy && set->type == PURPLE_LOG_IM) {
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2096 PidginBuddyCompletionEntry entry;
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2097 entry.is_buddy = FALSE;
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2098 entry.entry.logged_buddy = set;
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2099
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2100 if (filter_func(&entry, user_data)) {
25925
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2101 add_buddyname_autocomplete_entry(data->store,
18667
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2102 NULL, NULL, set->account, set->name);
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2103 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2104 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2105 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2106
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2107 static void
15500
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15444
diff changeset
2108 add_completion_list(PidginCompletionData *data)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2109 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
2110 PurpleBlistNode *gnode, *cnode, *bnode;
18667
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2111 PidginFilterBuddyCompletionEntryFunc filter_func = data->filter_func;
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2112 gpointer user_data = data->filter_func_user_data;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2113 GHashTable *sets;
18667
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2114
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2115 gtk_list_store_clear(data->store);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2116
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
2117 for (gnode = purple_get_blist()->root; gnode != NULL; gnode = gnode->next)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2118 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
2119 if (!PURPLE_BLIST_NODE_IS_GROUP(gnode))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2120 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2121
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2122 for (cnode = gnode->child; cnode != NULL; cnode = cnode->next)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2123 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
2124 if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2125 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2126
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2127 for (bnode = cnode->child; bnode != NULL; bnode = bnode->next)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2128 {
18667
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2129 PidginBuddyCompletionEntry entry;
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2130 entry.is_buddy = TRUE;
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2131 entry.entry.buddy = (PurpleBuddy *) bnode;
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2132
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2133 if (filter_func(&entry, user_data)) {
25925
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2134 add_buddyname_autocomplete_entry(data->store,
18667
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2135 ((PurpleContact *)cnode)->alias,
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2136 purple_buddy_get_contact_alias(entry.entry.buddy),
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2137 entry.entry.buddy->account,
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2138 entry.entry.buddy->name
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2139 );
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2140 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2141 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2142 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2143 }
18667
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2144
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
2145 sets = purple_log_get_log_sets();
18667
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2146 g_hash_table_foreach(sets, (GHFunc)get_log_set_name, data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2147 g_hash_table_destroy(sets);
18667
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2148
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2149 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2150
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2151 static void
25925
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2152 buddyname_autocomplete_destroyed_cb(GtkWidget *widget, gpointer data)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2153 {
17584
43da9c881fe9 Unleak a few bytes in the screenname completion code
Stu Tomlinson <stu@nosnilmot.com>
parents: 17494
diff changeset
2154 g_free(data);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
2155 purple_signals_disconnect_by_handle(widget);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2156 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2157
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2158 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2159 repopulate_autocomplete(gpointer something, gpointer data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2160 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2161 add_completion_list(data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2162 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2163
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2164 void
18667
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2165 pidgin_setup_screenname_autocomplete_with_filter(GtkWidget *entry, GtkWidget *accountopt, PidginFilterBuddyCompletionEntryFunc filter_func, gpointer user_data)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2166 {
18667
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2167 PidginCompletionData *data;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2168
25925
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2169 /*
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2170 * Store the displayed completion value, the buddy name, the UTF-8
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2171 * normalized & casefolded buddy name, the UTF-8 normalized &
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2172 * casefolded value for comparison, and the account.
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2173 */
18667
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2174 GtkListStore *store;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2175
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2176 GtkEntryCompletion *completion;
18667
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2177
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2178 data = g_new0(PidginCompletionData, 1);
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2179 store = gtk_list_store_new(5, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER);
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2180
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2181 data->entry = entry;
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2182 data->accountopt = accountopt;
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2183 if (filter_func == NULL) {
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2184 data->filter_func = pidgin_screenname_autocomplete_default_filter;
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2185 data->filter_func_user_data = NULL;
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2186 } else {
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2187 data->filter_func = filter_func;
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2188 data->filter_func_user_data = user_data;
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2189 }
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2190 data->store = store;
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2191
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2192 add_completion_list(data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2193
25925
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2194 /* Sort the completion list by buddy name */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2195 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2196 1, GTK_SORT_ASCENDING);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2197
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2198 completion = gtk_entry_completion_new();
25925
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2199 gtk_entry_completion_set_match_func(completion, buddyname_completion_match_func, NULL, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2200
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2201 g_signal_connect(G_OBJECT(completion), "match-selected",
25925
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2202 G_CALLBACK(buddyname_completion_match_selected_cb), data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2203
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2204 gtk_entry_set_completion(GTK_ENTRY(entry), completion);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2205 g_object_unref(completion);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2206
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2207 gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(store));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2208 g_object_unref(store);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2209
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2210 gtk_entry_completion_set_text_column(completion, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2211
18667
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2212 purple_signal_connect(purple_connections_get_handle(), "signed-on", entry,
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2213 PURPLE_CALLBACK(repopulate_autocomplete), data);
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2214 purple_signal_connect(purple_connections_get_handle(), "signed-off", entry,
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2215 PURPLE_CALLBACK(repopulate_autocomplete), data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2216
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
2217 purple_signal_connect(purple_accounts_get_handle(), "account-added", entry,
18667
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2218 PURPLE_CALLBACK(repopulate_autocomplete), data);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
2219 purple_signal_connect(purple_accounts_get_handle(), "account-removed", entry,
18667
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2220 PURPLE_CALLBACK(repopulate_autocomplete), data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2221
25925
6e1967b0f90b Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <mark@kingant.net>
parents: 25924
diff changeset
2222 g_signal_connect(G_OBJECT(entry), "destroy", G_CALLBACK(buddyname_autocomplete_destroyed_cb), data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2223 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2224
18667
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2225 gboolean
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2226 pidgin_screenname_autocomplete_default_filter(const PidginBuddyCompletionEntry *completion_entry, gpointer all_accounts) {
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2227 gboolean all = GPOINTER_TO_INT(all_accounts);
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2228
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2229 if (completion_entry->is_buddy) {
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2230 return all || purple_account_is_connected(completion_entry->entry.buddy->account);
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2231 } else {
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2232 return all || (completion_entry->entry.logged_buddy->account != NULL && purple_account_is_connected(completion_entry->entry.logged_buddy->account));
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2233 }
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2234 }
b256b4808a6b Screenname auto-completion filtering by Leonardo Fernandes, Fixes #519
Sean Egan <seanegan@gmail.com>
parents: 18643
diff changeset
2235
15500
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15444
diff changeset
2236 void pidgin_set_cursor(GtkWidget *widget, GdkCursorType cursor_type)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2237 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2238 GdkCursor *cursor;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2239
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2240 g_return_if_fail(widget != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2241 if (widget->window == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2242 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2243
22644
a1202a1aa150 Use the desired cursor, instead of always using GDK_WATCH.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22561
diff changeset
2244 cursor = gdk_cursor_new(cursor_type);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2245 gdk_window_set_cursor(widget->window, cursor);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2246 gdk_cursor_unref(cursor);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2247
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2248 gdk_display_flush(gdk_drawable_get_display(GDK_DRAWABLE(widget->window)));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2249 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2250
15500
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15444
diff changeset
2251 void pidgin_clear_cursor(GtkWidget *widget)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2252 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2253 g_return_if_fail(widget != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2254 if (widget->window == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2255 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2256
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2257 gdk_window_set_cursor(widget->window, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2258 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2259
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2260 struct _icon_chooser {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2261 GtkWidget *icon_filesel;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2262 GtkWidget *icon_preview;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2263 GtkWidget *icon_text;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2264
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2265 void (*callback)(const char*,gpointer);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2266 gpointer data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2267 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2268
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2269 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2270 icon_filesel_choose_cb(GtkWidget *widget, gint response, struct _icon_chooser *dialog)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2271 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2272 char *filename, *current_folder;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2273
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2274 if (response != GTK_RESPONSE_ACCEPT) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2275 if (response == GTK_RESPONSE_CANCEL) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2276 gtk_widget_destroy(dialog->icon_filesel);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2277 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2278 dialog->icon_filesel = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2279 if (dialog->callback)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2280 dialog->callback(NULL, dialog->data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2281 g_free(dialog);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2282 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2283 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2284
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2285 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog->icon_filesel));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2286 current_folder = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(dialog->icon_filesel));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2287 if (current_folder != NULL) {
16062
07554cc5d090 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents: 16010
diff changeset
2288 purple_prefs_set_path(PIDGIN_PREFS_ROOT "/filelocations/last_icon_folder", current_folder);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2289 g_free(current_folder);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2290 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2291
29087
2dcff225172e Start of killing off unneeded GTK_CHECK_VERSION checks in pidgin. Refs #10024
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27958
diff changeset
2292
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2293 if (dialog->callback)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2294 dialog->callback(filename, dialog->data);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2295 gtk_widget_destroy(dialog->icon_filesel);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2296 g_free(filename);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2297 g_free(dialog);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2298 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2299
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2300
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2301 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2302 icon_preview_change_cb(GtkFileChooser *widget, struct _icon_chooser *dialog)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2303 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2304 GdkPixbuf *pixbuf, *scale;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2305 int height, width;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2306 char *basename, *markup, *size;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2307 struct stat st;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2308 char *filename;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2309
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2310 filename = gtk_file_chooser_get_preview_filename(
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2311 GTK_FILE_CHOOSER(dialog->icon_filesel));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2312
31682
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
2313 if (!filename || g_stat(filename, &st) || !(pixbuf = pidgin_pixbuf_new_from_file(filename)))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2314 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2315 gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->icon_preview), NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2316 gtk_label_set_markup(GTK_LABEL(dialog->icon_text), "");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2317 g_free(filename);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2318 return;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2319 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2320
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2321 width = gdk_pixbuf_get_width(pixbuf);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2322 height = gdk_pixbuf_get_height(pixbuf);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2323 basename = g_path_get_basename(filename);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
2324 size = purple_str_size_to_units(st.st_size);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2325 markup = g_strdup_printf(_("<b>File:</b> %s\n"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2326 "<b>File size:</b> %s\n"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2327 "<b>Image size:</b> %dx%d"),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2328 basename, size, width, height);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2329
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2330 scale = gdk_pixbuf_scale_simple(pixbuf, width * 50 / height,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2331 50, GDK_INTERP_BILINEAR);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2332 gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->icon_preview), scale);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2333 gtk_label_set_markup(GTK_LABEL(dialog->icon_text), markup);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2334
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2335 g_object_unref(G_OBJECT(pixbuf));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2336 g_object_unref(G_OBJECT(scale));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2337 g_free(filename);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2338 g_free(basename);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2339 g_free(size);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2340 g_free(markup);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2341 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2342
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2343
15500
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15444
diff changeset
2344 GtkWidget *pidgin_buddy_icon_chooser_new(GtkWindow *parent, void(*callback)(const char *, gpointer), gpointer data) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2345 struct _icon_chooser *dialog = g_new0(struct _icon_chooser, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2346
16990
9adc82b72216 Display the image info label in the icon chooser preview area. I'm not sure why this was only being displayed in the pre-GTK 2.4.0 chooser. Also, always use our preview widget - we don't need to fallback to the GTK default previewer, this fixes #458 and seems like the right thing to do in this case.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16982
diff changeset
2347 GtkWidget *vbox;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2348 const char *current_folder;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2349
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2350 dialog->callback = callback;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2351 dialog->data = data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2352
16062
07554cc5d090 Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <stu@nosnilmot.com>
parents: 16010
diff changeset
2353 current_folder = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/filelocations/last_icon_folder");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2354
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2355 dialog->icon_filesel = gtk_file_chooser_dialog_new(_("Buddy Icon"),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2356 parent,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2357 GTK_FILE_CHOOSER_ACTION_OPEN,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2358 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2359 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2360 NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2361 gtk_dialog_set_default_response(GTK_DIALOG(dialog->icon_filesel), GTK_RESPONSE_ACCEPT);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2362 if ((current_folder != NULL) && (*current_folder != '\0'))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2363 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog->icon_filesel),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2364 current_folder);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2365
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2366 dialog->icon_preview = gtk_image_new();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2367 dialog->icon_text = gtk_label_new(NULL);
16990
9adc82b72216 Display the image info label in the icon chooser preview area. I'm not sure why this was only being displayed in the pre-GTK 2.4.0 chooser. Also, always use our preview widget - we don't need to fallback to the GTK default previewer, this fixes #458 and seems like the right thing to do in this case.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16982
diff changeset
2368
9adc82b72216 Display the image info label in the icon chooser preview area. I'm not sure why this was only being displayed in the pre-GTK 2.4.0 chooser. Also, always use our preview widget - we don't need to fallback to the GTK default previewer, this fixes #458 and seems like the right thing to do in this case.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16982
diff changeset
2369 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
9adc82b72216 Display the image info label in the icon chooser preview area. I'm not sure why this was only being displayed in the pre-GTK 2.4.0 chooser. Also, always use our preview widget - we don't need to fallback to the GTK default previewer, this fixes #458 and seems like the right thing to do in this case.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16982
diff changeset
2370 gtk_widget_set_size_request(GTK_WIDGET(vbox), -1, 50);
9adc82b72216 Display the image info label in the icon chooser preview area. I'm not sure why this was only being displayed in the pre-GTK 2.4.0 chooser. Also, always use our preview widget - we don't need to fallback to the GTK default previewer, this fixes #458 and seems like the right thing to do in this case.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16982
diff changeset
2371 gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(dialog->icon_preview), TRUE, FALSE, 0);
9adc82b72216 Display the image info label in the icon chooser preview area. I'm not sure why this was only being displayed in the pre-GTK 2.4.0 chooser. Also, always use our preview widget - we don't need to fallback to the GTK default previewer, this fixes #458 and seems like the right thing to do in this case.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16982
diff changeset
2372 gtk_box_pack_end(GTK_BOX(vbox), GTK_WIDGET(dialog->icon_text), FALSE, FALSE, 0);
9adc82b72216 Display the image info label in the icon chooser preview area. I'm not sure why this was only being displayed in the pre-GTK 2.4.0 chooser. Also, always use our preview widget - we don't need to fallback to the GTK default previewer, this fixes #458 and seems like the right thing to do in this case.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16982
diff changeset
2373 gtk_widget_show_all(vbox);
9adc82b72216 Display the image info label in the icon chooser preview area. I'm not sure why this was only being displayed in the pre-GTK 2.4.0 chooser. Also, always use our preview widget - we don't need to fallback to the GTK default previewer, this fixes #458 and seems like the right thing to do in this case.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16982
diff changeset
2374
9adc82b72216 Display the image info label in the icon chooser preview area. I'm not sure why this was only being displayed in the pre-GTK 2.4.0 chooser. Also, always use our preview widget - we don't need to fallback to the GTK default previewer, this fixes #458 and seems like the right thing to do in this case.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16982
diff changeset
2375 gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(dialog->icon_filesel), vbox);
9adc82b72216 Display the image info label in the icon chooser preview area. I'm not sure why this was only being displayed in the pre-GTK 2.4.0 chooser. Also, always use our preview widget - we don't need to fallback to the GTK default previewer, this fixes #458 and seems like the right thing to do in this case.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16982
diff changeset
2376 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(dialog->icon_filesel), TRUE);
9adc82b72216 Display the image info label in the icon chooser preview area. I'm not sure why this was only being displayed in the pre-GTK 2.4.0 chooser. Also, always use our preview widget - we don't need to fallback to the GTK default previewer, this fixes #458 and seems like the right thing to do in this case.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16982
diff changeset
2377 gtk_file_chooser_set_use_preview_label(GTK_FILE_CHOOSER(dialog->icon_filesel), FALSE);
9adc82b72216 Display the image info label in the icon chooser preview area. I'm not sure why this was only being displayed in the pre-GTK 2.4.0 chooser. Also, always use our preview widget - we don't need to fallback to the GTK default previewer, this fixes #458 and seems like the right thing to do in this case.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 16982
diff changeset
2378
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2379 g_signal_connect(G_OBJECT(dialog->icon_filesel), "update-preview",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2380 G_CALLBACK(icon_preview_change_cb), dialog);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2381 g_signal_connect(G_OBJECT(dialog->icon_filesel), "response",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2382 G_CALLBACK(icon_filesel_choose_cb), dialog);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2383 icon_preview_change_cb(NULL, dialog);
21755
5b0d9e08992d Make sure that the buddy icon file chooser dialog appears onscreen on windows. Fixes #4065.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21560
diff changeset
2384
5b0d9e08992d Make sure that the buddy icon file chooser dialog appears onscreen on windows. Fixes #4065.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21560
diff changeset
2385 #ifdef _WIN32
5b0d9e08992d Make sure that the buddy icon file chooser dialog appears onscreen on windows. Fixes #4065.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21560
diff changeset
2386 g_signal_connect(G_OBJECT(dialog->icon_filesel), "show",
5b0d9e08992d Make sure that the buddy icon file chooser dialog appears onscreen on windows. Fixes #4065.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21560
diff changeset
2387 G_CALLBACK(winpidgin_ensure_onscreen), dialog->icon_filesel);
5b0d9e08992d Make sure that the buddy icon file chooser dialog appears onscreen on windows. Fixes #4065.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21560
diff changeset
2388 #endif
5b0d9e08992d Make sure that the buddy icon file chooser dialog appears onscreen on windows. Fixes #4065.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21560
diff changeset
2389
5b0d9e08992d Make sure that the buddy icon file chooser dialog appears onscreen on windows. Fixes #4065.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 21560
diff changeset
2390 return dialog->icon_filesel;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2391 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2392
29648
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2393 /**
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2394 * @return True if any string from array a exists in array b.
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2395 */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2396 static gboolean
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2397 str_array_match(char **a, char **b)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2398 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2399 int i, j;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2400
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2401 if (!a || !b)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2402 return FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2403 for (i = 0; a[i] != NULL; i++)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2404 for (j = 0; b[j] != NULL; j++)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2405 if (!g_ascii_strcasecmp(a[i], b[j]))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2406 return TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2407 return FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2408 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2409
16381
72dc611f3257 Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents: 16375
diff changeset
2410 gpointer
72dc611f3257 Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents: 16375
diff changeset
2411 pidgin_convert_buddy_icon(PurplePlugin *plugin, const char *path, size_t *len)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2412 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
2413 PurplePluginProtocolInfo *prpl_info;
29648
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2414 PurpleBuddyIconSpec *spec;
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2415 int orig_width, orig_height, new_width, new_height;
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2416 GdkPixbufFormat *format;
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2417 char **pixbuf_formats;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2418 char **prpl_formats;
29648
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2419 GError *error = NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2420 gchar *contents;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2421 gsize length;
29648
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2422 GdkPixbuf *pixbuf, *original;
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2423 float scale_factor;
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2424 int i;
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2425 gchar *tmp;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2426
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
2427 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
29648
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2428 spec = &prpl_info->icon_spec;
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2429 g_return_val_if_fail(spec->format != NULL, NULL);
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2430
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2431 format = gdk_pixbuf_get_file_info(path, &orig_width, &orig_height);
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2432 if (format == NULL) {
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2433 purple_debug_warning("buddyicon", "Could not get file info of %s\n", path);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2434 return NULL;
29648
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2435 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2436
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2437 pixbuf_formats = gdk_pixbuf_format_get_extensions(format);
29648
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2438 prpl_formats = g_strsplit(spec->format, ",", 0);
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2439
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2440 if (str_array_match(pixbuf_formats, prpl_formats) && /* This is an acceptable format AND */
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2441 (!(spec->scale_rules & PURPLE_ICON_SCALE_SEND) || /* The prpl doesn't scale before it sends OR */
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2442 (spec->min_width <= orig_width && spec->max_width >= orig_width &&
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2443 spec->min_height <= orig_height && spec->max_height >= orig_height))) /* The icon is the correct size */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2444 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2445 g_strfreev(pixbuf_formats);
29087
2dcff225172e Start of killing off unneeded GTK_CHECK_VERSION checks in pidgin. Refs #10024
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27958
diff changeset
2446
29648
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2447 if (!g_file_get_contents(path, &contents, &length, &error)) {
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2448 purple_debug_warning("buddyicon", "Could not get file contents "
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2449 "of %s: %s\n", path, error->message);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2450 g_strfreev(prpl_formats);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2451 return NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2452 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2453
29648
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2454 if (spec->max_filesize == 0 || length < spec->max_filesize) {
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2455 /* The supplied image fits the file size, dimensions and type
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2456 constraints. Great! Return it without making any changes. */
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2457 if (len)
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2458 *len = length;
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2459 g_strfreev(prpl_formats);
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2460 return contents;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2461 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2462
29648
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2463 /* The image was too big. Fall-through and try scaling it down. */
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2464 g_free(contents);
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2465 } else {
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2466 g_strfreev(pixbuf_formats);
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2467 }
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2468
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2469 /* The original image wasn't compatible. Scale it or convert file type. */
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2470 pixbuf = gdk_pixbuf_new_from_file(path, &error);
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2471 if (error) {
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2472 purple_debug_warning("buddyicon", "Could not open icon '%s' for "
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2473 "conversion: %s\n", path, error->message);
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2474 g_error_free(error);
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2475 g_strfreev(prpl_formats);
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2476 return NULL;
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2477 }
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2478 original = g_object_ref(G_OBJECT(pixbuf));
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2479
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2480 new_width = orig_width;
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2481 new_height = orig_height;
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2482
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2483 /* Make sure the image is the correct dimensions */
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2484 if (spec->scale_rules & PURPLE_ICON_SCALE_SEND &&
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2485 (orig_width < spec->min_width || orig_width > spec->max_width ||
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2486 orig_height < spec->min_height || orig_height > spec->max_height))
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2487 {
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2488 purple_buddy_icon_get_scale_size(spec, &new_width, &new_height);
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2489
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2490 g_object_unref(G_OBJECT(pixbuf));
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2491 pixbuf = gdk_pixbuf_scale_simple(original, new_width, new_height, GDK_INTERP_HYPER);
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2492 }
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2493
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2494 scale_factor = 1;
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2495 do {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2496 for (i = 0; prpl_formats[i]; i++) {
29648
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2497 int quality = 100;
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2498 do {
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2499 const char *key = NULL;
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2500 const char *value = NULL;
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2501 gchar tmp_buf[4];
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2502
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2503 purple_debug_info("buddyicon", "Converting buddy icon to %s\n", prpl_formats[i]);
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2504
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2505 if (g_str_equal(prpl_formats[i], "png")) {
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2506 key = "compression";
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2507 value = "9";
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2508 } else if (g_str_equal(prpl_formats[i], "jpeg")) {
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2509 sprintf(tmp_buf, "%u", quality);
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2510 key = "quality";
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2511 value = tmp_buf;
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2512 }
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2513
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2514 if (!gdk_pixbuf_save_to_buffer(pixbuf, &contents, &length,
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2515 prpl_formats[i], &error, key, value, NULL))
29644
cfa57a2cd9d1 Use gdk_pixbuf_save_to_buffer() instead of gdk_pixbuf_save() to avoid saving
Mark Doliner <mark@kingant.net>
parents: 29617
diff changeset
2516 {
29648
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2517 /* The NULL checking of error is necessary due to this bug:
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2518 * http://bugzilla.gnome.org/show_bug.cgi?id=405539 */
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2519 purple_debug_warning("buddyicon",
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2520 "Could not convert to %s: %s\n", prpl_formats[i],
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2521 (error && error->message) ? error->message : "Unknown error");
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2522 g_error_free(error);
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2523 error = NULL;
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2524
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2525 /* We couldn't convert to this image type. Try the next
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2526 image type. */
15583
d91aed154695 Work around gdk-pixbuf brokenness when dealing with unrecognized parameters. Also, improve the error handling so we don't get a confusing error message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15573
diff changeset
2527 break;
d91aed154695 Work around gdk-pixbuf brokenness when dealing with unrecognized parameters. Also, improve the error handling so we don't get a confusing error message.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15573
diff changeset
2528 }
29648
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2529
29770
9e9c20b705d3 Allow icons to be exactly the max file size
Mark Doliner <mark@kingant.net>
parents: 29769
diff changeset
2530 if (spec->max_filesize == 0 || length <= spec->max_filesize) {
29648
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2531 /* We were able to save the image as this image type and
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2532 have it be within the size constraints. Great! Return
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2533 the image. */
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2534 purple_debug_info("buddyicon", "Converted image from "
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2535 "%dx%d to %dx%d, format=%s, quality=%u, "
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2536 "filesize=%zu\n", orig_width, orig_height,
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2537 new_width, new_height, prpl_formats[i], quality,
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2538 length);
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2539 if (len)
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2540 *len = length;
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2541 g_strfreev(prpl_formats);
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2542 g_object_unref(G_OBJECT(pixbuf));
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2543 g_object_unref(G_OBJECT(original));
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2544 return contents;
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2545 }
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2546
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2547 g_free(contents);
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2548
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2549 if (!g_str_equal(prpl_formats[i], "jpeg")) {
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2550 /* File size was too big and we can't lower the quality,
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2551 so skip to the next image type. */
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2552 break;
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2553 }
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2554
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2555 /* File size was too big, but we're dealing with jpeg so try
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2556 lowering the quality. */
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2557 quality -= 5;
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2558 } while (quality >= 70);
16381
72dc611f3257 Fix the custom icon stuff, and various memory leaks. At this point, custom
Richard Laager <rlaager@wiktel.com>
parents: 16375
diff changeset
2559 }
29648
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2560
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2561 /* We couldn't save the image in any format that was below the max
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2562 file size. Maybe we can reduce the image dimensions? */
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2563 scale_factor *= 0.8;
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2564 new_width = orig_width * scale_factor;
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2565 new_height = orig_height * scale_factor;
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2566 g_object_unref(G_OBJECT(pixbuf));
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2567 pixbuf = gdk_pixbuf_scale_simple(original, new_width, new_height, GDK_INTERP_HYPER);
29769
1a4362fca50e Oh! When setting a buddy icon, when we reduce the dimension in order to
Mark Doliner <mark@kingant.net>
parents: 29723
diff changeset
2568 } while ((new_width > 10 || new_height > 10) && new_width > spec->min_width && new_height > spec->min_height);
29648
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2569 g_strfreev(prpl_formats);
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2570 g_object_unref(G_OBJECT(pixbuf));
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2571 g_object_unref(G_OBJECT(original));
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2572
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2573 tmp = g_strdup_printf(_("The file '%s' is too large for %s. Please try a smaller image.\n"),
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2574 path, plugin->info->name);
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2575 purple_notify_error(NULL, _("Icon Error"), _("Could not set icon"), tmp);
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2576 g_free(tmp);
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2577
3b24193663bc Change pidgin_convert_buddy_icon() to be more accommodating when attempting
Mark Doliner <mark@kingant.net>
parents: 29645
diff changeset
2578 return NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2579 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2580
15500
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15444
diff changeset
2581 char *pidgin_make_pretty_arrows(const char *str)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2582 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2583 char *ret;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2584 char **split = g_strsplit(str, "->", -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2585 ret = g_strjoinv("\342\207\250", split);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2586 g_strfreev(split);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2587
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2588 split = g_strsplit(ret, "<-", -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2589 g_free(ret);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2590 ret = g_strjoinv("\342\207\246", split);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2591 g_strfreev(split);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2592
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2593 return ret;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2594 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2595
15500
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15444
diff changeset
2596 void pidgin_set_urgent(GtkWindow *window, gboolean urgent)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2597 {
29087
2dcff225172e Start of killing off unneeded GTK_CHECK_VERSION checks in pidgin. Refs #10024
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27958
diff changeset
2598 #if defined _WIN32
15514
75ffc646647f Win32 de-gaimification of pidgin
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15506
diff changeset
2599 winpidgin_window_flash(window, urgent);
21029
3a12f08b2185 Guard this X stuff so it's only compiled if GDK_WINDOWING_X11 is defined.
Stu Tomlinson <stu@nosnilmot.com>
parents: 20349
diff changeset
2600 #else
29088
886a0dfaa625 I screwed up the logic here and didn't realize it earlier.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 29087
diff changeset
2601 gtk_window_set_urgency_hint(window, urgent);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2602 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2603 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2604
26654
4a3a0c47dfe1 Hide the list of minidialogs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 26644
diff changeset
2605 static GSList *minidialogs = NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2606
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2607 static void *
22007
c38d72677c8a Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@wiktel.com>
parents: 21894
diff changeset
2608 pidgin_utils_get_handle(void)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2609 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2610 static int handle;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2611
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2612 return &handle;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2613 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2614
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
2615 static void connection_signed_off_cb(PurpleConnection *gc)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2616 {
22561
387024e316d1 Fix another scenario where a NULL callback can be called. I'm pretty confident this fixes #4901. There's also a fix in here to prevent freed memory from being accessed when removing minidialogs from a signed-off account that I've had sitting on my machine for a while.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22503
diff changeset
2617 GSList *list, *l_next;
387024e316d1 Fix another scenario where a NULL callback can be called. I'm pretty confident this fixes #4901. There's also a fix in here to prevent freed memory from being accessed when removing minidialogs from a signed-off account that I've had sitting on my machine for a while.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22503
diff changeset
2618 for (list = minidialogs; list; list = l_next) {
387024e316d1 Fix another scenario where a NULL callback can be called. I'm pretty confident this fixes #4901. There's also a fix in here to prevent freed memory from being accessed when removing minidialogs from a signed-off account that I've had sitting on my machine for a while.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22503
diff changeset
2619 l_next = list->next;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2620 if (g_object_get_data(G_OBJECT(list->data), "gc") == gc) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2621 gtk_widget_destroy(GTK_WIDGET(list->data));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2622 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2623 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2624 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2625
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2626 static void alert_killed_cb(GtkWidget *widget)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2627 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2628 minidialogs = g_slist_remove(minidialogs, widget);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2629 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2630
21402
9fef5d307a27 Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <will.thompson@collabora.co.uk>
parents: 21399
diff changeset
2631 struct _old_button_clicked_cb_data
9fef5d307a27 Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <will.thompson@collabora.co.uk>
parents: 21399
diff changeset
2632 {
9fef5d307a27 Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <will.thompson@collabora.co.uk>
parents: 21399
diff changeset
2633 PidginUtilMiniDialogCallback cb;
9fef5d307a27 Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <will.thompson@collabora.co.uk>
parents: 21399
diff changeset
2634 gpointer data;
9fef5d307a27 Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <will.thompson@collabora.co.uk>
parents: 21399
diff changeset
2635 };
9fef5d307a27 Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <will.thompson@collabora.co.uk>
parents: 21399
diff changeset
2636
9fef5d307a27 Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <will.thompson@collabora.co.uk>
parents: 21399
diff changeset
2637 static void
9fef5d307a27 Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <will.thompson@collabora.co.uk>
parents: 21399
diff changeset
2638 old_mini_dialog_button_clicked_cb(PidginMiniDialog *mini_dialog,
9fef5d307a27 Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <will.thompson@collabora.co.uk>
parents: 21399
diff changeset
2639 GtkButton *button,
9fef5d307a27 Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <will.thompson@collabora.co.uk>
parents: 21399
diff changeset
2640 gpointer user_data)
9fef5d307a27 Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <will.thompson@collabora.co.uk>
parents: 21399
diff changeset
2641 {
9fef5d307a27 Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <will.thompson@collabora.co.uk>
parents: 21399
diff changeset
2642 struct _old_button_clicked_cb_data *data = user_data;
9fef5d307a27 Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <will.thompson@collabora.co.uk>
parents: 21399
diff changeset
2643 data->cb(data->data, button);
21405
7ea1f93cffe2 Don't leak all bar one of the closure structs allocated by
Will Thompson <will.thompson@collabora.co.uk>
parents: 21402
diff changeset
2644 }
7ea1f93cffe2 Don't leak all bar one of the closure structs allocated by
Will Thompson <will.thompson@collabora.co.uk>
parents: 21402
diff changeset
2645
7ea1f93cffe2 Don't leak all bar one of the closure structs allocated by
Will Thompson <will.thompson@collabora.co.uk>
parents: 21402
diff changeset
2646 static void
7ea1f93cffe2 Don't leak all bar one of the closure structs allocated by
Will Thompson <will.thompson@collabora.co.uk>
parents: 21402
diff changeset
2647 old_mini_dialog_destroy_cb(GtkWidget *dialog,
7ea1f93cffe2 Don't leak all bar one of the closure structs allocated by
Will Thompson <will.thompson@collabora.co.uk>
parents: 21402
diff changeset
2648 GList *cb_datas)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2649 {
21405
7ea1f93cffe2 Don't leak all bar one of the closure structs allocated by
Will Thompson <will.thompson@collabora.co.uk>
parents: 21402
diff changeset
2650 while (cb_datas != NULL)
7ea1f93cffe2 Don't leak all bar one of the closure structs allocated by
Will Thompson <will.thompson@collabora.co.uk>
parents: 21402
diff changeset
2651 {
7ea1f93cffe2 Don't leak all bar one of the closure structs allocated by
Will Thompson <will.thompson@collabora.co.uk>
parents: 21402
diff changeset
2652 g_free(cb_datas->data);
7ea1f93cffe2 Don't leak all bar one of the closure structs allocated by
Will Thompson <will.thompson@collabora.co.uk>
parents: 21402
diff changeset
2653 cb_datas = g_list_delete_link(cb_datas, cb_datas);
7ea1f93cffe2 Don't leak all bar one of the closure structs allocated by
Will Thompson <will.thompson@collabora.co.uk>
parents: 21402
diff changeset
2654 }
21402
9fef5d307a27 Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <will.thompson@collabora.co.uk>
parents: 21399
diff changeset
2655 }
9fef5d307a27 Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <will.thompson@collabora.co.uk>
parents: 21399
diff changeset
2656
30358
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2657 static void
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2658 mini_dialog_init(PidginMiniDialog *mini_dialog, PurpleConnection *gc, void *user_data, va_list args)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2659 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2660 const char *button_text;
21405
7ea1f93cffe2 Don't leak all bar one of the closure structs allocated by
Will Thompson <will.thompson@collabora.co.uk>
parents: 21402
diff changeset
2661 GList *cb_datas = NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2662 static gboolean first_call = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2663
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2664 if (first_call) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2665 first_call = FALSE;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
2666 purple_signal_connect(purple_connections_get_handle(), "signed-off",
21402
9fef5d307a27 Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <will.thompson@collabora.co.uk>
parents: 21399
diff changeset
2667 pidgin_utils_get_handle(),
9fef5d307a27 Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <will.thompson@collabora.co.uk>
parents: 21399
diff changeset
2668 PURPLE_CALLBACK(connection_signed_off_cb), NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2669 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2670
21402
9fef5d307a27 Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <will.thompson@collabora.co.uk>
parents: 21399
diff changeset
2671 g_object_set_data(G_OBJECT(mini_dialog), "gc" ,gc);
9fef5d307a27 Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <will.thompson@collabora.co.uk>
parents: 21399
diff changeset
2672 g_signal_connect(G_OBJECT(mini_dialog), "destroy",
9fef5d307a27 Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <will.thompson@collabora.co.uk>
parents: 21399
diff changeset
2673 G_CALLBACK(alert_killed_cb), NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2674
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2675 while ((button_text = va_arg(args, char*))) {
22561
387024e316d1 Fix another scenario where a NULL callback can be called. I'm pretty confident this fixes #4901. There's also a fix in here to prevent freed memory from being accessed when removing minidialogs from a signed-off account that I've had sitting on my machine for a while.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22503
diff changeset
2676 struct _old_button_clicked_cb_data *data = NULL;
387024e316d1 Fix another scenario where a NULL callback can be called. I'm pretty confident this fixes #4901. There's also a fix in here to prevent freed memory from being accessed when removing minidialogs from a signed-off account that I've had sitting on my machine for a while.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22503
diff changeset
2677 PidginMiniDialogCallback wrapper_cb = NULL;
21402
9fef5d307a27 Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <will.thompson@collabora.co.uk>
parents: 21399
diff changeset
2678 PidginUtilMiniDialogCallback callback =
9fef5d307a27 Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <will.thompson@collabora.co.uk>
parents: 21399
diff changeset
2679 va_arg(args, PidginUtilMiniDialogCallback);
22561
387024e316d1 Fix another scenario where a NULL callback can be called. I'm pretty confident this fixes #4901. There's also a fix in here to prevent freed memory from being accessed when removing minidialogs from a signed-off account that I've had sitting on my machine for a while.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22503
diff changeset
2680
387024e316d1 Fix another scenario where a NULL callback can be called. I'm pretty confident this fixes #4901. There's also a fix in here to prevent freed memory from being accessed when removing minidialogs from a signed-off account that I've had sitting on my machine for a while.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22503
diff changeset
2681 if (callback != NULL) {
387024e316d1 Fix another scenario where a NULL callback can be called. I'm pretty confident this fixes #4901. There's also a fix in here to prevent freed memory from being accessed when removing minidialogs from a signed-off account that I've had sitting on my machine for a while.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22503
diff changeset
2682 data = g_new0(struct _old_button_clicked_cb_data, 1);
387024e316d1 Fix another scenario where a NULL callback can be called. I'm pretty confident this fixes #4901. There's also a fix in here to prevent freed memory from being accessed when removing minidialogs from a signed-off account that I've had sitting on my machine for a while.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22503
diff changeset
2683 data->cb = callback;
387024e316d1 Fix another scenario where a NULL callback can be called. I'm pretty confident this fixes #4901. There's also a fix in here to prevent freed memory from being accessed when removing minidialogs from a signed-off account that I've had sitting on my machine for a while.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22503
diff changeset
2684 data->data = user_data;
387024e316d1 Fix another scenario where a NULL callback can be called. I'm pretty confident this fixes #4901. There's also a fix in here to prevent freed memory from being accessed when removing minidialogs from a signed-off account that I've had sitting on my machine for a while.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22503
diff changeset
2685 wrapper_cb = old_mini_dialog_button_clicked_cb;
387024e316d1 Fix another scenario where a NULL callback can be called. I'm pretty confident this fixes #4901. There's also a fix in here to prevent freed memory from being accessed when removing minidialogs from a signed-off account that I've had sitting on my machine for a while.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22503
diff changeset
2686 }
21402
9fef5d307a27 Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <will.thompson@collabora.co.uk>
parents: 21399
diff changeset
2687 pidgin_mini_dialog_add_button(mini_dialog, button_text,
22561
387024e316d1 Fix another scenario where a NULL callback can be called. I'm pretty confident this fixes #4901. There's also a fix in here to prevent freed memory from being accessed when removing minidialogs from a signed-off account that I've had sitting on my machine for a while.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 22503
diff changeset
2688 wrapper_cb, data);
21405
7ea1f93cffe2 Don't leak all bar one of the closure structs allocated by
Will Thompson <will.thompson@collabora.co.uk>
parents: 21402
diff changeset
2689 cb_datas = g_list_append(cb_datas, data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2690 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2691
21405
7ea1f93cffe2 Don't leak all bar one of the closure structs allocated by
Will Thompson <will.thompson@collabora.co.uk>
parents: 21402
diff changeset
2692 g_signal_connect(G_OBJECT(mini_dialog), "destroy",
7ea1f93cffe2 Don't leak all bar one of the closure structs allocated by
Will Thompson <will.thompson@collabora.co.uk>
parents: 21402
diff changeset
2693 G_CALLBACK(old_mini_dialog_destroy_cb), cb_datas);
30358
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2694 }
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2695
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2696 #define INIT_AND_RETURN_MINI_DIALOG(mini_dialog) \
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2697 va_list args; \
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2698 va_start(args, user_data); \
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2699 mini_dialog_init(mini_dialog, gc, user_data, args); \
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2700 va_end(args); \
21402
9fef5d307a27 Create a PidginMiniDialog widget; make pidgin_make_mini_dialog() in gtkutils.c
Will Thompson <will.thompson@collabora.co.uk>
parents: 21399
diff changeset
2701 return GTK_WIDGET(mini_dialog);
30358
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2702
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2703 GtkWidget *
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2704 pidgin_make_mini_dialog(PurpleConnection *gc,
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2705 const char *icon_name,
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2706 const char *primary,
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2707 const char *secondary,
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2708 void *user_data,
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2709 ...)
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2710 {
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2711 PidginMiniDialog *mini_dialog = pidgin_mini_dialog_new(primary, secondary, icon_name);
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2712 INIT_AND_RETURN_MINI_DIALOG(mini_dialog);
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2713 }
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2714
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2715 GtkWidget *
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2716 pidgin_make_mini_dialog_with_custom_icon(PurpleConnection *gc,
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2717 GdkPixbuf *custom_icon,
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2718 const char *primary,
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2719 const char *secondary,
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2720 void *user_data,
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2721 ...)
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2722 {
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2723 PidginMiniDialog *mini_dialog = pidgin_mini_dialog_new_with_custom_icon(primary, secondary, custom_icon);
c62fac7ada0d Display the protocol icon for the authorization request dialog
ivan.komarov@soc.pidgin.im
parents: 29770
diff changeset
2724 INIT_AND_RETURN_MINI_DIALOG(mini_dialog);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2725 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2726
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2727 /*
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2728 * "This is so dead sexy."
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2729 * "Two thumbs up."
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2730 * "Best movie of the year."
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2731 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2732 * This is the function that handles CTRL+F searching in the buddy list.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2733 * It finds the top-most buddy/group/chat/whatever containing the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2734 * entered string.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2735 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2736 * It's somewhat ineffecient, because we strip all the HTML from the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2737 * "name" column of the buddy list (because the GtkTreeModel does not
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2738 * contain the screen name in a non-markedup format). But the alternative
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2739 * is to add an extra column to the GtkTreeModel. And this function is
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2740 * used rarely, so it shouldn't matter TOO much.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2741 */
15500
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15444
diff changeset
2742 gboolean pidgin_tree_view_search_equal_func(GtkTreeModel *model, gint column,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2743 const gchar *key, GtkTreeIter *iter, gpointer data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2744 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2745 gchar *enteredstring;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2746 gchar *tmp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2747 gchar *withmarkup;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2748 gchar *nomarkup;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2749 gchar *normalized;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2750 gboolean result;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2751 size_t i;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2752 size_t len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2753 PangoLogAttr *log_attrs;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2754 gchar *word;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2755
17082
7ade887fd3f6 Replace strcasecmp() calls with glib equivalents.
Richard Laager <rlaager@wiktel.com>
parents: 17071
diff changeset
2756 if (g_ascii_strcasecmp(key, "Global Thermonuclear War") == 0)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2757 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
2758 purple_notify_info(NULL, "WOPR",
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2759 "Wouldn't you prefer a nice game of chess?", NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2760 return FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2761 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2762
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2763 gtk_tree_model_get(model, iter, column, &withmarkup, -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2764 if (withmarkup == NULL) /* This is probably a separator */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2765 return TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2766
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2767 tmp = g_utf8_normalize(key, -1, G_NORMALIZE_DEFAULT);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2768 enteredstring = g_utf8_casefold(tmp, -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2769 g_free(tmp);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2770
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
2771 nomarkup = purple_markup_strip_html(withmarkup);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2772 tmp = g_utf8_normalize(nomarkup, -1, G_NORMALIZE_DEFAULT);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2773 g_free(nomarkup);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2774 normalized = g_utf8_casefold(tmp, -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2775 g_free(tmp);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2776
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
2777 if (purple_str_has_prefix(normalized, enteredstring))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2778 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2779 g_free(withmarkup);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2780 g_free(enteredstring);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2781 g_free(normalized);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2782 return FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2783 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2784
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2785
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2786 /* Use Pango to separate by words. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2787 len = g_utf8_strlen(normalized, -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2788 log_attrs = g_new(PangoLogAttr, len + 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2789
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2790 pango_get_log_attrs(normalized, strlen(normalized), -1, NULL, log_attrs, len + 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2791
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2792 word = normalized;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2793 result = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2794 for (i = 0; i < (len - 1) ; i++)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2795 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2796 if (log_attrs[i].is_word_start &&
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
2797 purple_str_has_prefix(word, enteredstring))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2798 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2799 result = FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2800 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2801 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2802 word = g_utf8_next_char(word);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2803 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2804 g_free(log_attrs);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2805
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2806 /* The non-Pango version. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2807 #if 0
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2808 word = normalized;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2809 result = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2810 while (word[0] != '\0')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2811 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2812 gunichar c = g_utf8_get_char(word);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2813 if (!g_unichar_isalnum(c))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2814 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2815 word = g_utf8_find_next_char(word, NULL);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15821
diff changeset
2816 if (purple_str_has_prefix(word, enteredstring))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2817 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2818 result = FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2819 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2820 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2821 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2822 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2823 word = g_utf8_find_next_char(word, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2824 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2825 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2826
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2827 g_free(withmarkup);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2828 g_free(enteredstring);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2829 g_free(normalized);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2830
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2831 return result;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2832 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2833
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2834
15506
311315e979f7 gtkutils changes
Sean Egan <seanegan@gmail.com>
parents: 15500
diff changeset
2835 gboolean pidgin_gdk_pixbuf_is_opaque(GdkPixbuf *pixbuf) {
30430
351d07aefb09 Kill off many dead assignments and any useless remaining variables.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30429
diff changeset
2836 int height, rowstride, i;
30429
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2837 unsigned char *pixels;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2838 unsigned char *row;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2839
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2840 if (!gdk_pixbuf_get_has_alpha(pixbuf))
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2841 return TRUE;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2842
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2843 height = gdk_pixbuf_get_height (pixbuf);
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2844 rowstride = gdk_pixbuf_get_rowstride (pixbuf);
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2845 pixels = gdk_pixbuf_get_pixels (pixbuf);
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2846
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2847 row = pixels;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2848 for (i = 3; i < rowstride; i+=4) {
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2849 if (row[i] < 0xfe)
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2850 return FALSE;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2851 }
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2852
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2853 for (i = 1; i < height - 1; i++) {
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2854 row = pixels + (i * rowstride);
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2855 if (row[3] < 0xfe || row[rowstride - 1] < 0xfe) {
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2856 return FALSE;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2857 }
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2858 }
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2859
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2860 row = pixels + ((height - 1) * rowstride);
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2861 for (i = 3; i < rowstride; i += 4) {
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2862 if (row[i] < 0xfe)
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2863 return FALSE;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2864 }
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2865
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2866 return TRUE;
15412
e6b40365930c More statusbox tweaks:
Sean Egan <seanegan@gmail.com>
parents: 15380
diff changeset
2867 }
e6b40365930c More statusbox tweaks:
Sean Egan <seanegan@gmail.com>
parents: 15380
diff changeset
2868
18212
77b9ceb83426 Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@gmail.com>
parents: 18166
diff changeset
2869 void pidgin_gdk_pixbuf_make_round(GdkPixbuf *pixbuf) {
77b9ceb83426 Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@gmail.com>
parents: 18166
diff changeset
2870 int width, height, rowstride;
30429
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2871 guchar *pixels;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2872 if (!gdk_pixbuf_get_has_alpha(pixbuf))
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2873 return;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2874 width = gdk_pixbuf_get_width(pixbuf);
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2875 height = gdk_pixbuf_get_height(pixbuf);
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2876 rowstride = gdk_pixbuf_get_rowstride(pixbuf);
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2877 pixels = gdk_pixbuf_get_pixels(pixbuf);
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2878
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2879 if (width < 6 || height < 6)
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2880 return;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2881 /* Top left */
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2882 pixels[3] = 0;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2883 pixels[7] = 0x80;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2884 pixels[11] = 0xC0;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2885 pixels[rowstride + 3] = 0x80;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2886 pixels[rowstride * 2 + 3] = 0xC0;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2887
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2888 /* Top right */
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2889 pixels[width * 4 - 1] = 0;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2890 pixels[width * 4 - 5] = 0x80;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2891 pixels[width * 4 - 9] = 0xC0;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2892 pixels[rowstride + (width * 4) - 1] = 0x80;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2893 pixels[(2 * rowstride) + (width * 4) - 1] = 0xC0;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2894
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2895 /* Bottom left */
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2896 pixels[(height - 1) * rowstride + 3] = 0;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2897 pixels[(height - 1) * rowstride + 7] = 0x80;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2898 pixels[(height - 1) * rowstride + 11] = 0xC0;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2899 pixels[(height - 2) * rowstride + 3] = 0x80;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2900 pixels[(height - 3) * rowstride + 3] = 0xC0;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2901
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2902 /* Bottom right */
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2903 pixels[height * rowstride - 1] = 0;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2904 pixels[(height - 1) * rowstride - 1] = 0x80;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2905 pixels[(height - 2) * rowstride - 1] = 0xC0;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2906 pixels[height * rowstride - 5] = 0x80;
922c8c553758 Space-to-tab.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30416
diff changeset
2907 pixels[height * rowstride - 9] = 0xC0;
18212
77b9ceb83426 Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@gmail.com>
parents: 18166
diff changeset
2908 }
77b9ceb83426 Rounds icons in the infopane. Since gdk_pixbuf_animation_get_static_image seems to return pixbufs without alpha channels, this only rounds animated icons that aren't transparent.
Sean Egan <seanegan@gmail.com>
parents: 18166
diff changeset
2909
18215
16bf31872b7a Chat topics in status line of chat infopanes
Sean Egan <seanegan@gmail.com>
parents: 18212
diff changeset
2910 const char *pidgin_get_dim_grey_string(GtkWidget *widget) {
16bf31872b7a Chat topics in status line of chat infopanes
Sean Egan <seanegan@gmail.com>
parents: 18212
diff changeset
2911 static char dim_grey_string[8] = "";
16bf31872b7a Chat topics in status line of chat infopanes
Sean Egan <seanegan@gmail.com>
parents: 18212
diff changeset
2912 GtkStyle *style;
16bf31872b7a Chat topics in status line of chat infopanes
Sean Egan <seanegan@gmail.com>
parents: 18212
diff changeset
2913
16bf31872b7a Chat topics in status line of chat infopanes
Sean Egan <seanegan@gmail.com>
parents: 18212
diff changeset
2914 if (!widget)
16bf31872b7a Chat topics in status line of chat infopanes
Sean Egan <seanegan@gmail.com>
parents: 18212
diff changeset
2915 return "dim grey";
16bf31872b7a Chat topics in status line of chat infopanes
Sean Egan <seanegan@gmail.com>
parents: 18212
diff changeset
2916
16bf31872b7a Chat topics in status line of chat infopanes
Sean Egan <seanegan@gmail.com>
parents: 18212
diff changeset
2917 style = gtk_widget_get_style(widget);
16bf31872b7a Chat topics in status line of chat infopanes
Sean Egan <seanegan@gmail.com>
parents: 18212
diff changeset
2918 if (!style)
16bf31872b7a Chat topics in status line of chat infopanes
Sean Egan <seanegan@gmail.com>
parents: 18212
diff changeset
2919 return "dim grey";
25924
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 25881
diff changeset
2920
18215
16bf31872b7a Chat topics in status line of chat infopanes
Sean Egan <seanegan@gmail.com>
parents: 18212
diff changeset
2921 snprintf(dim_grey_string, sizeof(dim_grey_string), "#%02x%02x%02x",
16bf31872b7a Chat topics in status line of chat infopanes
Sean Egan <seanegan@gmail.com>
parents: 18212
diff changeset
2922 style->text_aa[GTK_STATE_NORMAL].red >> 8,
16bf31872b7a Chat topics in status line of chat infopanes
Sean Egan <seanegan@gmail.com>
parents: 18212
diff changeset
2923 style->text_aa[GTK_STATE_NORMAL].green >> 8,
16bf31872b7a Chat topics in status line of chat infopanes
Sean Egan <seanegan@gmail.com>
parents: 18212
diff changeset
2924 style->text_aa[GTK_STATE_NORMAL].blue >> 8);
16bf31872b7a Chat topics in status line of chat infopanes
Sean Egan <seanegan@gmail.com>
parents: 18212
diff changeset
2925 return dim_grey_string;
16bf31872b7a Chat topics in status line of chat infopanes
Sean Egan <seanegan@gmail.com>
parents: 18212
diff changeset
2926 }
16bf31872b7a Chat topics in status line of chat infopanes
Sean Egan <seanegan@gmail.com>
parents: 18212
diff changeset
2927
20028
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2928 static void
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2929 combo_box_changed_cb(GtkComboBox *combo_box, GtkEntry *entry)
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2930 {
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2931 char *text = gtk_combo_box_get_active_text(combo_box);
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2932 gtk_entry_set_text(entry, text ? text : "");
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2933 g_free(text);
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2934 }
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2935
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2936 static gboolean
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2937 entry_key_pressed_cb(GtkWidget *entry, GdkEventKey *key, GtkComboBox *combo)
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2938 {
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2939 if (key->keyval == GDK_Down || key->keyval == GDK_Up) {
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2940 gtk_combo_box_popup(combo);
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2941 return TRUE;
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2942 }
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2943 return FALSE;
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2944 }
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2945
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2946 GtkWidget *
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2947 pidgin_text_combo_box_entry_new(const char *default_item, GList *items)
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2948 {
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2949 GtkComboBox *ret = NULL;
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2950 GtkWidget *the_entry = NULL;
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2951
31178
3cec1e97e698 Modify the editable comboboxes to be more friendly to GTK+ themes that don't
hugo@oxygen-icons.org
parents: 31156
diff changeset
2952 ret = GTK_COMBO_BOX(gtk_combo_box_entry_new_text());
20028
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2953 the_entry = gtk_entry_new();
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2954 gtk_container_add(GTK_CONTAINER(ret), the_entry);
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2955
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2956 if (default_item)
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2957 gtk_entry_set_text(GTK_ENTRY(the_entry), default_item);
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2958
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2959 for (; items != NULL ; items = items->next) {
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2960 char *text = items->data;
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2961 if (text && *text)
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2962 gtk_combo_box_append_text(ret, text);
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2963 }
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2964
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2965 g_signal_connect(G_OBJECT(ret), "changed", (GCallback)combo_box_changed_cb, the_entry);
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2966 g_signal_connect_after(G_OBJECT(the_entry), "key-press-event", G_CALLBACK(entry_key_pressed_cb), ret);
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2967
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2968 return GTK_WIDGET(ret);
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2969 }
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2970
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2971 const char *pidgin_text_combo_box_entry_get_text(GtkWidget *widget)
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2972 {
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2973 return gtk_entry_get_text(GTK_ENTRY(GTK_BIN((widget))->child));
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2974 }
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2975
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2976 void pidgin_text_combo_box_entry_set_text(GtkWidget *widget, const char *text)
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2977 {
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2978 gtk_entry_set_text(GTK_ENTRY(GTK_BIN((widget))->child), (text));
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2979 }
a2b4eac83902 Part of #1332 to introduce pidgin_text_combo_box_new_entry and
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
2980
21992
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
2981 GtkWidget *
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
2982 pidgin_add_widget_to_vbox(GtkBox *vbox, const char *widget_label, GtkSizeGroup *sg, GtkWidget *widget, gboolean expand, GtkWidget **p_label)
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
2983 {
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
2984 GtkWidget *hbox;
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
2985 GtkWidget *label = NULL;
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
2986
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
2987 if (widget_label) {
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
2988 hbox = gtk_hbox_new(FALSE, 5);
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
2989 gtk_widget_show(hbox);
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
2990 gtk_box_pack_start(vbox, hbox, FALSE, FALSE, 0);
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
2991
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
2992 label = gtk_label_new_with_mnemonic(widget_label);
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
2993 gtk_widget_show(label);
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
2994 if (sg) {
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
2995 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
2996 gtk_size_group_add_widget(sg, label);
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
2997 }
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
2998 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
2999 } else {
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
3000 hbox = GTK_WIDGET(vbox);
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
3001 }
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
3002
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
3003 gtk_widget_show(widget);
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
3004 gtk_box_pack_start(GTK_BOX(hbox), widget, expand, TRUE, 0);
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
3005 if (label) {
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
3006 gtk_label_set_mnemonic_widget(GTK_LABEL(label), widget);
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
3007 pidgin_set_accessible_label (widget, label);
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
3008 }
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
3009
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
3010 if (p_label)
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
3011 (*p_label) = label;
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
3012 return hbox;
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
3013 }
1690d040addd Remove a lot of duplication from a lot of places. Closes #4558.
Gabriel Schulhof <nix@go-nix.ca>
parents: 21894
diff changeset
3014
21888
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3015 gboolean pidgin_auto_parent_window(GtkWidget *widget)
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3016 {
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3017 #if 0
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3018 /* This looks at the most recent window that received focus, and makes
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3019 * that the parent window. */
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3020 #ifndef _WIN32
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3021 static GdkAtom _WindowTime = GDK_NONE;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3022 static GdkAtom _Cardinal = GDK_NONE;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3023 GList *windows = NULL;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3024 GtkWidget *parent = NULL;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3025 time_t window_time = 0;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3026
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3027 windows = gtk_window_list_toplevels();
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3028
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3029 if (_WindowTime == GDK_NONE) {
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3030 _WindowTime = gdk_x11_xatom_to_atom(gdk_x11_get_xatom_by_name("_NET_WM_USER_TIME"));
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3031 }
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3032 if (_Cardinal == GDK_NONE) {
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3033 _Cardinal = gdk_atom_intern("CARDINAL", FALSE);
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3034 }
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3035
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3036 while (windows) {
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3037 GtkWidget *window = windows->data;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3038 guchar *data = NULL;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3039 int al = 0;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3040 time_t value;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3041
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3042 windows = g_list_delete_link(windows, windows);
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3043
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3044 if (window == widget ||
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3045 !GTK_WIDGET_VISIBLE(window))
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3046 continue;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3047
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3048 if (!gdk_property_get(window->window, _WindowTime, _Cardinal, 0, sizeof(time_t), FALSE,
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3049 NULL, NULL, &al, &data))
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3050 continue;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3051 value = *(time_t *)data;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3052 if (window_time < value) {
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3053 window_time = value;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3054 parent = window;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3055 }
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3056 g_free(data);
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3057 }
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3058 if (windows)
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3059 g_list_free(windows);
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3060 if (parent) {
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3061 if (!gtk_get_current_event() && gtk_window_has_toplevel_focus(GTK_WINDOW(parent))) {
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3062 /* The window is in focus, and the new window was not triggered by a keypress/click
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3063 * event. So do not set it transient, to avoid focus stealing and all that.
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3064 */
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3065 return FALSE;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3066 }
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3067 gtk_window_set_transient_for(GTK_WINDOW(widget), GTK_WINDOW(parent));
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3068 return TRUE;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3069 }
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3070 return FALSE;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3071 #endif
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3072 #else
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3073 /* This finds the currently active window and makes that the parent window. */
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3074 GList *windows = NULL;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3075 GtkWidget *parent = NULL;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3076 GdkEvent *event = gtk_get_current_event();
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3077 GdkWindow *menu = NULL;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3078
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3079 if (event == NULL)
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3080 /* The window was not triggered by a user action. */
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3081 return FALSE;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3082
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3083 /* We need to special case events from a popup menu. */
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3084 if (event->type == GDK_BUTTON_RELEASE) {
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3085 /* XXX: Neither of the following works:
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3086 menu = event->button.window;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3087 menu = gdk_window_get_parent(event->button.window);
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3088 menu = gdk_window_get_toplevel(event->button.window);
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3089 */
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3090 } else if (event->type == GDK_KEY_PRESS)
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3091 menu = event->key.window;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3092
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3093 windows = gtk_window_list_toplevels();
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3094 while (windows) {
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3095 GtkWidget *window = windows->data;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3096 windows = g_list_delete_link(windows, windows);
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3097
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3098 if (window == widget ||
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3099 !GTK_WIDGET_VISIBLE(window)) {
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3100 continue;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3101 }
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3102
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3103 if (gtk_window_has_toplevel_focus(GTK_WINDOW(window)) ||
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3104 (menu && menu == window->window)) {
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3105 parent = window;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3106 break;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3107 }
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3108 }
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3109 if (windows)
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3110 g_list_free(windows);
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3111 if (parent) {
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3112 gtk_window_set_transient_for(GTK_WINDOW(widget), GTK_WINDOW(parent));
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3113 return TRUE;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3114 }
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3115 return FALSE;
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3116 #endif
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3117 }
c88a3f2dbb52 Try to make a window transient for a suitable parent window. This currently
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 21652
diff changeset
3118
31682
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3119 static GObject *pidgin_pixbuf_from_data_helper(const guchar *buf, gsize count, gboolean animated)
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3120 {
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3121 GObject *pixbuf;
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3122 GdkPixbufLoader *loader;
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3123 GError *error = NULL;
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3124
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3125 loader = gdk_pixbuf_loader_new();
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3126
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3127 if (!gdk_pixbuf_loader_write(loader, buf, count, &error) || error) {
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3128 purple_debug_warning("gtkutils", "gdk_pixbuf_loader_write() "
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3129 "failed with size=%zu: %s\n", count,
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3130 error ? error->message : "(no error message)");
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3131 if (error)
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3132 g_error_free(error);
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3133 g_object_unref(G_OBJECT(loader));
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3134 return NULL;
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3135 }
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3136
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3137 if (!gdk_pixbuf_loader_close(loader, &error) || error) {
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3138 purple_debug_warning("gtkutils", "gdk_pixbuf_loader_close() "
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3139 "failed for image of size %zu: %s\n", count,
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3140 error ? error->message : "(no error message)");
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3141 if (error)
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3142 g_error_free(error);
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3143 g_object_unref(G_OBJECT(loader));
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3144 return NULL;
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3145 }
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3146
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3147 if (animated)
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3148 pixbuf = G_OBJECT(gdk_pixbuf_loader_get_animation(loader));
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3149 else
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3150 pixbuf = G_OBJECT(gdk_pixbuf_loader_get_pixbuf(loader));
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3151 if (!pixbuf) {
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3152 purple_debug_warning("gtkutils", "%s() returned NULL for image "
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3153 "of size %zu\n",
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3154 animated ? "gdk_pixbuf_loader_get_animation"
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3155 : "gdk_pixbuf_loader_get_pixbuf", count);
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3156 g_object_unref(G_OBJECT(loader));
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3157 return NULL;
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3158 }
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3159
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3160 g_object_ref(pixbuf);
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3161 g_object_unref(G_OBJECT(loader));
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3162
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3163 return pixbuf;
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3164 }
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3165
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3166 GdkPixbuf *pidgin_pixbuf_from_data(const guchar *buf, gsize count)
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3167 {
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3168 return GDK_PIXBUF(pidgin_pixbuf_from_data_helper(buf, count, FALSE));
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3169 }
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3170
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3171 GdkPixbufAnimation *pidgin_pixbuf_anim_from_data(const guchar *buf, gsize count)
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3172 {
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3173 return GDK_PIXBUF_ANIMATION(pidgin_pixbuf_from_data_helper(buf, count, TRUE));
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3174 }
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3175
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3176 GdkPixbuf *pidgin_pixbuf_from_imgstore(PurpleStoredImage *image)
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3177 {
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3178 return pidgin_pixbuf_from_data(purple_imgstore_get_data(image),
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3179 purple_imgstore_get_size(image));
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3180 }
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3181
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3182 GdkPixbuf *pidgin_pixbuf_new_from_file(const gchar *filename)
23126
ce984959bda0 Add a utility function to create a pixbuf from a stored image.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23124
diff changeset
3183 {
ce984959bda0 Add a utility function to create a pixbuf from a stored image.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23124
diff changeset
3184 GdkPixbuf *pixbuf;
31682
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3185 GError *error = NULL;
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3186
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3187 pixbuf = gdk_pixbuf_new_from_file(filename, &error);
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3188 if (!pixbuf || error) {
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3189 purple_debug_warning("gtkutils", "gdk_pixbuf_new_from_file() "
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3190 "returned %s for file %s: %s\n",
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3191 pixbuf ? "something" : "nothing",
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3192 filename,
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3193 error ? error->message : "(no error message)");
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3194 if (error)
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3195 g_error_free(error);
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3196 if (pixbuf)
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3197 g_object_unref(G_OBJECT(pixbuf));
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3198 return NULL;
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3199 }
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3200
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3201 return pixbuf;
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3202 }
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3203
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3204 GdkPixbuf *pidgin_pixbuf_new_from_file_at_size(const char *filename, int width, int height)
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3205 {
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3206 GdkPixbuf *pixbuf;
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3207 GError *error = NULL;
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3208
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3209 pixbuf = gdk_pixbuf_new_from_file_at_size(filename,
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3210 width, height, &error);
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3211 if (!pixbuf || error) {
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3212 purple_debug_warning("gtkutils", "gdk_pixbuf_new_from_file_at_size() "
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3213 "returned %s for file %s: %s\n",
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3214 pixbuf ? "something" : "nothing",
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3215 filename,
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3216 error ? error->message : "(no error message)");
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3217 if (error)
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3218 g_error_free(error);
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3219 if (pixbuf)
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3220 g_object_unref(G_OBJECT(pixbuf));
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3221 return NULL;
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3222 }
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3223
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3224 return pixbuf;
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3225 }
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3226
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3227 GdkPixbuf *pidgin_pixbuf_new_from_file_at_scale(const char *filename, int width, int height, gboolean preserve_aspect_ratio)
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3228 {
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3229 GdkPixbuf *pixbuf;
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3230 GError *error = NULL;
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3231
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3232 pixbuf = gdk_pixbuf_new_from_file_at_scale(filename,
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3233 width, height, preserve_aspect_ratio, &error);
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3234 if (!pixbuf || error) {
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3235 purple_debug_warning("gtkutils", "gdk_pixbuf_new_from_file_at_scale() "
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3236 "returned %s for file %s: %s\n",
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3237 pixbuf ? "something" : "nothing",
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3238 filename,
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3239 error ? error->message : "(no error message)");
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3240 if (error)
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3241 g_error_free(error);
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3242 if (pixbuf)
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3243 g_object_unref(G_OBJECT(pixbuf));
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3244 return NULL;
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3245 }
e2c6e4fc3c84 Start looking at the GError parameter every time we call these functions:
Mark Doliner <mark@kingant.net>
parents: 31374
diff changeset
3246
23126
ce984959bda0 Add a utility function to create a pixbuf from a stored image.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23124
diff changeset
3247 return pixbuf;
ce984959bda0 Add a utility function to create a pixbuf from a stored image.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23124
diff changeset
3248 }
ce984959bda0 Add a utility function to create a pixbuf from a stored image.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23124
diff changeset
3249
25197
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3250 static void url_copy(GtkWidget *w, gchar *url)
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3251 {
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3252 GtkClipboard *clipboard;
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3253
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3254 clipboard = gtk_widget_get_clipboard(w, GDK_SELECTION_PRIMARY);
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3255 gtk_clipboard_set_text(clipboard, url, -1);
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3256
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3257 clipboard = gtk_widget_get_clipboard(w, GDK_SELECTION_CLIPBOARD);
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3258 gtk_clipboard_set_text(clipboard, url, -1);
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3259 }
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3260
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3261 static gboolean
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3262 link_context_menu(GtkIMHtml *imhtml, GtkIMHtmlLink *link, GtkWidget *menu)
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3263 {
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3264 GtkWidget *img, *item;
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3265 const char *url;
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3266
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3267 url = gtk_imhtml_link_get_url(link);
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3268
25845
6d4b56b81871 Fix a comment
Richard Laager <rlaager@wiktel.com>
parents: 25197
diff changeset
3269 /* Open Link */
25197
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3270 img = gtk_image_new_from_stock(GTK_STOCK_JUMP_TO, GTK_ICON_SIZE_MENU);
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3271 item = gtk_image_menu_item_new_with_mnemonic(_("_Open Link"));
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3272 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), img);
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3273 g_signal_connect_swapped(G_OBJECT(item), "activate", G_CALLBACK(gtk_imhtml_link_activate), link);
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3274 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3275
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3276 /* Copy Link Location */
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3277 img = gtk_image_new_from_stock(GTK_STOCK_COPY, GTK_ICON_SIZE_MENU);
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3278 item = gtk_image_menu_item_new_with_mnemonic(_("_Copy Link Location"));
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3279 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), img);
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3280 g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(url_copy), (gpointer)url);
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3281 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3282
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3283 return TRUE;
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3284 }
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3285
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3286 static gboolean
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3287 copy_email_address(GtkIMHtml *imhtml, GtkIMHtmlLink *link, GtkWidget *menu)
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3288 {
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3289 GtkWidget *img, *item;
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3290 const char *text;
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3291 char *address;
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3292 #define MAILTOSIZE (sizeof("mailto:") - 1)
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3293
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3294 text = gtk_imhtml_link_get_url(link);
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3295 g_return_val_if_fail(text && strlen(text) > MAILTOSIZE, FALSE);
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3296 address = (char*)text + MAILTOSIZE;
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3297
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3298 /* Copy Email Address */
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3299 img = gtk_image_new_from_stock(GTK_STOCK_COPY, GTK_ICON_SIZE_MENU);
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3300 item = gtk_image_menu_item_new_with_mnemonic(_("_Copy Email Address"));
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3301 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), img);
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3302 g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(url_copy), address);
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3303 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3304
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3305 return TRUE;
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3306 }
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3307
27397
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3308 static void
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3309 file_open_uri(GtkIMHtml *imhtml, const char *uri)
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3310 {
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3311 /* Copied from gtkft.c:open_button_cb */
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3312 #ifdef _WIN32
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3313 /* If using Win32... */
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3314 int code;
31819
70ff869a74d1 Open an explorer.exe window at the location of the file when clicking
Mark Doliner <mark@kingant.net>
parents: 31682
diff changeset
3315 if (purple_str_has_prefix(uri, "file://"))
70ff869a74d1 Open an explorer.exe window at the location of the file when clicking
Mark Doliner <mark@kingant.net>
parents: 31682
diff changeset
3316 {
70ff869a74d1 Open an explorer.exe window at the location of the file when clicking
Mark Doliner <mark@kingant.net>
parents: 31682
diff changeset
3317 gchar *escaped = g_shell_quote(uri);
70ff869a74d1 Open an explorer.exe window at the location of the file when clicking
Mark Doliner <mark@kingant.net>
parents: 31682
diff changeset
3318 gchar *param = g_strconcat("/select,\"", uri, "\"", NULL);
31944
7b1cb7651609 Fix parameter types passed to ShellExecuteW(). One of these is just a warning
Daniel Atallah <daniel.atallah@gmail.com>
parents: 31819
diff changeset
3319 wchar_t *wc_param = g_utf8_to_utf16(param, -1, NULL, NULL, NULL);
7b1cb7651609 Fix parameter types passed to ShellExecuteW(). One of these is just a warning
Daniel Atallah <daniel.atallah@gmail.com>
parents: 31819
diff changeset
3320
7b1cb7651609 Fix parameter types passed to ShellExecuteW(). One of these is just a warning
Daniel Atallah <daniel.atallah@gmail.com>
parents: 31819
diff changeset
3321 code = (int)ShellExecuteW(NULL, L"OPEN", L"explorer.exe", wc_param, NULL, SW_NORMAL);
31819
70ff869a74d1 Open an explorer.exe window at the location of the file when clicking
Mark Doliner <mark@kingant.net>
parents: 31682
diff changeset
3322
70ff869a74d1 Open an explorer.exe window at the location of the file when clicking
Mark Doliner <mark@kingant.net>
parents: 31682
diff changeset
3323 g_free(wc_param);
70ff869a74d1 Open an explorer.exe window at the location of the file when clicking
Mark Doliner <mark@kingant.net>
parents: 31682
diff changeset
3324 g_free(param);
70ff869a74d1 Open an explorer.exe window at the location of the file when clicking
Mark Doliner <mark@kingant.net>
parents: 31682
diff changeset
3325 g_free(escaped);
70ff869a74d1 Open an explorer.exe window at the location of the file when clicking
Mark Doliner <mark@kingant.net>
parents: 31682
diff changeset
3326 } else {
70ff869a74d1 Open an explorer.exe window at the location of the file when clicking
Mark Doliner <mark@kingant.net>
parents: 31682
diff changeset
3327 wchar_t *wc_filename = g_utf8_to_utf16(
70ff869a74d1 Open an explorer.exe window at the location of the file when clicking
Mark Doliner <mark@kingant.net>
parents: 31682
diff changeset
3328 uri, -1, NULL, NULL, NULL);
70ff869a74d1 Open an explorer.exe window at the location of the file when clicking
Mark Doliner <mark@kingant.net>
parents: 31682
diff changeset
3329
70ff869a74d1 Open an explorer.exe window at the location of the file when clicking
Mark Doliner <mark@kingant.net>
parents: 31682
diff changeset
3330 code = (int)ShellExecuteW(NULL, NULL, wc_filename, NULL, NULL,
70ff869a74d1 Open an explorer.exe window at the location of the file when clicking
Mark Doliner <mark@kingant.net>
parents: 31682
diff changeset
3331 SW_SHOW);
70ff869a74d1 Open an explorer.exe window at the location of the file when clicking
Mark Doliner <mark@kingant.net>
parents: 31682
diff changeset
3332
70ff869a74d1 Open an explorer.exe window at the location of the file when clicking
Mark Doliner <mark@kingant.net>
parents: 31682
diff changeset
3333 g_free(wc_filename);
70ff869a74d1 Open an explorer.exe window at the location of the file when clicking
Mark Doliner <mark@kingant.net>
parents: 31682
diff changeset
3334 }
27397
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3335
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3336 if (code == SE_ERR_ASSOCINCOMPLETE || code == SE_ERR_NOASSOC)
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3337 {
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3338 purple_notify_error(imhtml, NULL,
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3339 _("There is no application configured to open this type of file."), NULL);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3340 }
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3341 else if (code < 32)
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3342 {
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3343 purple_notify_error(imhtml, NULL,
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3344 _("An error occurred while opening the file."), NULL);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3345 purple_debug_warning("gtkutils", "filename: %s; code: %d\n", uri, code);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3346 }
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3347 #else
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3348 char *command = NULL;
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3349 char *tmp = NULL;
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3350 GError *error = NULL;
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3351
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3352 if (purple_running_gnome())
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3353 {
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3354 char *escaped = g_shell_quote(uri);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3355 command = g_strdup_printf("gnome-open %s", escaped);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3356 g_free(escaped);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3357 }
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3358 else if (purple_running_kde())
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3359 {
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3360 char *escaped = g_shell_quote(uri);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3361
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3362 if (purple_str_has_suffix(uri, ".desktop"))
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3363 command = g_strdup_printf("kfmclient openURL %s 'text/plain'", escaped);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3364 else
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3365 command = g_strdup_printf("kfmclient openURL %s", escaped);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3366 g_free(escaped);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3367 }
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3368 else
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3369 {
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3370 purple_notify_uri(NULL, uri);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3371 return;
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3372 }
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3373
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3374 if (purple_program_is_valid(command))
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3375 {
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3376 gint exit_status;
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3377 if (!g_spawn_command_line_sync(command, NULL, NULL, &exit_status, &error))
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3378 {
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3379 tmp = g_strdup_printf(_("Error launching %s: %s"),
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3380 uri, error->message);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3381 purple_notify_error(imhtml, NULL, _("Unable to open file."), tmp);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3382 g_free(tmp);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3383 g_error_free(error);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3384 }
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3385 if (exit_status != 0)
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3386 {
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3387 char *primary = g_strdup_printf(_("Error running %s"), command);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3388 char *secondary = g_strdup_printf(_("Process returned error code %d"),
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3389 exit_status);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3390 purple_notify_error(imhtml, NULL, primary, secondary);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3391 g_free(tmp);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3392 }
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3393 }
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3394 #endif
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3395 }
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3396
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3397 #define FILELINKSIZE (sizeof("file://") - 1)
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3398 static gboolean
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3399 file_clicked_cb(GtkIMHtml *imhtml, GtkIMHtmlLink *link)
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3400 {
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3401 const char *uri = gtk_imhtml_link_get_url(link) + FILELINKSIZE;
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3402 file_open_uri(imhtml, uri);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3403 return TRUE;
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3404 }
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3405
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3406 static gboolean
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3407 open_containing_cb(GtkIMHtml *imhtml, const char *url)
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3408 {
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3409 char *dir = g_path_get_dirname(url + FILELINKSIZE);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3410 file_open_uri(imhtml, dir);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3411 g_free(dir);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3412 return TRUE;
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3413 }
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3414
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3415 static gboolean
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3416 file_context_menu(GtkIMHtml *imhtml, GtkIMHtmlLink *link, GtkWidget *menu)
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3417 {
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3418 GtkWidget *img, *item;
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3419 const char *url;
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3420
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3421 url = gtk_imhtml_link_get_url(link);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3422
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3423 /* Open File */
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3424 img = gtk_image_new_from_stock(GTK_STOCK_JUMP_TO, GTK_ICON_SIZE_MENU);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3425 item = gtk_image_menu_item_new_with_mnemonic(_("_Open File"));
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3426 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), img);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3427 g_signal_connect_swapped(G_OBJECT(item), "activate", G_CALLBACK(gtk_imhtml_link_activate), link);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3428 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3429
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3430 /* Open Containing Directory */
27418
e420ce168630 Set the "Open Containing Directory" icon to the "directory" stock icon
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27397
diff changeset
3431 img = gtk_image_new_from_stock(GTK_STOCK_DIRECTORY, GTK_ICON_SIZE_MENU);
27397
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3432 item = gtk_image_menu_item_new_with_mnemonic(_("Open _Containing Directory"));
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3433 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), img);
29087
2dcff225172e Start of killing off unneeded GTK_CHECK_VERSION checks in pidgin. Refs #10024
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27958
diff changeset
3434
27397
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3435 g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(open_containing_cb), (gpointer)url);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3436 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3437
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3438 return TRUE;
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3439 }
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3440
27435
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3441 #define AUDIOLINKSIZE (sizeof("audio://") - 1)
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3442 static gboolean
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3443 audio_clicked_cb(GtkIMHtml *imhtml, GtkIMHtmlLink *link)
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3444 {
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3445 const char *uri;
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3446 PidginConversation *conv = g_object_get_data(G_OBJECT(imhtml), "gtkconv");
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3447 if (!conv) /* no playback in debug window */
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3448 return TRUE;
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3449 uri = gtk_imhtml_link_get_url(link) + AUDIOLINKSIZE;
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3450 purple_sound_play_file(uri, NULL);
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3451 return TRUE;
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3452 }
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3453
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3454 static void
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3455 savefile_write_cb(gpointer user_data, char *file)
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3456 {
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3457 char *temp_file = user_data;
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3458 gchar *contents;
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3459 gsize length;
28181
5ceac3a20b93 GError needs to be initialized to NULL. I can't help but think that this
Mark Doliner <mark@kingant.net>
parents: 28172
diff changeset
3460 GError *error = NULL;
27435
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3461
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3462 if (!g_file_get_contents(temp_file, &contents, &length, &error)) {
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3463 purple_debug_error("gtkutils", "Unable to read contents of %s: %s\n",
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3464 temp_file, error->message);
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3465 g_error_free(error);
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3466 return;
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3467 }
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3468
27562
a0baa4da3217 Use purple_util_write_data_to_file_absolute. Closes #9688.
Paul Aurich <paul@darkrain42.org>
parents: 27435
diff changeset
3469 if (!purple_util_write_data_to_file_absolute(file, contents, length)) {
a0baa4da3217 Use purple_util_write_data_to_file_absolute. Closes #9688.
Paul Aurich <paul@darkrain42.org>
parents: 27435
diff changeset
3470 purple_debug_error("gtkutils", "Unable to write contents to %s\n",
a0baa4da3217 Use purple_util_write_data_to_file_absolute. Closes #9688.
Paul Aurich <paul@darkrain42.org>
parents: 27435
diff changeset
3471 file);
27435
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3472 }
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3473 }
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3474
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3475 static gboolean
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3476 save_file_cb(GtkWidget *item, const char *url)
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3477 {
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3478 PidginConversation *conv = g_object_get_data(G_OBJECT(item), "gtkconv");
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3479 if (!conv)
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3480 return TRUE;
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3481 purple_request_file(conv->active_conv, _("Save File"), NULL, TRUE,
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3482 G_CALLBACK(savefile_write_cb), NULL,
32241
308519b40f50 Use purple_conversation accessor methods.
andrew.victor@mxit.com
parents: 32199
diff changeset
3483 purple_conversation_get_account(conv->active_conv), NULL, conv->active_conv,
27435
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3484 (void *)url);
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3485 return TRUE;
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3486 }
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3487
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3488 static gboolean
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3489 audio_context_menu(GtkIMHtml *imhtml, GtkIMHtmlLink *link, GtkWidget *menu)
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3490 {
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3491 GtkWidget *img, *item;
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3492 const char *url;
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3493 PidginConversation *conv = g_object_get_data(G_OBJECT(imhtml), "gtkconv");
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3494 if (!conv) /* No menu in debug window */
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3495 return TRUE;
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3496
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3497 url = gtk_imhtml_link_get_url(link);
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3498
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3499 /* Play Sound */
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3500 img = gtk_image_new_from_stock(GTK_STOCK_MEDIA_PLAY, GTK_ICON_SIZE_MENU);
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3501 item = gtk_image_menu_item_new_with_mnemonic(_("_Play Sound"));
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3502 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), img);
29087
2dcff225172e Start of killing off unneeded GTK_CHECK_VERSION checks in pidgin. Refs #10024
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27958
diff changeset
3503
27435
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3504 g_signal_connect_swapped(G_OBJECT(item), "activate", G_CALLBACK(gtk_imhtml_link_activate), link);
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3505 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3506
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3507 /* Save File */
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3508 img = gtk_image_new_from_stock(GTK_STOCK_SAVE, GTK_ICON_SIZE_MENU);
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3509 item = gtk_image_menu_item_new_with_mnemonic(_("_Save File"));
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3510 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), img);
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3511 g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(save_file_cb), (gpointer)(url+AUDIOLINKSIZE));
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3512 g_object_set_data(G_OBJECT(item), "gtkconv", conv);
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3513 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3514
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3515 return TRUE;
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3516 }
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3517
25142
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3518 /* XXX: The following two functions are for demonstration purposes only! */
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3519 static gboolean
25197
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3520 open_dialog(GtkIMHtml *imhtml, GtkIMHtmlLink *link)
25142
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3521 {
25197
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3522 const char *url;
25142
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3523 const char *str;
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3524
25197
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3525 url = gtk_imhtml_link_get_url(link);
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3526 if (!url || strlen(url) < sizeof("open://"))
25142
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3527 return FALSE;
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3528
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3529 str = url + sizeof("open://") - 1;
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3530
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3531 if (strcmp(str, "accounts") == 0)
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3532 pidgin_accounts_window_show();
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3533 else if (strcmp(str, "prefs") == 0)
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3534 pidgin_prefs_show();
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3535 else
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3536 return FALSE;
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3537 return TRUE;
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3538 }
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3539
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3540 static gboolean
25197
284fd17c6020 Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25142
diff changeset
3541 dummy(GtkIMHtml *imhtml, GtkIMHtmlLink *link, GtkWidget *menu)
25142
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3542 {
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3543 return TRUE;
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3544 }
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3545
25860
5dedfe149cb3 Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@wiktel.com>
parents: 25851
diff changeset
3546 static gboolean
25865
726b251cb913 Cleanup the GNOME URL registration code
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25862
diff changeset
3547 register_gnome_url_handlers(void)
25850
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3548 {
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3549 char *tmp;
25851
291b84bf4f8b Finish up the GNOME URL handler code:
Richard Laager <rlaager@wiktel.com>
parents: 25850
diff changeset
3550 char *err;
25850
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3551 char *c;
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3552 char *start;
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3553
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3554 tmp = g_find_program_in_path("gconftool-2");
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3555 if (tmp == NULL)
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3556 return FALSE;
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3557
26243
0a1f7bff1ddd Apply Paul's second patch to fix some memory leaks found in valgrind.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26235
diff changeset
3558 g_free(tmp);
25850
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3559 tmp = NULL;
26243
0a1f7bff1ddd Apply Paul's second patch to fix some memory leaks found in valgrind.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 26235
diff changeset
3560
25850
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3561 if (!g_spawn_command_line_sync("gconftool-2 --all-dirs /desktop/gnome/url-handlers",
25851
291b84bf4f8b Finish up the GNOME URL handler code:
Richard Laager <rlaager@wiktel.com>
parents: 25850
diff changeset
3562 &tmp, &err, NULL, NULL))
291b84bf4f8b Finish up the GNOME URL handler code:
Richard Laager <rlaager@wiktel.com>
parents: 25850
diff changeset
3563 {
25865
726b251cb913 Cleanup the GNOME URL registration code
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25862
diff changeset
3564 g_free(tmp);
25851
291b84bf4f8b Finish up the GNOME URL handler code:
Richard Laager <rlaager@wiktel.com>
parents: 25850
diff changeset
3565 g_free(err);
25850
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3566 g_return_val_if_reached(FALSE);
25851
291b84bf4f8b Finish up the GNOME URL handler code:
Richard Laager <rlaager@wiktel.com>
parents: 25850
diff changeset
3567 }
291b84bf4f8b Finish up the GNOME URL handler code:
Richard Laager <rlaager@wiktel.com>
parents: 25850
diff changeset
3568 g_free(err);
291b84bf4f8b Finish up the GNOME URL handler code:
Richard Laager <rlaager@wiktel.com>
parents: 25850
diff changeset
3569 err = NULL;
25850
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3570
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3571 for (c = start = tmp ; *c ; c++)
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3572 {
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3573 /* Skip leading spaces. */
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3574 if (c == start && *c == ' ')
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3575 start = c + 1;
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3576 else if (*c == '\n')
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3577 {
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3578 *c = '\0';
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3579 if (g_str_has_prefix(start, "/desktop/gnome/url-handlers/"))
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3580 {
25851
291b84bf4f8b Finish up the GNOME URL handler code:
Richard Laager <rlaager@wiktel.com>
parents: 25850
diff changeset
3581 char *cmd;
291b84bf4f8b Finish up the GNOME URL handler code:
Richard Laager <rlaager@wiktel.com>
parents: 25850
diff changeset
3582 char *tmp2 = NULL;
25850
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3583 char *protocol;
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3584
25851
291b84bf4f8b Finish up the GNOME URL handler code:
Richard Laager <rlaager@wiktel.com>
parents: 25850
diff changeset
3585 /* If there is an enabled boolean, honor it. */
291b84bf4f8b Finish up the GNOME URL handler code:
Richard Laager <rlaager@wiktel.com>
parents: 25850
diff changeset
3586 cmd = g_strdup_printf("gconftool-2 -g %s/enabled", start);
291b84bf4f8b Finish up the GNOME URL handler code:
Richard Laager <rlaager@wiktel.com>
parents: 25850
diff changeset
3587 if (g_spawn_command_line_sync(cmd, &tmp2, &err, NULL, NULL))
291b84bf4f8b Finish up the GNOME URL handler code:
Richard Laager <rlaager@wiktel.com>
parents: 25850
diff changeset
3588 {
291b84bf4f8b Finish up the GNOME URL handler code:
Richard Laager <rlaager@wiktel.com>
parents: 25850
diff changeset
3589 g_free(err);
25865
726b251cb913 Cleanup the GNOME URL registration code
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25862
diff changeset
3590 err = NULL;
25851
291b84bf4f8b Finish up the GNOME URL handler code:
Richard Laager <rlaager@wiktel.com>
parents: 25850
diff changeset
3591 if (!strcmp(tmp2, "false\n"))
291b84bf4f8b Finish up the GNOME URL handler code:
Richard Laager <rlaager@wiktel.com>
parents: 25850
diff changeset
3592 {
291b84bf4f8b Finish up the GNOME URL handler code:
Richard Laager <rlaager@wiktel.com>
parents: 25850
diff changeset
3593 g_free(tmp2);
25865
726b251cb913 Cleanup the GNOME URL registration code
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25862
diff changeset
3594 g_free(cmd);
25851
291b84bf4f8b Finish up the GNOME URL handler code:
Richard Laager <rlaager@wiktel.com>
parents: 25850
diff changeset
3595 start = c + 1;
291b84bf4f8b Finish up the GNOME URL handler code:
Richard Laager <rlaager@wiktel.com>
parents: 25850
diff changeset
3596 continue;
291b84bf4f8b Finish up the GNOME URL handler code:
Richard Laager <rlaager@wiktel.com>
parents: 25850
diff changeset
3597 }
291b84bf4f8b Finish up the GNOME URL handler code:
Richard Laager <rlaager@wiktel.com>
parents: 25850
diff changeset
3598 }
25865
726b251cb913 Cleanup the GNOME URL registration code
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25862
diff changeset
3599 g_free(cmd);
726b251cb913 Cleanup the GNOME URL registration code
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25862
diff changeset
3600 g_free(tmp2);
25851
291b84bf4f8b Finish up the GNOME URL handler code:
Richard Laager <rlaager@wiktel.com>
parents: 25850
diff changeset
3601
25850
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3602 start += sizeof("/desktop/gnome/url-handlers/") - 1;
25862
b6f2c637a3d9 In the GNOME URL registration, ftp, gopher, http, and https are now
Richard Laager <rlaager@wiktel.com>
parents: 25861
diff changeset
3603
25868
ba083e5f633b Remove all the special-casing in the GNOME URL handler registration.
Richard Laager <rlaager@wiktel.com>
parents: 25865
diff changeset
3604 protocol = g_strdup_printf("%s:", start);
28403
3fdad8b715c7 Fix the win32 URIs to only linkify if the protocol is followed by a colon.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28379
diff changeset
3605 registered_url_handlers = g_slist_prepend(registered_url_handlers, protocol);
25868
ba083e5f633b Remove all the special-casing in the GNOME URL handler registration.
Richard Laager <rlaager@wiktel.com>
parents: 25865
diff changeset
3606 gtk_imhtml_class_register_protocol(protocol, url_clicked_cb, link_context_menu);
25850
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3607 }
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3608 start = c + 1;
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3609 }
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3610 }
25865
726b251cb913 Cleanup the GNOME URL registration code
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 25862
diff changeset
3611 g_free(tmp);
25850
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3612
28403
3fdad8b715c7 Fix the win32 URIs to only linkify if the protocol is followed by a colon.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28379
diff changeset
3613 return (registered_url_handlers != NULL);
25850
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3614 }
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3615
28379
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3616 #ifdef _WIN32
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3617 static void
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3618 winpidgin_register_win32_url_handlers(void)
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3619 {
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3620 int idx = 0;
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3621 LONG ret = ERROR_SUCCESS;
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3622
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3623 do {
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3624 DWORD nameSize = 256;
29221
62e4159afc84 Handle non-ASCII protocol names on Win32
Daniel Atallah <daniel.atallah@gmail.com>
parents: 29218
diff changeset
3625 wchar_t start[256];
62e4159afc84 Handle non-ASCII protocol names on Win32
Daniel Atallah <daniel.atallah@gmail.com>
parents: 29218
diff changeset
3626 ret = RegEnumKeyExW(HKEY_CLASSES_ROOT, idx++, start, &nameSize,
28379
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3627 NULL, NULL, NULL, NULL);
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3628 if (ret == ERROR_SUCCESS) {
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3629 HKEY reg_key = NULL;
29221
62e4159afc84 Handle non-ASCII protocol names on Win32
Daniel Atallah <daniel.atallah@gmail.com>
parents: 29218
diff changeset
3630 ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, start, 0, KEY_READ, &reg_key);
28379
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3631 if (ret == ERROR_SUCCESS) {
29221
62e4159afc84 Handle non-ASCII protocol names on Win32
Daniel Atallah <daniel.atallah@gmail.com>
parents: 29218
diff changeset
3632 ret = RegQueryValueExW(reg_key, L"URL Protocol", NULL, NULL, NULL, NULL);
28379
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3633 if (ret == ERROR_SUCCESS) {
29221
62e4159afc84 Handle non-ASCII protocol names on Win32
Daniel Atallah <daniel.atallah@gmail.com>
parents: 29218
diff changeset
3634 gchar *utf8 = g_utf16_to_utf8(start, -1, NULL, NULL, NULL);
62e4159afc84 Handle non-ASCII protocol names on Win32
Daniel Atallah <daniel.atallah@gmail.com>
parents: 29218
diff changeset
3635 gchar *protocol = g_strdup_printf("%s:", utf8);
62e4159afc84 Handle non-ASCII protocol names on Win32
Daniel Atallah <daniel.atallah@gmail.com>
parents: 29218
diff changeset
3636 g_free(utf8);
28403
3fdad8b715c7 Fix the win32 URIs to only linkify if the protocol is followed by a colon.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28379
diff changeset
3637 registered_url_handlers = g_slist_prepend(registered_url_handlers, protocol);
28379
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3638 /* We still pass everything to the "http" "open" handler for security reasons */
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3639 gtk_imhtml_class_register_protocol(protocol, url_clicked_cb, link_context_menu);
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3640 }
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3641 RegCloseKey(reg_key);
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3642 }
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3643 ret = ERROR_SUCCESS;
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3644 }
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3645 } while (ret == ERROR_SUCCESS);
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3646
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3647 if (ret != ERROR_NO_MORE_ITEMS)
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3648 purple_debug_error("winpidgin", "Error iterating HKEY_CLASSES_ROOT subkeys: %ld\n",
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3649 ret);
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3650 }
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3651 #endif
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3652
31367
917c597beb97 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31014
diff changeset
3653 GtkWidget *
917c597beb97 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31014
diff changeset
3654 pidgin_make_scrollable(GtkWidget *child, GtkPolicyType hscrollbar_policy, GtkPolicyType vscrollbar_policy, GtkShadowType shadow_type, int width, int height)
917c597beb97 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31014
diff changeset
3655 {
917c597beb97 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31014
diff changeset
3656 GtkWidget *sw = gtk_scrolled_window_new(NULL, NULL);
917c597beb97 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31014
diff changeset
3657
917c597beb97 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31014
diff changeset
3658 if (G_LIKELY(sw)) {
917c597beb97 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31014
diff changeset
3659 gtk_widget_show(sw);
917c597beb97 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31014
diff changeset
3660 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), hscrollbar_policy, vscrollbar_policy);
917c597beb97 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31014
diff changeset
3661 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), shadow_type);
917c597beb97 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31014
diff changeset
3662 if (width != -1 || height != -1)
917c597beb97 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31014
diff changeset
3663 gtk_widget_set_size_request(sw, width, height);
917c597beb97 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31014
diff changeset
3664 if (child) {
917c597beb97 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31014
diff changeset
3665 if (GTK_WIDGET_GET_CLASS(child)->set_scroll_adjustments_signal)
917c597beb97 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31014
diff changeset
3666 gtk_container_add(GTK_CONTAINER(sw), child);
917c597beb97 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31014
diff changeset
3667 else
917c597beb97 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31014
diff changeset
3668 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw), child);
917c597beb97 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31014
diff changeset
3669 }
917c597beb97 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31014
diff changeset
3670 return sw;
917c597beb97 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31014
diff changeset
3671 }
917c597beb97 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31014
diff changeset
3672
917c597beb97 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31014
diff changeset
3673 return child;
917c597beb97 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31014
diff changeset
3674 }
917c597beb97 Add pidgin_make_scrollable and use it. Cleans up a bunch of duplicate code. Net code loss of 180 lines. Fixes #13073.
Gabriel Schulhof <nix@go-nix.ca>
parents: 31014
diff changeset
3675
25142
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3676 void pidgin_utils_init(void)
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3677 {
25861
48cf0a545621 Revert the URL scheme passing changes, keeping the miscellaneous other stuff
Richard Laager <rlaager@wiktel.com>
parents: 25860
diff changeset
3678 gtk_imhtml_class_register_protocol("http://", url_clicked_cb, link_context_menu);
48cf0a545621 Revert the URL scheme passing changes, keeping the miscellaneous other stuff
Richard Laager <rlaager@wiktel.com>
parents: 25860
diff changeset
3679 gtk_imhtml_class_register_protocol("https://", url_clicked_cb, link_context_menu);
48cf0a545621 Revert the URL scheme passing changes, keeping the miscellaneous other stuff
Richard Laager <rlaager@wiktel.com>
parents: 25860
diff changeset
3680 gtk_imhtml_class_register_protocol("ftp://", url_clicked_cb, link_context_menu);
48cf0a545621 Revert the URL scheme passing changes, keeping the miscellaneous other stuff
Richard Laager <rlaager@wiktel.com>
parents: 25860
diff changeset
3681 gtk_imhtml_class_register_protocol("gopher://", url_clicked_cb, link_context_menu);
48cf0a545621 Revert the URL scheme passing changes, keeping the miscellaneous other stuff
Richard Laager <rlaager@wiktel.com>
parents: 25860
diff changeset
3682 gtk_imhtml_class_register_protocol("mailto:", url_clicked_cb, copy_email_address);
25868
ba083e5f633b Remove all the special-casing in the GNOME URL handler registration.
Richard Laager <rlaager@wiktel.com>
parents: 25865
diff changeset
3683
27397
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3684 gtk_imhtml_class_register_protocol("file://", file_clicked_cb, file_context_menu);
27435
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3685 gtk_imhtml_class_register_protocol("audio://", audio_clicked_cb, audio_context_menu);
27397
39c6f1d0cf26 Install a custom GtkIMHtml procol handler for the "file://" type which
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27284
diff changeset
3686
25868
ba083e5f633b Remove all the special-casing in the GNOME URL handler registration.
Richard Laager <rlaager@wiktel.com>
parents: 25865
diff changeset
3687 /* Example custom URL handler. */
ba083e5f633b Remove all the special-casing in the GNOME URL handler registration.
Richard Laager <rlaager@wiktel.com>
parents: 25865
diff changeset
3688 gtk_imhtml_class_register_protocol("open://", open_dialog, dummy);
ba083e5f633b Remove all the special-casing in the GNOME URL handler registration.
Richard Laager <rlaager@wiktel.com>
parents: 25865
diff changeset
3689
ba083e5f633b Remove all the special-casing in the GNOME URL handler registration.
Richard Laager <rlaager@wiktel.com>
parents: 25865
diff changeset
3690 /* If we're under GNOME, try registering the system URL handlers. */
ba083e5f633b Remove all the special-casing in the GNOME URL handler registration.
Richard Laager <rlaager@wiktel.com>
parents: 25865
diff changeset
3691 if (purple_running_gnome())
ba083e5f633b Remove all the special-casing in the GNOME URL handler registration.
Richard Laager <rlaager@wiktel.com>
parents: 25865
diff changeset
3692 register_gnome_url_handlers();
28379
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3693
29617
7ed0ddbdd2a8 Use an inline RC style to get rid of some other padding to make the small
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29615
diff changeset
3694 /* Used to make small buttons */
7ed0ddbdd2a8 Use an inline RC style to get rid of some other padding to make the small
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29615
diff changeset
3695 gtk_rc_parse_string("style \"pidgin-small-close-button\"\n"
7ed0ddbdd2a8 Use an inline RC style to get rid of some other padding to make the small
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29615
diff changeset
3696 "{\n"
7ed0ddbdd2a8 Use an inline RC style to get rid of some other padding to make the small
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29615
diff changeset
3697 "GtkWidget::focus-padding = 0\n"
7ed0ddbdd2a8 Use an inline RC style to get rid of some other padding to make the small
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29615
diff changeset
3698 "GtkWidget::focus-line-width = 0\n"
7ed0ddbdd2a8 Use an inline RC style to get rid of some other padding to make the small
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29615
diff changeset
3699 "xthickness = 0\n"
7ed0ddbdd2a8 Use an inline RC style to get rid of some other padding to make the small
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29615
diff changeset
3700 "ythickness = 0\n"
29723
0625cebc84d7 Use cute little "¡ß" on the close buttons in conversation tabs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29648
diff changeset
3701 "GtkContainer::border-width = 0\n"
0625cebc84d7 Use cute little "¡ß" on the close buttons in conversation tabs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29648
diff changeset
3702 "GtkButton::inner-border = {0, 0, 0, 0}\n"
0625cebc84d7 Use cute little "¡ß" on the close buttons in conversation tabs.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 29648
diff changeset
3703 "GtkButton::default-border = {0, 0, 0, 0}\n"
29617
7ed0ddbdd2a8 Use an inline RC style to get rid of some other padding to make the small
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29615
diff changeset
3704 "}\n"
7ed0ddbdd2a8 Use an inline RC style to get rid of some other padding to make the small
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29615
diff changeset
3705 "widget \"*.pidgin-small-close-button\" style \"pidgin-small-close-button\"");
7ed0ddbdd2a8 Use an inline RC style to get rid of some other padding to make the small
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29615
diff changeset
3706
28379
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3707 #ifdef _WIN32
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3708 winpidgin_register_win32_url_handlers();
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3709 #endif
d2ffe8240a45 Register URL handlers for everything that Windows has knows about like we do
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28185
diff changeset
3710
25142
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3711 }
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3712
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3713 void pidgin_utils_uninit(void)
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3714 {
25861
48cf0a545621 Revert the URL scheme passing changes, keeping the miscellaneous other stuff
Richard Laager <rlaager@wiktel.com>
parents: 25860
diff changeset
3715 gtk_imhtml_class_register_protocol("open://", NULL, NULL);
25850
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3716
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3717 /* If we have GNOME handlers registered, unregister them. */
28403
3fdad8b715c7 Fix the win32 URIs to only linkify if the protocol is followed by a colon.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28379
diff changeset
3718 if (registered_url_handlers)
25850
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3719 {
28403
3fdad8b715c7 Fix the win32 URIs to only linkify if the protocol is followed by a colon.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28379
diff changeset
3720 GSList *l;
3fdad8b715c7 Fix the win32 URIs to only linkify if the protocol is followed by a colon.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28379
diff changeset
3721 for (l = registered_url_handlers; l; l = l->next)
25850
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3722 {
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3723 gtk_imhtml_class_register_protocol((char *)l->data, NULL, NULL);
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3724 g_free(l->data);
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3725 }
28403
3fdad8b715c7 Fix the win32 URIs to only linkify if the protocol is followed by a colon.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28379
diff changeset
3726 g_slist_free(registered_url_handlers);
3fdad8b715c7 Fix the win32 URIs to only linkify if the protocol is followed by a colon.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 28379
diff changeset
3727 registered_url_handlers = NULL;
25850
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3728 return;
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3729 }
27435
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3730
ff18653ef9f4 Add support in Pidgin for playing back audio:// links. Also include a "Save
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27418
diff changeset
3731 gtk_imhtml_class_register_protocol("audio://", NULL, NULL);
27418
e420ce168630 Set the "Open Containing Directory" icon to the "directory" stock icon
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 27397
diff changeset
3732 gtk_imhtml_class_register_protocol("file://", NULL, NULL);
25850
5b16203f76be First round of GNOME URL handler support.
Richard Laager <rlaager@wiktel.com>
parents: 25845
diff changeset
3733
25861
48cf0a545621 Revert the URL scheme passing changes, keeping the miscellaneous other stuff
Richard Laager <rlaager@wiktel.com>
parents: 25860
diff changeset
3734 gtk_imhtml_class_register_protocol("http://", NULL, NULL);
48cf0a545621 Revert the URL scheme passing changes, keeping the miscellaneous other stuff
Richard Laager <rlaager@wiktel.com>
parents: 25860
diff changeset
3735 gtk_imhtml_class_register_protocol("https://", NULL, NULL);
48cf0a545621 Revert the URL scheme passing changes, keeping the miscellaneous other stuff
Richard Laager <rlaager@wiktel.com>
parents: 25860
diff changeset
3736 gtk_imhtml_class_register_protocol("ftp://", NULL, NULL);
48cf0a545621 Revert the URL scheme passing changes, keeping the miscellaneous other stuff
Richard Laager <rlaager@wiktel.com>
parents: 25860
diff changeset
3737 gtk_imhtml_class_register_protocol("mailto:", NULL, NULL);
48cf0a545621 Revert the URL scheme passing changes, keeping the miscellaneous other stuff
Richard Laager <rlaager@wiktel.com>
parents: 25860
diff changeset
3738 gtk_imhtml_class_register_protocol("gopher://", NULL, NULL);
25142
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3739 }
38a2f78f80a7 Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 24451
diff changeset
3740