Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: pidgin/gtkdocklet-gtk.c
- ===================================================================
- --- a/pidgin/gtkdocklet-gtk.c 067bfa0897fcb1b8cab70aea3f7e97f0a15f53dd
- +++ b/pidgin/gtkdocklet-gtk.c 067bfa0897fcb1b8cab70aea3f7e97f0a15f53dd
- @@ -0,0 +1,168 @@
- +/*
- + * System tray icon (aka docklet) plugin for Purple
- + *
- + * Copyright (C) 2007 Anders Hasselqvist
- + *
- + * This program is free software; you can redistribute it and/or
- + * modify it under the terms of the GNU General Public License as
- + * published by the Free Software Foundation; either version 2 of the
- + * License, or (at your option) any later version.
- + *
- + * This program is distributed in the hope that it will be useful, but
- + * WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- + * General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program; if not, write to the Free Software
- + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- + * 02111-1307, USA.
- + */
- +
- +#include "internal.h"
- +#include "pidgin.h"
- +#include "debug.h"
- +#include "prefs.h"
- +#include "pidginstock.h"
- +#include "gtkdocklet.h"
- +
- +#if GTK_CHECK_VERSION(2,10,0)
- +
- +/* globals */
- +GtkStatusIcon *docklet = NULL;
- +
- +static void
- +docklet_gtk_status_activated_cb(GtkStatusIcon *status_icon, gpointer user_data)
- +{
- + purple_debug_info("docklet", "button clicked %d\n", 1);
- +
- + pidgin_docklet_clicked(1);
- +}
- +
- +static void
- +docklet_gtk_status_clicked_cb(GtkStatusIcon *status_icon, guint button, guint activate_time, gpointer user_data)
- +{
- + purple_debug_info("docklet", "button clicked %d\n", button);
- +
- + pidgin_docklet_clicked(button);
- +}
- +
- +static void
- +docklet_gtk_status_update_icon(PurpleStatusPrimitive status, gboolean connecting, gboolean pending)
- +{
- + const gchar *icon_name = NULL;
- +
- + switch (status) {
- + case PURPLE_STATUS_OFFLINE:
- + icon_name = PIDGIN_STOCK_TRAY_OFFLINE;
- + break;
- + case PURPLE_STATUS_AWAY:
- + icon_name = PIDGIN_STOCK_TRAY_AWAY;
- + break;
- + case PURPLE_STATUS_UNAVAILABLE:
- + icon_name = PIDGIN_STOCK_TRAY_BUSY;
- + break;
- + case PURPLE_STATUS_EXTENDED_AWAY:
- + icon_name = PIDGIN_STOCK_TRAY_XA;
- + break;
- + case PURPLE_STATUS_INVISIBLE:
- + icon_name = PIDGIN_STOCK_TRAY_INVISIBLE;
- + break;
- + default:
- + icon_name = PIDGIN_STOCK_TRAY_AVAILABLE;
- + break;
- + }
- +
- + if (pending)
- + icon_name = PIDGIN_STOCK_TRAY_PENDING;
- + if (connecting)
- + icon_name = PIDGIN_STOCK_TRAY_CONNECT;
- +
- + if (icon_name) {
- + gtk_status_icon_set_from_stock(docklet, icon_name);
- + }
- +
- + if(purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/docklet/blink")) {
- + gtk_status_icon_set_blinking(docklet, (pending && !connecting));
- + } else if(gtk_status_icon_get_blinking(docklet)) {
- + gtk_status_icon_set_blinking(docklet, FALSE);
- + }
- +}
- +
- +static void
- +docklet_gtk_status_set_tooltip(gchar *tooltip)
- +{
- + if (tooltip) {
- + gtk_status_icon_set_tooltip(docklet, tooltip);
- + } else {
- + gtk_status_icon_set_tooltip(docklet, NULL);
- + }
- +}
- +
- +static void
- +docklet_gtk_status_position_menu(GtkMenu *menu,
- + int *x, int *y, gboolean *push_in,
- + gpointer user_data)
- +{
- + gtk_status_icon_position_menu(menu, x, y, push_in, docklet);
- +}
- +
- +static void
- +docklet_gtk_status_destroy(void)
- +{
- + g_return_if_fail(docklet != NULL);
- +
- + pidgin_docklet_remove();
- +
- + g_object_unref(G_OBJECT(docklet));
- + docklet = NULL;
- +
- + purple_debug_info("docklet", "destroyed\n");
- +}
- +
- +static void
- +docklet_gtk_status_create(gboolean recreate)
- +{
- + if (docklet) {
- + /* if this is being called when a tray icon exists, it's because
- + something messed up. try destroying it before we proceed,
- + although docklet_refcount may be all hosed. hopefully won't happen. */
- + purple_debug_warning("docklet", "trying to create icon but it already exists?\n");
- + docklet_gtk_status_destroy();
- + }
- +
- + docklet = gtk_status_icon_new();
- + g_return_if_fail(docklet != NULL);
- +
- + g_signal_connect(G_OBJECT(docklet), "activate", G_CALLBACK(docklet_gtk_status_activated_cb), NULL);
- + g_signal_connect(G_OBJECT(docklet), "popup-menu", G_CALLBACK(docklet_gtk_status_clicked_cb), NULL);
- +
- + pidgin_docklet_embedded();
- + gtk_status_icon_set_visible(docklet, TRUE);
- + purple_debug_info("docklet", "created\n");
- +}
- +
- +static void
- +docklet_gtk_status_create_ui_op(void)
- +{
- + docklet_gtk_status_create(FALSE);
- +}
- +
- +static struct docklet_ui_ops ui_ops =
- +{
- + docklet_gtk_status_create_ui_op,
- + docklet_gtk_status_destroy,
- + docklet_gtk_status_update_icon,
- + NULL,
- + docklet_gtk_status_set_tooltip,
- + docklet_gtk_status_position_menu
- +};
- +
- +void
- +docklet_ui_init(void)
- +{
- + pidgin_docklet_set_ui_ops(&ui_ops);
- +}
- +
- +#endif /* GTK_CHECK_VERSION(2,10,0) */
- +
- ============================================================
- Index: pidgin/Makefile.am
- ===================================================================
- --- a/pidgin/Makefile.am 85c83e33db8e13395f710e8d6bce44b97cc19c18
- +++ b/pidgin/Makefile.am 9764675159d95ab81d52d35c2f37831a81347fe7
- @@ -87,6 +87,7 @@
- gtkdialogs.c \
- gtkdnd-hints.c \
- gtkdocklet.c \
- + gtkdocklet-gtk.c \
- gtkdocklet-x11.c \
- gtkeventloop.c \
- gtkexpander.c \
- ============================================================
- Index: pidgin/gtkdocklet-x11.c
- ===================================================================
- --- a/pidgin/gtkdocklet-x11.c 5bc5a9b08a44a9fa85818233cd383264ac96109a
- +++ b/pidgin/gtkdocklet-x11.c 5afb93cfca02d22eb57e93dcf11ad1190157553d
- @@ -34,6 +34,8 @@
- #include "gtkdocklet.h"
- #include <gdk/gdkkeysyms.h>
- +#if !GTK_CHECK_VERSION(2,10,0)
- +
- #define SHORT_EMBED_TIMEOUT 5000
- #define LONG_EMBED_TIMEOUT 15000
- @@ -352,3 +354,6 @@
- purple_prefs_add_none(PIDGIN_PREFS_ROOT "/docklet/x11");
- purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/docklet/x11/embedded", FALSE);
- }
- +
- +#endif /* !GTK_CHECK_VERSION(2,10,0) */
- +
- ============================================================
- Index: pidgin/gtkdocklet.h
- ===================================================================
- --- a/pidgin/gtkdocklet.h ab60eb18264813e2890efe5deb5819497d35fc57
- +++ b/pidgin/gtkdocklet.h 16acb1dd32c2646895f80d34f177dca23aa5e72c
- @@ -49,7 +49,7 @@
- void pidgin_docklet_uninit(void);
- void*pidgin_docklet_get_handle(void);
- -/* function in gtkdocklet-{x11,win32}.c */
- +/* function in gtkdocklet-{gtk,x11,win32}.c */
- void docklet_ui_init(void);
- #endif /* _GTKDOCKLET_H_ */
- ============================================================
- Index: pidgin/pidginstock.c
- ===================================================================
- --- a/pidgin/pidginstock.c c760ceb63ae60f491a23e5843b336adf6f26b73f
- +++ b/pidgin/pidginstock.c ded881b2cb875ae154578a9f15f892328a804d11
- @@ -198,8 +198,11 @@
- { PIDGIN_STOCK_STATUS_LOGOUT, "status", "log-out.png", TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, NULL },
- { PIDGIN_STOCK_STATUS_OFFLINE, "status", "offline.png", TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, PIDGIN_STOCK_STATUS_OFFLINE_I },
- { PIDGIN_STOCK_STATUS_PERSON, "status", "person.png", TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL },
- - { PIDGIN_STOCK_STATUS_MESSAGE, "toolbar", "message-new.png", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
- + { PIDGIN_STOCK_STATUS_MESSAGE, "toolbar", "message-new.png", TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL }
- +};
- +const SizedStockIcon sized_tray_icons [] = {
- +
- { PIDGIN_STOCK_TRAY_AVAILABLE, "tray", "tray-online.png", FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL },
- { PIDGIN_STOCK_TRAY_INVISIBLE, "tray", "tray-invisible.png", FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL },
- { PIDGIN_STOCK_TRAY_AWAY, "tray", "tray-away.png", FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL },
- @@ -332,7 +335,8 @@
- static void
- add_sized_icon(GtkIconSet *iconset, GtkIconSize sizeid, PidginIconTheme *theme,
- - const char *size, SizedStockIcon sized_icon, gboolean translucent)
- + const char *size, SizedStockIcon sized_icon, gboolean translucent,
- + gboolean size_wildcarded)
- {
- char *filename;
- GtkIconSource *source;
- @@ -349,7 +353,7 @@
- gtk_icon_source_set_direction(source, GTK_TEXT_DIR_LTR);
- gtk_icon_source_set_direction_wildcarded(source, !sized_icon.rtl);
- gtk_icon_source_set_size(source, sizeid);
- - gtk_icon_source_set_size_wildcarded(source, FALSE);
- + gtk_icon_source_set_size_wildcarded(source, size_wildcarded);
- gtk_icon_source_set_state_wildcarded(source, TRUE);
- gtk_icon_set_add_source(iconset, source);
- gtk_icon_source_free(source);
- @@ -359,7 +363,7 @@
- gtk_icon_source_set_pixbuf(source, pixbuf);
- gtk_icon_source_set_direction_wildcarded(source, TRUE);
- gtk_icon_source_set_size(source, GTK_ICON_SIZE_MENU);
- - gtk_icon_source_set_size_wildcarded(source, FALSE);
- + gtk_icon_source_set_size_wildcarded(source, size_wildcarded);
- gtk_icon_source_set_state_wildcarded(source, TRUE);
- gtk_icon_set_add_source(iconset, source);
- gtk_icon_source_free(source);
- @@ -379,7 +383,7 @@
- gtk_icon_source_set_filename(source, filename);
- gtk_icon_source_set_direction(source, GTK_TEXT_DIR_RTL);
- gtk_icon_source_set_size(source, sizeid);
- - gtk_icon_source_set_size_wildcarded(source, FALSE);
- + gtk_icon_source_set_size_wildcarded(source, size_wildcarded);
- gtk_icon_source_set_state_wildcarded(source, TRUE);
- gtk_icon_set_add_source(iconset, source);
- g_free(filename);
- @@ -435,9 +439,9 @@
- #define ADD_SIZED_ICON(name, size) \
- if (sized_status_icons[i].name) { \
- - add_sized_icon(normal, name, PIDGIN_ICON_THEME(theme), size, sized_status_icons[i], FALSE); \
- + add_sized_icon(normal, name, PIDGIN_ICON_THEME(theme), size, sized_status_icons[i], FALSE, FALSE); \
- if (sized_status_icons[i].translucent_name) \
- - add_sized_icon(translucent, name, PIDGIN_ICON_THEME(theme), size, sized_status_icons[i], TRUE); \
- + add_sized_icon(translucent, name, PIDGIN_ICON_THEME(theme), size, sized_status_icons[i], TRUE, FALSE); \
- }
- ADD_SIZED_ICON(microscopic, "11");
- ADD_SIZED_ICON(extra_small, "16");
- @@ -456,6 +460,35 @@
- }
- }
- + for (i = 0; i < G_N_ELEMENTS(sized_tray_icons); i++)
- + {
- + normal = gtk_icon_set_new();
- + if (sized_tray_icons[i].translucent_name)
- + translucent = gtk_icon_set_new();
- +
- +#define ADD_SIZED_ICON(name, size) \
- + if (sized_tray_icons[i].name) { \
- + add_sized_icon(normal, name, PIDGIN_ICON_THEME(theme), size, sized_tray_icons[i], FALSE, TRUE); \
- + if (sized_tray_icons[i].translucent_name) \
- + add_sized_icon(translucent, name, PIDGIN_ICON_THEME(theme), size, sized_tray_icons[i], TRUE, TRUE); \
- + }
- + ADD_SIZED_ICON(microscopic, "11");
- + ADD_SIZED_ICON(extra_small, "16");
- + ADD_SIZED_ICON(small, "22");
- + ADD_SIZED_ICON(medium, "32");
- + ADD_SIZED_ICON(large, "48");
- + ADD_SIZED_ICON(huge, "64");
- +#undef ADD_SIZED_ICON
- +
- + gtk_icon_factory_add(icon_factory, sized_tray_icons[i].name, normal);
- + gtk_icon_set_unref(normal);
- +
- + if (sized_tray_icons[i].translucent_name) {
- + gtk_icon_factory_add(icon_factory, sized_tray_icons[i].translucent_name, translucent);
- + gtk_icon_set_unref(translucent);
- + }
- + }
- +
- gtk_widget_destroy(win);
- g_object_unref(G_OBJECT(icon_factory));
- reload_settings();
- @@ -527,7 +560,7 @@
- #define ADD_SIZED_ICON(name, size) \
- if (sized_stock_icons[i].name) \
- - add_sized_icon(iconset, name, PIDGIN_ICON_THEME(theme), size, sized_stock_icons[i], FALSE);
- + add_sized_icon(iconset, name, PIDGIN_ICON_THEME(theme), size, sized_stock_icons[i], FALSE, FALSE);
- ADD_SIZED_ICON(microscopic, "11");
- ADD_SIZED_ICON(extra_small, "16");
- ADD_SIZED_ICON(small, "22");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement