[gnome-calendar/calendar-editor] source-dialog: add a header function



commit 145ae54aadc7b9f0921b5eaaa73ae8799de1f3b3
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Apr 7 16:41:06 2015 -0300

    source-dialog: add a header function
    
    So each row can have a separator at
    it's header.

 src/gcal-source-dialog.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/src/gcal-source-dialog.c b/src/gcal-source-dialog.c
index 78ddc40..22d1b71 100644
--- a/src/gcal-source-dialog.c
+++ b/src/gcal-source-dialog.c
@@ -98,6 +98,10 @@ static gboolean   description_label_link_activated      (GtkWidget            *w
                                                          gchar                *uri,
                                                          gpointer              user_data);
 
+static void       display_header_func                   (GtkListBoxRow        *row,
+                                                         GtkListBoxRow        *before,
+                                                         gpointer              user_data);
+
 static void       name_entry_text_changed               (GObject             *object,
                                                          GParamSpec          *pspec,
                                                          gpointer             user_data);
@@ -249,6 +253,27 @@ description_label_link_activated (GtkWidget *widget,
   return TRUE;
 }
 
+/**
+ * display_header_func:
+ *
+ * Shows a separator before each row.
+ *
+ */
+static void
+display_header_func (GtkListBoxRow *row,
+                     GtkListBoxRow *before,
+                     gpointer       user_data)
+{
+  if (before != NULL)
+    {
+      GtkWidget *header;
+
+      header = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
+      gtk_widget_show (header);
+
+      gtk_list_box_row_set_header (row, header);
+    }
+}
 
 /**
  * name_entry_text_changed:
@@ -929,6 +954,10 @@ gcal_source_dialog_constructed (GObject *object)
   g_object_set_data (G_OBJECT (priv->cancel_button), "response", GINT_TO_POINTER (GTK_RESPONSE_CANCEL));
   g_object_set_data (G_OBJECT (priv->remove_button), "response", GINT_TO_POINTER 
(GCAL_RESPONSE_REMOVE_SOURCE));
 
+  // Setup listbox header functions
+  gtk_list_box_set_header_func (GTK_LIST_BOX (priv->calendars_listbox), display_header_func, NULL, NULL);
+  gtk_list_box_set_header_func (GTK_LIST_BOX (priv->online_accounts_listbox), display_header_func, NULL, 
NULL);
+
   /* File filter */
   filter = gtk_file_filter_new ();
   gtk_file_filter_set_name (filter, _("Calendar files"));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]