[gnome-builder/wip/greeter] greeter: more plumbing for project rows
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/greeter] greeter: more plumbing for project rows
- Date: Sat, 9 May 2015 02:59:47 +0000 (UTC)
commit 9f756366cfd69dfc886bc0639eeb0dfa285847a2
Author: Christian Hergert <christian hergert me>
Date: Fri May 8 19:59:43 2015 -0700
greeter: more plumbing for project rows
src/greeter/gb-greeter-project-row.c | 21 +++++++--
src/greeter/gb-greeter-window.c | 80 ++++++++++++++++++++++++++++++++--
src/greeter/gb-greeter-window.h | 5 ++
3 files changed, 98 insertions(+), 8 deletions(-)
---
diff --git a/src/greeter/gb-greeter-project-row.c b/src/greeter/gb-greeter-project-row.c
index 3747f5a..02ea68e 100644
--- a/src/greeter/gb-greeter-project-row.c
+++ b/src/greeter/gb-greeter-project-row.c
@@ -21,6 +21,8 @@
#include <glib/gi18n.h>
#include <ide.h>
+#include "egg-binding-set.h"
+
#include "gb-greeter-project-row.h"
struct _GbGreeterProjectRow
@@ -28,11 +30,12 @@ struct _GbGreeterProjectRow
GtkListBoxRow parent_instance;
IdeProjectInfo *project_info;
+ EggBindingSet *bindings;
- GtkLabel *date_label;
- GtkLabel *description_label;
- GtkLabel *location_label;
- GtkLabel *title_label;
+ 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)
@@ -62,6 +65,7 @@ gb_greeter_project_row_set_project_info (GbGreeterProjectRow *self,
if (g_set_object (&self->project_info, project_info))
{
+ egg_binding_set_set_source (self->bindings, project_info);
g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_PROJECT_INFO]);
}
}
@@ -144,4 +148,13 @@ static void
gb_greeter_project_row_init (GbGreeterProjectRow *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
+
+ self->bindings = egg_binding_set_new ();
+
+ egg_binding_set_bind (self->bindings, "name", self->title_label, "label", 0);
+#if 0
+ egg_binding_set_bind (self->bindings, "directory", self->location_label, "label", 0);
+ egg_binding_set_bind (self->bindings, "description", self->description_label, "label", 0);
+ egg_binding_set_bind (self->bindings, "last-modified-at", self->date_label, "label", 0);
+#endif
}
diff --git a/src/greeter/gb-greeter-window.c b/src/greeter/gb-greeter-window.c
index 505e952..21bad6f 100644
--- a/src/greeter/gb-greeter-window.c
+++ b/src/greeter/gb-greeter-window.c
@@ -16,7 +16,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#define G_LOG_DOMAIN "gb-greeter-window"
+
#include <glib/gi18n.h>
+#include <ide.h>
+
+#include "egg-signal-group.h"
#include "gb-greeter-project-row.h"
#include "gb-greeter-window.h"
@@ -24,22 +29,48 @@
struct _GbGreeterWindow
{
- GtkApplicationWindow parent_instance;
+ GtkApplicationWindow parent_instance;
+
+ EggSignalGroup *signal_group;
+ IdeRecentProjects *recent_projects;
- GtkWidget *header_bar;
- GtkListBox *my_projects_list_box;
- GtkListBox *other_projects_list_box;
+ GtkWidget *header_bar;
+ GtkListBox *my_projects_list_box;
+ GtkListBox *other_projects_list_box;
};
G_DEFINE_TYPE (GbGreeterWindow, gb_greeter_window, GTK_TYPE_APPLICATION_WINDOW)
enum {
PROP_0,
+ PROP_RECENT_PROJECTS,
LAST_PROP
};
static GParamSpec *gParamSpecs [LAST_PROP];
+IdeRecentProjects *
+gb_greeter_window_get_recent_projects (GbGreeterWindow *self)
+{
+ g_return_val_if_fail (GB_IS_GREETER_WINDOW (self), NULL);
+
+ return self->recent_projects;
+}
+
+void
+gb_greeter_window_set_recent_projects (GbGreeterWindow *self,
+ IdeRecentProjects *recent_projects)
+{
+ g_return_if_fail (GB_IS_GREETER_WINDOW (self));
+ g_return_if_fail (!recent_projects || IDE_IS_RECENT_PROJECTS (recent_projects));
+
+ if (g_set_object (&self->recent_projects, recent_projects))
+ {
+ egg_signal_group_set_target (self->signal_group, recent_projects);
+ g_object_notify_by_pspec (G_OBJECT (self), gParamSpecs [PROP_RECENT_PROJECTS]);
+ }
+}
+
static void
gb_greeter_window_row_header_cb (GtkListBoxRow *row,
GtkListBoxRow *before,
@@ -60,10 +91,26 @@ gb_greeter_window_row_header_cb (GtkListBoxRow *row,
}
static void
+gb_greeter_window__recent_projects_items_changed (GListModel *list_model,
+ guint position,
+ guint removed,
+ guint added,
+ gpointer user_data)
+{
+ IdeRecentProjects *recent_projects = (IdeRecentProjects *)list_model;
+
+ g_assert (G_IS_LIST_MODEL (list_model));
+ g_assert (IDE_IS_RECENT_PROJECTS (recent_projects));
+}
+
+static void
gb_greeter_window_finalize (GObject *object)
{
GbGreeterWindow *self = (GbGreeterWindow *)object;
+ g_clear_object (&self->signal_group);
+ g_clear_object (&self->recent_projects);
+
G_OBJECT_CLASS (gb_greeter_window_parent_class)->finalize (object);
}
@@ -77,6 +124,10 @@ gb_greeter_window_get_property (GObject *object,
switch (prop_id)
{
+ case PROP_RECENT_PROJECTS:
+ g_value_set_object (value, gb_greeter_window_get_recent_projects (self));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -92,6 +143,10 @@ gb_greeter_window_set_property (GObject *object,
switch (prop_id)
{
+ case PROP_RECENT_PROJECTS:
+ gb_greeter_window_set_recent_projects (self, g_value_get_object (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -107,6 +162,15 @@ gb_greeter_window_class_init (GbGreeterWindowClass *klass)
object_class->get_property = gb_greeter_window_get_property;
object_class->set_property = gb_greeter_window_set_property;
+ gParamSpecs [PROP_RECENT_PROJECTS] =
+ g_param_spec_object ("recent-projects",
+ _("Recent Projects"),
+ _("The recent projects that have been mined."),
+ IDE_TYPE_RECENT_PROJECTS,
+ (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class, PROP_RECENT_PROJECTS,
+ gParamSpecs [PROP_RECENT_PROJECTS]);
+
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);
@@ -119,6 +183,14 @@ gb_greeter_window_class_init (GbGreeterWindowClass *klass)
static void
gb_greeter_window_init (GbGreeterWindow *self)
{
+ self->signal_group = egg_signal_group_new (IDE_TYPE_RECENT_PROJECTS);
+
+ egg_signal_group_connect_object (self->signal_group,
+ "items-changed",
+ G_CALLBACK (gb_greeter_window__recent_projects_items_changed),
+ self,
+ G_CONNECT_SWAPPED);
+
gtk_widget_init_template (GTK_WIDGET (self));
gtk_list_box_set_header_func (self->my_projects_list_box,
diff --git a/src/greeter/gb-greeter-window.h b/src/greeter/gb-greeter-window.h
index cdf09d2..0a0b79f 100644
--- a/src/greeter/gb-greeter-window.h
+++ b/src/greeter/gb-greeter-window.h
@@ -20,6 +20,7 @@
#define GB_GREETER_WINDOW_H
#include <gtk/gtk.h>
+#include <ide.h>
G_BEGIN_DECLS
@@ -27,6 +28,10 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GbGreeterWindow, gb_greeter_window, GB, GREETER_WINDOW, GtkApplicationWindow)
+IdeRecentProjects *gb_greeter_window_get_recent_projects (GbGreeterWindow *self);
+void gb_greeter_window_set_recent_projects (GbGreeterWindow *self,
+ IdeRecentProjects *recent_projects);
+
G_END_DECLS
#endif /* GB_GREETER_WINDOW_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]