[gnome-calendar/ui-rewrite] manager: update retrieve sources API
- From: Erick Pérez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/ui-rewrite] manager: update retrieve sources API
- Date: Thu, 4 Dec 2014 21:31:32 +0000 (UTC)
commit 0e7daabe34603c41a7f2910055ca6e04ce849876
Author: Erick Pérez Castellanos <erick red gmail com>
Date: Wed Dec 3 11:03:54 2014 -0500
manager: update retrieve sources API
The move to newer API is to drop GtkListStore dependency on the manager.
src/gcal-manager.c | 53 ++++++++++++++++++++++++++++++---------------------
src/gcal-manager.h | 8 ++----
src/gcal-window.c | 20 +++---------------
3 files changed, 38 insertions(+), 43 deletions(-)
---
diff --git a/src/gcal-manager.c b/src/gcal-manager.c
index 3fe43ab..ae1dd56 100644
--- a/src/gcal-manager.c
+++ b/src/gcal-manager.c
@@ -512,12 +512,38 @@ gcal_manager_new (void)
return GCAL_MANAGER (g_object_new (GCAL_TYPE_MANAGER, NULL));
}
-GtkListStore*
-gcal_manager_get_sources_model (GcalManager *manager)
+/**
+ * gcal_manager_get_sources:
+ * @manager:
+ *
+ * Retrieve a list of the sources used in the application.
+ *
+ * Returns: (Transfer full) a { link GList} object
+ * to be freed with g_list_free()
+ **/
+GList*
+gcal_manager_get_sources (GcalManager *manager)
{
- /* FIXME: stub code, since we don't keep a calendars list-store
- anymore */
- return NULL;
+ GcalManagerPrivate *priv;
+
+ priv = gcal_manager_get_instance_private (manager);
+ return g_hash_table_get_keys (priv->clients);
+}
+
+/**
+ * gcal_manager_get_default_source:
+ * @manager: App singleton { link GcalManager} instance
+ *
+ * Returns: (Transfer full): an { link ESource} object. Free with g_object_unref().
+ **/
+ESource*
+gcal_manager_get_default_source (GcalManager *manager)
+{
+ GcalManagerPrivate *priv;
+
+ priv = gcal_manager_get_instance_private (manager);
+
+ return e_source_registry_ref_default_calendar (priv->source_registry);
}
icaltimezone*
@@ -634,23 +660,6 @@ gcal_manager_add_source (GcalManager *manager,
return e_source_dup_uid (source);
}
-gchar*
-gcal_manager_get_default_source (GcalManager *manager)
-{
- GcalManagerPrivate *priv;
-
- ESource *edefault;
- gchar *source_uid;
-
- priv = gcal_manager_get_instance_private (manager);
-
- edefault = e_source_registry_ref_default_calendar (priv->source_registry);
- source_uid = e_source_dup_uid (edefault);
-
- g_object_unref (edefault);
- return source_uid;
-}
-
void
gcal_manager_refresh (GcalManager *manager)
{
diff --git a/src/gcal-manager.h b/src/gcal-manager.h
index bf0cf93..baa0e3e 100644
--- a/src/gcal-manager.h
+++ b/src/gcal-manager.h
@@ -22,8 +22,6 @@
#include "e-cal-data-model.h"
-#include <gtk/gtk.h>
-
#include <libical/icaltime.h>
G_BEGIN_DECLS
@@ -62,7 +60,9 @@ GType gcal_manager_get_type (void);
GcalManager* gcal_manager_new (void);
-GtkListStore* gcal_manager_get_sources_model (GcalManager *manager);
+GList* gcal_manager_get_sources (GcalManager *manager);
+
+ESource* gcal_manager_get_default_source (GcalManager *manager);
icaltimezone* gcal_manager_get_system_timezone (GcalManager *manager);
@@ -84,8 +84,6 @@ gchar* gcal_manager_add_source (GcalManager *manager
const gchar *backend,
const gchar *color);
-gchar* gcal_manager_get_default_source (GcalManager *manager);
-
void gcal_manager_refresh (GcalManager *manager);
gboolean gcal_manager_is_client_writable (GcalManager *manager,
diff --git a/src/gcal-window.c b/src/gcal-window.c
index aee0ab2..8ed19d5 100644
--- a/src/gcal-window.c
+++ b/src/gcal-window.c
@@ -524,8 +524,6 @@ prepare_new_event_widget (GcalWindow *window)
{
GcalWindowPrivate *priv;
- gchar *uid;
-
struct tm tm_date;
gchar start[64];
gchar *title_date;
@@ -544,16 +542,6 @@ prepare_new_event_widget (GcalWindow *window)
gcal_new_event_widget_set_title (new_widget, title_date);
g_free (title_date);
- /* FIXME: do this somehow since GcalManager doesn't keep
- a list store of calendars anymore, and this is a stub method */
- gcal_new_event_widget_set_calendars (
- new_widget,
- GTK_TREE_MODEL (gcal_manager_get_sources_model (priv->manager)));
-
- uid = gcal_manager_get_default_source (priv->manager);
- gcal_new_event_widget_set_default_calendar (new_widget, uid);
- g_free (uid);
-
/* clear entry */
widget = gcal_new_event_widget_get_entry (new_widget);
gtk_entry_set_text (GTK_ENTRY (widget), "");
@@ -688,7 +676,7 @@ create_event (gpointer user_data,
GcalNewEventWidget *new_widget;
- gchar *uid;
+ ESource *source;
gchar *summary;
priv = gcal_window_get_instance_private (GCAL_WINDOW (user_data));
@@ -697,16 +685,16 @@ create_event (gpointer user_data,
if (widget == gcal_new_event_widget_get_details_button (new_widget))
priv->open_edit_dialog = TRUE;
- uid = gcal_new_event_widget_get_calendar_uid (new_widget);
+ source = gcal_manager_get_default_source (priv->manager);
summary = gcal_new_event_widget_get_summary (new_widget);
/* create the event */
gcal_manager_create_event (priv->manager,
- uid, summary,
+ e_source_get_uid (source), summary,
priv->event_creation_data->start_date,
priv->event_creation_data->end_date);
- g_free (uid);
+ g_object_unref (source);
g_free (summary);
/* reset and hide */
set_new_event_mode (GCAL_WINDOW (user_data), FALSE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]