~timchen119/ubuntu/trusty/gnome-bluetooth/lp1035431

« back to all changes in this revision

Viewing changes to applet/notify.c

  • Committer: Bazaar Package Importer
  • Author(s): Emilio Pozuelo Monfort
  • Date: 2011-02-27 15:45:22 UTC
  • mfrom: (1.3.2 upstream)
  • mto: (2.2.3 experimental) (1.5.1)
  • mto: This revision was merged to the branch mainline in revision 53.
  • Revision ID: james.westby@ubuntu.com-20110227154522-dnnoqasv5v3mv42a
Tags: upstream-2.91.5
ImportĀ upstreamĀ versionĀ 2.91.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include <libnotify/notify.h>
32
32
#include "notify.h"
33
33
 
 
34
#define ACTIVE_ICON_NAME "bluetooth-active"
 
35
#define DISABLE_ICON_NAME "bluetooth-disabled"
 
36
 
34
37
static GtkStatusIcon *statusicon = NULL;
35
 
static char *icon_name = NULL;
 
38
static gboolean bt_enabled = FALSE;
 
39
static GIcon *icon_enabled = NULL, *icon_disabled = NULL;
36
40
static char *tooltip = NULL;
37
41
static NotifyNotification *notify = NULL;
38
42
 
71
75
                notify_notification_close(notify, NULL);
72
76
        }
73
77
 
74
 
        notify = notify_notification_new(summary, message, icon_name, NULL);
 
78
        notify = notify_notification_new(summary, message, ACTIVE_ICON_NAME);
75
79
 
76
80
        notify_notification_set_timeout(notify, timeout);
77
81
 
110
114
{
111
115
        notify_init("bluetooth-manager");
112
116
 
113
 
        statusicon = gtk_status_icon_new_from_icon_name(icon_name);
 
117
        icon_enabled = g_themed_icon_new_with_default_fallbacks (ACTIVE_ICON_NAME"-symbolic");
 
118
        icon_disabled = g_themed_icon_new_with_default_fallbacks (DISABLE_ICON_NAME"-symbolic");
 
119
 
 
120
        statusicon = gtk_status_icon_new_from_gicon(bt_enabled ? icon_enabled : icon_disabled);
 
121
        gtk_status_icon_set_title (GTK_STATUS_ICON (statusicon),
 
122
                                   _("Bluetooth"));
114
123
        gtk_status_icon_set_tooltip_markup(statusicon, tooltip);
115
124
 
 
125
        /* XXX: Make sure the status icon is actually shown */
 
126
        gtk_status_icon_set_visible(statusicon, FALSE);
 
127
        gtk_status_icon_set_visible(statusicon, TRUE);
 
128
 
116
129
        return statusicon;
117
130
}
118
131
 
120
133
{
121
134
        close_notification();
122
135
 
123
 
        g_object_unref(statusicon);
124
 
 
125
 
        g_free (icon_name);
126
 
        icon_name = NULL;
 
136
        g_object_unref (statusicon);
 
137
        g_object_unref (icon_enabled);
 
138
        g_object_unref (icon_disabled);
127
139
        g_free (tooltip);
128
140
        tooltip = NULL;
129
141
 
144
156
 
145
157
void set_icon(gboolean enabled)
146
158
{
147
 
        const char *name = (enabled ? "bluetooth-active" : "bluetooth-disabled");
148
159
        const char *_tooltip = enabled ? _("Bluetooth: Enabled") : _("Bluetooth: Disabled");
149
160
 
 
161
        bt_enabled = enabled;
 
162
 
150
163
        if (statusicon == NULL) {
151
 
                g_free (icon_name);
152
164
                g_free (tooltip);
153
 
                icon_name = g_strdup (name);
154
165
                tooltip = g_strdup (_tooltip);
155
166
        } else {
156
 
                gtk_status_icon_set_from_icon_name (statusicon, name);
 
167
                gtk_status_icon_set_from_gicon (statusicon, enabled ? icon_enabled : icon_disabled);
157
168
                gtk_status_icon_set_tooltip_markup(statusicon, _tooltip);
158
169
        }
159
170
}
160
 
 
161
 
void enable_blinking(void)
162
 
{
163
 
        gtk_status_icon_set_blinking(statusicon, TRUE);
164
 
}
165
 
 
166
 
void disable_blinking(void)
167
 
{
168
 
        gtk_status_icon_set_blinking(statusicon, FALSE);
169
 
}
170
 
 
171
 
gboolean query_blinking(void)
172
 
{
173
 
        return gtk_status_icon_get_blinking(statusicon);
174
 
}