app: implemented sync action
Useful when the local calendar differs from the remote calendar (i.e. you added an event at Google Calendar).
This commit is contained in:
committed by
Erick Pérez Castellanos
parent
3887951323
commit
2e8b677d6a
@@ -32,6 +32,11 @@
|
|||||||
<attribute name="label" translatable="yes">_New Event</attribute>
|
<attribute name="label" translatable="yes">_New Event</attribute>
|
||||||
<attribute name="action">app.new</attribute>
|
<attribute name="action">app.new</attribute>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<attribute name="label" translatable="yes">_Synchronize</attribute>
|
||||||
|
<attribute name="action">app.sync</attribute>
|
||||||
|
<attribute name="accel">F5</attribute>
|
||||||
|
</item>
|
||||||
</section>
|
</section>
|
||||||
</menu>
|
</menu>
|
||||||
</interface>
|
</interface>
|
||||||
|
|||||||
@@ -64,6 +64,10 @@ static void gcal_application_show_about (GSimpleAction *
|
|||||||
GVariant *parameter,
|
GVariant *parameter,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
|
static void gcal_application_sync (GSimpleAction *sync,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer app);
|
||||||
|
|
||||||
static void gcal_application_quit (GSimpleAction *simple,
|
static void gcal_application_quit (GSimpleAction *simple,
|
||||||
GVariant *parameter,
|
GVariant *parameter,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
@@ -83,6 +87,7 @@ static GOptionEntry gcal_application_goptions[] = {
|
|||||||
|
|
||||||
static const GActionEntry gcal_app_entries[] = {
|
static const GActionEntry gcal_app_entries[] = {
|
||||||
{ "new", gcal_application_create_new_event },
|
{ "new", gcal_application_create_new_event },
|
||||||
|
{ "sync", gcal_application_sync },
|
||||||
{ "search", gcal_application_launch_search },
|
{ "search", gcal_application_launch_search },
|
||||||
{ "about", gcal_application_show_about },
|
{ "about", gcal_application_show_about },
|
||||||
{ "quit", gcal_application_quit },
|
{ "quit", gcal_application_quit },
|
||||||
@@ -264,6 +269,18 @@ gcal_application_create_new_event (GSimpleAction *new_event,
|
|||||||
gcal_window_new_event (GCAL_WINDOW (priv->window));
|
gcal_window_new_event (GCAL_WINDOW (priv->window));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gcal_application_sync (GSimpleAction *sync,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer app)
|
||||||
|
{
|
||||||
|
GcalApplicationPrivate *priv;
|
||||||
|
|
||||||
|
priv = gcal_application_get_instance_private (GCAL_APPLICATION (app));
|
||||||
|
|
||||||
|
gcal_manager_refresh (priv->manager);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gcal_application_launch_search (GSimpleAction *search,
|
gcal_application_launch_search (GSimpleAction *search,
|
||||||
GVariant *parameter,
|
GVariant *parameter,
|
||||||
|
|||||||
@@ -90,6 +90,10 @@ static void on_client_connected (GObject *sour
|
|||||||
GAsyncResult *result,
|
GAsyncResult *result,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
|
static void on_client_refreshed (GObject *source_object,
|
||||||
|
GAsyncResult *result,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
static void on_event_updated (GObject *source_object,
|
static void on_event_updated (GObject *source_object,
|
||||||
GAsyncResult *result,
|
GAsyncResult *result,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
@@ -282,6 +286,27 @@ on_client_connected (GObject *source_object,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_client_refreshed (GObject *source_object,
|
||||||
|
GAsyncResult *result,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GError *error;
|
||||||
|
|
||||||
|
error = NULL;
|
||||||
|
if (e_client_refresh_finish (E_CLIENT (source_object), result, &error))
|
||||||
|
{
|
||||||
|
/* FIXME: add notification to UI */
|
||||||
|
;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* FIXME: do something when there was some error */
|
||||||
|
g_warning ("Error synchronizing client");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* on_component_updated:
|
* on_component_updated:
|
||||||
* @source_object: {@link ECalClient} source
|
* @source_object: {@link ECalClient} source
|
||||||
@@ -600,6 +625,35 @@ gcal_manager_get_default_source (GcalManager *manager)
|
|||||||
return source_uid;
|
return source_uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gcal_manager_refresh (GcalManager *manager)
|
||||||
|
{
|
||||||
|
GcalManagerPrivate *priv;
|
||||||
|
GList *clients;
|
||||||
|
GList *l;
|
||||||
|
|
||||||
|
priv = gcal_manager_get_instance_private (manager);
|
||||||
|
clients = g_hash_table_get_values (priv->clients);
|
||||||
|
|
||||||
|
/* refresh clients */
|
||||||
|
for (l = clients; l != NULL; l = l->next)
|
||||||
|
{
|
||||||
|
GcalManagerUnit *unit;
|
||||||
|
|
||||||
|
unit = (GcalManagerUnit*) l->data;
|
||||||
|
|
||||||
|
if (! e_client_check_refresh_supported (E_CLIENT (unit->client)))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
e_client_refresh (E_CLIENT (unit->client),
|
||||||
|
NULL,
|
||||||
|
on_client_refreshed,
|
||||||
|
manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free (clients);
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gcal_manager_is_client_writable (GcalManager *manager,
|
gcal_manager_is_client_writable (GcalManager *manager,
|
||||||
ESource *source)
|
ESource *source)
|
||||||
|
|||||||
@@ -81,6 +81,8 @@ gchar* gcal_manager_add_source (GcalManager *manager
|
|||||||
|
|
||||||
gchar* gcal_manager_get_default_source (GcalManager *manager);
|
gchar* gcal_manager_get_default_source (GcalManager *manager);
|
||||||
|
|
||||||
|
void gcal_manager_refresh (GcalManager *manager);
|
||||||
|
|
||||||
gboolean gcal_manager_is_client_writable (GcalManager *manager,
|
gboolean gcal_manager_is_client_writable (GcalManager *manager,
|
||||||
ESource *source);
|
ESource *source);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user