[gnome-calendar/calendar-management] source-manager: show edit source popover when row is activated



commit eec830d4fa70eed07322965ab2f3caa819bdb5b7
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Feb 3 15:59:07 2015 -0200

    source-manager: show edit source popover when row is activated

 data/ui/source-manager-dialog.ui |    3 ++-
 src/gcal-source-manager-dialog.c |   31 +++++++++++++++----------------
 2 files changed, 17 insertions(+), 17 deletions(-)
---
diff --git a/data/ui/source-manager-dialog.ui b/data/ui/source-manager-dialog.ui
index a198449..8f863a1 100644
--- a/data/ui/source-manager-dialog.ui
+++ b/data/ui/source-manager-dialog.ui
@@ -57,7 +57,8 @@
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="selection_mode">none</property>
-                        <property name="activate_on_single_click">False</property>
+                        <property name="activate_on_single_click">True</property>
+                        <signal name="row_activated" handler="row_activated_cb" 
object="GcalSourceManagerDialog" swapped="no"/>
                       </object>
                     </child>
                   </object>
diff --git a/src/gcal-source-manager-dialog.c b/src/gcal-source-manager-dialog.c
index 00d1f48..dc77e1a 100644
--- a/src/gcal-source-manager-dialog.c
+++ b/src/gcal-source-manager-dialog.c
@@ -27,6 +27,7 @@ struct _GcalSourceManagerDialogPrivate
 {
   GtkWidget               *add_button;
   GtkWidget               *headerbar;
+  GtkWidget               *source_popover;
   GtkWidget               *sources_listbox;
 
   /*
@@ -64,7 +65,7 @@ static void     display_header_func                        (GtkListBoxRow
                                                             GtkListBoxRow       *before,
                                                             gpointer             user_data);
 
-static void     row_selected_cb                            (GtkListBox          *listbox,
+static void     row_activated_cb                           (GtkListBox          *listbox,
                                                             GtkListBoxRow       *row,
                                                             gpointer             user_data);
 
@@ -220,7 +221,7 @@ display_header_func (GtkListBoxRow *row,
 }
 
 /**
- * row_selected_cb:
+ * row_activated_cb:
  *
  * Updates the edit stack properties,
  * according to the row selected.
@@ -228,24 +229,17 @@ display_header_func (GtkListBoxRow *row,
  * Returns:
  */
 static void
-row_selected_cb (GtkListBox    *listbox,
-                 GtkListBoxRow *row,
-                 gpointer       user_data)
+row_activated_cb (GtkListBox    *listbox,
+                  GtkListBoxRow *row,
+                  gpointer       user_data)
 {
   GcalSourceManagerDialogPrivate *priv;
   priv = gcal_source_manager_dialog_get_instance_private (GCAL_SOURCE_MANAGER_DIALOG (user_data));
 
   if (row != NULL)
     {
-      ESource *source;
-      ESourceSelectable *extension;
-      GdkRGBA color;
-
-      source = g_hash_table_lookup (priv->row_to_source, row);
-      extension = E_SOURCE_SELECTABLE (e_source_get_extension (source, E_SOURCE_EXTENSION_CALENDAR));
-
-      /* source color */
-      gdk_rgba_parse (&color, e_source_selectable_get_color (E_SOURCE_SELECTABLE (extension)));
+      gtk_popover_set_relative_to (GTK_POPOVER (priv->source_popover), row);
+      gtk_widget_show (priv->source_popover);
     }
 }
 
@@ -565,9 +559,10 @@ gcal_source_manager_dialog_class_init (GcalSourceManagerDialogClass *klass)
 
   gtk_widget_class_bind_template_child_private (widget_class, GcalSourceManagerDialog, add_button);
   gtk_widget_class_bind_template_child_private (widget_class, GcalSourceManagerDialog, headerbar);
+  gtk_widget_class_bind_template_child_private (widget_class, GcalSourceManagerDialog, source_popover);
   gtk_widget_class_bind_template_child_private (widget_class, GcalSourceManagerDialog, sources_listbox);
 
-  gtk_widget_class_bind_template_callback (widget_class, row_selected_cb);
+  gtk_widget_class_bind_template_callback (widget_class, row_activated_cb);
 }
 
 static void
@@ -577,7 +572,7 @@ gcal_source_manager_dialog_constructed (GObject *object)
   GSimpleAction *file_action, *local_action, *url_action;
 
   GtkBuilder *builder;
-  GMenuModel *sourcesmenu;
+  GMenuModel *sourcesmenu, *editsourcemenu;
 
   if (G_OBJECT_CLASS (gcal_source_manager_dialog_parent_class)->constructed != NULL)
     G_OBJECT_CLASS (gcal_source_manager_dialog_parent_class)->constructed (object);
@@ -593,6 +588,10 @@ gcal_source_manager_dialog_constructed (GObject *object)
   sourcesmenu = (GMenuModel*) gtk_builder_get_object (builder, "sourcesmenu");
   gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (priv->add_button), sourcesmenu);
 
+  /* edit source menu */
+  editsourcemenu = (GMenuModel*) gtk_builder_get_object (builder, "editsourcemenu");
+  gtk_popover_bind_model (GTK_POPOVER (priv->source_popover), editsourcemenu, "sources");
+
   g_object_unref (builder);
 
   /* action group */


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