[gnome-calendar] source-dialog: add calendars to the list
- From: Erick Pérez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] source-dialog: add calendars to the list
- Date: Mon, 25 May 2015 16:54:55 +0000 (UTC)
commit 59eb0269e54c9147e0f96aa698c45b8dd748cef1
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue Apr 7 23:16:54 2015 -0300
source-dialog: add calendars to the list
This does not differentiate GOA calendars
from normal ones. It'll happen in the near
future.
src/gcal-source-dialog.c | 101 +++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 100 insertions(+), 1 deletions(-)
---
diff --git a/src/gcal-source-dialog.c b/src/gcal-source-dialog.c
index 3b7814d..721bb05 100644
--- a/src/gcal-source-dialog.c
+++ b/src/gcal-source-dialog.c
@@ -82,6 +82,11 @@ struct _GcalSourceDialog
#define ENTRY_PROGRESS_TIMEOUT 100
+static void add_source (GcalManager *manager,
+ ESource *source,
+ gboolean enabled,
+ gpointer user_data);
+
static void action_widget_activated (GtkWidget *widget,
gpointer user_data);
@@ -102,6 +107,9 @@ static void display_header_func (GtkListBoxRow *r
GtkListBoxRow *before,
gpointer user_data);
+static GtkWidget* make_row_from_source (GcalSourceDialog *dialog,
+ ESource *source);
+
static void name_entry_text_changed (GObject *object,
GParamSpec *pspec,
gpointer user_data);
@@ -143,6 +151,21 @@ static void discover_sources_cb (GObject *so
G_DEFINE_TYPE_WITH_PRIVATE (GcalSourceDialog, gcal_source_dialog, GTK_TYPE_DIALOG)
+static void
+add_source (GcalManager *manager,
+ ESource *source,
+ gboolean enabled,
+ gpointer user_data)
+{
+ GcalSourceDialogPrivate *priv = GCAL_SOURCE_DIALOG (user_data)->priv;
+ GtkWidget *row;
+
+ row = make_row_from_source (GCAL_SOURCE_DIALOG (user_data), source);
+ g_object_set_data (G_OBJECT (row), "source", source);
+
+ gtk_container_add (GTK_CONTAINER (priv->calendars_listbox), row);
+}
+
/**
* action_widget_activated:
* @widget: the button which emited the signal.
@@ -276,6 +299,71 @@ display_header_func (GtkListBoxRow *row,
}
/**
+ * make_row_from_source:
+ *
+ * Create a GtkListBoxRow for a given
+ * ESource.
+ *
+ * Returns: (transfer full) the new row
+ */
+static GtkWidget*
+make_row_from_source (GcalSourceDialog *dialog,
+ ESource *source)
+{
+ GcalSourceDialogPrivate *priv = dialog->priv;
+ GtkWidget *bottom_label;
+ GtkWidget *top_label;
+ GdkPixbuf *pixbuf;
+ GtkWidget *icon;
+ GtkWidget *grid;
+ GtkWidget *row;
+ GdkRGBA color;
+ gchar *parent_name;
+
+ get_source_parent_name_color (priv->manager, source, &parent_name, NULL);
+ row = gtk_list_box_row_new ();
+
+ /* main box */
+ grid = g_object_new (GTK_TYPE_GRID,
+ "border-width", 6,
+ "column-spacing", 12,
+ NULL);
+
+ /* source color icon */
+ gdk_rgba_parse (&color, get_color_name_from_source (source));
+ pixbuf = get_circle_pixbuf_from_color (&color, 24);
+ icon = gtk_image_new_from_pixbuf (pixbuf);
+
+ /* source name label */
+ top_label = g_object_new (GTK_TYPE_LABEL,
+ "label", e_source_get_display_name (source),
+ "xalign", 0.0,
+ "hexpand", TRUE,
+ NULL);
+
+ /* parent source name label */
+ bottom_label = g_object_new (GTK_TYPE_LABEL,
+ "label", parent_name,
+ "xalign", 0.0,
+ "hexpand", TRUE,
+ NULL);
+ gtk_style_context_add_class (gtk_widget_get_style_context (bottom_label), "dim-label");
+
+
+ gtk_grid_attach (GTK_GRID (grid), icon, 0, 0, 1, 2);
+ gtk_grid_attach (GTK_GRID (grid), top_label, 1, 0, 1, 1);
+ gtk_grid_attach (GTK_GRID (grid), bottom_label, 1, 1, 1, 1);
+ gtk_container_add (GTK_CONTAINER (row), grid);
+
+ gtk_widget_show_all (row);
+
+ g_object_unref (pixbuf);
+ g_free (parent_name);
+
+ return row;
+}
+
+/**
* name_entry_text_changed:
*
* Callend when the name entry's text
@@ -1050,7 +1138,18 @@ gcal_source_dialog_set_manager (GcalSourceDialog *dialog,
priv->manager = manager;
- /* TODO: connect ::source-added & ::source-removed signals */
+ if (gcal_manager_load_completed (priv->manager))
+ {
+ GList *sources, *l;
+
+ sources = gcal_manager_get_sources_connected (priv->manager);
+
+ for (l = sources; l != NULL; l = l->next)
+ add_source (priv->manager, l->data, gcal_manager_source_enabled (priv->manager, l->data), dialog);
+ }
+
+ g_signal_connect (priv->manager, "source-added", G_CALLBACK (add_source), dialog);
+ /* TODO: connect ::source-removed signals */
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]