~ubuntu-branches/ubuntu/vivid/liferea/vivid-proposed

« back to all changes in this revision

Viewing changes to .pc/libunity.patch/src/ui/ui_tray.c

  • Committer: Package Import Robot
  • Author(s): bojo42
  • Date: 2012-03-29 14:17:21 UTC
  • mfrom: (1.3.9) (3.2.5 sid)
  • Revision ID: package-import@ubuntu.com-20120329141721-tbfopcrc5797wxt7
Tags: 1.8.3-0.1ubuntu1
* New upstream release (LP: #290666, #371754, #741543, #716688)
* Merge from Debian unstable (LP: #935147), remaining changes:
* debian/patches:
  - drop gtk-status-icon.patch & notification-append as in upstream
  - drop fix_systray_behavior as mostly upstreamed and rest seems unused
  - 01_ubuntu_feedlists: update & rename, move planets to "Open Source"  
  - add_X-Ubuntu-Gettext-Domain: rebase
  - libunity.patch: rebase, apply before indicator patch (liferea_shell.c)
  - libindicate_increase_version.patch: exclude from libindicate.patch
  - deactivate libindicate.patch, seems partly upstreamed and needs rework
* debian/control: libindicate-dev, libindicate-gtk-dev & libunity-dev
* debian/liferea.indicate & liferea.install: ship indicator desktop file
* debian/rules: enable libindicate

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
2
 * @file ui_tray.c tray icon handling
3
3
 * 
4
 
 * Copyright (C) 2003-2009 Lars Lindner <lars.lindner@gmail.com>
 
4
 * Copyright (C) 2003-2011 Lars Lindner <lars.lindner@gmail.com>
5
5
 * Copyright (C) 2004 Christophe Barbe <christophe.barbe@ufies.org>
6
6
 * Copyright (C) 2009 Hubert Figuiere <hub@figuiere.net>
7
7
 *
20
20
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21
21
 */
22
22
 
23
 
#ifdef HAVE_CONFIG_H
24
 
#  include <config.h>
25
 
#endif
26
 
 
27
23
#include <math.h>
28
24
#include <string.h>
29
25
#include <gtk/gtk.h>
32
28
#include "common.h"
33
29
#include "conf.h"
34
30
#include "feedlist.h"
35
 
#include "net.h"
 
31
#include "net_monitor.h"
36
32
#include "ui/liferea_shell.h"
37
 
#include "ui/ui_common.h"
 
33
#include "ui/icons.h"
 
34
#include "ui/popup_menu.h"
38
35
#include "ui/ui_indicator.h"
39
 
#include "ui/ui_popup.h"
40
36
#include "ui/ui_tray.h"
41
37
 
42
38
// FIXME: determine this from Pango or Cairo somehow...
52
48
 
53
49
static void ui_tray_install(void);
54
50
 
 
51
GtkStatusIcon*
 
52
ui_tray_get_status_icon (void)
 
53
{
 
54
        if (!trayIcon_priv)
 
55
                return NULL;
 
56
 
 
57
        return trayIcon_priv->status_icon;
 
58
}
 
59
 
55
60
static void
56
61
ui_tray_tooltip_set (const gchar *message)
57
62
{
65
70
        cairo_surface_t *cs;
66
71
        gchar           *str;
67
72
        guint           newItems;
 
73
        gboolean        show_new_count_in_tray;
68
74
        gint            size, i, j;
69
75
        gint            w, h;
70
76
        int             stride, pstride;
87
93
        } else {
88
94
                size = MAX(h,w);
89
95
        }
90
 
        
91
 
        if(!conf_get_bool_value(SHOW_NEW_COUNT_IN_TRAY))
 
96
 
 
97
        conf_get_bool_value (SHOW_NEW_COUNT_IN_TRAY, &show_new_count_in_tray);
 
98
        if (!show_new_count_in_tray)
92
99
                return trayIcon_priv->currentIcon;
93
100
        
94
101
        newItems = feedlist_get_new_item_count();
102
109
        cairo_paint (c);
103
110
 
104
111
        if(newItems > 0) {
105
 
                guint textWidth, textStart;
 
112
                gint textWidth, textStart;
106
113
                /* GtkStatusIcon doesn't allow non-square icons yet, so the
107
114
                 * part that doesn't fit is just cropped. Don't put a large
108
115
                 * text there then, otherwise it won't appear entirely.
160
167
 
161
168
 
162
169
static void
163
 
ui_tray_icon_set (gint newItems, GdkPixbuf *icon)
 
170
ui_tray_icon_set (gint newItems, const GdkPixbuf *icon)
164
171
{
 
172
        gboolean        show_new_count_in_tray;
165
173
 
166
174
        g_assert (trayIcon_priv->status_icon);
167
175
 
168
176
        /* Having two code branches here to have real transparency
169
177
           at least with new count disabled... */
170
 
        if (conf_get_bool_value (SHOW_NEW_COUNT_IN_TRAY)) {     
171
 
 
172
 
                trayIcon_priv->currentIcon = icon;
173
 
 
 
178
        conf_get_bool_value (SHOW_NEW_COUNT_IN_TRAY, &show_new_count_in_tray);
 
179
        
 
180
        if (show_new_count_in_tray) {
 
181
                trayIcon_priv->currentIcon = (GdkPixbuf *)icon;
174
182
                gtk_status_icon_set_from_pixbuf (trayIcon_priv->status_icon, ui_tray_make_icon ());
175
183
        } else {
176
184
                /* Skip loading icon if already displayed. */
177
185
                if (icon == trayIcon_priv->currentIcon)
178
186
                        return;
179
 
                trayIcon_priv->currentIcon = icon;
180
 
                gtk_status_icon_set_from_pixbuf(trayIcon_priv->status_icon, icon);
 
187
                        
 
188
                trayIcon_priv->currentIcon = (GdkPixbuf *)icon;
 
189
                gtk_status_icon_set_from_pixbuf(trayIcon_priv->status_icon, trayIcon_priv->currentIcon);
181
190
        }
182
191
}
183
192
 
192
201
        if (!trayIcon_priv)
193
202
                return;
194
203
 
 
204
        /* The indicator overrides the tray icon. If the indicator applet
 
205
           is present, we hide the tray icon and use the indicator instead.
 
206
           Application logic in that case, however, stays as if the tray
 
207
           icon was shown, so the application can be, e.g., minimized to
 
208
           the indicator. */
195
209
        if (ui_indicator_is_visible ()) {
196
210
                gtk_status_icon_set_visible (trayIcon_priv->status_icon, FALSE);
197
211
                return;
203
217
        unreadItems = feedlist_get_unread_item_count ();
204
218
                
205
219
        if (newItems != 0) {
206
 
                if (network_is_online ())
207
 
                        ui_tray_icon_set (newItems, icons[ICON_AVAILABLE]);
208
 
                else
209
 
                        ui_tray_icon_set (newItems, icons[ICON_AVAILABLE_OFFLINE]);
210
 
                        
 
220
                ui_tray_icon_set (newItems, icon_get (network_monitor_is_online ()?ICON_AVAILABLE:ICON_AVAILABLE_OFFLINE));
211
221
                msg = g_strdup_printf (ngettext ("%d new item", "%d new items", newItems), newItems);
212
222
        } else {
213
 
                if (network_is_online ())
214
 
                        ui_tray_icon_set (newItems, icons[ICON_EMPTY]);
215
 
                else
216
 
                        ui_tray_icon_set (newItems, icons[ICON_EMPTY_OFFLINE]);
217
 
                        
 
223
                ui_tray_icon_set (newItems, icon_get (network_monitor_is_online ()?ICON_EMPTY:ICON_EMPTY_OFFLINE));
218
224
                msg = g_strdup (_("No new items"));
219
225
        }
220
226
 
229
235
}
230
236
 
231
237
 
 
238
 
232
239
static void
233
240
tray_icon_popup (GtkStatusIcon *status_icon,
234
241
                 guint          button,
261
268
        g_signal_connect(trayIcon_priv->status_icon, "popup-menu",
262
269
                         G_CALLBACK(tray_icon_popup), NULL);
263
270
        
264
 
// No URL dropping support on the status icon.
265
 
// liferea_shell_setup_URL_receiver (trayIcon_priv->eventBox);
266
 
        
267
271
        ui_tray_update();
268
272
        trayIcon_priv->trayCount++;
269
273
}
285
289
        if(enabled) {
286
290
                if(!trayIcon_priv)
287
291
                        ui_tray_install();
 
292
                
 
293
                ui_indicator_init ();
288
294
        } else {
289
295
                if(trayIcon_priv)
290
296
                        ui_tray_remove();
 
297
                
 
298
                ui_indicator_destroy ();
291
299
        }
292
300
}
293
301