manager: Handle refresh in the source directly
Instead of implementing code to refresh sources, let's just use the ESourceRefresh extension and let Evolution handle that.
This commit is contained in:
+6
-9
@@ -345,6 +345,7 @@ on_client_connected (GObject *source_object,
|
||||
gpointer user_data)
|
||||
{
|
||||
GcalManagerUnit *unit;
|
||||
ESourceRefresh *refresh_extension;
|
||||
ESourceOffline *offline_extension;
|
||||
GcalManager *self;
|
||||
ECalClient *client;
|
||||
@@ -410,6 +411,11 @@ on_client_connected (GObject *source_object,
|
||||
offline_extension = e_source_get_extension (source, E_SOURCE_EXTENSION_OFFLINE);
|
||||
e_source_offline_set_stay_synchronized (offline_extension, TRUE);
|
||||
|
||||
/* And also make sure the source is periodically updated */
|
||||
refresh_extension = e_source_get_extension (source, E_SOURCE_EXTENSION_REFRESH);
|
||||
e_source_refresh_set_enabled (refresh_extension, TRUE);
|
||||
e_source_refresh_set_interval_minutes (refresh_extension, 30);
|
||||
|
||||
e_source_registry_commit_source (self->source_registry,
|
||||
source,
|
||||
NULL,
|
||||
@@ -423,15 +429,6 @@ on_client_connected (GObject *source_object,
|
||||
GCAL_EXIT;
|
||||
}
|
||||
|
||||
/**
|
||||
* load_source:
|
||||
* @self: Manager instance
|
||||
* @source: Loaded source
|
||||
*
|
||||
* Create @GcalManagerUnit data, add it to internal hash of sources.
|
||||
* Open/connect to calendars available
|
||||
*
|
||||
**/
|
||||
static void
|
||||
load_source (GcalManager *self,
|
||||
ESource *source)
|
||||
|
||||
+1
-32
@@ -157,8 +157,6 @@ struct _GcalWindow
|
||||
GtkWidget *calendar_listbox;
|
||||
GtkWidget *source_dialog;
|
||||
|
||||
gint refresh_timeout;
|
||||
gint refresh_timeout_id;
|
||||
gint open_edit_dialog_timeout_id;
|
||||
|
||||
GcalTimeFormat time_format;
|
||||
@@ -194,8 +192,6 @@ enum
|
||||
};
|
||||
|
||||
#define SAVE_GEOMETRY_ID_TIMEOUT 100 /* ms */
|
||||
#define FAST_REFRESH_TIMEOUT 900000 /* ms */
|
||||
#define SLOW_REFRESH_TIMEOUT 3600000 /* ms */
|
||||
|
||||
#define gcal_window_add_accelerator(app,action,...) {\
|
||||
const gchar *tmp[] = {__VA_ARGS__, NULL};\
|
||||
@@ -919,27 +915,6 @@ source_changed (GcalWindow *window,
|
||||
g_list_free (children);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
refresh_sources (GcalWindow *window)
|
||||
{
|
||||
static gint current_timeout = FAST_REFRESH_TIMEOUT;
|
||||
|
||||
/* refresh sources */
|
||||
gcal_manager_refresh (window->manager);
|
||||
|
||||
/* check window state */
|
||||
if (current_timeout != window->refresh_timeout)
|
||||
{
|
||||
current_timeout = window->refresh_timeout;
|
||||
|
||||
window->refresh_timeout_id = g_timeout_add (window->refresh_timeout, (GSourceFunc) refresh_sources, window);
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
window_state_changed (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
@@ -955,9 +930,6 @@ window_state_changed (GtkWidget *widget,
|
||||
|
||||
window->is_maximized = state->new_window_state & GDK_WINDOW_STATE_MAXIMIZED;
|
||||
|
||||
/* update timeout time according to the state */
|
||||
window->refresh_timeout = (active ? FAST_REFRESH_TIMEOUT : SLOW_REFRESH_TIMEOUT);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1238,7 +1210,6 @@ gcal_window_finalize (GObject *object)
|
||||
save_geometry (window);
|
||||
|
||||
gcal_clear_timeout (&window->open_edit_dialog_timeout_id);
|
||||
gcal_clear_timeout (&window->refresh_timeout_id);
|
||||
|
||||
/* If we have a queued event to delete, remove it now */
|
||||
if (window->event_to_delete)
|
||||
@@ -1579,9 +1550,6 @@ gcal_window_init (GcalWindow *self)
|
||||
self->views[GCAL_WINDOW_VIEW_MONTH] = self->month_view;
|
||||
self->views[GCAL_WINDOW_VIEW_YEAR] = self->year_view;
|
||||
|
||||
/* refresh timeout, first is fast */
|
||||
self->refresh_timeout_id = g_timeout_add (FAST_REFRESH_TIMEOUT, (GSourceFunc) refresh_sources, self);
|
||||
|
||||
/* calendars popover */
|
||||
gtk_list_box_set_sort_func (GTK_LIST_BOX (self->calendar_listbox),
|
||||
(GtkListBoxSortFunc) calendar_listbox_sort_func,
|
||||
@@ -1603,6 +1571,7 @@ gcal_window_init (GcalWindow *self)
|
||||
g_object_bind_property (self, "manager", self->month_view, "manager", G_BINDING_DEFAULT);
|
||||
g_object_bind_property (self, "manager", self->year_view, "manager", G_BINDING_DEFAULT);
|
||||
g_object_bind_property (self, "manager", self->quick_add_popover, "manager", G_BINDING_DEFAULT);
|
||||
g_object_bind_property (self, "manager", self->search_popover, "manager", G_BINDING_DEFAULT);
|
||||
g_object_bind_property (self, "time-format", self->edit_dialog, "time-format", G_BINDING_DEFAULT);
|
||||
g_object_bind_property (self, "time-format", self->search_popover, "time-format", G_BINDING_DEFAULT);
|
||||
g_object_bind_property (self, "time-format", self->week_view, "time-format", G_BINDING_DEFAULT);
|
||||
|
||||
Reference in New Issue
Block a user