~ubuntu-branches/ubuntu/trusty/blam/trusty

« back to all changes in this revision

Viewing changes to src/Application.cs

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2006-03-14 14:57:31 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060314145731-8ksmc4mhwzk3bn1j
Tags: 1.8.2+cvs20060124-0ubuntu1
* New CVS snapshot
* egg-sharp.diff:
  + Fix the TrayIcon breakage by replacing it with generic TrayIcon
    implementation used by banshee, beagle, etc
* firefox.diff:
  + Fix build with firefox 1.5
    (Closes: Malone #4839, #5354, #5876, #32758, #34368, #34581)
* gtk-sharp2.diff:
  + Build with Gtk#2

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
using Gtk;
12
12
using GtkSharp;
13
13
using Gnome;
14
 
using Mono.Posix;
 
14
using Mono.Unix;
15
15
using System;
16
16
using System.Collections;
17
17
using System.IO;
20
20
namespace Imendio.Blam {
21
21
 
22
22
    public class Application : Program {
23
 
        public static Application TheApp;
24
 
        
25
 
        [Widget] Gtk.Window         mainWindow = null;
26
 
        [Widget] Gtk.ScrolledWindow channelListSw = null;
27
 
        [Widget] Gtk.ScrolledWindow itemListSw = null;
28
 
        [Widget] Gtk.Paned          channelPaned = null;
29
 
        [Widget] Gtk.Paned          itemPaned = null;
30
 
        [Widget] Gtk.Label          blogNameLabel = null;
31
 
        [Widget] Gtk.Statusbar      statusbar = null;
32
 
        [Widget] Gtk.Label          channelsLabel = null;
33
 
        private string              channelsLabelText;
34
 
 
35
 
        [Widget] Gtk.MenuItem       refreshChannelMenuItem = null;
36
 
        [Widget] Gtk.MenuItem       markChannelAsReadMenuItem = null;
37
 
        [Widget] Gtk.MenuItem       removeChannelMenuItem = null;
38
 
        [Widget] Gtk.MenuItem       editChannelMenuItem = null;
39
 
        
40
 
        [Widget] Gtk.MenuItem       markEntryAsUnreadMenuItem = null;
41
 
        [Widget] Gtk.MenuItem       nextUnreadMenuItem = null;
42
 
        
 
23
        public static Application TheApp;
 
24
 
 
25
        [Widget] Gtk.Window         mainWindow = null;
 
26
        [Widget] Gtk.ScrolledWindow channelListSw = null;
 
27
        [Widget] Gtk.ScrolledWindow itemListSw = null;
 
28
        [Widget] Gtk.Paned          channelPaned = null;
 
29
        [Widget] Gtk.Paned          itemPaned = null;
 
30
        [Widget] Gtk.Label          blogNameLabel = null;
 
31
        [Widget] Gtk.Statusbar      statusbar = null;
 
32
        [Widget] Gtk.Label          channelsLabel = null;
 
33
        private string              channelsLabelText;
 
34
 
 
35
        [Widget] Gtk.MenuItem       refreshChannelMenuItem = null;
 
36
        [Widget] Gtk.MenuItem       markChannelAsReadMenuItem = null;
 
37
        [Widget] Gtk.MenuItem       removeChannelMenuItem = null;
 
38
        [Widget] Gtk.MenuItem       editChannelMenuItem = null;
 
39
 
 
40
        [Widget] Gtk.MenuItem       markEntryAsUnreadMenuItem = null;
 
41
        [Widget] Gtk.MenuItem       editEntryKeywordsMenuItem = null;
 
42
        [Widget] Gtk.MenuItem       nextUnreadMenuItem = null;
 
43
 
43
44
        //[Widget] Gtk.MenuItem       printMenuItem;
44
45
 
45
 
        private Gtk.FileSelection   exportFileDialog;
46
 
        
47
 
        private ChannelList channelList;
48
 
        private ItemList    itemList;
49
 
        private ItemView    itemView;
50
 
 
51
 
        private TrayIcon    trayIcon;
52
 
 
53
 
        public static string BaseDir;
54
 
        
55
 
        private MessageConnection messageConn;
56
 
 
57
 
        private AddChannelDialog  addChannelDialog;
58
 
        private ChannelDialog     channelDialog;
59
 
        private PreferencesDialog preferencesDialog;
60
 
        private OpmlDialog        opmlDialog;
61
 
        
62
 
        private ChannelCollection mCollection;
63
 
 
64
 
        private uint              mAutoRefreshId;
65
 
 
66
 
        private MessageConnection.MessageReceivedHandler mIpcHandler;
67
 
        
68
 
        enum TargetType {
69
 
            String,
70
 
            UriList
71
 
        };
72
 
 
73
 
        public static TargetEntry[] DragEntries = new TargetEntry[] {
74
 
            new TargetEntry("STRING", 0, (uint)TargetType.String),
75
 
            new TargetEntry("text/plain", 0, (uint)TargetType.String),
76
 
            new TargetEntry("text/uri-list", 0, (uint)TargetType.UriList)
77
 
        };
78
 
 
79
 
        public Gtk.Window Window {
80
 
            get {
81
 
                return (Gtk.Window) mainWindow;
82
 
            }
83
 
        }
84
 
 
85
 
        public ChannelCollection CCollection {
86
 
            get {
87
 
                return mCollection;
88
 
            }
89
 
        }
90
 
 
91
 
        public ItemList ItemList {
92
 
            get {
93
 
                return itemList;
94
 
            }
95
 
        }
96
 
        
 
46
        private Gtk.FileSelection   exportFileDialog;
 
47
 
 
48
        private ChannelList channelList;
 
49
        private ItemList    itemList;
 
50
        private ItemView    itemView;
 
51
 
 
52
        private ThemeManager mThemeManager;
 
53
 
 
54
        private TrayIcon    trayIcon;
 
55
 
 
56
        public static string BaseDir;
 
57
 
 
58
        private MessageConnection messageConn;
 
59
 
 
60
        private AddChannelDialog  addChannelDialog;
 
61
        private ChannelDialog     channelDialog;
 
62
        private PreferencesDialog preferencesDialog;
 
63
        private OpmlDialog        opmlDialog;
 
64
 
 
65
        private ChannelCollection mCollection;
 
66
 
 
67
        private uint              mAutoRefreshId;
 
68
 
 
69
 
 
70
        private MessageConnection.MessageReceivedHandler mIpcHandler;
 
71
 
 
72
        enum TargetType {
 
73
            String,
 
74
            UriList
 
75
        };
 
76
 
 
77
        public static TargetEntry[] DragEntries = new TargetEntry[] {
 
78
            new TargetEntry("STRING", 0, (uint)TargetType.String),
 
79
            new TargetEntry("text/plain", 0, (uint)TargetType.String),
 
80
            new TargetEntry("text/uri-list", 0, (uint)TargetType.UriList)
 
81
        };
 
82
 
 
83
        public Gtk.Window Window {
 
84
            get {
 
85
                return(Gtk.Window) mainWindow;
 
86
            }
 
87
        }
 
88
 
 
89
        public ChannelCollection CCollection {
 
90
            get {
 
91
                return mCollection;
 
92
            }
 
93
        }
 
94
 
 
95
        public ItemList ItemList {
 
96
            get {
 
97
                return itemList;
 
98
            }
 
99
        }
 
100
 
 
101
                public ThemeManager ThemeManager {
 
102
                        get {
 
103
                                return mThemeManager;
 
104
                        }
 
105
                }
 
106
 
97
107
        public Application (string[] args, params object[] props) : base ("Blam", Defines.VERSION, Modules.UI, args, props)
98
108
        {
99
 
            messageConn = new MessageConnection ("Blam");
100
 
            if (!messageConn.IsServer) {
101
 
                messageConn.Send ("ShowWindow");
102
 
                messageConn.Close ();
103
 
                Gdk.Global.NotifyStartupComplete ();
104
 
                Environment.Exit (0);
105
 
            }
106
 
 
107
 
            mIpcHandler = new MessageConnection.MessageReceivedHandler (MessageReceivedCb) ;
108
 
            messageConn.SetCallback (mIpcHandler);
109
 
 
110
 
            Proxy.InitProxy ();
 
109
            messageConn = new MessageConnection ("Blam");
 
110
            if (!messageConn.IsServer) {
 
111
                messageConn.Send ("ShowWindow");
 
112
                messageConn.Close ();
 
113
                Gdk.Global.NotifyStartupComplete ();
 
114
                Environment.Exit (0);
 
115
            }
 
116
 
 
117
            mIpcHandler = new MessageConnection.MessageReceivedHandler (MessageReceivedCb) ;
 
118
            messageConn.SetCallback (mIpcHandler);
 
119
 
 
120
            Proxy.InitProxy ();
111
121
            Utils.GeckoInit ();
112
122
 
113
 
            string homeDirectory = Environment.GetEnvironmentVariable("HOME");
114
 
 
115
 
            Mono.Posix.Catalog.Init ("blam", Defines.GNOME_LOCALE_DIR);
116
 
 
117
 
            BaseDir = homeDirectory + "/.gnome2/blam";
118
 
            if (!File.Exists(BaseDir)) {
119
 
                Directory.CreateDirectory(BaseDir);
120
 
            }
121
 
 
122
 
            mCollection = ChannelCollection.LoadFromFile (BaseDir + "/collection.xml");
123
 
 
124
 
            mCollection.ChannelUpdated         += ChannelUpdatedCb;
125
 
            mCollection.ChannelAdded           += ChannelAddedCb;
126
 
            mCollection.ChannelRemoved         += ChannelRemovedCb;
127
 
            mCollection.ChannelRefreshStarted  += ChannelRefreshStartedCb;
128
 
            mCollection.ChannelRefreshFinished += ChannelRefreshFinishedCb;
 
123
            Catalog.Init ("blam", Defines.GNOME_LOCALE_DIR);
 
124
 
 
125
            if (!File.Exists(BaseDir)) {
 
126
                Directory.CreateDirectory(Defines.APP_HOMEDIR);
 
127
            }
 
128
 
 
129
            mCollection = ChannelCollection.LoadFromFile (Defines.APP_HOMEDIR + "/collection.xml");
 
130
 
 
131
            mCollection.ChannelUpdated         += ChannelUpdatedCb;
 
132
            mCollection.ChannelAdded           += ChannelAddedCb;
 
133
            mCollection.ChannelRemoved         += ChannelRemovedCb;
 
134
            mCollection.ChannelRefreshStarted  += ChannelRefreshStartedCb;
 
135
            mCollection.ChannelRefreshFinished += ChannelRefreshFinishedCb;
 
136
 
 
137
            mThemeManager = new ThemeManager ();
129
138
 
130
139
            PrepareGUI();
131
140
 
132
 
            Conf.AddNotify (new NotifyEventHandler (ConfNotifyHandler));
133
 
            // Uncommented until support for checking whether a channels should
134
 
            // be refreshed on startup.
135
 
            //GLib.Idle.Add (new GLib.IdleHandler (IdleRefreshAll));
136
 
        }
137
 
            
138
 
        private void PrepareGUI()
139
 
        {
140
 
            Glade.XML gladeXML = Glade.XML.FromAssembly("blam.glade",
141
 
                                                        "mainWindow", null);
142
 
            gladeXML.Autoconnect(this);
143
 
                                              
144
 
            channelList = new ChannelList(mCollection.Channels);
145
 
            ((Container)channelListSw).Child = channelList;
146
 
 
147
 
            channelList.ChannelSelectedEvent   += ChannelSelected;
148
 
            channelList.EditChannelEvent       += EditChannelActivated;
149
 
            channelList.MarkChannelAsReadEvent += MarkChannelAsReadActivated;
150
 
            channelList.RemoveChannelEvent     += RemoveChannelActivated;
151
 
            channelList.RefreshChannelEvent    += RefreshChannelActivated;
152
 
           
153
 
            itemView = new ItemView ();
 
141
            Conf.AddNotify (new NotifyEventHandler (ConfNotifyHandler));
 
142
 
 
143
            GLib.Idle.Add (new GLib.IdleHandler (IdleRefreshAll));
 
144
 
 
145
            SetupDBus ();
 
146
        }
 
147
 
 
148
        private void PrepareGUI()
 
149
        {
 
150
            Glade.XML gladeXML = Glade.XML.FromAssembly("blam.glade",
 
151
                                                        "mainWindow", null);
 
152
            gladeXML.Autoconnect(this);
 
153
 
 
154
            channelList = new ChannelList(mCollection.Channels);
 
155
            ((Container)channelListSw).Child = channelList;
 
156
 
 
157
            channelList.ChannelSelectedEvent   += ChannelSelected;
 
158
            channelList.EditChannelEvent       += EditChannelActivated;
 
159
            channelList.MarkChannelAsReadEvent += MarkChannelAsReadActivated;
 
160
            channelList.RemoveChannelEvent     += RemoveChannelActivated;
 
161
            channelList.RefreshChannelEvent    += RefreshChannelActivated;
 
162
 
 
163
            itemView = new ItemView ();
154
164
 
155
165
            Frame f = new Frame ();
156
166
            f.Shadow = ShadowType.In;
159
169
            f.Show ();
160
170
            itemView.OnUrl += OnUrl;
161
171
 
162
 
            itemList = new ItemList(itemView);
 
172
            itemList = new ItemList(itemView);
163
173
            ((Container)itemListSw).Child = itemList;
164
174
 
165
 
            itemList.ItemSelected += ItemSelected;
166
 
 
167
 
            trayIcon = new TrayIcon (Catalog.GetString ("Imendio Blam News Reader"));
168
 
            trayIcon.Image.Pixbuf = Gdk.Pixbuf.LoadFromResource ("blam-tray-icon.png");
169
 
            trayIcon.ButtonPressEvent += TrayIconButtonPressCb;
170
 
            channelsLabelText = channelsLabel.Text;
171
 
            UpdateTotalNumberOfUnread ();
172
 
            
173
 
            //printMenuItem.Sensitive = false;
174
 
            SensitizeChannelMenuItems(false);
175
 
 
176
 
            // Setup drag-n-drop
177
 
            Gtk.Drag.DestSet(mainWindow, DestDefaults.All,
178
 
                             DragEntries, DragAction.Copy | DragAction.Move);
179
 
            mainWindow.DragDataReceived += DragDataReceivedCb;
180
 
 
181
 
            RestoreWindowState();
182
 
 
183
 
            mainWindow.Icon = Gdk.Pixbuf.LoadFromResource("blam.png");
184
 
            
 
175
            itemList.ItemSelected += ItemSelected;
 
176
 
 
177
            trayIcon = new TrayIcon (Catalog.GetString ("Imendio Blam News Reader"));
 
178
            trayIcon.Image.Pixbuf = Gdk.Pixbuf.LoadFromResource ("blam-tray-icon.png");
 
179
            trayIcon.ButtonPressEvent += TrayIconButtonPressCb;
 
180
            channelsLabelText = channelsLabel.Text;
 
181
            UpdateTotalNumberOfUnread ();
 
182
 
 
183
            //printMenuItem.Sensitive = false;
 
184
            SensitizeChannelMenuItems(false);
 
185
 
 
186
            // Setup drag-n-drop
 
187
            Gtk.Drag.DestSet(mainWindow, DestDefaults.All,
 
188
                             DragEntries, DragAction.Copy | DragAction.Move);
 
189
            mainWindow.DragDataReceived += DragDataReceivedCb;
 
190
 
 
191
            RestoreWindowState();
 
192
 
 
193
            mainWindow.Icon = Gdk.Pixbuf.LoadFromResource("blam.png");
 
194
 
185
195
            mainWindow.ShowAll ();
186
 
            
187
 
            channelDialog = new ChannelDialog (this);
188
 
            addChannelDialog = new AddChannelDialog (this);
189
 
            preferencesDialog = new PreferencesDialog (this.Window);
190
 
            opmlDialog = new OpmlDialog (this.Window);
191
 
            opmlDialog.ChannelAdded += mCollection.Add;
192
 
            opmlDialog.ImportFinished += OpmlImportFinished;
193
 
 
194
 
        }
195
 
 
196
 
        private void ChannelSelected(Channel channel)
197
 
        {
198
 
            if (channel == null) {
199
 
                SensitizeChannelMenuItems(false);
200
 
                return;
201
 
            }
202
 
            
203
 
            itemList.CurrentChannel = channel;
204
 
            
205
 
            blogNameLabel.Markup = "<b>" + channel.Name + "</b>";
206
 
            mainWindow.Title = "Blam - " + channel.Name;
207
 
            
208
 
            SensitizeChannelMenuItems(true);
209
 
        }
210
 
 
211
 
        private void SensitizeChannelMenuItems (bool sensitive)
212
 
        {
213
 
            refreshChannelMenuItem.Sensitive = sensitive;
214
 
            removeChannelMenuItem.Sensitive = sensitive;
215
 
            editChannelMenuItem.Sensitive = sensitive;
216
 
            markChannelAsReadMenuItem.Sensitive = sensitive;
217
 
        }
218
 
        
219
 
        private void ItemSelected(Imendio.Blam.Item item)
220
 
        {
221
 
            itemView.CurrentItem = item;
222
 
            //printMenuItem.Sensitive = true;
223
 
        }
224
 
 
225
 
        public void MarkEntryAsUnreadActivated (object obj, EventArgs args)
226
 
        {
227
 
            Item item = itemList.GetSelected ();
228
 
            if (item == null) {
229
 
                return;
230
 
            }
231
 
 
232
 
            // Toggle unread status
233
 
            item.SetUnread (!item.Unread, false);
234
 
        }
235
 
 
236
 
        public void MenuChannelActivated (object obj, EventArgs args)
237
 
        {
238
 
            Channel channel = channelList.GetSelected ();
239
 
 
240
 
            bool sensitive = true;
241
 
            if (channel == null) {
242
 
                sensitive = false;
243
 
            }
244
 
            
245
 
            SensitizeChannelMenuItems (sensitive);
246
 
        }
247
 
 
248
 
        public void MenuEntryActivated (object obj, EventArgs args)
249
 
        {
250
 
            Item item = itemList.GetSelected ();
251
 
 
252
 
            if (item == null) {
253
 
                markEntryAsUnreadMenuItem.Sensitive = false;
254
 
                return;
255
 
            }
256
 
 
257
 
            markEntryAsUnreadMenuItem.Sensitive = true;
258
 
 
259
 
            string str = "";
260
 
            if (!item.Unread) {
261
 
                str = Catalog.GetString ("_Mark as unread");
262
 
            } else {
263
 
                str = Catalog.GetString ("_Mark as read");
264
 
            }
265
 
 
266
 
            ((Label) markEntryAsUnreadMenuItem.Child).TextWithMnemonic = str;
267
 
        }
268
 
 
269
 
        public void NextUnreadActivated(object obj, EventArgs args)
270
 
        {
271
 
            if (channelList.NextUnread()) {
272
 
                itemList.NextUnread();
273
 
            }
274
 
        }
275
 
  
276
 
        public void MainWindowKeyPressed (object obj, KeyPressEventArgs args)
277
 
        {
278
 
            switch (args.Event.Key) {
279
 
            case (Gdk.Key.period):
280
 
            case (Gdk.Key.bracketright):
281
 
                // Couldn't figure out how to get this to the menu item itself.
282
 
                nextUnreadMenuItem.Activate ();
283
 
                break;
 
196
 
 
197
            channelDialog = new ChannelDialog (this);
 
198
            addChannelDialog = new AddChannelDialog (this);
 
199
            preferencesDialog = new PreferencesDialog (this.Window);
 
200
            opmlDialog = new OpmlDialog (this.Window);
 
201
            opmlDialog.ChannelAdded += mCollection.Add;
 
202
            opmlDialog.ImportFinished += OpmlImportFinished;
 
203
 
 
204
        }
 
205
 
 
206
#if ENABLE_DBUS
 
207
        private DBus.Connection dbusConnection;
 
208
        private void SetupDBus ()
 
209
        {
 
210
            try {
 
211
                this.dbusConnection = DBus.Bus.GetSessionBus ();
 
212
                DBus.Service service = new DBus.Service (this.dbusConnection, DBusFeedReaderProxy.Service);
 
213
 
 
214
                DBusFeedReader feedReader = new DBusFeedReader (this);
 
215
                service.RegisterObject(feedReader, DBusFeedReaderProxy.ObjectPath);
 
216
            } catch (Exception e) {
 
217
                Console.WriteLine("Failed to init dbus interface, I won't receive any dbus message, be warned !");
 
218
            }
 
219
        }
 
220
#else
 
221
        private void SetupDBus ()
 
222
        {
 
223
            // Do nothing
 
224
        }
 
225
#endif
 
226
 
 
227
        private void ChannelSelected(Channel channel)
 
228
        {
 
229
            if (channel == null) {
 
230
                SensitizeChannelMenuItems(false);
 
231
                return;
 
232
            }
 
233
 
 
234
            itemList.CurrentChannel = channel;
 
235
 
 
236
            blogNameLabel.Markup = "<b>" + channel.Name + "</b>";
 
237
            mainWindow.Title = "Blam - " + channel.Name;
 
238
 
 
239
            SensitizeChannelMenuItems(true);
 
240
        }
 
241
 
 
242
        private void SensitizeChannelMenuItems (bool sensitive)
 
243
        {
 
244
            refreshChannelMenuItem.Sensitive = sensitive;
 
245
            removeChannelMenuItem.Sensitive = sensitive;
 
246
            editChannelMenuItem.Sensitive = sensitive;
 
247
            markChannelAsReadMenuItem.Sensitive = sensitive;
 
248
            editEntryKeywordsMenuItem.Sensitive = sensitive;
 
249
        }
 
250
 
 
251
        private void ItemSelected(Imendio.Blam.Item item)
 
252
        {
 
253
            itemView.CurrentItem = item;
 
254
            //printMenuItem.Sensitive = true;
 
255
        }
 
256
 
 
257
        public void MarkEntryAsUnreadActivated (object obj, EventArgs args)
 
258
        {
 
259
            Item item = itemList.GetSelected ();
 
260
            if (item == null) {
 
261
                return;
 
262
            }
 
263
 
 
264
            // Toggle unread status
 
265
            item.SetUnread (!item.Unread, false);
 
266
        }
 
267
 
 
268
        public void EditEntryKeywordsActivated (object obj, EventArgs args)
 
269
        {
 
270
            Item item = itemList.GetSelected ();
 
271
            if (item == null) {
 
272
                return;
 
273
            }
 
274
 
 
275
            // FIXME: Show edit keywords dialog
 
276
        }
 
277
 
 
278
        public void MenuChannelActivated (object obj, EventArgs args)
 
279
        {
 
280
            Channel channel = channelList.GetSelected ();
 
281
 
 
282
            bool sensitive = true;
 
283
            if (channel == null) {
 
284
                sensitive = false;
 
285
            }
 
286
 
 
287
            SensitizeChannelMenuItems (sensitive);
 
288
        }
 
289
 
 
290
        public void MenuEntryActivated (object obj, EventArgs args)
 
291
        {
 
292
            Item item = itemList.GetSelected ();
 
293
 
 
294
            if (item == null) {
 
295
                markEntryAsUnreadMenuItem.Sensitive = false;
 
296
                return;
 
297
            }
 
298
 
 
299
            markEntryAsUnreadMenuItem.Sensitive = true;
 
300
 
 
301
            string str = "";
 
302
            if (!item.Unread) {
 
303
                str = Catalog.GetString ("_Mark as unread");
 
304
            } else {
 
305
                str = Catalog.GetString ("_Mark as read");
 
306
            }
 
307
 
 
308
            ((Label) markEntryAsUnreadMenuItem.Child).TextWithMnemonic = str;
 
309
        }
 
310
 
 
311
        public void NextUnreadActivated(object obj, EventArgs args)
 
312
        {
 
313
            if (channelList.NextUnread()) {
 
314
                itemList.NextUnread();
 
315
            }
 
316
        }
 
317
 
 
318
        public void MainWindowKeyPressed (object obj, KeyPressEventArgs args)
 
319
        {
 
320
            switch (args.Event.Key) {
 
321
            case (Gdk.Key.period):
 
322
            case (Gdk.Key.bracketright):
 
323
                // Couldn't figure out how to get this to the menu item itself.
 
324
                nextUnreadMenuItem.Activate ();
 
325
                break;
284
326
            case (Gdk.Key.Escape):
285
327
                mainWindow.Iconify ();
286
328
                break;
287
 
            }
288
 
        }
 
329
            }
 
330
        }
289
331
 
290
332
        /*private void PrintActivated(object obj, EventArgs args)
291
 
        {
292
 
            Blam.PrintDialog dialog = new Blam.PrintDialog(itemView);
293
 
            dialog.Run();
294
 
        }*/
295
 
 
296
 
        public void ImportOpmlActivated (object obj, EventArgs args)
297
 
        {
298
 
            opmlDialog.Show ();
299
 
        }
300
 
 
301
 
        private bool ShowFileExistsDialog (Gtk.Window parentWindow, string fileName)
302
 
        {
303
 
            string str = String.Format (Catalog.GetString ("File {0} already exists"), fileName);
304
 
            
305
 
            string msg = Catalog.GetString ("Do you want to overwrite the file?");
306
 
 
307
 
            Gtk.Dialog dialog = ConfirmationDialog.Create (parentWindow,
308
 
                                                           Catalog.GetString ("_Overwrite"),
309
 
                                                           str, msg);
310
 
 
311
 
            int result = dialog.Run ();
312
 
            dialog.Destroy ();
313
 
 
314
 
            switch (result) {
315
 
            case (int)ResponseType.Ok:
316
 
                return true;
317
 
            }
318
 
            
319
 
            return false;
320
 
        }
321
 
 
322
 
        public void ExportOpmlActivated (object obj, EventArgs args)
323
 
        {
324
 
            if (exportFileDialog == null) {
325
 
                exportFileDialog = new Gtk.FileSelection (Catalog.GetString ("Export to..."));
326
 
                exportFileDialog.Modal = true;
327
 
                exportFileDialog.ShowFileops = true;
328
 
                exportFileDialog.TransientFor = mainWindow;
329
 
            }
330
 
 
331
 
            bool finished = false;
332
 
            bool write = false;
333
 
            string fileName = "";
334
 
 
335
 
            while (!finished) {
336
 
                int result = exportFileDialog.Run ();
337
 
 
338
 
                switch (result) {
339
 
                case (int)ResponseType.Ok:
340
 
                    fileName = exportFileDialog.Filename;
341
 
                    
342
 
                    if (!File.Exists (fileName)) {
343
 
                        write = true;
344
 
                        finished = true;
345
 
                    } else {
346
 
                        write = ShowFileExistsDialog (exportFileDialog, fileName);
347
 
                        if (write) {
348
 
                            finished = true;
349
 
                        }
350
 
                    }
351
 
                    break;
352
 
                case (int)ResponseType.Cancel:
353
 
                    finished = true;
354
 
                    break;
355
 
                }
356
 
            }
357
 
            
358
 
            exportFileDialog.Hide ();
359
 
 
360
 
            if (write) {
361
 
                OpmlWriter.Write (mCollection, fileName);
362
 
            }
363
 
        }
364
 
 
365
 
        private void OpmlImportFinished (string status)
366
 
        {
367
 
            uint contextId = statusbar.GetContextId("status");
368
 
           
369
 
            if (status != null) {
370
 
                statusbar.Push(contextId, status);
371
 
            }
372
 
        }
373
 
 
374
 
        public void QuitActivated(object obj, EventArgs args)
375
 
        {
376
 
            SaveWindowState();
377
 
            mainWindow.Hide();
378
 
 
379
 
            mCollection.SaveToFile ();
380
 
 
381
 
            Quit();
382
 
        }
383
 
 
384
 
        public void CopyActivated (object obj, EventArgs args)
385
 
        {
 
333
    {
 
334
        Blam.PrintDialog dialog = new Blam.PrintDialog(itemView);
 
335
        dialog.Run();
 
336
    }*/
 
337
 
 
338
        public void ImportOpmlActivated (object obj, EventArgs args)
 
339
        {
 
340
            opmlDialog.Show ();
 
341
        }
 
342
 
 
343
        private bool ShowFileExistsDialog (Gtk.Window parentWindow, string fileName)
 
344
        {
 
345
            string str = String.Format (Catalog.GetString ("File {0} already exists"), fileName);
 
346
 
 
347
            string msg = Catalog.GetString ("Do you want to overwrite the file?");
 
348
 
 
349
            Gtk.Dialog dialog = ConfirmationDialog.Create (parentWindow,
 
350
                                                           Catalog.GetString ("_Overwrite"),
 
351
                                                           str, msg);
 
352
 
 
353
            int result = dialog.Run ();
 
354
            dialog.Destroy ();
 
355
 
 
356
            switch (result) {
 
357
            case (int)ResponseType.Ok:
 
358
                return true;
 
359
            }
 
360
 
 
361
            return false;
 
362
        }
 
363
 
 
364
        public void ExportOpmlActivated (object obj, EventArgs args)
 
365
        {
 
366
            if (exportFileDialog == null) {
 
367
                exportFileDialog = new Gtk.FileSelection (Catalog.GetString ("Export to..."));
 
368
                exportFileDialog.Modal = true;
 
369
                exportFileDialog.ShowFileops = true;
 
370
                exportFileDialog.TransientFor = mainWindow;
 
371
            }
 
372
 
 
373
            bool finished = false;
 
374
            bool write = false;
 
375
            string fileName = "";
 
376
 
 
377
            while (!finished) {
 
378
                int result = exportFileDialog.Run ();
 
379
 
 
380
                switch (result) {
 
381
                case (int)ResponseType.Ok:
 
382
                    fileName = exportFileDialog.Filename;
 
383
 
 
384
                    if (!File.Exists (fileName)) {
 
385
                        write = true;
 
386
                        finished = true;
 
387
                    } else {
 
388
                        write = ShowFileExistsDialog (exportFileDialog, fileName);
 
389
                        if (write) {
 
390
                            finished = true;
 
391
                        }
 
392
                    }
 
393
                    break;
 
394
                case (int)ResponseType.Cancel:
 
395
                    finished = true;
 
396
                    break;
 
397
                }
 
398
            }
 
399
 
 
400
            exportFileDialog.Hide ();
 
401
 
 
402
            if (write) {
 
403
                OpmlWriter.Write (mCollection, fileName);
 
404
            }
 
405
        }
 
406
 
 
407
        private void OpmlImportFinished (string status)
 
408
        {
 
409
            uint contextId = statusbar.GetContextId("status");
 
410
 
 
411
            if (status != null) {
 
412
                statusbar.Push(contextId, status);
 
413
            }
 
414
        }
 
415
 
 
416
        public void QuitActivated(object obj, EventArgs args)
 
417
        {
 
418
            SaveWindowState();
 
419
            mainWindow.Hide();
 
420
 
 
421
            mCollection.SaveToFile ();
 
422
 
 
423
            Quit();
 
424
        }
 
425
 
 
426
        public void CopyActivated (object obj, EventArgs args)
 
427
        {
386
428
            // FIXME: Check how to do this
387
429
            //itemView.Copy ();
388
 
        }
389
 
 
390
 
        public void PreferencesActivated (object obj, EventArgs args)
391
 
        {
392
 
            preferencesDialog.Show ();
393
 
        }
394
 
 
395
 
        public void AboutActivated (object obj, EventArgs args)
396
 
        {
397
 
            About.Show (mainWindow);
398
 
        }
399
 
        
400
 
        public void AddChannelActivated (object obj, EventArgs args)
401
 
        {
402
 
            addChannelDialog.Show ();
403
 
        }
404
 
 
405
 
        public void EditChannelActivated (Channel channel)
406
 
        {
407
 
            if (channel != null) {
408
 
                channelDialog.Show (channel);
409
 
            }
410
 
        }
411
 
        
412
 
        public void EditChannelActivated(object obj, EventArgs args)
413
 
        {
414
 
            EditChannelActivated (channelList.GetSelected ());
415
 
        }
416
 
 
417
 
        public void MarkChannelAsReadActivated (Channel channel)
418
 
        {
419
 
            if (channel.MarkAsRead ()) {
420
 
                CCollection.Update (channel);
421
 
            }
422
 
        }
423
 
 
424
 
        public void MarkChannelAsReadActivated (object obj, EventArgs args)
425
 
        {
426
 
            MarkChannelAsReadActivated (channelList.GetSelected ());
427
 
        }
428
 
 
429
 
        public void RemoveChannelActivated(Channel channel)
430
 
        {
431
 
            if (channel != null) {
432
 
                RemoveChannelDialog.Show (mainWindow, mCollection, channel);
433
 
            }
434
 
        }
435
 
 
436
 
        public void RemoveChannelActivated(object obj, EventArgs args)
437
 
        {
438
 
            Channel channel = channelList.GetSelected ();
439
 
 
440
 
            RemoveChannelActivated(channel);
441
 
        }
442
 
 
443
 
        public void RefreshChannelActivated(Channel channel)
444
 
        {
445
 
            if (channel != null) {
446
 
                mCollection.Refresh (channel);
447
 
            }
448
 
        }
449
 
        
450
 
        public void RefreshChannelActivated(object obj, EventArgs args)
451
 
        {
452
 
            Channel channel = channelList.GetSelected ();
453
 
 
454
 
            RefreshChannelActivated(channel);
455
 
        }
456
 
        
457
 
        public void RefreshAllActivated(object obj, EventArgs args)
458
 
        {
459
 
            mCollection.RefreshAll ();
460
 
            
461
 
            StartStopAutoRefresh ();
462
 
        }
463
 
 
464
 
        private void DragDataReceivedCb(object o, DragDataReceivedArgs args)
465
 
        {
466
 
            SelectionData d = args.SelectionData;
467
 
            
468
 
            if (d.Length < 0 && d.Format != 8){
469
 
                Gtk.Drag.Finish(args.Context, false, false, args.Time);
470
 
                return;
471
 
            }
472
 
           
473
 
            Gtk.Drag.Finish(args.Context, true, true, args.Time);
474
 
 
475
 
            UTF8Encoding encoding = new UTF8Encoding( );
476
 
            string text = encoding.GetString(d.Data);
477
 
 
478
 
            addChannelDialog.Show (text);
479
 
        }
480
 
        
 
430
        }
 
431
 
 
432
        public void PreferencesActivated (object obj, EventArgs args)
 
433
        {
 
434
            preferencesDialog.Show ();
 
435
        }
 
436
 
 
437
        public void AboutActivated (object obj, EventArgs args)
 
438
        {
 
439
            About.Show (mainWindow);
 
440
        }
 
441
 
 
442
        public void AddChannelActivated (object obj, EventArgs args)
 
443
        {
 
444
            addChannelDialog.Show ();
 
445
        }
 
446
 
 
447
        public void EditChannelActivated (Channel channel)
 
448
        {
 
449
            if (channel != null) {
 
450
                channelDialog.Show (channel);
 
451
            }
 
452
        }
 
453
 
 
454
        public void EditChannelActivated(object obj, EventArgs args)
 
455
        {
 
456
            EditChannelActivated (channelList.GetSelected ());
 
457
        }
 
458
 
 
459
        public void MarkChannelAsReadActivated (Channel channel)
 
460
        {
 
461
            if (channel.MarkAsRead ()) {
 
462
                CCollection.Update (channel);
 
463
            }
 
464
        }
 
465
 
 
466
        public void MarkChannelAsReadActivated (object obj, EventArgs args)
 
467
        {
 
468
            MarkChannelAsReadActivated (channelList.GetSelected ());
 
469
        }
 
470
 
 
471
        public void RemoveChannelActivated(Channel channel)
 
472
        {
 
473
            if (channel != null) {
 
474
                RemoveChannelDialog.Show (mainWindow, mCollection, channel);
 
475
            }
 
476
        }
 
477
 
 
478
        public void RemoveChannelActivated(object obj, EventArgs args)
 
479
        {
 
480
            Channel channel = channelList.GetSelected ();
 
481
 
 
482
            RemoveChannelActivated(channel);
 
483
        }
 
484
 
 
485
        public void RefreshChannelActivated(Channel channel)
 
486
        {
 
487
            if (channel != null) {
 
488
                mCollection.Refresh (channel);
 
489
            }
 
490
        }
 
491
 
 
492
        public void RefreshChannelActivated(object obj, EventArgs args)
 
493
        {
 
494
            Channel channel = channelList.GetSelected ();
 
495
 
 
496
            RefreshChannelActivated(channel);
 
497
        }
 
498
 
 
499
        public void RefreshAllActivated(object obj, EventArgs args)
 
500
        {
 
501
            mCollection.RefreshAll ();
 
502
        }
 
503
 
 
504
        private void DragDataReceivedCb(object o, DragDataReceivedArgs args)
 
505
        {
 
506
            SelectionData d = args.SelectionData;
 
507
 
 
508
            if (d.Length < 0 && d.Format != 8){
 
509
                Gtk.Drag.Finish(args.Context, false, false, args.Time);
 
510
                return;
 
511
            }
 
512
 
 
513
            Gtk.Drag.Finish(args.Context, true, true, args.Time);
 
514
 
 
515
            UTF8Encoding encoding = new UTF8Encoding( );
 
516
            string text = encoding.GetString(d.Data);
 
517
 
 
518
            addChannelDialog.Show (text);
 
519
        }
 
520
 
481
521
        private void OnUrl (string url)
482
522
        {
483
523
            uint contextId = statusbar.GetContextId("on_url");
484
 
            
 
524
 
485
525
            statusbar.Pop(contextId);
486
526
            if (url != null) {
487
527
                statusbar.Push(contextId, url);
488
528
            }
489
529
        }
490
530
 
491
 
        private void ChannelAddedCb (Channel channel)
492
 
        {
493
 
            channelList.Add (channel);
494
 
        }
495
 
        
496
 
        private void ChannelUpdatedCb (Channel channel)
497
 
        {
498
 
            channelList.Updated (channel);
499
 
            UpdateTotalNumberOfUnread ();
500
 
        }
501
 
 
502
 
        private void ChannelRemovedCb (Channel channel)
503
 
        {
504
 
            channelList.Remove (channel);
505
 
            UpdateTotalNumberOfUnread ();
506
 
        }
507
 
 
508
 
        private void ChannelRefreshStartedCb (Channel channel)
509
 
        {
510
 
            uint contextId = statusbar.GetContextId("update-status");
511
 
            string statusString;
512
 
 
513
 
            statusString = String.Format (Catalog.GetString ("Refreshing: {0}"), channel.Name);
514
 
 
515
 
            statusbar.Push (contextId, statusString);
516
 
        }
517
 
 
518
 
        private void ChannelRefreshFinishedCb (Channel channel)
519
 
        {
520
 
            uint contextId = statusbar.GetContextId("update-status");
521
 
 
522
 
            statusbar.Pop (contextId);
523
 
            channelList.Updated (channel);
524
 
            UpdateTotalNumberOfUnread ();
525
 
 
526
 
            if (channelList.GetSelected () == channel) {
527
 
                itemList.UpdateList ();
528
 
            }
529
 
        }
530
 
 
531
 
        //public bool IdleRefreshAll ()
532
 
        //      {
533
 
        //    mCollection.RefreshAll ();
534
 
        //
535
 
        //StartStopAutoRefresh ();
536
 
        //return false;
537
 
        //}
538
 
 
539
 
        private bool TimeoutRefreshAll ()
540
 
        {
541
 
            mCollection.RefreshAll ();
542
 
 
543
 
            /* Continue until source is removed */
544
 
            return true;
545
 
        }
546
 
 
547
 
        private void StartStopAutoRefresh ()
548
 
        {
549
 
            bool doAutoRefresh;
550
 
            int  refreshRate;
551
 
 
552
 
            if (mAutoRefreshId != 0) {
553
 
                GLib.Source.Remove (mAutoRefreshId);
554
 
                mAutoRefreshId = 0;
555
 
            }
556
 
 
557
 
            doAutoRefresh = Conf.Get (Preference.AUTO_REFRESH, false);
558
 
            if (!doAutoRefresh) {
559
 
                return;
560
 
            }
561
 
 
562
 
            refreshRate = Conf.Get (Preference.AUTO_REFRESH_RATE, 15);
563
 
            if (refreshRate >= 1) {
564
 
                mAutoRefreshId = GLib.Timeout.Add ((uint) (refreshRate * 60 * 1000),
565
 
                                                   new GLib.TimeoutHandler (TimeoutRefreshAll));
566
 
            }
567
 
        }
568
 
 
569
 
        private void ConfNotifyHandler (object sender, NotifyEventArgs args)
570
 
        {
571
 
            if (args.Key == Conf.GetFullKey (Preference.AUTO_REFRESH) ||
572
 
                args.Key == Conf.GetFullKey (Preference.AUTO_REFRESH_RATE)) {
573
 
                StartStopAutoRefresh ();
574
 
            }
575
 
        }
576
 
 
577
 
        private void TrayIconButtonPressCb (object o, ButtonPressEventArgs args)
578
 
        {
579
 
            mainWindow.Present ();
580
 
        }
581
 
 
582
 
        private void RestoreWindowState()
583
 
        {
584
 
            int width, height;
585
 
            int position_x, position_y;
586
 
            string state;
587
 
 
588
 
            state = Conf.Get ("ui/main_window_state", "normal");
589
 
        
590
 
            width = Conf.Get ("ui/main_window_width", 600);
591
 
            height = Conf.Get ("ui/main_window_height", 400);
592
 
            
593
 
            mainWindow.Resize(width, height);
594
 
 
595
 
            position_x = Conf.Get("ui/main_window_position_x", -1);
596
 
            position_y = Conf.Get("ui/main_window_position_y", -1);
597
 
            if (position_x >= 0 && position_y >= 0) {
598
 
                mainWindow.Move(position_x, position_y);
599
 
            }
600
 
 
601
 
            width = Conf.Get("ui/channel_list_width", 180);
602
 
            channelPaned.Position = width;
603
 
 
604
 
            height = Conf.Get("ui/item_list_height", 100);
605
 
            itemPaned.Position = height;
606
 
 
607
 
            if (state == "maximized") {
608
 
                mainWindow.Maximize ();
609
 
            }
610
 
        }
611
 
 
612
 
        private void SaveWindowState()
613
 
        {
614
 
            int height, width;
615
 
            int position_x, position_y;
616
 
            
617
 
            if (mainWindow.GdkWindow.State != Gdk.WindowState.Maximized) {
618
 
                Conf.Set ("ui/main_window_state", "normal");
619
 
            
620
 
                mainWindow.GetSize (out width, out height);
621
 
            
622
 
                Conf.Set ("ui/main_window_width", width);
623
 
                Conf.Set ("ui/main_window_height", height);
624
 
        
625
 
                Conf.Set ("ui/channel_list_width", channelPaned.Position);
626
 
                Conf.Set ("ui/item_list_height", itemPaned.Position);
627
 
        
628
 
                mainWindow.GetPosition (out position_x, out position_y);
629
 
 
630
 
                Conf.Set ("ui/main_window_position_x", position_x);
631
 
                Conf.Set ("ui/main_window_position_y", position_y);
632
 
            } else {
633
 
                Conf.Set ("ui/main_window_state", "maximized");
634
 
            }
635
 
 
636
 
            Conf.Sync ();
637
 
        }
638
 
 
639
 
        private void UpdateTotalNumberOfUnread ()
640
 
        {
641
 
            int nrOfUnread;
642
 
 
643
 
            nrOfUnread = mCollection.NrOfUnreadItems;
644
 
 
645
 
            channelsLabel.Markup = string.Format("<b>" +
646
 
                                                 channelsLabelText +
647
 
                                                 "</b>",
648
 
                                                 nrOfUnread);
649
 
            if (nrOfUnread > 0) {
650
 
                trayIcon.Show ();
651
 
                trayIcon.Tooltip = string.Format (Catalog.GetPluralString ("{0} unread item", "{0} unread items", nrOfUnread),
652
 
                                                  nrOfUnread);
653
 
            } else {
654
 
                trayIcon.Hide ();
655
 
            }
656
 
        }
657
 
        
658
 
        private void MessageReceivedCb (string message, IntPtr userData)
659
 
        {
660
 
            if (!message.Equals ("ShowWindow")) {
661
 
                return;
662
 
            }
663
 
 
664
 
            mainWindow.Present ();
665
 
            //mCollection.RefreshAll ();
666
 
        }
 
531
        private void ChannelAddedCb (Channel channel)
 
532
        {
 
533
            channelList.Add (channel);
 
534
        }
 
535
 
 
536
        private void ChannelUpdatedCb (Channel channel)
 
537
        {
 
538
            channelList.Updated (channel);
 
539
            UpdateTotalNumberOfUnread ();
 
540
        }
 
541
 
 
542
        private void ChannelRemovedCb (Channel channel)
 
543
        {
 
544
            channelList.Remove (channel);
 
545
            UpdateTotalNumberOfUnread ();
 
546
        }
 
547
 
 
548
        private void ChannelRefreshStartedCb (Channel channel)
 
549
        {
 
550
            uint contextId = statusbar.GetContextId("update-status");
 
551
            string statusString;
 
552
 
 
553
            statusString = String.Format (Catalog.GetString ("Refreshing: {0}"), channel.Name);
 
554
 
 
555
            statusbar.Push (contextId, statusString);
 
556
        }
 
557
 
 
558
        private void ChannelRefreshFinishedCb (Channel channel)
 
559
        {
 
560
            uint contextId = statusbar.GetContextId("update-status");
 
561
 
 
562
            statusbar.Pop (contextId);
 
563
            channelList.Updated (channel);
 
564
            UpdateTotalNumberOfUnread ();
 
565
 
 
566
            if (channelList.GetSelected () == channel) {
 
567
                itemList.UpdateList ();
 
568
            }
 
569
        }
 
570
 
 
571
        public bool IdleRefreshAll ()
 
572
        {
 
573
            TimeoutRefreshAll ();
 
574
 
 
575
            StartStopAutoRefresh ();
 
576
            return false;
 
577
        }
 
578
 
 
579
        private bool TimeoutRefreshAll ()
 
580
        {
 
581
            int refreshRate;
 
582
 
 
583
            if (Conf.Get (Preference.AUTO_REFRESH, false) == false) {
 
584
                // User don't want auto refresh.
 
585
                return false;
 
586
            }
 
587
 
 
588
            refreshRate = Conf.Get (Preference.AUTO_REFRESH_RATE, 15);
 
589
 
 
590
            mCollection.RefreshAll (refreshRate);
 
591
 
 
592
            /* Continue until source is removed */
 
593
            return true;
 
594
        }
 
595
 
 
596
        private void StartStopAutoRefresh ()
 
597
        {
 
598
            bool doAutoRefresh;
 
599
 
 
600
            if (mAutoRefreshId != 0) {
 
601
                GLib.Source.Remove (mAutoRefreshId);
 
602
                mAutoRefreshId = 0;
 
603
            }
 
604
 
 
605
            doAutoRefresh = Conf.Get (Preference.AUTO_REFRESH, false);
 
606
            if (!doAutoRefresh) {
 
607
                return;
 
608
            }
 
609
 
 
610
            // Check if any feeds require refresh every ten seconds
 
611
            mAutoRefreshId = GLib.Timeout.Add ((uint) (10 * 1000),
 
612
                                               new GLib.TimeoutHandler (TimeoutRefreshAll));
 
613
        }
 
614
 
 
615
        private void ConfNotifyHandler (object sender, NotifyEventArgs args)
 
616
        {
 
617
            if (args.Key == Conf.GetFullKey (Preference.AUTO_REFRESH)) {
 
618
                StartStopAutoRefresh ();
 
619
            }
 
620
        }
 
621
 
 
622
        private void TrayIconButtonPressCb (object o, ButtonPressEventArgs args)
 
623
        {
 
624
            mainWindow.Present ();
 
625
        }
 
626
 
 
627
        private void RestoreWindowState()
 
628
        {
 
629
            int width, height;
 
630
            int position_x, position_y;
 
631
            string state;
 
632
 
 
633
            state = Conf.Get ("ui/main_window_state", "normal");
 
634
 
 
635
            width = Conf.Get ("ui/main_window_width", 600);
 
636
            height = Conf.Get ("ui/main_window_height", 400);
 
637
 
 
638
            mainWindow.Resize(width, height);
 
639
 
 
640
            position_x = Conf.Get("ui/main_window_position_x", -1);
 
641
            position_y    =    Conf.Get(   "ui/main_window_position_y",    -1);
 
642
            if (position_x >= 0 && position_y >= 0) {
 
643
                mainWindow.Move(position_x, position_y);
 
644
            }
 
645
 
 
646
            width = Conf.Get("ui/channel_list_width", 180);
 
647
            channelPaned.Position = width;
 
648
 
 
649
            height = Conf.Get("ui/item_list_height", 100);
 
650
            itemPaned.Position = height;
 
651
 
 
652
            if (state == "maximized") {
 
653
                mainWindow.Maximize ();
 
654
            }
 
655
        }
 
656
 
 
657
        private void SaveWindowState()
 
658
        {
 
659
            int height, width;
 
660
            int position_x, position_y;
 
661
 
 
662
            if (mainWindow.GdkWindow.State != Gdk.WindowState.Maximized) {
 
663
                Conf.Set ("ui/main_window_state", "normal");
 
664
 
 
665
                mainWindow.GetSize (out width, out height);
 
666
 
 
667
                Conf.Set ("ui/main_window_width", width);
 
668
                Conf.Set ("ui/main_window_height", height);
 
669
 
 
670
                Conf.Set ("ui/channel_list_width", channelPaned.Position);
 
671
                Conf.Set ("ui/item_list_height", itemPaned.Position);
 
672
 
 
673
                mainWindow.GetPosition (out position_x, out position_y);
 
674
 
 
675
                Conf.Set ("ui/main_window_position_x", position_x);
 
676
                Conf.Set ("ui/main_window_position_y", position_y);
 
677
            } else {
 
678
                Conf.Set ("ui/main_window_state", "maximized");
 
679
            }
 
680
 
 
681
            Conf.Sync ();
 
682
        }
 
683
 
 
684
        private void UpdateTotalNumberOfUnread ()
 
685
        {
 
686
            int nrOfUnread;
 
687
 
 
688
            nrOfUnread = mCollection.NrOfUnreadItems;
 
689
 
 
690
            channelsLabel.Markup = string.Format("<b>" +
 
691
                                                 channelsLabelText +
 
692
                                                 "</b>",
 
693
                                                 nrOfUnread);
 
694
            if (nrOfUnread > 0) {
 
695
                trayIcon.Show ();
 
696
                trayIcon.Tooltip = string.Format (Catalog.GetPluralString ("{0} unread item", "{0} unread items", nrOfUnread),
 
697
                                                  nrOfUnread);
 
698
            } else {
 
699
                trayIcon.Hide ();
 
700
            }
 
701
        }
 
702
 
 
703
        private void MessageReceivedCb (string message, IntPtr userData)
 
704
        {
 
705
            if (!message.Equals ("ShowWindow")) {
 
706
                return;
 
707
            }
 
708
 
 
709
            mainWindow.Present ();
 
710
            //mCollection.RefreshAll ();
 
711
        }
667
712
 
668
713
        public static void Main(string[] args)
669
 
        {
 
714
        {
670
715
            TheApp = new Application (args);
671
716
            TheApp.Run ();
672
 
            // new Application(args).Run();
673
 
        }
 
717
            // new Application(args).Run();
 
718
        }
674
719
    }
675
720
}