[gnome-builder] greeter: use section for action buttons instead of header



commit c46bb8fa071179507b1d3ccdfff217bcf8309666
Author: Christian Hergert <chergert redhat com>
Date:   Fri Jan 18 16:58:57 2019 -0800

    greeter: use section for action buttons instead of header
    
    This is some incremental work to implement the buttons in main content
    area instead of the header bar.
    
    More work needs to be done, but this gets things started.

 src/libide/greeter/ide-greeter-buttons-section.c | 112 +++++++++++++++++++++++
 src/libide/greeter/ide-greeter-buttons-section.h |  36 ++++++++
 src/libide/greeter/ide-greeter-workspace.c       |  45 +++++----
 src/libide/greeter/ide-greeter-workspace.ui      |  24 +----
 src/libide/greeter/meson.build                   |   1 +
 5 files changed, 175 insertions(+), 43 deletions(-)
---
diff --git a/src/libide/greeter/ide-greeter-buttons-section.c 
b/src/libide/greeter/ide-greeter-buttons-section.c
new file mode 100644
index 000000000..4f7c66663
--- /dev/null
+++ b/src/libide/greeter/ide-greeter-buttons-section.c
@@ -0,0 +1,112 @@
+/* ide-greeter-buttons-section.c
+ *
+ * Copyright 2019 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define G_LOG_DOMAIN "ide-greeter-buttons-section"
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+
+#include "ide-greeter-buttons-section.h"
+
+struct _IdeGreeterButtonsSection
+{
+  GtkBin  parent_instance;
+  GtkBox *box;
+};
+
+G_DEFINE_TYPE_WITH_CODE (IdeGreeterButtonsSection, ide_greeter_buttons_section, GTK_TYPE_BIN,
+                         G_IMPLEMENT_INTERFACE (IDE_TYPE_GREETER_SECTION, NULL))
+
+static void
+ide_greeter_buttons_section_class_init (IdeGreeterButtonsSectionClass *klass)
+{
+}
+
+static void
+ide_greeter_buttons_section_init (IdeGreeterButtonsSection *self)
+{
+  PangoAttrList *attrs;
+  GtkBox *vbox;
+  GtkLabel *label;
+
+  g_object_set (self,
+                "width-request", 600,
+                "halign", GTK_ALIGN_CENTER,
+                NULL);
+
+  attrs = pango_attr_list_new ();
+  pango_attr_list_insert (attrs, pango_attr_weight_new (PANGO_WEIGHT_BOLD));
+
+  vbox = g_object_new (GTK_TYPE_BOX,
+                       "orientation", GTK_ORIENTATION_VERTICAL,
+                       "spacing", 6,
+                       "visible", TRUE,
+                       NULL);
+  gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (vbox));
+
+  label = g_object_new (GTK_TYPE_LABEL,
+                        "attributes", attrs,
+                        "xalign", 0.0f,
+                        "label", _("Add a Project"),
+                        "visible", TRUE,
+                        NULL);
+  dzl_gtk_widget_add_style_class (GTK_WIDGET (label), "dim-label");
+  gtk_container_add (GTK_CONTAINER (vbox), GTK_WIDGET (label));
+
+  self->box = g_object_new (DZL_TYPE_PRIORITY_BOX,
+                            "orientation", GTK_ORIENTATION_HORIZONTAL,
+                            "homogeneous", TRUE,
+                            "spacing", 12,
+                            "visible", TRUE,
+                            NULL);
+  gtk_container_add (GTK_CONTAINER (vbox), GTK_WIDGET (self->box));
+
+  ide_greeter_buttons_section_add_button (self,
+                                          0,
+                                          g_object_new (GTK_TYPE_BUTTON,
+                                                        "label", _("Select a Folder…"),
+                                                        "visible", TRUE,
+                                                        "action-name", "win.open",
+                                                        NULL));
+  ide_greeter_buttons_section_add_button (self,
+                                          100,
+                                          g_object_new (GTK_TYPE_BUTTON,
+                                                        "label", _("Clone…"),
+                                                        "visible", TRUE,
+                                                        "action-name", "win.surface",
+                                                        "action-target", g_variant_new_string ("clone"),
+                                                        NULL));
+
+  g_clear_pointer (&attrs, pango_attr_list_unref);
+}
+
+void
+ide_greeter_buttons_section_add_button (IdeGreeterButtonsSection *self,
+                                        gint                      priority,
+                                        GtkWidget                *widget)
+{
+  g_return_if_fail (IDE_IS_GREETER_BUTTONS_SECTION (self));
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+
+  gtk_container_add_with_properties (GTK_CONTAINER (self->box), widget,
+                                     "priority", priority,
+                                     NULL);
+}
diff --git a/src/libide/greeter/ide-greeter-buttons-section.h 
b/src/libide/greeter/ide-greeter-buttons-section.h
new file mode 100644
index 000000000..f25372ddd
--- /dev/null
+++ b/src/libide/greeter/ide-greeter-buttons-section.h
@@ -0,0 +1,36 @@
+/* ide-greeter-buttons-section.h
+ *
+ * Copyright 2019 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include "ide-greeter-section.h"
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_GREETER_BUTTONS_SECTION (ide_greeter_buttons_section_get_type())
+
+G_DECLARE_FINAL_TYPE (IdeGreeterButtonsSection, ide_greeter_buttons_section, IDE, GREETER_BUTTONS_SECTION, 
GtkBin)
+
+IdeGreeterButtonsSection *ide_greeter_buttons_section_new        (void);
+void                      ide_greeter_buttons_section_add_button (IdeGreeterButtonsSection *self,
+                                                                  gint                      priority,
+                                                                  GtkWidget                *button);
+
+G_END_DECLS
diff --git a/src/libide/greeter/ide-greeter-workspace.c b/src/libide/greeter/ide-greeter-workspace.c
index 2a31ce4a7..aced3ebc0 100644
--- a/src/libide/greeter/ide-greeter-workspace.c
+++ b/src/libide/greeter/ide-greeter-workspace.c
@@ -27,6 +27,7 @@
 #include <libpeas/peas.h>
 
 #include "ide-clone-surface.h"
+#include "ide-greeter-buttons-section.h"
 #include "ide-greeter-private.h"
 #include "ide-greeter-workspace.h"
 
@@ -46,26 +47,27 @@
 
 struct _IdeGreeterWorkspace
 {
-  IdeWorkspace       parent_instance;
+  IdeWorkspace              parent_instance;
 
-  PeasExtensionSet  *addins;
-  DzlPatternSpec    *pattern_spec;
-  GSimpleAction     *delete_action;
-  GSimpleAction     *purge_action;
+  PeasExtensionSet         *addins;
+  DzlPatternSpec           *pattern_spec;
+  GSimpleAction            *delete_action;
+  GSimpleAction            *purge_action;
 
   /* Template Widgets */
-  IdeCloneSurface   *clone_surface;
-  IdeHeaderBar      *header_bar;
-  DzlPriorityBox    *sections;
-  DzlPriorityBox    *left_box;
-  GtkStack          *surfaces;
-  IdeSurface        *sections_surface;
-  GtkSearchEntry    *search_entry;
-  GtkButton         *back_button;
-  GtkButton         *select_button;
-  GtkActionBar      *action_bar;
-
-  guint              selection_mode : 1;
+  IdeCloneSurface          *clone_surface;
+  IdeHeaderBar             *header_bar;
+  DzlPriorityBox           *sections;
+  DzlPriorityBox           *left_box;
+  GtkStack                 *surfaces;
+  IdeSurface               *sections_surface;
+  GtkSearchEntry           *search_entry;
+  GtkButton                *back_button;
+  GtkButton                *select_button;
+  GtkActionBar             *action_bar;
+  IdeGreeterButtonsSection *buttons_section;
+
+  guint                     selection_mode : 1;
 };
 
 G_DEFINE_TYPE (IdeGreeterWorkspace, ide_greeter_workspace, IDE_TYPE_WORKSPACE)
@@ -628,6 +630,11 @@ ide_greeter_workspace_init (IdeGreeterWorkspace *self)
 
   _ide_greeter_workspace_init_actions (self);
   _ide_greeter_workspace_init_shortcuts (self);
+
+  self->buttons_section = g_object_new (IDE_TYPE_GREETER_BUTTONS_SECTION,
+                                        "visible", TRUE,
+                                        NULL);
+  ide_greeter_workspace_add_section (self, IDE_GREETER_SECTION (self->buttons_section));
 }
 
 IdeGreeterWorkspace *
@@ -698,9 +705,7 @@ ide_greeter_workspace_add_button (IdeGreeterWorkspace *self,
   g_return_if_fail (IDE_IS_GREETER_WORKSPACE (self));
   g_return_if_fail (GTK_IS_WIDGET (button));
 
-  gtk_container_add_with_properties (GTK_CONTAINER (self->left_box), button,
-                                     "priority", priority,
-                                     NULL);
+  ide_greeter_buttons_section_add_button (self->buttons_section, priority, button);
 }
 
 /**
diff --git a/src/libide/greeter/ide-greeter-workspace.ui b/src/libide/greeter/ide-greeter-workspace.ui
index e36fc25ee..05338f2f2 100644
--- a/src/libide/greeter/ide-greeter-workspace.ui
+++ b/src/libide/greeter/ide-greeter-workspace.ui
@@ -32,29 +32,6 @@
             <property name="hexpand">false</property>
             <property name="homogeneous">true</property>
             <property name="visible">true</property>
-            <child>
-              <object class="GtkButton">
-                <property name="action-name">win.open</property>
-                <property name="label" translatable="yes">_Open…</property>
-                <property name="use-underline">true</property>
-                <property name="visible">true</property>
-              </object>
-              <packing>
-                <property name="priority">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton">
-                <property name="action-name">win.surface</property>
-                <property name="action-target">'clone'</property>
-                <property name="label" translatable="yes">_Clone…</property>
-                <property name="use-underline">true</property>
-                <property name="visible">true</property>
-              </object>
-              <packing>
-                <property name="priority">10</property>
-              </packing>
-            </child>
           </object>
           <packing>
             <property name="pack-type">start</property>
@@ -112,6 +89,7 @@
                             <property name="visible">true</property>
                             <child>
                               <object class="GtkSearchEntry" id="search_entry">
+                                <property name="placeholder-text" translatable="yes">Search all Builder 
projects…</property>
                                 <property name="halign">center</property>
                                 <property name="visible">true</property>
                                 <property name="width-chars">45</property>
diff --git a/src/libide/greeter/meson.build b/src/libide/greeter/meson.build
index 68e932c0d..afaebb382 100644
--- a/src/libide/greeter/meson.build
+++ b/src/libide/greeter/meson.build
@@ -33,6 +33,7 @@ libide_greeter_public_sources = [
 libide_greeter_private_sources = [
   'ide-greeter-workspace-actions.c',
   'ide-greeter-workspace-shortcuts.c',
+  'ide-greeter-buttons-section.c',
 ]
 
 #


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