3 * Copyright (C) 2009-2010 troorl
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * troorl <troorl@gmail.com>
24 public class TrayIcon : StatusIcon {
26 private MainWindow parent;
28 private Gdk.Pixbuf logo;
29 private Gdk.Pixbuf logo_fresh;
34 set{ _popup = value; }
37 public TrayIcon(MainWindow _parent, Prefs _prefs, Gdk.Pixbuf _logo,
38 Gdk.Pixbuf _logo_fresh) {
45 var theme = IconTheme.get_default();
47 if(!theme.has_icon("pino-tray-icon")) {
51 var info = theme.lookup_icon("pino-tray-icon", 22, IconLookupFlags.USE_BUILTIN);
52 logo = info.load_icon();
55 if(!theme.has_icon("pino-tray-icon")) {
57 logo_fresh = _logo_fresh;
59 var info = theme.lookup_icon("pino-tray-icon-fresh", 22, IconLookupFlags.USE_BUILTIN);
60 logo_fresh = info.load_icon();
64 set_from_pixbuf(logo);
65 parent.set_icon(logo);
67 set_tooltip_text(_("%s - not only a twitter client").printf(Config.APPNAME));
69 popup_menu.connect((button, activate_time) => {
70 _popup.popup(null, null, null, button, activate_time);
73 activate.connect(() => {
77 if(parent.first_show) {
80 parent.first_show = false;
85 parent.move(prefs.left, prefs.top);
90 var server = Indicate.Server.ref_default();
92 server.set_type("message.pino");
93 server.set_desktop_file(Config.DESKTOP_FILE_PATH);
94 server.server_display.connect(dirty_activate);
98 indicator = new Indicate.Indicator();
99 indicator.set_property("subtype", "pino");
100 indicator.set_property("sender", "troorl");
101 indicator.set_property("body", "bla bla bla");
102 indicator.user_display.connect(dirty_activate);
109 private void dirty_activate() {
111 Process.spawn_async(null, {Config.APP_PATH, "/"}, null,
112 GLib.SpawnFlags.STDERR_TO_DEV_NULL, null, null);
113 } catch(GLib.SpawnError e) {
118 public void new_tweets(bool y) {
120 set_from_pixbuf(logo_fresh);
121 parent.set_icon(logo_fresh);
124 set_from_pixbuf(logo);
125 parent.set_icon(logo);