[gnome-builder/wip/project-selector: 21/72] project-selection: more work on selection pattern



commit f9d4ea484bfd2dc01bf8884e88b1939c41c9f2bb
Author: Christian Hergert <christian hergert me>
Date:   Thu Apr 2 12:53:43 2015 -0700

    project-selection: more work on selection pattern
    
    I want to be able to choose between the initial-setup and project-selection
    patterns after i've implemented a bit of both. Otherwise I feel like I'll
    make the wrong choice.

 data/ui/gb-project-window.ui      |   50 +++++-------------------
 src/app/gb-application.c          |    4 +-
 src/workbench/gb-project-window.c |   77 ++++++++++++++++++++++++++++++++++---
 3 files changed, 83 insertions(+), 48 deletions(-)
---
diff --git a/data/ui/gb-project-window.ui b/data/ui/gb-project-window.ui
index a28abcc..a4cc4e7 100644
--- a/data/ui/gb-project-window.ui
+++ b/data/ui/gb-project-window.ui
@@ -5,39 +5,30 @@
     <property name="default-width">800</property>
     <property name="default-height">600</property>
     <child type="titlebar">
-      <object class="GtkHeaderBar">
+      <object class="GtkHeaderBar" id="header_bar">
         <property name="show-close-button">true</property>
         <property name="title" translatable="yes">Builder</property>
         <property name="visible">true</property>
         <child>
-          <object class="GtkButton">
+          <object class="GtkButton" id="new_button">
+            <property name="label" translatable="yes">New</property>
             <property name="visible">true</property>
             <style>
-              <class name="image-button"/>
+              <class name="text-button"/>
             </style>
-            <child>
-              <object class="GtkImage">
-                <property name="icon-name">list-add-symbolic</property>
-                <property name="visible">true</property>
-              </object>
-            </child>
           </object>
           <packing>
             <property name="pack-type">start</property>
           </packing>
         </child>
         <child>
-          <object class="GtkMenuButton">
-            <property name="visible">true</property>
+          <object class="GtkButton" id="cancel_button">
+            <property name="label" translatable="yes">_Cancel</property>
+            <property name="use-underline">true</property>
+            <property name="visible">false</property>
             <style>
-              <class name="image-button"/>
+              <class name="text-button"/>
             </style>
-            <child>
-              <object class="GtkImage">
-                <property name="icon-name">open-menu-symbolic</property>
-                <property name="visible">true</property>
-              </object>
-            </child>
           </object>
           <packing>
             <property name="pack-type">end</property>
@@ -104,33 +95,12 @@
         </child>
         <child>
           <object class="GbScrolledWindow">
-            <property name="margin">24</property>
-            <property name="shadow-type">in</property>
-            <property name="hexpand">true</property>
-            <property name="vexpand">true</property>
-            <property name="valign">center</property>
-            <property name="halign">center</property>
-            <property name="min-content-width">400</property>
-            <property name="max-content-width">500</property>
-            <property name="min-content-height">200</property>
-            <property name="max-content-height">500</property>
+            <property name="expand">true</property>
             <property name="visible">true</property>
             <child>
               <object class="GtkListBox" id="listbox">
                 <property name="visible">true</property>
                 <property name="selection-mode">none</property>
-                <child>
-                  <object class="GtkListBoxRow">
-                    <property name="visible">true</property>
-                    <child>
-                      <object class="GtkImage">
-                        <property name="margin">12</property>
-                        <property name="visible">true</property>
-                        <property name="icon-name">view-more-symbolic</property>
-                      </object>
-                    </child>
-                  </object>
-                </child>
               </object>
             </child>
           </object>
diff --git a/src/app/gb-application.c b/src/app/gb-application.c
index a57ff00..4fe9820 100644
--- a/src/app/gb-application.c
+++ b/src/app/gb-application.c
@@ -480,14 +480,14 @@ gb_application_show_projects_window (GbApplication *self)
 
   for (; windows; windows = windows->next)
     {
-      if (GB_IS_INITIAL_SETUP_DIALOG (windows->data))
+      if (GB_IS_PROJECT_WINDOW (windows->data))
         {
           gtk_window_present (windows->data);
           return;
         }
     }
 
-  window = g_object_new (GB_TYPE_INITIAL_SETUP_DIALOG,
+  window = g_object_new (GB_TYPE_PROJECT_WINDOW,
                          "application", self,
                          NULL);
   gtk_window_maximize (GTK_WINDOW (window));
diff --git a/src/workbench/gb-project-window.c b/src/workbench/gb-project-window.c
index b91840a..bfb0e9a 100644
--- a/src/workbench/gb-project-window.c
+++ b/src/workbench/gb-project-window.c
@@ -36,7 +36,10 @@ struct _GbProjectWindow
 
   GSettings       *settings;
 
+  GtkButton       *cancel_button;
+  GtkHeaderBar    *header_bar;
   GtkListBox      *listbox;
+  GtkButton       *new_button;
   GtkSearchBar    *search_bar;
   GtkToggleButton *search_button;
   GtkRevealer     *search_revealer;
@@ -222,9 +225,9 @@ create_row (GbProjectWindow *self,
                           g_object_unref);
 
   box = g_object_new (GTK_TYPE_BOX,
+                      "margin", 12,
                       "orientation", GTK_ORIENTATION_HORIZONTAL,
                       "visible", TRUE,
-                      "margin", 12,
                       NULL);
 
   check = g_object_new (GTK_TYPE_CHECK_BUTTON,
@@ -236,7 +239,7 @@ create_row (GbProjectWindow *self,
 
   image = g_object_new (GTK_TYPE_IMAGE,
                         "icon-name", icon_name,
-                        "pixel-size", 32,
+                        "pixel-size", 64,
                         "margin-end", 12,
                         "margin-start", 12,
                         "visible", TRUE,
@@ -244,6 +247,8 @@ create_row (GbProjectWindow *self,
 
   vbox = g_object_new (GTK_TYPE_BOX,
                        "orientation", GTK_ORIENTATION_VERTICAL,
+                       "valign", GTK_ALIGN_CENTER,
+                       "vexpand", TRUE,
                        "visible", TRUE,
                        NULL);
 
@@ -305,8 +310,10 @@ gb_project_window__miner_discovered_cb (GbProjectWindow *self,
   g_assert (IDE_IS_PROJECT_MINER (miner));
 
   row = create_row (self, project_info);
+#if 0
   if (!is_recent_project (self, project_info))
     gtk_widget_set_visible (row, FALSE);
+#endif
   gtk_container_add (GTK_CONTAINER (self->listbox), row);
 }
 
@@ -381,6 +388,48 @@ gb_project_window__listbox_sort (GtkListBoxRow *row1,
 }
 
 static void
+gb_project_window__select_button_notify_active (GbProjectWindow *self,
+                                                GParamSpec      *pspec,
+                                                GtkToggleButton *select_button)
+{
+  GtkStyleContext *style_context;
+  gboolean active;
+
+  g_assert (GB_IS_PROJECT_WINDOW (self));
+  g_assert (GTK_IS_TOGGLE_BUTTON (select_button));
+
+  active = gtk_toggle_button_get_active (select_button);
+  style_context = gtk_widget_get_style_context (GTK_WIDGET (self->header_bar));
+
+  if (active)
+    {
+      gtk_widget_set_visible (GTK_WIDGET (self->new_button), FALSE);
+      gtk_widget_set_visible (GTK_WIDGET (self->select_button), FALSE);
+      gtk_widget_set_visible (GTK_WIDGET (self->cancel_button), TRUE);
+      gtk_header_bar_set_show_close_button (self->header_bar, FALSE);
+      gtk_style_context_add_class (style_context, "selection-mode");
+    }
+  else
+    {
+      gtk_style_context_remove_class (style_context, "selection-mode");
+      gtk_widget_set_visible (GTK_WIDGET (self->new_button), TRUE);
+      gtk_widget_set_visible (GTK_WIDGET (self->select_button), TRUE);
+      gtk_widget_set_visible (GTK_WIDGET (self->cancel_button), FALSE);
+      gtk_header_bar_set_show_close_button (self->header_bar, TRUE);
+    }
+}
+
+static void
+gb_project_window__cancel_button_clicked (GbProjectWindow *self,
+                                          GtkButton       *cancel_button)
+{
+  g_assert (GB_IS_PROJECT_WINDOW (self));
+  g_assert (GTK_IS_BUTTON (cancel_button));
+
+  gtk_toggle_button_set_active (self->select_button, FALSE);
+}
+
+static void
 gb_project_window_constructed (GObject *object)
 {
   GbProjectWindow *self = (GbProjectWindow *)object;
@@ -400,18 +449,31 @@ gb_project_window_constructed (GObject *object)
                           self->search_revealer, "reveal-child",
                           G_BINDING_SYNC_CREATE);
 
-  ide_project_miner_mine_async (miner,
-                                NULL,
-                                gb_project_window__miner_mine_cb,
-                                g_object_ref (self));
+  g_signal_connect_object (self->select_button,
+                           "notify::active",
+                           G_CALLBACK (gb_project_window__select_button_notify_active),
+                           self,
+                           G_CONNECT_SWAPPED);
+
+  g_signal_connect_object (self->cancel_button,
+                           "clicked",
+                           G_CALLBACK (gb_project_window__cancel_button_clicked),
+                           self,
+                           G_CONNECT_SWAPPED);
 
   gtk_list_box_set_header_func (self->listbox,
                                 gb_project_window__listbox_header_cb,
                                 NULL, NULL);
+
   gtk_list_box_set_sort_func (self->listbox,
                               gb_project_window__listbox_sort,
                               NULL, NULL);
 
+  ide_project_miner_mine_async (miner,
+                                NULL,
+                                gb_project_window__miner_mine_cb,
+                                g_object_ref (self));
+
   G_OBJECT_CLASS (gb_project_window_parent_class)->constructed (object);
 }
 
@@ -435,6 +497,9 @@ gb_project_window_class_init (GbProjectWindowClass *klass)
 
   GB_WIDGET_CLASS_TEMPLATE (klass, "gb-project-window.ui");
 
+  GB_WIDGET_CLASS_BIND (klass, GbProjectWindow, cancel_button);
+  GB_WIDGET_CLASS_BIND (klass, GbProjectWindow, header_bar);
+  GB_WIDGET_CLASS_BIND (klass, GbProjectWindow, new_button);
   GB_WIDGET_CLASS_BIND (klass, GbProjectWindow, listbox);
   GB_WIDGET_CLASS_BIND (klass, GbProjectWindow, search_bar);
   GB_WIDGET_CLASS_BIND (klass, GbProjectWindow, search_button);


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