[gnome-builder/wip/greeter] greeter: stub out project row using GtkListBoxRow subclass
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/greeter] greeter: stub out project row using GtkListBoxRow subclass
- Date: Sat, 9 May 2015 02:45:36 +0000 (UTC)
commit e45dc16faa17febce64e7cbf5b991fdddfdcce73
Author: Christian Hergert <christian hergert me>
Date: Fri May 8 19:39:16 2015 -0700
greeter: stub out project row using GtkListBoxRow subclass
data/ui/gb-greeter-project-row.ui | 73 ++++++++++++++
data/ui/gb-greeter-window.ui | 131 ++++----------------------
src/Makefile.am | 2 +
src/greeter/gb-greeter-project-row.c | 147 +++++++++++++++++++++++++++++
src/greeter/gb-greeter-project-row.h | 32 ++++++
src/greeter/gb-greeter-window.c | 31 ++++++-
src/resources/gnome-builder.gresource.xml | 1 +
7 files changed, 302 insertions(+), 115 deletions(-)
---
diff --git a/data/ui/gb-greeter-project-row.ui b/data/ui/gb-greeter-project-row.ui
new file mode 100644
index 0000000..4ba5ca0
--- /dev/null
+++ b/data/ui/gb-greeter-project-row.ui
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.15 -->
+ <template class="GbGreeterProjectRow" parent="GtkListBoxRow">
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">vertical</property>
+ <property name="margin">12</property>
+ <property name="visible">true</property>
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">horizontal</property>
+ <property name="visible">true</property>
+ <child>
+ <object class="GtkLabel" id="title_label">
+ <property name="visible">true</property>
+ <property name="hexpand">true</property>
+ <property name="valign">baseline</property>
+ <property name="xalign">0.0</property>
+ <attributes>
+ <attribute name="scale" value="1.2"/>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="date_label">
+ <property name="visible">true</property>
+ <property name="hexpand">true</property>
+ <property name="valign">baseline</property>
+ <property name="xalign">1.0</property>
+ <attributes>
+ <attribute name="scale" value="0.833333"/>
+ </attributes>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="description_label">
+ <property name="valign">baseline</property>
+ <property name="visible">true</property>
+ <property name="xalign">0.0</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">horizontal</property>
+ <property name="visible">true</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="location_label">
+ <property name="hexpand">true</property>
+ <property name="visible">true</property>
+ <property name="valign">baseline</property>
+ <property name="xalign">0.0</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ <attributes>
+ <attribute name="scale" value="0.833333"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/data/ui/gb-greeter-window.ui b/data/ui/gb-greeter-window.ui
index 03c1777..8e68b58 100644
--- a/data/ui/gb-greeter-window.ui
+++ b/data/ui/gb-greeter-window.ui
@@ -119,121 +119,23 @@
<property name="visible">true</property>
<property name="selection-mode">none</property>
<child>
- <object class="GtkListBoxRow">
+ <object class="GbGreeterProjectRow">
+ <property name="visible">true</property>
+ </object>
+ </child>
+ <child>
+ <object class="GbGreeterProjectRow">
+ <property name="visible">true</property>
+ </object>
+ </child>
+ <child>
+ <object class="GbGreeterProjectRow">
+ <property name="visible">true</property>
+ </object>
+ </child>
+ <child>
+ <object class="GbGreeterProjectRow">
<property name="visible">true</property>
- <child>
- <object class="GtkBox">
- <property name="orientation">vertical</property>
- <property name="margin">12</property>
- <property name="visible">true</property>
- <child>
- <object class="GtkBox">
- <property name="orientation">horizontal</property>
- <property name="visible">true</property>
- <child>
- <object class="GtkLabel">
- <property name="visible">true</property>
- <property name="hexpand">true</property>
- <property name="valign">baseline</property>
- <property name="label">gnome-builder</property>
- <property name="xalign">0.0</property>
- <attributes>
- <attribute name="scale" value="1.2"/>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible">true</property>
- <property name="hexpand">true</property>
- <property name="valign">baseline</property>
- <property name="label">5 minutes ago</property>
- <property name="xalign">1.0</property>
- <attributes>
- <attribute name="scale" value="0.833333"/>
- </attributes>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="label">An IDE for writing GNOME-based
software.</property>
- <property name="valign">baseline</property>
- <property name="visible">true</property>
- <property name="xalign">0.0</property>
- </object>
- </child>
- <child>
- <object class="GtkBox">
- <property name="orientation">horizontal</property>
- <property name="visible">true</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel">
- <property name="label">Projects/gnome-builder</property>
- <property name="hexpand">true</property>
- <property name="visible">true</property>
- <property name="valign">baseline</property>
- <property name="xalign">0.0</property>
- <style>
- <class name="dim-label"/>
- </style>
- <attributes>
- <attribute name="scale" value="0.833333"/>
- </attributes>
- </object>
- </child>
- <child>
- <object class="GtkEventBox">
- <property name="visible">true</property>
- <style>
- <class name="pill-box"/>
- </style>
- <child>
- <object class="GtkLabel">
- <property name="label">C</property>
- <property name="xpad">6</property>
- <property name="ypad">3</property>
- <property name="hexpand">false</property>
- <property name="valign">baseline</property>
- <property name="visible">true</property>
- <attributes>
- <attribute name="scale" value="0.833333"/>
- </attributes>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkEventBox">
- <property name="visible">true</property>
- <style>
- <class name="pill-box"/>
- </style>
- <child>
- <object class="GtkLabel">
- <property name="label">JavaScript</property>
- <property name="xpad">6</property>
- <property name="ypad">3</property>
- <property name="hexpand">false</property>
- <property name="valign">baseline</property>
- <property name="visible">true</property>
- <attributes>
- <attribute name="scale" value="0.833333"/>
- </attributes>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
</object>
</child>
</object>
@@ -269,6 +171,7 @@
<child>
<object class="GtkListBox" id="other_projects_list_box">
<property name="visible">true</property>
+ <property name="selection-mode">none</property>
<child>
<object class="GtkListBoxRow">
<property name="visible">true</property>
diff --git a/src/Makefile.am b/src/Makefile.am
index bcdeed8..3ce00fb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -74,6 +74,8 @@ libgnome_builder_la_SOURCES = \
gd/gd-tagged-entry.h \
gedit/gedit-menu-stack-switcher.c \
gedit/gedit-menu-stack-switcher.h \
+ greeter/gb-greeter-project-row.c \
+ greeter/gb-greeter-project-row.h \
greeter/gb-greeter-window.c \
greeter/gb-greeter-window.h \
html/gb-html-document.c \
diff --git a/src/greeter/gb-greeter-project-row.c b/src/greeter/gb-greeter-project-row.c
new file mode 100644
index 0000000..3747f5a
--- /dev/null
+++ b/src/greeter/gb-greeter-project-row.c
@@ -0,0 +1,147 @@
+/* gb-greeter-project-row.c
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * 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/>.
+ */
+
+#define G_LOG_DOMAIN "gb-greeter-project-row"
+
+#include <glib/gi18n.h>
+#include <ide.h>
+
+#include "gb-greeter-project-row.h"
+
+struct _GbGreeterProjectRow
+{
+ GtkListBoxRow parent_instance;
+
+ IdeProjectInfo *project_info;
+
+ GtkLabel *date_label;
+ GtkLabel *description_label;
+ GtkLabel *location_label;
+ GtkLabel *title_label;
+};
+
+G_DEFINE_TYPE (GbGreeterProjectRow, gb_greeter_project_row, GTK_TYPE_LIST_BOX_ROW)
+
+enum {
+ PROP_0,
+ PROP_PROJECT_INFO,
+ LAST_PROP
+};
+
+static GParamSpec *gParamSpecs [LAST_PROP];
+
+IdeProjectInfo *
+gb_greeter_project_row_get_project_info (GbGreeterProjectRow *self)
+{
+ g_return_val_if_fail (GB_IS_GREETER_PROJECT_ROW (self), NULL);
+
+ return self->project_info;
+}
+
+void
+gb_greeter_project_row_set_project_info (GbGreeterProjectRow *self,
+ IdeProjectInfo *project_info)
+{
+ g_return_if_fail (GB_IS_GREETER_PROJECT_ROW (self));
+ g_return_if_fail (!project_info || IDE_IS_PROJECT_INFO (project_info));
+
+ if (g_set_object (&self->project_info, project_info))
+ {
+ g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_PROJECT_INFO]);
+ }
+}
+
+static void
+gb_greeter_project_row_finalize (GObject *object)
+{
+ GbGreeterProjectRow *self = (GbGreeterProjectRow *)object;
+
+ g_clear_object (&self->project_info);
+
+ G_OBJECT_CLASS (gb_greeter_project_row_parent_class)->finalize (object);
+}
+
+static void
+gb_greeter_project_row_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GbGreeterProjectRow *self = GB_GREETER_PROJECT_ROW (object);
+
+ switch (prop_id)
+ {
+ case PROP_PROJECT_INFO:
+ g_value_set_object (value, gb_greeter_project_row_get_project_info (self));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gb_greeter_project_row_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GbGreeterProjectRow *self = GB_GREETER_PROJECT_ROW (object);
+
+ switch (prop_id)
+ {
+ case PROP_PROJECT_INFO:
+ gb_greeter_project_row_set_project_info (self, g_value_get_object (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+gb_greeter_project_row_class_init (GbGreeterProjectRowClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->finalize = gb_greeter_project_row_finalize;
+ object_class->get_property = gb_greeter_project_row_get_property;
+ object_class->set_property = gb_greeter_project_row_set_property;
+
+ gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/builder/ui/gb-greeter-project-row.ui");
+ gtk_widget_class_bind_template_child (widget_class, GbGreeterProjectRow, date_label);
+ gtk_widget_class_bind_template_child (widget_class, GbGreeterProjectRow, description_label);
+ gtk_widget_class_bind_template_child (widget_class, GbGreeterProjectRow, location_label);
+ gtk_widget_class_bind_template_child (widget_class, GbGreeterProjectRow, title_label);
+
+ gParamSpecs [PROP_PROJECT_INFO] =
+ g_param_spec_object ("project-info",
+ _("Project Info"),
+ _("The project info to render."),
+ IDE_TYPE_PROJECT_INFO,
+ (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class, PROP_PROJECT_INFO,
+ gParamSpecs [PROP_PROJECT_INFO]);
+}
+
+static void
+gb_greeter_project_row_init (GbGreeterProjectRow *self)
+{
+ gtk_widget_init_template (GTK_WIDGET (self));
+}
diff --git a/src/greeter/gb-greeter-project-row.h b/src/greeter/gb-greeter-project-row.h
new file mode 100644
index 0000000..bd48963
--- /dev/null
+++ b/src/greeter/gb-greeter-project-row.h
@@ -0,0 +1,32 @@
+/* gb-greeter-project-row.h
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * 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/>.
+ */
+
+#ifndef GB_GREETER_PROJECT_ROW_H
+#define GB_GREETER_PROJECT_ROW_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GB_TYPE_GREETER_PROJECT_ROW (gb_greeter_project_row_get_type())
+
+G_DECLARE_FINAL_TYPE (GbGreeterProjectRow, gb_greeter_project_row, GB, GREETER_PROJECT_ROW, GtkListBoxRow)
+
+G_END_DECLS
+
+#endif /* GB_GREETER_PROJECT_ROW_H */
diff --git a/src/greeter/gb-greeter-window.c b/src/greeter/gb-greeter-window.c
index 1e33c0d..505e952 100644
--- a/src/greeter/gb-greeter-window.c
+++ b/src/greeter/gb-greeter-window.c
@@ -18,6 +18,7 @@
#include <glib/gi18n.h>
+#include "gb-greeter-project-row.h"
#include "gb-greeter-window.h"
#include "gb-scrolled-window.h"
@@ -25,7 +26,9 @@ struct _GbGreeterWindow
{
GtkApplicationWindow parent_instance;
- GtkWidget *header_bar;
+ GtkWidget *header_bar;
+ GtkListBox *my_projects_list_box;
+ GtkListBox *other_projects_list_box;
};
G_DEFINE_TYPE (GbGreeterWindow, gb_greeter_window, GTK_TYPE_APPLICATION_WINDOW)
@@ -38,6 +41,25 @@ enum {
static GParamSpec *gParamSpecs [LAST_PROP];
static void
+gb_greeter_window_row_header_cb (GtkListBoxRow *row,
+ GtkListBoxRow *before,
+ gpointer user_data)
+{
+ g_assert (GTK_IS_LIST_BOX_ROW (row));
+
+ if (before != NULL)
+ {
+ GtkWidget *header;
+
+ header = g_object_new (GTK_TYPE_SEPARATOR,
+ "orientation", GTK_ORIENTATION_HORIZONTAL,
+ "visible", TRUE,
+ NULL);
+ gtk_list_box_row_set_header (row, header);
+ }
+}
+
+static void
gb_greeter_window_finalize (GObject *object)
{
GbGreeterWindow *self = (GbGreeterWindow *)object;
@@ -87,7 +109,10 @@ gb_greeter_window_class_init (GbGreeterWindowClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/builder/ui/gb-greeter-window.ui");
gtk_widget_class_bind_template_child (widget_class, GbGreeterWindow, header_bar);
+ gtk_widget_class_bind_template_child (widget_class, GbGreeterWindow, my_projects_list_box);
+ gtk_widget_class_bind_template_child (widget_class, GbGreeterWindow, other_projects_list_box);
+ g_type_ensure (GB_TYPE_GREETER_PROJECT_ROW);
g_type_ensure (GB_TYPE_SCROLLED_WINDOW);
}
@@ -95,4 +120,8 @@ static void
gb_greeter_window_init (GbGreeterWindow *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
+
+ gtk_list_box_set_header_func (self->my_projects_list_box,
+ gb_greeter_window_row_header_cb,
+ NULL, NULL);
}
diff --git a/src/resources/gnome-builder.gresource.xml b/src/resources/gnome-builder.gresource.xml
index 9bdc220..1329ee3 100644
--- a/src/resources/gnome-builder.gresource.xml
+++ b/src/resources/gnome-builder.gresource.xml
@@ -42,6 +42,7 @@
<file alias="ui/gb-editor-tweak-widget.ui">../../data/ui/gb-editor-tweak-widget.ui</file>
<file alias="ui/gb-editor-view.ui">../../data/ui/gb-editor-view.ui</file>
<file alias="ui/gb-editor-workspace.ui">../../data/ui/gb-editor-workspace.ui</file>
+ <file alias="ui/gb-greeter-project-row.ui">../../data/ui/gb-greeter-project-row.ui</file>
<file alias="ui/gb-greeter-window.ui">../../data/ui/gb-greeter-window.ui</file>
<file alias="ui/gb-html-view.ui">../../data/ui/gb-html-view.ui</file>
<file alias="ui/gb-new-file-popover.ui">../../data/ui/gb-new-file-popover.ui</file>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]