[gnome-todo/wip/lists] application: move the GSettings from application to the manager
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-todo/wip/lists] application: move the GSettings from application to the manager
- Date: Mon, 15 Jun 2015 14:14:34 +0000 (UTC)
commit 9e63e8e83087b63d5da5d0e8a77a312b7da0de03
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Mon Jun 15 10:54:13 2015 -0300
application: move the GSettings from application to the manager
src/gtd-application.c | 47 +-------------------------
src/gtd-application.h | 5 ---
src/gtd-initial-setup-window.c | 17 +++-------
src/gtd-manager.c | 72 ++++++++++++++++++++++++++++++++++++++++
src/gtd-manager.h | 11 ++++++
5 files changed, 90 insertions(+), 62 deletions(-)
---
diff --git a/src/gtd-application.c b/src/gtd-application.c
index 22d24f3..f98b5f5 100644
--- a/src/gtd-application.c
+++ b/src/gtd-application.c
@@ -33,7 +33,6 @@
typedef struct
{
GtkCssProvider *provider;
- GSettings *settings;
GtdManager *manager;
GtkWidget *window;
@@ -154,9 +153,7 @@ finish_initial_setup (GtdApplication *application)
run_window (application);
- g_settings_set_boolean (application->priv->settings,
- "first-run",
- FALSE);
+ gtd_manager_set_is_first_run (application->priv->manager, FALSE);
g_clear_pointer (&application->priv->initial_setup, gtk_widget_destroy);
}
@@ -194,7 +191,7 @@ gtd_application_activate (GApplication *application)
GtdApplicationPrivate *priv = GTD_APPLICATION (application)->priv;
gboolean first_run;
- first_run = g_settings_get_boolean (priv->settings, "first-run");
+ first_run = gtd_manager_get_is_first_run (priv->manager);
if (!priv->provider)
{
@@ -238,9 +235,6 @@ gtd_application_finalize (GObject *object)
{
GtdApplication *self = GTD_APPLICATION (object);
- /* Clear settings */
- g_clear_object (&(self->priv->settings));
-
G_OBJECT_CLASS (gtd_application_parent_class)->finalize (object);
}
@@ -281,8 +275,6 @@ gtd_application_init (GtdApplication *self)
{
GtdApplicationPrivate *priv = gtd_application_get_instance_private (self);
- priv->settings = g_settings_new ("org.gnome.todo");
-
self->priv = priv;
}
@@ -293,38 +285,3 @@ gtd_application_get_manager (GtdApplication *app)
return app->priv->manager;
}
-
-/**
- * gtd_application_get_storage_location:
- *
- * Retrieves the default storage location for new #GtdTaskList.
- *
- * Returns: (transfer full): a newly allocated string containing the default
- * storage location. "local" is the default.
- */
-gchar*
-gtd_application_get_storage_location (GtdApplication *app)
-{
- g_return_val_if_fail (GTD_IS_APPLICATION (app), NULL);
-
- return g_settings_get_string (app->priv->settings, "storage-location");
-}
-
-/**
- * gtd_application_set_storage_location:
- *
- * Sets the default storage location for the application. New lists will
- * be created there by default.
- *
- * Returns:
- */
-void
-gtd_application_set_storage_location (GtdApplication *application,
- const gchar *location)
-{
- g_return_if_fail (GTD_IS_APPLICATION (application));
-
- g_settings_set_string (application->priv->settings,
- "storage-location",
- location);
-}
diff --git a/src/gtd-application.h b/src/gtd-application.h
index 2e975b2..8fb1d14 100644
--- a/src/gtd-application.h
+++ b/src/gtd-application.h
@@ -33,11 +33,6 @@ GtdApplication* gtd_application_new (void);
GtdManager* gtd_application_get_manager (GtdApplication
*application);
-gchar* gtd_application_get_storage_location (GtdApplication *app);
-
-void gtd_application_set_storage_location (GtdApplication *application,
- const gchar *location);
-
G_END_DECLS
#endif /* GTD_APPLICATION_H */
diff --git a/src/gtd-initial-setup-window.c b/src/gtd-initial-setup-window.c
index f57e394..286ede1 100644
--- a/src/gtd-initial-setup-window.c
+++ b/src/gtd-initial-setup-window.c
@@ -30,7 +30,6 @@ typedef struct
GtkWidget *done_button;
GtkWidget *storage_selector;
- GtdApplication *application;
GtdManager *manager;
} GtdInitialSetupWindowPrivate;
@@ -71,7 +70,7 @@ gtd_initial_setup_window__location_selected (GtdInitialSetupWindow *window,
gtk_widget_set_sensitive (priv->done_button, storage != NULL);
if (storage)
- gtd_application_set_storage_location (priv->application, gtd_storage_get_id (storage));
+ gtd_manager_set_default_storage (priv->manager, gtd_storage_get_id (storage));
}
static void
@@ -240,16 +239,10 @@ gtd_initial_setup_window_init (GtdInitialSetupWindow *self)
GtkWidget*
gtd_initial_setup_window_new (GtdApplication *application)
{
- GtdInitialSetupWindow *window;
-
g_return_val_if_fail (GTD_IS_APPLICATION (application), NULL);
- window = g_object_new (GTD_TYPE_INITIAL_SETUP_WINDOW,
- "application", application,
- "manager", gtd_application_get_manager (application),
- NULL);
-
- window->priv->application = application;
-
- return GTK_WIDGET (window);
+ return g_object_new (GTD_TYPE_INITIAL_SETUP_WINDOW,
+ "application", application,
+ "manager", gtd_application_get_manager (application),
+ NULL);
}
diff --git a/src/gtd-manager.c b/src/gtd-manager.c
index 8dce9a9..ecb9b38 100644
--- a/src/gtd-manager.c
+++ b/src/gtd-manager.c
@@ -1240,3 +1240,75 @@ gtd_manager_get_storage_locations (GtdManager *manager)
return g_list_copy (manager->priv->storage_locations);
}
+
+/**
+ * gtd_manager_get_default_storage:
+ * @manager: a #GtdManager
+ *
+ * Retrieves the default storage location id. Default is "local".
+ *
+ * Returns: (transfer full): the default storage id. Free with @g_free after use.
+ */
+gchar*
+gtd_manager_get_default_storage (GtdManager *manager)
+{
+ g_return_val_if_fail (GTD_IS_MANAGER (manager), NULL);
+
+ return g_settings_get_string (manager->priv->settings, "srotage-location");
+}
+
+/**
+ * gtd_manager_set_default_storage:
+ * @manager: a #GtdManager
+ * @default_storage: the default storage location.
+ *
+ * Sets the default storage location id.
+ *
+ * Returns:
+ */
+void
+gtd_manager_set_default_storage (GtdManager *manager,
+ const gchar *default_storage)
+{
+ g_return_if_fail (GTD_IS_MANAGER (manager));
+
+ g_settings_set_string (manager->priv->settings,
+ "storage-location",
+ default_storage);
+}
+
+/**
+ * gtd_manager_get_is_first_run:
+ * @manager: a #GtdManager
+ *
+ * Retrieves the 'first-run' setting.
+ *
+ * Returns: %TRUE if GNOME To Do was never run before, %FALSE otherwise.
+ */
+gboolean
+gtd_manager_get_is_first_run (GtdManager *manager)
+{
+ g_return_val_if_fail (GTD_IS_MANAGER (manager), FALSE);
+
+ return g_settings_get_boolean (manager->priv->settings, "first-run");
+}
+
+/**
+ * gtd_manager_set_is_first_run:
+ * @manager: a #GtdManager
+ * @is_first_run: %TRUE to make it first run, %FALSE otherwise.
+ *
+ * Sets the 'first-run' setting.
+ *
+ * Returns:
+ */
+void
+gtd_manager_set_is_first_run (GtdManager *manager,
+ gboolean is_first_run)
+{
+ g_return_if_fail (GTD_IS_MANAGER (manager));
+
+ g_settings_set_boolean (manager->priv->settings,
+ "first-run",
+ is_first_run);
+}
diff --git a/src/gtd-manager.h b/src/gtd-manager.h
index 00bd1fe..41e5058 100644
--- a/src/gtd-manager.h
+++ b/src/gtd-manager.h
@@ -62,6 +62,17 @@ GoaClient* gtd_manager_get_goa_client (GtdManager
gboolean gtd_manager_is_goa_client_ready (GtdManager *manager);
+/* Settings */
+gchar* gtd_manager_get_default_storage (GtdManager *manager);
+
+void gtd_manager_set_default_storage (GtdManager *manager,
+ const gchar *default_storage);
+
+gboolean gtd_manager_get_is_first_run (GtdManager *manager);
+
+void gtd_manager_set_is_first_run (GtdManager *manager,
+ gboolean is_first_run);
+
G_END_DECLS
#endif /* GTD_MANAGER_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]