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

« back to all changes in this revision

Viewing changes to src/feedlist.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 feedlist.c  subscriptions as an hierarchic tree
3
3
 *
4
 
 * Copyright (C) 2005-2009 Lars Lindner <lars.lindner@gmail.com>
 
4
 * Copyright (C) 2005-2011 Lars Lindner <lars.lindner@gmail.com>
5
5
 * Copyright (C) 2005-2006 Nathan J. Conrad <t98502@users.sourceforge.net>
6
6
 *            
7
7
 * This program is free software; you can redistribute it and/or modify
29
29
#include "feedlist.h"
30
30
#include "folder.h"
31
31
#include "itemlist.h"
32
 
#include "net.h"
 
32
#include "net_monitor.h"
33
33
#include "node.h"
34
 
#include "script.h"
35
34
#include "update.h"
36
35
#include "vfolder.h"
 
36
#include "ui/feed_list_view.h"
37
37
#include "ui/itemview.h"
38
38
#include "ui/liferea_shell.h"
39
 
#include "ui/ui_feedlist.h"
40
39
#include "ui/ui_node.h"
41
 
#include "ui/ui_subscription.h"
42
40
#include "ui/ui_tray.h"
43
41
#include "fl_sources/node_source.h"
44
 
#include "notification/notification.h"
45
42
 
46
 
static void feedlist_class_init (FeedListClass *klass);
47
 
static void feedlist_init       (FeedList *fl);
48
43
static void feedlist_save       (void);
49
44
 
50
45
#define FEEDLIST_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), FEEDLIST_TYPE, FeedListPrivate))
60
55
        guint           saveTimer;      /**< timer id for delayed feed list saving */
61
56
        guint           autoUpdateTimer; /**< timer id for auto update */
62
57
 
63
 
        gboolean        loading;        /**< this flag prevents the feed list being saved before it is completely loaded */
 
58
        gboolean        loading;        /**< prevents the feed list being saved before it is completely loaded */
64
59
};
65
60
 
66
61
#define ROOTNODE feedlist->priv->rootNode
67
62
#define SELECTED feedlist->priv->selectedNode
68
63
 
69
 
#define IS_SELECTED(node) (feedlist->priv->selectedNode == node)
70
 
 
71
64
static GObjectClass *parent_class = NULL;
72
65
static FeedList *feedlist = NULL;
73
66
 
74
 
GType
75
 
feedlist_get_type (void) 
76
 
{
77
 
        static GType type = 0;
78
 
 
79
 
        if (G_UNLIKELY (type == 0)) 
80
 
        {
81
 
                static const GTypeInfo our_info = 
82
 
                {
83
 
                        sizeof (FeedListClass),
84
 
                        NULL, /* base_init */
85
 
                        NULL, /* base_finalize */
86
 
                        (GClassInitFunc) feedlist_class_init,
87
 
                        NULL,
88
 
                        NULL, /* class_data */
89
 
                        sizeof (FeedList),
90
 
                        0, /* n_preallocs */
91
 
                        (GInstanceInitFunc) feedlist_init
92
 
                };
93
 
 
94
 
                type = g_type_register_static (G_TYPE_OBJECT,
95
 
                                               "FeedList",
96
 
                                               &our_info, 0);
97
 
        }
98
 
 
99
 
        return type;
100
 
}
 
67
G_DEFINE_TYPE (FeedList, feedlist, G_TYPE_OBJECT);
101
68
 
102
69
static void
103
70
feedlist_free_node (nodePtr node)
146
113
{
147
114
        debug_enter ("feedlist_auto_update");
148
115
 
149
 
        if (network_is_online ())
 
116
        if (network_monitor_is_online ())
150
117
                node_auto_update_subscription (ROOTNODE);
151
118
        else
152
119
                debug0 (DEBUG_UPDATE, "no update processing because we are offline!");
156
123
        return TRUE;
157
124
}
158
125
 
 
126
static void
 
127
on_network_status_changed (gpointer instance, gboolean online, gpointer data)
 
128
{
 
129
        if (online) feedlist_auto_update (NULL);
 
130
}
 
131
 
159
132
/* This method is used to initialize the node states in the feed list */
160
133
static void
161
134
feedlist_init_node (nodePtr node) 
175
148
static void
176
149
feedlist_init (FeedList *fl)
177
150
{
 
151
        gint    startup_feed_action;
 
152
 
178
153
        debug_enter ("feedlist_init");
179
154
        
180
155
        /* 1. Prepare globally accessible singleton */
192
167
        debug0 (DEBUG_CACHE, "Initializing node state");
193
168
        feedlist_foreach (feedlist_init_node);
194
169
 
195
 
        debug0 (DEBUG_GUI, "Notification setup");       
196
 
        notification_enable (conf_get_bool_value (SHOW_POPUP_WINDOWS));
197
170
        ui_tray_update ();
198
171
 
199
172
        /* 4. Check if feeds do need updating. */
200
173
        debug0 (DEBUG_UPDATE, "Performing initial feed update");
201
 
        switch (conf_get_int_value (STARTUP_FEED_ACTION)) {
202
 
                case 1: /* Update all feeds */
203
 
                        debug0 (DEBUG_UPDATE, "initial update: updating all feeds");
 
174
        conf_get_int_value (STARTUP_FEED_ACTION, &startup_feed_action);
 
175
        if (0 == startup_feed_action) {
 
176
                /* Update all feeds */
 
177
                if (network_monitor_is_online ()) {
 
178
                        debug0 (DEBUG_UPDATE, "initial update: updating all feeds");            
204
179
                        node_update_subscription (feedlist_get_root (), GUINT_TO_POINTER (0));
205
 
                        break;
206
 
                case 2:
207
 
                        debug0 (DEBUG_UPDATE, "initial update: resetting feed counter");
208
 
                        feedlist_reset_update_counters (NULL);
209
 
                        break;
210
 
                default:
211
 
                        debug0 (DEBUG_UPDATE, "initial update: using auto update");
212
 
                        /* default, which is to use the lastPoll times, does not need any actions here. */;
 
180
                } else {
 
181
                        debug0 (DEBUG_UPDATE, "initial update: prevented because we are offline");
 
182
                }
 
183
        } else {
 
184
                debug0 (DEBUG_UPDATE, "initial update: resetting feed counter");
 
185
                feedlist_reset_update_counters (NULL);
213
186
        }
214
187
 
215
188
        /* 5. Start automatic updating */
216
189
        feedlist->priv->autoUpdateTimer = g_timeout_add_seconds (10, feedlist_auto_update, NULL);
 
190
        g_signal_connect (network_monitor_get (), "online-status-changed", G_CALLBACK (on_network_status_changed), NULL);
217
191
 
218
192
        /* 6. Finally save the new feed list state */
219
193
        feedlist->priv->loading = FALSE;
267
241
static void
268
242
feedlist_update_node_counters (nodePtr node)
269
243
{
270
 
        if (node->needsRecount) {
271
 
                if (IS_VFOLDER (node))
272
 
                        vfolder_update_counters (node); /* simple vfolder only update */
273
 
                else
274
 
                        node_update_counters (node);    /* update with parent propagation */
275
 
        }
 
244
        node_update_counters (node);    /* update with parent propagation */
 
245
 
276
246
        if (node->needsUpdate)
277
247
                ui_node_update (node->id);
278
248
        if (node->children)
346
316
void
347
317
feedlist_node_was_updated (nodePtr node, guint newCount)
348
318
{
349
 
        vfolder_foreach (vfolder_update_counters);                      
350
319
        node_update_counters (node);
351
320
        feedlist_update_new_item_count (newCount);
352
321
}
412
381
 
413
382
        feedlist_node_imported (node);
414
383
        
415
 
        ui_feedlist_select (node);
416
 
        
417
 
        if (node->subscription)
418
 
                script_run_for_hook (SCRIPT_HOOK_NEW_SUBSCRIPTION);
 
384
        feed_list_view_select (node);
419
385
}
420
386
 
421
387
void
430
396
void
431
397
feedlist_node_removed (nodePtr node)
432
398
{
433
 
        if (IS_SELECTED (node))
 
399
        if (node == SELECTED)
434
400
                feedlist_unselect ();
435
401
                
436
402
        /* First remove all children */
535
501
        itemview_update ();
536
502
                
537
503
        itemlist_unload (FALSE /* mark all read */);
538
 
        ui_feedlist_select (NULL);
 
504
        feed_list_view_select (NULL);
539
505
        liferea_shell_update_feed_menu (TRUE, FALSE, FALSE);
540
506
        liferea_shell_update_allitems_actions (FALSE, FALSE);
541
507
}
554
520
                if (0 != feedlist->priv->newCount)
555
521
                        feedlist_reset_new_item_count ();
556
522
 
557
 
                script_run_for_hook (SCRIPT_HOOK_FEED_UNSELECT);
558
 
 
559
523
                /* Unload visible items. */
560
524
                itemlist_unload (TRUE);
561
525
        
567
531
                } else {
568
532
                        itemview_clear ();
569
533
                }
570
 
                
571
 
                if (SELECTED)
572
 
                        script_run_for_hook (SCRIPT_HOOK_FEED_SELECTED);
573
534
        }
574
535
 
575
536
        debug_exit ("feedlist_selection_changed");