[gnome-todo/wip/gbsneto/plugins: 50/62] project: remove needless private fields
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-todo/wip/gbsneto/plugins: 50/62] project: remove needless private fields
- Date: Fri, 15 Jan 2016 01:07:23 +0000 (UTC)
commit 162625a8262115c9fc1ac6f26181ce8e2e4c21f3
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Mon Jan 4 04:31:14 2016 -0200
project: remove needless private fields
src/provider/gtd-provider-dialog.c | 142 ++--------------------
src/provider/gtd-provider-dialog.h | 5 -
src/provider/gtd-provider-popover.c | 160 +++++-------------------
src/provider/gtd-provider-selector.c | 226 ++++++++++++----------------------
4 files changed, 122 insertions(+), 411 deletions(-)
---
diff --git a/src/provider/gtd-provider-dialog.c b/src/provider/gtd-provider-dialog.c
index 30a864a..1fab797 100644
--- a/src/provider/gtd-provider-dialog.c
+++ b/src/provider/gtd-provider-dialog.c
@@ -23,44 +23,28 @@
#include <glib/gi18n.h>
-typedef struct
+struct _GtdProviderDialog
{
+ GtkDialog parent;
GtkWidget *headerbar;
GtkWidget *provider_selector;
-
- GtdManager *manager;
-} GtdProviderDialogPrivate;
-
-struct _GtdProviderDialog
-{
- GtkDialog parent;
-
- /*<private>*/
- GtdProviderDialogPrivate *priv;
};
-G_DEFINE_TYPE_WITH_PRIVATE (GtdProviderDialog, gtd_provider_dialog, GTK_TYPE_DIALOG)
-
-enum {
- PROP_0,
- PROP_MANAGER,
- LAST_PROP
-};
+G_DEFINE_TYPE (GtdProviderDialog, gtd_provider_dialog, GTK_TYPE_DIALOG)
static void
gtd_provider_dialog__provider_selected (GtdProviderDialog *dialog,
GtdProvider *provider)
{
- GtdProviderDialogPrivate *priv;
+ GtdManager *manager;
g_return_if_fail (GTD_IS_PROVIDER_DIALOG (dialog));
- g_return_if_fail (GTD_IS_MANAGER (dialog->priv->manager));
g_return_if_fail (GTD_IS_PROVIDER (provider));
- priv = dialog->priv;
+ manager = gtd_manager_get_default ();
if (provider)
- gtd_manager_set_default_provider (priv->manager, provider);
+ gtd_manager_set_default_provider (manager, provider);
}
static void
@@ -72,58 +56,13 @@ gtd_provider_dialog_finalize (GObject *object)
static void
gtd_provider_dialog_constructed (GObject *object)
{
- GtdProviderDialogPrivate *priv;
+ GtdProviderDialog *self = GTD_PROVIDER_DIALOG (object);
/* Chain up */
G_OBJECT_CLASS (gtd_provider_dialog_parent_class)->constructed (object);
- priv = GTD_PROVIDER_DIALOG (object)->priv;
-
- gtk_window_set_titlebar (GTK_WINDOW (object), priv->headerbar);
-
- g_object_bind_property (object,
- "manager",
- priv->provider_selector,
- "manager",
- G_BINDING_DEFAULT);
-}
-
-static void
-gtd_provider_dialog_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GtdProviderDialog *self = GTD_PROVIDER_DIALOG (object);
-
- switch (prop_id)
- {
- case PROP_MANAGER:
- g_value_set_object (value, self->priv->manager);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
-}
-
-static void
-gtd_provider_dialog_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GtdProviderDialog *self = GTD_PROVIDER_DIALOG (object);
-
- switch (prop_id)
- {
- case PROP_MANAGER:
- gtd_provider_dialog_set_manager (self, g_value_get_object (value));
- break;
+ gtk_window_set_titlebar (GTK_WINDOW (object), self->headerbar);
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
}
static void
@@ -134,28 +73,11 @@ gtd_provider_dialog_class_init (GtdProviderDialogClass *klass)
object_class->finalize = gtd_provider_dialog_finalize;
object_class->constructed = gtd_provider_dialog_constructed;
- object_class->get_property = gtd_provider_dialog_get_property;
- object_class->set_property = gtd_provider_dialog_set_property;
-
-
- /**
- * GtdProviderDialog::manager:
- *
- * A weak reference to the application's #GtdManager instance.
- */
- g_object_class_install_property (
- object_class,
- PROP_MANAGER,
- g_param_spec_object ("manager",
- "Manager of this window's application",
- "The manager of the window's application",
- GTD_TYPE_MANAGER,
- G_PARAM_READWRITE));
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/todo/ui/provider-dialog.ui");
- gtk_widget_class_bind_template_child_private (widget_class, GtdProviderDialog, headerbar);
- gtk_widget_class_bind_template_child_private (widget_class, GtdProviderDialog, provider_selector);
+ gtk_widget_class_bind_template_child (widget_class, GtdProviderDialog, headerbar);
+ gtk_widget_class_bind_template_child (widget_class, GtdProviderDialog, provider_selector);
gtk_widget_class_bind_template_callback (widget_class, gtd_provider_dialog__provider_selected);
}
@@ -163,8 +85,6 @@ gtd_provider_dialog_class_init (GtdProviderDialogClass *klass)
static void
gtd_provider_dialog_init (GtdProviderDialog *self)
{
- self->priv = gtd_provider_dialog_get_instance_private (self);
-
gtk_widget_init_template (GTK_WIDGET (self));
}
@@ -180,45 +100,3 @@ gtd_provider_dialog_new (void)
{
return g_object_new (GTD_TYPE_PROVIDER_DIALOG, NULL);
}
-
-/**
- * gtd_provider_dialog_get_manager:
- * @dialog: a #GtdProviderDialog
- *
- * Retrieves @dialog's internal #GtdManager.
- *
- * Returns: (transfer none): the @dialog's #GtdManager
- */
-GtdManager*
-gtd_provider_dialog_get_manager (GtdProviderDialog *dialog)
-{
- g_return_val_if_fail (GTD_IS_PROVIDER_DIALOG (dialog), NULL);
-
- return dialog->priv->manager;
-}
-
-/**
- * gtd_provider_dialog_set_manager:
- * @dialog: a #GtdProviderDialog
- * @manager: a #GtdManager
- *
- * Sets the @dialog's #GtdManager.
- *
- * Returns:
- */
-void
-gtd_provider_dialog_set_manager (GtdProviderDialog *dialog,
- GtdManager *manager)
-{
- GtdProviderDialogPrivate *priv;
-
- g_return_if_fail (GTD_IS_PROVIDER_DIALOG (dialog));
-
- priv = dialog->priv;
-
- if (priv->manager != manager)
- {
- priv->manager = manager;
- g_object_notify (G_OBJECT (dialog), "manager");
- }
-}
diff --git a/src/provider/gtd-provider-dialog.h b/src/provider/gtd-provider-dialog.h
index cc419b3..690d4bc 100644
--- a/src/provider/gtd-provider-dialog.h
+++ b/src/provider/gtd-provider-dialog.h
@@ -31,11 +31,6 @@ G_DECLARE_FINAL_TYPE (GtdProviderDialog, gtd_provider_dialog, GTD, PROVIDER_DIAL
GtkWidget* gtd_provider_dialog_new (void);
-GtdManager* gtd_provider_dialog_get_manager (GtdProviderDialog *dialog);
-
-void gtd_provider_dialog_set_manager (GtdProviderDialog *dialog,
- GtdManager *manager);
-
G_END_DECLS
#endif /* GTD_PROVIDER_DIALOG_H */
diff --git a/src/provider/gtd-provider-popover.c b/src/provider/gtd-provider-popover.c
index 9412061..b9e033f 100644
--- a/src/provider/gtd-provider-popover.c
+++ b/src/provider/gtd-provider-popover.c
@@ -24,53 +24,39 @@
#include <glib/gi18n.h>
-typedef struct
+struct _GtdProviderPopover
{
+ GtkPopover parent;
+
GtkWidget *change_location_button;
GtkWidget *location_provider_image;
GtkWidget *new_list_create_button;
GtkWidget *new_list_name_entry;
GtkWidget *stack;
GtkWidget *provider_selector;
-
- GtdManager *manager;
-} GtdProviderPopoverPrivate;
-
-struct _GtdProviderPopover
-{
- GtkPopover parent;
-
- /*<private>*/
- GtdProviderPopoverPrivate *priv;
};
-G_DEFINE_TYPE_WITH_PRIVATE (GtdProviderPopover, gtd_provider_popover, GTK_TYPE_POPOVER)
-
-enum {
- PROP_0,
- PROP_MANAGER,
- LAST_PROP
-};
+G_DEFINE_TYPE (GtdProviderPopover, gtd_provider_popover, GTK_TYPE_POPOVER)
static void
clear_and_hide (GtdProviderPopover *popover)
{
- GtdProviderPopoverPrivate *priv;
+ GtdManager *manager;
GList *locations;
GList *l;
g_return_if_fail (GTD_IS_PROVIDER_POPOVER (popover));
- priv = popover->priv;
+ manager = gtd_manager_get_default ();
/* Select the default source again */
- locations = gtd_manager_get_providers (priv->manager);
+ locations = gtd_manager_get_providers (manager);
for (l = locations; l != NULL; l = l->next)
{
if (FALSE)//gtd_provider_get_is_default (l->data))
{
- gtd_provider_selector_set_selected_provider (GTD_PROVIDER_SELECTOR (priv->provider_selector),
l->data);
+ gtd_provider_selector_set_selected_provider (GTD_PROVIDER_SELECTOR (popover->provider_selector),
l->data);
break;
}
}
@@ -78,7 +64,7 @@ clear_and_hide (GtdProviderPopover *popover)
g_list_free (locations);
/* By clearing the text, Create button will get insensitive */
- gtk_entry_set_text (GTK_ENTRY (priv->new_list_name_entry), "");
+ gtk_entry_set_text (GTK_ENTRY (popover->new_list_name_entry), "");
/* Hide the popover at last */
gtk_widget_hide (GTK_WIDGET (popover));
@@ -89,20 +75,18 @@ gtd_provider_popover__closed (GtdProviderPopover *popover)
{
g_return_if_fail (GTD_IS_PROVIDER_POPOVER (popover));
- gtk_stack_set_visible_child_name (GTK_STACK (popover->priv->stack), "main");
+ gtk_stack_set_visible_child_name (GTK_STACK (popover->stack), "main");
}
static void
create_task_list (GtdProviderPopover *popover)
{
- GtdProviderPopoverPrivate *priv;
GtdTaskList *task_list;
GtdProvider *provider;
const gchar *name;
- priv = popover->priv;
- provider = gtd_provider_selector_get_selected_provider (GTD_PROVIDER_SELECTOR (priv->provider_selector));
- name = gtk_entry_get_text (GTK_ENTRY (priv->new_list_name_entry));
+ provider = gtd_provider_selector_get_selected_provider (GTD_PROVIDER_SELECTOR
(popover->provider_selector));
+ name = gtk_entry_get_text (GTK_ENTRY (popover->new_list_name_entry));
task_list = gtd_task_list_new (provider);
gtd_task_list_set_name (task_list, name);
@@ -125,13 +109,9 @@ static void
gtd_provider_popover__action_button_clicked (GtdProviderPopover *popover,
GtkWidget *button)
{
- GtdProviderPopoverPrivate *priv;
-
g_return_if_fail (GTD_IS_PROVIDER_POPOVER (popover));
- priv = popover->priv;
-
- if (button == priv->new_list_create_button)
+ if (button == popover->new_list_create_button)
create_task_list (popover);
clear_and_hide (popover);
@@ -142,55 +122,43 @@ gtd_provider_popover__text_changed_cb (GtdProviderPopover *popover,
GParamSpec *spec,
GtkEntry *entry)
{
- GtdProviderPopoverPrivate *priv;
-
g_return_if_fail (GTD_IS_PROVIDER_POPOVER (popover));
g_return_if_fail (GTK_IS_ENTRY (entry));
- priv = popover->priv;
-
- gtk_widget_set_sensitive (priv->new_list_create_button, gtk_entry_get_text_length (entry) > 0);
+ gtk_widget_set_sensitive (popover->new_list_create_button, gtk_entry_get_text_length (entry) > 0);
}
static void
gtd_provider_popover__change_location_clicked (GtdProviderPopover *popover,
GtkWidget *button)
{
- GtdProviderPopoverPrivate *priv;
-
g_return_if_fail (GTD_IS_PROVIDER_POPOVER (popover));
- priv = popover->priv;
-
- if (button == priv->change_location_button)
- gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "selector");
+ if (button == popover->change_location_button)
+ gtk_stack_set_visible_child_name (GTK_STACK (popover->stack), "selector");
else
- gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "main");
+ gtk_stack_set_visible_child_name (GTK_STACK (popover->stack), "main");
}
static void
gtd_provider_popover__provider_selected (GtdProviderPopover *popover,
GtdProvider *provider)
{
- GtdProviderPopoverPrivate *priv;
-
g_return_if_fail (GTD_IS_PROVIDER_POPOVER (popover));
g_return_if_fail (GTD_IS_PROVIDER (provider));
- priv = popover->priv;
-
if (provider)
{
- gtk_image_set_from_gicon (GTK_IMAGE (priv->location_provider_image),
+ gtk_image_set_from_gicon (GTK_IMAGE (popover->location_provider_image),
gtd_provider_get_icon (provider),
GTK_ICON_SIZE_BUTTON);
- gtk_widget_set_tooltip_text (priv->change_location_button, gtd_provider_get_name (provider));
+ gtk_widget_set_tooltip_text (popover->change_location_button, gtd_provider_get_name (provider));
/* Go back immediately after selecting a provider */
- gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "main");
+ gtk_stack_set_visible_child_name (GTK_STACK (popover->stack), "main");
if (gtk_widget_is_visible (GTK_WIDGET (popover)))
- gtk_widget_grab_focus (priv->new_list_name_entry);
+ gtk_widget_grab_focus (popover->new_list_name_entry);
}
}
@@ -203,71 +171,23 @@ gtd_provider_popover_finalize (GObject *object)
static void
gtd_provider_popover_constructed (GObject *object)
{
- GtdProviderPopoverPrivate *priv;
+ GtdProviderPopover *popover;
GtdProvider *provider;
G_OBJECT_CLASS (gtd_provider_popover_parent_class)->constructed (object);
- priv = GTD_PROVIDER_POPOVER (object)->priv;
- provider = gtd_provider_selector_get_selected_provider (GTD_PROVIDER_SELECTOR (priv->provider_selector));
-
- g_object_bind_property (object,
- "manager",
- priv->provider_selector,
- "manager",
- G_BINDING_DEFAULT);
+ popover = GTD_PROVIDER_POPOVER (object);
+ provider = gtd_provider_selector_get_selected_provider (GTD_PROVIDER_SELECTOR
(popover->provider_selector));
if (provider)
{
- gtk_image_set_from_gicon (GTK_IMAGE (priv->location_provider_image),
+ gtk_image_set_from_gicon (GTK_IMAGE (popover->location_provider_image),
gtd_provider_get_icon (provider),
GTK_ICON_SIZE_BUTTON);
}
}
static void
-gtd_provider_popover_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GtdProviderPopover *self = GTD_PROVIDER_POPOVER (object);
-
- switch (prop_id)
- {
- case PROP_MANAGER:
- g_value_set_object (value, self->priv->manager);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
-}
-
-static void
-gtd_provider_popover_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GtdProviderPopover *self = GTD_PROVIDER_POPOVER (object);
-
- switch (prop_id)
- {
- case PROP_MANAGER:
- if (self->priv->manager != g_value_get_object (value))
- {
- self->priv->manager = g_value_get_object (value);
- g_object_notify (object, "manager");
- }
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
-}
-
-static void
gtd_provider_popover_class_init (GtdProviderPopoverClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -275,31 +195,15 @@ gtd_provider_popover_class_init (GtdProviderPopoverClass *klass)
object_class->finalize = gtd_provider_popover_finalize;
object_class->constructed = gtd_provider_popover_constructed;
- object_class->get_property = gtd_provider_popover_get_property;
- object_class->set_property = gtd_provider_popover_set_property;
-
- /**
- * GtdProviderPopover::manager:
- *
- * A weak reference to the application's #GtdManager instance.
- */
- g_object_class_install_property (
- object_class,
- PROP_MANAGER,
- g_param_spec_object ("manager",
- "Manager of this window's application",
- "The manager of the window's application",
- GTD_TYPE_MANAGER,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/todo/ui/provider-popover.ui");
- gtk_widget_class_bind_template_child_private (widget_class, GtdProviderPopover, change_location_button);
- gtk_widget_class_bind_template_child_private (widget_class, GtdProviderPopover, location_provider_image);
- gtk_widget_class_bind_template_child_private (widget_class, GtdProviderPopover, new_list_create_button);
- gtk_widget_class_bind_template_child_private (widget_class, GtdProviderPopover, new_list_name_entry);
- gtk_widget_class_bind_template_child_private (widget_class, GtdProviderPopover, stack);
- gtk_widget_class_bind_template_child_private (widget_class, GtdProviderPopover, provider_selector);
+ gtk_widget_class_bind_template_child (widget_class, GtdProviderPopover, change_location_button);
+ gtk_widget_class_bind_template_child (widget_class, GtdProviderPopover, location_provider_image);
+ gtk_widget_class_bind_template_child (widget_class, GtdProviderPopover, new_list_create_button);
+ gtk_widget_class_bind_template_child (widget_class, GtdProviderPopover, new_list_name_entry);
+ gtk_widget_class_bind_template_child (widget_class, GtdProviderPopover, stack);
+ gtk_widget_class_bind_template_child (widget_class, GtdProviderPopover, provider_selector);
gtk_widget_class_bind_template_callback (widget_class, gtd_provider_popover__action_button_clicked);
gtk_widget_class_bind_template_callback (widget_class, gtd_provider_popover__change_location_clicked);
@@ -312,8 +216,6 @@ gtd_provider_popover_class_init (GtdProviderPopoverClass *klass)
static void
gtd_provider_popover_init (GtdProviderPopover *self)
{
- self->priv = gtd_provider_popover_get_instance_private (self);
-
gtk_widget_init_template (GTK_WIDGET (self));
}
diff --git a/src/provider/gtd-provider-selector.c b/src/provider/gtd-provider-selector.c
index f8e5af8..89f8705 100644
--- a/src/provider/gtd-provider-selector.c
+++ b/src/provider/gtd-provider-selector.c
@@ -24,8 +24,10 @@
#include <glib/gi18n.h>
-typedef struct
+struct _GtdProviderSelector
{
+ GtkBox parent;
+
GtkWidget *listbox;
GtkWidget *local_check;
@@ -35,26 +37,15 @@ typedef struct
GtkWidget *owncloud_stub_row;
GtkWidget *local_row;
- GtdManager *manager;
-
gint select_default : 1;
gint show_local_provider : 1;
gint show_stub_rows : 1;
-} GtdProviderSelectorPrivate;
-
-struct _GtdProviderSelector
-{
- GtkBox parent;
-
- /*< private >*/
- GtdProviderSelectorPrivate *priv;
};
-G_DEFINE_TYPE_WITH_PRIVATE (GtdProviderSelector, gtd_provider_selector, GTK_TYPE_BOX)
+G_DEFINE_TYPE (GtdProviderSelector, gtd_provider_selector, GTK_TYPE_BOX)
enum {
PROP_0,
- PROP_MANAGER,
PROP_SELECT_DEFAULT,
PROP_SHOW_LOCAL,
PROP_SHOW_STUB_ROWS,
@@ -102,7 +93,6 @@ gtd_provider_selector__default_provider_changed (GtdProviderSelector *selector,
GtdProvider *current,
GtdProvider *previous)
{
- GtdProviderSelectorPrivate *priv;
GList *children;
GList *l;
@@ -110,12 +100,10 @@ gtd_provider_selector__default_provider_changed (GtdProviderSelector *selector,
g_return_if_fail (GTD_IS_PROVIDER (previous));
g_return_if_fail (GTD_IS_PROVIDER (current));
- priv = selector->priv;
-
- if (!priv->select_default)
+ if (!selector->select_default)
return;
- children = gtk_container_get_children (GTK_CONTAINER (priv->listbox));
+ children = gtk_container_get_children (GTK_CONTAINER (selector->listbox));
for (l = children; l != NULL; l = l->next)
{
@@ -138,22 +126,18 @@ static void
gtd_provider_selector__listbox_row_activated (GtdProviderSelector *selector,
GtkWidget *row)
{
- GtdProviderSelectorPrivate *priv;
-
g_return_if_fail (GTD_IS_PROVIDER_SELECTOR (selector));
- priv = selector->priv;
-
/* The row is either one of the stub rows, or a GtdGoaRow */
- if (row == priv->google_stub_row)
+ if (row == selector->google_stub_row)
{
spawn ("add", "google");
}
- else if (row == priv->owncloud_stub_row)
+ else if (row == selector->owncloud_stub_row)
{
spawn ("add", "owncloud");
}
- else if (row == priv->exchange_stub_row)
+ else if (row == selector->exchange_stub_row)
{
spawn ("add", "exchange");
}
@@ -163,7 +147,7 @@ gtd_provider_selector__listbox_row_activated (GtdProviderSelector *selector,
GList *children;
GList *l;
- children = gtk_container_get_children (GTK_CONTAINER (priv->listbox));
+ children = gtk_container_get_children (GTK_CONTAINER (selector->listbox));
provider = gtd_provider_row_get_provider (GTD_PROVIDER_ROW (row));
for (l = children; l != NULL; l = l->next)
@@ -195,12 +179,9 @@ static void
gtd_provider_selector__check_toggled (GtdProviderSelector *selector,
GtkToggleButton *check)
{
- GtdProviderSelectorPrivate *priv;
g_return_if_fail (GTD_IS_PROVIDER_SELECTOR (selector));
- priv = selector->priv;
-
/*
* Unset the currently selected provider location row when the check button is
* activated. No need to do this when deactivated, since we already did.
@@ -212,8 +193,8 @@ gtd_provider_selector__check_toggled (GtdProviderSelector *selector,
GList *children;
GList *l;
- children = gtk_container_get_children (GTK_CONTAINER (priv->listbox));
- local_provider = gtd_provider_row_get_provider (GTD_PROVIDER_ROW (priv->local_row));
+ children = gtk_container_get_children (GTK_CONTAINER (selector->listbox));
+ local_provider = gtd_provider_row_get_provider (GTD_PROVIDER_ROW (selector->local_row));
for (l = children; l != NULL; l = l->next)
{
@@ -239,7 +220,6 @@ static void
gtd_provider_selector__remove_provider (GtdProviderSelector *selector,
GtdProvider *provider)
{
- GtdProviderSelectorPrivate *priv;
GList *children;
GList *l;
gint exchange;
@@ -249,8 +229,7 @@ gtd_provider_selector__remove_provider (GtdProviderSelector *selector,
g_return_if_fail (GTD_IS_PROVIDER_SELECTOR (selector));
g_return_if_fail (GTD_IS_PROVIDER (provider));
- priv = selector->priv;
- children = gtk_container_get_children (GTK_CONTAINER (priv->listbox));
+ children = gtk_container_get_children (GTK_CONTAINER (selector->listbox));
exchange = google = owncloud = 0;
for (l = children; l != NULL; l = l->next)
@@ -279,9 +258,9 @@ gtd_provider_selector__remove_provider (GtdProviderSelector *selector,
}
}
- gtk_widget_set_visible (priv->exchange_stub_row, exchange == 0);
- gtk_widget_set_visible (priv->google_stub_row, google == 0);
- gtk_widget_set_visible (priv->owncloud_stub_row, owncloud == 0);
+ gtk_widget_set_visible (selector->exchange_stub_row, exchange == 0);
+ gtk_widget_set_visible (selector->google_stub_row, google == 0);
+ gtk_widget_set_visible (selector->owncloud_stub_row, owncloud == 0);
g_list_free (children);
}
@@ -290,29 +269,26 @@ static void
gtd_provider_selector__add_provider (GtdProviderSelector *selector,
GtdProvider *provider)
{
- GtdProviderSelectorPrivate *priv;
GtkWidget *row;
const gchar *provider_id;
g_return_if_fail (GTD_IS_PROVIDER_SELECTOR (selector));
g_return_if_fail (GTD_IS_PROVIDER (provider));
- priv = selector->priv;
-
row = gtd_provider_row_new (provider);
provider_id = gtd_provider_get_id (provider);
- gtk_container_add (GTK_CONTAINER (priv->listbox), row);
+ gtk_container_add (GTK_CONTAINER (selector->listbox), row);
/* track the local provider row */
if (g_strcmp0 (provider_id, "local") == 0)
{
- gtk_widget_set_visible (row, priv->show_local_provider);
- priv->local_row = row;
+ gtk_widget_set_visible (row, selector->show_local_provider);
+ selector->local_row = row;
}
/* Auto selects the default provider row when needed */
- if (priv->select_default &&
+ if (selector->select_default &&
//gtd_provider_get_is_default (provider) &&
!gtd_provider_selector_get_selected_provider (selector))
{
@@ -321,26 +297,26 @@ gtd_provider_selector__add_provider (GtdProviderSelector *selector,
/* hide the related stub row */
if (g_strcmp0 (provider_id, "exchange") == 0)
- gtk_widget_hide (priv->exchange_stub_row);
+ gtk_widget_hide (selector->exchange_stub_row);
else if (g_strcmp0 (provider_id, "google") == 0)
- gtk_widget_hide (priv->google_stub_row);
+ gtk_widget_hide (selector->google_stub_row);
else if (g_strcmp0 (provider_id, "owncloud") == 0)
- gtk_widget_hide (priv->owncloud_stub_row);
+ gtk_widget_hide (selector->owncloud_stub_row);
}
static void
gtd_provider_selector__fill_accounts (GtdProviderSelector *selector)
{
- GtdProviderSelectorPrivate *priv;
+ GtdManager *manager;
GList *providers;
GList *l;
g_return_if_fail (GTD_IS_PROVIDER_SELECTOR (selector));
- priv = selector->priv;
+ manager = gtd_manager_get_default ();
/* load accounts */
- providers = gtd_manager_get_providers (priv->manager);
+ providers = gtd_manager_get_providers (manager);
for (l = providers; l != NULL; l = l->next)
gtd_provider_selector__add_provider (selector, l->data);
@@ -370,17 +346,15 @@ sort_func (GtkListBoxRow *row1,
static void
gtd_provider_selector_constructed (GObject *object)
{
- GtdProviderSelectorPrivate *priv;
+ GtdProviderSelector *self = GTD_PROVIDER_SELECTOR (object);
G_OBJECT_CLASS (gtd_provider_selector_parent_class)->constructed (object);
- priv = GTD_PROVIDER_SELECTOR (object)->priv;
-
- gtk_list_box_set_header_func (GTK_LIST_BOX (priv->listbox),
+ gtk_list_box_set_header_func (GTK_LIST_BOX (self->listbox),
display_header_func,
NULL,
NULL);
- gtk_list_box_set_sort_func (GTK_LIST_BOX (priv->listbox),
+ gtk_list_box_set_sort_func (GTK_LIST_BOX (self->listbox),
(GtkListBoxSortFunc) sort_func,
NULL,
NULL);
@@ -402,20 +376,16 @@ gtd_provider_selector_get_property (GObject *object,
switch (prop_id)
{
- case PROP_MANAGER:
- g_value_set_object (value, self->priv->manager);
- break;
-
case PROP_SELECT_DEFAULT:
- g_value_set_boolean (value, self->priv->select_default);
+ g_value_set_boolean (value, self->select_default);
break;
case PROP_SHOW_LOCAL:
- g_value_set_boolean (value, self->priv->show_local_provider);
+ g_value_set_boolean (value, self->show_local_provider);
break;
case PROP_SHOW_STUB_ROWS:
- g_value_set_boolean (value, self->priv->show_stub_rows);
+ g_value_set_boolean (value, self->show_stub_rows);
break;
default:
@@ -433,32 +403,6 @@ gtd_provider_selector_set_property (GObject *object,
switch (prop_id)
{
- case PROP_MANAGER:
- self->priv->manager = g_value_get_object (value);
-
- if (!self->priv->manager)
- break;
-
- gtd_provider_selector__fill_accounts (self);
-
- g_signal_connect_swapped (self->priv->manager,
- "default-provider-changed",
- G_CALLBACK (gtd_provider_selector__default_provider_changed),
- object);
-
- g_signal_connect_swapped (self->priv->manager,
- "provider-added",
- G_CALLBACK (gtd_provider_selector__add_provider),
- object);
-
- g_signal_connect_swapped (self->priv->manager,
- "provider-removed",
- G_CALLBACK (gtd_provider_selector__remove_provider),
- object);
-
- g_object_notify (object, "manager");
- break;
-
case PROP_SELECT_DEFAULT:
gtd_provider_selector_set_select_default (self, g_value_get_boolean (value));
break;
@@ -503,19 +447,6 @@ gtd_provider_selector_class_init (GtdProviderSelectorClass *klass)
1,
GTD_TYPE_PROVIDER);
- /**
- * GtdProviderSelector::manager:
- *
- * A weak reference to the application's #GtdManager instance.
- */
- g_object_class_install_property (
- object_class,
- PROP_MANAGER,
- g_param_spec_object ("manager",
- "Manager of this window's application",
- "The manager of the window's application",
- GTD_TYPE_MANAGER,
- G_PARAM_READWRITE));
/**
* GtdProviderSelector::show-local-provider:
@@ -561,11 +492,11 @@ gtd_provider_selector_class_init (GtdProviderSelectorClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/todo/ui/provider-selector.ui");
- gtk_widget_class_bind_template_child_private (widget_class, GtdProviderSelector, exchange_stub_row);
- gtk_widget_class_bind_template_child_private (widget_class, GtdProviderSelector, google_stub_row);
- gtk_widget_class_bind_template_child_private (widget_class, GtdProviderSelector, listbox);
- gtk_widget_class_bind_template_child_private (widget_class, GtdProviderSelector, local_check);
- gtk_widget_class_bind_template_child_private (widget_class, GtdProviderSelector, owncloud_stub_row);
+ gtk_widget_class_bind_template_child (widget_class, GtdProviderSelector, exchange_stub_row);
+ gtk_widget_class_bind_template_child (widget_class, GtdProviderSelector, google_stub_row);
+ gtk_widget_class_bind_template_child (widget_class, GtdProviderSelector, listbox);
+ gtk_widget_class_bind_template_child (widget_class, GtdProviderSelector, local_check);
+ gtk_widget_class_bind_template_child (widget_class, GtdProviderSelector, owncloud_stub_row);
gtk_widget_class_bind_template_callback (widget_class, gtd_provider_selector__check_toggled);
gtk_widget_class_bind_template_callback (widget_class, gtd_provider_selector__listbox_row_activated);
@@ -574,8 +505,29 @@ gtd_provider_selector_class_init (GtdProviderSelectorClass *klass)
static void
gtd_provider_selector_init (GtdProviderSelector *self)
{
- self->priv = gtd_provider_selector_get_instance_private (self);
- self->priv->show_stub_rows = TRUE;
+ GtdManager *manager;
+
+ self->show_stub_rows = TRUE;
+
+ /* Setup the manager */
+ manager = gtd_manager_get_default ();
+
+ gtd_provider_selector__fill_accounts (self);
+
+ g_signal_connect_swapped (manager,
+ "default-provider-changed",
+ G_CALLBACK (gtd_provider_selector__default_provider_changed),
+ self);
+
+ g_signal_connect_swapped (manager,
+ "provider-added",
+ G_CALLBACK (gtd_provider_selector__add_provider),
+ self);
+
+ g_signal_connect_swapped (manager,
+ "provider-removed",
+ G_CALLBACK (gtd_provider_selector__remove_provider),
+ self);
gtk_widget_init_template (GTK_WIDGET (self));
}
@@ -604,20 +556,16 @@ void
gtd_provider_selector_show_local (GtdProviderSelector *selector,
gboolean show)
{
- GtdProviderSelectorPrivate *priv;
-
g_return_if_fail (GTD_IS_PROVIDER_SELECTOR (selector));
- priv = selector->priv;
-
- if (priv->show_local_provider != show)
+ if (selector->show_local_provider != show)
{
- priv->show_local_provider = show;
+ selector->show_local_provider = show;
- gtk_widget_set_visible (priv->local_check, !show);
+ gtk_widget_set_visible (selector->local_check, !show);
- if (priv->local_row)
- gtk_widget_set_visible (priv->local_row, show);
+ if (selector->local_row)
+ gtk_widget_set_visible (selector->local_row, show);
g_object_notify (G_OBJECT (selector), "show-local");
}
@@ -637,7 +585,7 @@ gtd_provider_selector_get_select_default (GtdProviderSelector *selector)
{
g_return_val_if_fail (GTD_IS_PROVIDER_SELECTOR (selector), FALSE);
- return selector->priv->select_default;
+ return selector->select_default;
}
/**
@@ -653,15 +601,11 @@ void
gtd_provider_selector_set_select_default (GtdProviderSelector *selector,
gboolean select_default)
{
- GtdProviderSelectorPrivate *priv;
-
g_return_if_fail (GTD_IS_PROVIDER_SELECTOR (selector));
- priv = selector->priv;
-
- if (priv->select_default != select_default)
+ if (selector->select_default != select_default)
{
- priv->select_default = select_default;
+ selector->select_default = select_default;
if (select_default)
{
@@ -669,7 +613,7 @@ gtd_provider_selector_set_select_default (GtdProviderSelector *selector,
GList *l;
/* Select the appropriate row */
- children = gtk_container_get_children (GTK_CONTAINER (priv->listbox));
+ children = gtk_container_get_children (GTK_CONTAINER (selector->listbox));
for (l = children; l != NULL; l = l->next)
{
@@ -704,16 +648,14 @@ gtd_provider_selector_set_select_default (GtdProviderSelector *selector,
GtdProvider*
gtd_provider_selector_get_selected_provider (GtdProviderSelector *selector)
{
- GtdProviderSelectorPrivate *priv;
GtdProvider *provider;
GList *children;
GList *l;
g_return_val_if_fail (GTD_IS_PROVIDER_SELECTOR (selector), NULL);
- priv = selector->priv;
provider = NULL;
- children = gtk_container_get_children (GTK_CONTAINER (priv->listbox));
+ children = gtk_container_get_children (GTK_CONTAINER (selector->listbox));
for (l = children; l != NULL; l = l->next)
{
@@ -742,14 +684,12 @@ void
gtd_provider_selector_set_selected_provider (GtdProviderSelector *selector,
GtdProvider *provider)
{
- GtdProviderSelectorPrivate *priv;
GList *children;
GList *l;
g_return_if_fail (GTD_IS_PROVIDER_SELECTOR (selector));
- priv = selector->priv;
- children = gtk_container_get_children (GTK_CONTAINER (priv->listbox));
+ children = gtk_container_get_children (GTK_CONTAINER (selector->listbox));
for (l = children; l != NULL; l = l->next)
{
@@ -776,7 +716,7 @@ gtd_provider_selector_get_show_stub_rows (GtdProviderSelector *selector)
{
g_return_val_if_fail (GTD_IS_PROVIDER_SELECTOR (selector), FALSE);
- return selector->priv->show_stub_rows;
+ return selector->show_stub_rows;
}
/**
@@ -792,15 +732,11 @@ void
gtd_provider_selector_set_show_stub_rows (GtdProviderSelector *selector,
gboolean show_stub_rows)
{
- GtdProviderSelectorPrivate *priv;
-
g_return_if_fail (GTD_IS_PROVIDER_SELECTOR (selector));
- priv = selector->priv;
-
- if (priv->show_stub_rows != show_stub_rows)
+ if (selector->show_stub_rows != show_stub_rows)
{
- priv->show_stub_rows = show_stub_rows;
+ selector->show_stub_rows = show_stub_rows;
/*
* If we're showing the stub rows, it must check which ones should be shown.
@@ -814,7 +750,7 @@ gtd_provider_selector_set_show_stub_rows (GtdProviderSelector *selector,
gint exchange_counter;
gint owncloud_counter;
- children = gtk_container_get_children (GTK_CONTAINER (priv->listbox));
+ children = gtk_container_get_children (GTK_CONTAINER (selector->listbox));
google_counter = 0;
exchange_counter = 0;
owncloud_counter = 0;
@@ -837,17 +773,17 @@ gtd_provider_selector_set_show_stub_rows (GtdProviderSelector *selector,
}
}
- gtk_widget_set_visible (priv->google_stub_row, google_counter == 0);
- gtk_widget_set_visible (priv->exchange_stub_row, exchange_counter == 0);
- gtk_widget_set_visible (priv->owncloud_stub_row, owncloud_counter == 0);
+ gtk_widget_set_visible (selector->google_stub_row, google_counter == 0);
+ gtk_widget_set_visible (selector->exchange_stub_row, exchange_counter == 0);
+ gtk_widget_set_visible (selector->owncloud_stub_row, owncloud_counter == 0);
g_list_free (children);
}
else
{
- gtk_widget_hide (priv->exchange_stub_row);
- gtk_widget_hide (priv->google_stub_row);
- gtk_widget_hide (priv->owncloud_stub_row);
+ gtk_widget_hide (selector->exchange_stub_row);
+ gtk_widget_hide (selector->google_stub_row);
+ gtk_widget_hide (selector->owncloud_stub_row);
}
g_object_notify (G_OBJECT (selector), "show-stub-rows");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]