[gnome-todo/wip/lists] window: add internal storage dialog



commit a93e7f6806fbee0cb0c5e5e12d8a0b85c53276a2
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Sat Jun 20 23:33:41 2015 -0300

    window: add internal storage dialog

 data/ui/window.ui |    8 +++++++-
 src/gtd-window.c  |   36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 1 deletions(-)
---
diff --git a/data/ui/window.ui b/data/ui/window.ui
index d41baf8..adaabbe 100644
--- a/data/ui/window.ui
+++ b/data/ui/window.ui
@@ -6,6 +6,11 @@
     <property name="can_focus">False</property>
     <property name="position">bottom</property>
   </object>
+  <object class="GtdStorageDialog" id="storage_dialog">
+    <property name="visible">False</property>
+    <property name="modal">True</property>
+    <property name="transient_for">GtdWindow</property>
+  </object>
   <template class="GtdWindow" parent="GtkApplicationWindow">
     <property name="can_focus">False</property>
     <property name="default_width">800</property>
@@ -133,7 +138,8 @@
                                 <child>
                                   <object class="GtkFlowBox" id="lists_flowbox">
                                     <property name="visible">True</property>
-                                    <property name="can_focus">False</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="has_focus">True</property>
                                     <property name="halign">start</property>
                                     <property name="valign">start</property>
                                     <property name="hexpand">True</property>
diff --git a/src/gtd-window.c b/src/gtd-window.c
index ddb3dc7..8941222 100644
--- a/src/gtd-window.c
+++ b/src/gtd-window.c
@@ -19,6 +19,7 @@
 #include "gtd-application.h"
 #include "gtd-list-view.h"
 #include "gtd-manager.h"
+#include "gtd-storage-dialog.h"
 #include "gtd-task-list.h"
 #include "gtd-task-list-item.h"
 #include "gtd-window.h"
@@ -38,6 +39,7 @@ typedef struct
   GtkRevealer                   *notification_revealer;
   GtkSpinner                    *notification_spinner;
   GtkStackSwitcher              *stack_switcher;
+  GtdStorageDialog              *storage_dialog;
   GtdListView                   *list_view;
 
   /* mode */
@@ -80,6 +82,10 @@ typedef struct
 
 #define LOADING_LISTS_NOTIFICATION_ID            "loading-lists-id"
 
+static void          gtd_window__change_storage_action           (GSimpleAction         *simple,
+                                                                  GVariant              *parameter,
+                                                                  gpointer               user_data);
+
 static gboolean      gtd_window__execute_notification_data       (NotificationData      *data);
 
 
@@ -89,6 +95,10 @@ void                 notification_data_free                      (NotificationDa
 
 G_DEFINE_TYPE_WITH_PRIVATE (GtdWindow, gtd_window, GTK_TYPE_APPLICATION_WINDOW)
 
+static const GActionEntry gtd_window_entries[] = {
+  { "change-storage", gtd_window__change_storage_action }
+};
+
 enum {
   PROP_0,
   PROP_MANAGER,
@@ -105,6 +115,20 @@ notification_data_free (NotificationData *data)
 }
 
 static void
+gtd_window__change_storage_action (GSimpleAction *simple,
+                                   GVariant      *parameter,
+                                   gpointer       user_data)
+{
+  GtdWindowPrivate *priv;
+
+  g_return_if_fail (GTD_IS_WINDOW (user_data));
+
+  priv = GTD_WINDOW (user_data)->priv;
+
+  gtk_dialog_run (GTK_DIALOG (priv->storage_dialog));
+}
+
+static void
 gtd_window__notification_close_button_clicked (GtkButton *button,
                                                gpointer   user_data)
 {
@@ -342,6 +366,11 @@ gtd_window_constructed (GObject *object)
                           priv->new_list_popover,
                           "manager",
                           G_BINDING_DEFAULT);
+  g_object_bind_property (object,
+                          "manager",
+                          priv->storage_dialog,
+                          "manager",
+                          G_BINDING_DEFAULT);
 }
 
 GtkWidget*
@@ -463,6 +492,7 @@ gtd_window_class_init (GtdWindowClass *klass)
   gtk_widget_class_bind_template_child_private (widget_class, GtdWindow, notification_revealer);
   gtk_widget_class_bind_template_child_private (widget_class, GtdWindow, notification_spinner);
   gtk_widget_class_bind_template_child_private (widget_class, GtdWindow, stack_switcher);
+  gtk_widget_class_bind_template_child_private (widget_class, GtdWindow, storage_dialog);
 
   gtk_widget_class_bind_template_callback (widget_class, gtd_window__back_button_clicked);
   gtk_widget_class_bind_template_callback (widget_class, gtd_window__list_color_set);
@@ -477,6 +507,12 @@ gtd_window_init (GtdWindow *self)
 
   self->priv->notification_queue = g_queue_new ();
 
+  /* add actions */
+  g_action_map_add_action_entries (G_ACTION_MAP (self),
+                                   gtd_window_entries,
+                                   G_N_ELEMENTS (gtd_window_entries),
+                                   self);
+
   gtk_widget_init_template (GTK_WIDGET (self));
 }
 


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