[gnome-builder] newcomers: use IdeGreeterRow for newcomers section
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] newcomers: use IdeGreeterRow for newcomers section
- Date: Tue, 22 Jan 2019 02:37:17 +0000 (UTC)
commit 73ec99eb8df844b5dd80464ae8ceb7b3e7904bdf
Author: Christian Hergert <chergert redhat com>
Date: Mon Jan 21 18:23:57 2019 -0800
newcomers: use IdeGreeterRow for newcomers section
src/plugins/newcomers/gbp-newcomers-project.c | 62 ++++----
src/plugins/newcomers/gbp-newcomers-project.h | 4 +-
src/plugins/newcomers/gbp-newcomers-section.c | 38 ++---
src/plugins/newcomers/gbp-newcomers-section.ui | 187 +++++++++++++------------
4 files changed, 154 insertions(+), 137 deletions(-)
---
diff --git a/src/plugins/newcomers/gbp-newcomers-project.c b/src/plugins/newcomers/gbp-newcomers-project.c
index 4d9f8154c..eb460b8fb 100644
--- a/src/plugins/newcomers/gbp-newcomers-project.c
+++ b/src/plugins/newcomers/gbp-newcomers-project.c
@@ -26,9 +26,9 @@
struct _GbpNewcomersProject
{
- GtkFlowBoxChild parent_instance;
+ IdeGreeterRow parent_instance;
- gchar *uri;
+ IdeProjectInfo *project_info;
GtkLabel *label;
GtkImage *icon;
@@ -37,6 +37,7 @@ struct _GbpNewcomersProject
enum {
PROP_0,
+ PROP_DESCRIPTION,
PROP_ICON_NAME,
PROP_LANGUAGES,
PROP_NAME,
@@ -44,29 +45,18 @@ enum {
N_PROPS
};
-G_DEFINE_TYPE (GbpNewcomersProject, gbp_newcomers_project, GTK_TYPE_FLOW_BOX_CHILD)
+G_DEFINE_TYPE (GbpNewcomersProject, gbp_newcomers_project, IDE_TYPE_GREETER_ROW)
static GParamSpec *properties [N_PROPS];
static void
-gbp_newcomers_project_set_languages (GbpNewcomersProject *self,
- const gchar * const *languages)
+gbp_newcomers_project_constructed (GObject *object)
{
- g_assert (GBP_IS_NEWCOMERS_PROJECT (self));
+ GbpNewcomersProject *self = (GbpNewcomersProject *)object;
- if (languages == NULL)
- return;
+ G_OBJECT_CLASS (gbp_newcomers_project_parent_class)->constructed (object);
- for (guint i = 0; languages[i] != NULL; i++)
- {
- GtkWidget *tag;
-
- tag = dzl_pill_box_new (languages[i]);
- gtk_container_add_with_properties (GTK_CONTAINER (self->tags_box), tag,
- "pack-type", GTK_PACK_END,
- NULL);
- gtk_widget_show (tag);
- }
+ ide_greeter_row_set_project_info (IDE_GREETER_ROW (self), self->project_info);
}
static void
@@ -74,7 +64,7 @@ gbp_newcomers_project_destroy (GtkWidget *widget)
{
GbpNewcomersProject *self = GBP_NEWCOMERS_PROJECT (widget);
- g_clear_pointer (&self->uri, g_free);
+ g_clear_object (&self->project_info);
GTK_WIDGET_CLASS (gbp_newcomers_project_parent_class)->destroy (widget);
}
@@ -97,6 +87,10 @@ gbp_newcomers_project_get_property (GObject *object,
g_value_set_string (value, gbp_newcomers_project_get_name (self));
break;
+ case PROP_DESCRIPTION:
+ g_value_set_string (value, ide_project_info_get_description (self->project_info));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -113,19 +107,23 @@ gbp_newcomers_project_set_property (GObject *object,
switch (prop_id)
{
case PROP_URI:
- self->uri = g_value_dup_string (value);
+ ide_project_info_set_vcs_uri (self->project_info, g_value_get_string (value));
break;
case PROP_LANGUAGES:
- gbp_newcomers_project_set_languages (self, g_value_get_boxed (value));
+ ide_project_info_set_languages (self->project_info, g_value_get_boxed (value));
+ break;
+
+ case PROP_DESCRIPTION:
+ ide_project_info_set_description (self->project_info, g_value_get_string (value));
break;
case PROP_NAME:
- gtk_label_set_label (self->label, g_value_get_string (value));
+ ide_project_info_set_name (self->project_info, g_value_get_string (value));
break;
case PROP_ICON_NAME:
- g_object_set (self->icon, "icon-name", g_value_get_string (value), NULL);
+ ide_project_info_set_icon_name (self->project_info, g_value_get_string (value));
break;
default:
@@ -139,6 +137,7 @@ gbp_newcomers_project_class_init (GbpNewcomersProjectClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ object_class->constructed = gbp_newcomers_project_constructed;
object_class->get_property = gbp_newcomers_project_get_property;
object_class->set_property = gbp_newcomers_project_set_property;
@@ -158,6 +157,13 @@ gbp_newcomers_project_class_init (GbpNewcomersProjectClass *klass)
NULL,
(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+ properties [PROP_DESCRIPTION] =
+ g_param_spec_string ("description",
+ "Description",
+ "The description of the newcomer project",
+ NULL,
+ (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+
properties [PROP_LANGUAGES] =
g_param_spec_boxed ("languages",
"Languages",
@@ -174,16 +180,12 @@ gbp_newcomers_project_class_init (GbpNewcomersProjectClass *klass)
g_object_class_install_properties (object_class, N_PROPS, properties);
- gtk_widget_class_set_template_from_resource (widget_class, "/plugins/newcomers/gbp-newcomers-project.ui");
- gtk_widget_class_bind_template_child (widget_class, GbpNewcomersProject, label);
- gtk_widget_class_bind_template_child (widget_class, GbpNewcomersProject, icon);
- gtk_widget_class_bind_template_child (widget_class, GbpNewcomersProject, tags_box);
}
static void
gbp_newcomers_project_init (GbpNewcomersProject *self)
{
- gtk_widget_init_template (GTK_WIDGET (self));
+ self->project_info = ide_project_info_new ();
}
const gchar *
@@ -191,7 +193,7 @@ gbp_newcomers_project_get_name (GbpNewcomersProject *self)
{
g_return_val_if_fail (GBP_IS_NEWCOMERS_PROJECT (self), NULL);
- return self->label ? gtk_label_get_label (self->label) : NULL;
+ return ide_project_info_get_name (self->project_info);
}
const gchar *
@@ -199,5 +201,5 @@ gbp_newcomers_project_get_uri (GbpNewcomersProject *self)
{
g_return_val_if_fail (GBP_IS_NEWCOMERS_PROJECT (self), NULL);
- return self->uri;
+ return ide_project_info_get_vcs_uri (self->project_info);
}
diff --git a/src/plugins/newcomers/gbp-newcomers-project.h b/src/plugins/newcomers/gbp-newcomers-project.h
index 2aaf4dcd8..10f287d66 100644
--- a/src/plugins/newcomers/gbp-newcomers-project.h
+++ b/src/plugins/newcomers/gbp-newcomers-project.h
@@ -20,13 +20,13 @@
#pragma once
-#include <gtk/gtk.h>
+#include <libide-greeter.h>
G_BEGIN_DECLS
#define GBP_TYPE_NEWCOMERS_PROJECT (gbp_newcomers_project_get_type())
-G_DECLARE_FINAL_TYPE (GbpNewcomersProject, gbp_newcomers_project, GBP, NEWCOMERS_PROJECT, GtkFlowBoxChild)
+G_DECLARE_FINAL_TYPE (GbpNewcomersProject, gbp_newcomers_project, GBP, NEWCOMERS_PROJECT, IdeGreeterRow)
const gchar *gbp_newcomers_project_get_name (GbpNewcomersProject *self);
const gchar *gbp_newcomers_project_get_uri (GbpNewcomersProject *self);
diff --git a/src/plugins/newcomers/gbp-newcomers-section.c b/src/plugins/newcomers/gbp-newcomers-section.c
index 3de236be2..d719b0311 100644
--- a/src/plugins/newcomers/gbp-newcomers-section.c
+++ b/src/plugins/newcomers/gbp-newcomers-section.c
@@ -29,7 +29,7 @@
struct _GbpNewcomersSection
{
GtkBin parent_instance;
- GtkFlowBox *flowbox;
+ GtkListBox *list_box;
};
typedef struct
@@ -45,9 +45,9 @@ enum {
N_PROPS
};
-static void gbp_newcomers_section_child_activated (GbpNewcomersSection *self,
- GbpNewcomersProject *project,
- GtkFlowBox *flowbox);
+static void gbp_newcomers_section_row_activated (GbpNewcomersSection *self,
+ GbpNewcomersProject *project,
+ GtkListBox *list_box);
static void
delayed_activate_free (gpointer data)
@@ -103,7 +103,7 @@ gbp_newcomers_section_filter (IdeGreeterSection *section,
g_assert (GBP_IS_NEWCOMERS_SECTION (self));
- gtk_container_foreach (GTK_CONTAINER (self->flowbox),
+ gtk_container_foreach (GTK_CONTAINER (self->list_box),
gbp_newcomers_section_filter_child,
&filter);
@@ -127,9 +127,9 @@ gbp_newcomers_section_activate_cb (GtkWidget *widget,
if (activate->handled || !gtk_widget_get_visible (widget))
return;
- gbp_newcomers_section_child_activated (activate->self,
+ gbp_newcomers_section_row_activated (activate->self,
project,
- activate->self->flowbox);
+ activate->self->list_box);
activate->handled = TRUE;
}
@@ -148,7 +148,7 @@ gbp_newcomers_section_activate_first (IdeGreeterSection *section)
activate.self = self;
activate.handled = FALSE;
- gtk_container_foreach (GTK_CONTAINER (self->flowbox),
+ gtk_container_foreach (GTK_CONTAINER (self->list_box),
gbp_newcomers_section_activate_cb,
&activate);
@@ -182,9 +182,9 @@ clear_selection_from_timeout (gpointer data)
g_assert (GBP_IS_NEWCOMERS_SECTION (self));
- if (self->flowbox != NULL)
- gtk_flow_box_selected_foreach (self->flowbox,
- (GtkFlowBoxForeachFunc)gtk_flow_box_unselect_child,
+ if (self->list_box != NULL)
+ gtk_list_box_selected_foreach (self->list_box,
+ (GtkListBoxForeachFunc)gtk_list_box_unselect_row,
NULL);
return G_SOURCE_REMOVE;
@@ -224,15 +224,15 @@ do_selection_from_timeout (gpointer data)
}
static void
-gbp_newcomers_section_child_activated (GbpNewcomersSection *self,
- GbpNewcomersProject *project,
- GtkFlowBox *flowbox)
+gbp_newcomers_section_row_activated (GbpNewcomersSection *self,
+ GbpNewcomersProject *project,
+ GtkListBox *list_box)
{
DelayedActivate *state;
g_assert (GBP_IS_NEWCOMERS_SECTION (self));
g_assert (GBP_IS_NEWCOMERS_PROJECT (project));
- g_assert (GTK_IS_FLOW_BOX (flowbox));
+ g_assert (GTK_IS_LIST_BOX (list_box));
state = g_slice_new0 (DelayedActivate);
state->self = g_object_ref (self);
@@ -281,7 +281,7 @@ gbp_newcomers_section_class_init (GbpNewcomersSectionClass *klass)
gtk_widget_class_set_css_name (widget_class, "newcomers");
gtk_widget_class_set_template_from_resource (widget_class, "/plugins/newcomers/gbp-newcomers-section.ui");
- gtk_widget_class_bind_template_child (widget_class, GbpNewcomersSection, flowbox);
+ gtk_widget_class_bind_template_child (widget_class, GbpNewcomersSection, list_box);
g_type_ensure (GBP_TYPE_NEWCOMERS_PROJECT);
}
@@ -291,9 +291,9 @@ gbp_newcomers_section_init (GbpNewcomersSection *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
- g_signal_connect_object (self->flowbox,
- "child-activated",
- G_CALLBACK (gbp_newcomers_section_child_activated),
+ g_signal_connect_object (self->list_box,
+ "row-activated",
+ G_CALLBACK (gbp_newcomers_section_row_activated),
self,
G_CONNECT_SWAPPED | G_CONNECT_AFTER);
}
diff --git a/src/plugins/newcomers/gbp-newcomers-section.ui b/src/plugins/newcomers/gbp-newcomers-section.ui
index d2b7a49f2..ec855d75a 100644
--- a/src/plugins/newcomers/gbp-newcomers-section.ui
+++ b/src/plugins/newcomers/gbp-newcomers-section.ui
@@ -8,9 +8,13 @@
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<property name="visible">true</property>
+ <property name="width-request">600</property>
+ <property name="halign">center</property>
+ <property name="valign">start</property>
<child>
<object class="GtkLabel">
<property name="visible">true</property>
+ <property name="xalign">0.0</property>
<property name="label" translatable="yes">Suggested GNOME Projects</property>
<style>
<class name="dim-label"/>
@@ -21,95 +25,106 @@
</object>
</child>
<child>
- <object class="GtkFlowBox" id="flowbox">
+ <object class="GtkFrame">
+ <property name="shadow-type">in</property>
<property name="visible">true</property>
- <property name="halign">center</property>
- <property name="valign">start</property>
- <property name="selection-mode">browse</property>
- <property name="min-children-per-line">3</property>
- <property name="max-children-per-line">5</property>
<child>
- <object class="GbpNewcomersProject">
- <property name="name" translatable="yes">Polari</property>
- <property name="icon-name">org.gnome.Polari</property>
- <property name="uri">https://gitlab.gnome.org/GNOME/polari.git</property>
+ <object class="GtkListBox" id="list_box">
<property name="visible">true</property>
- <property name="languages">C
-JavaScript</property>
- </object>
- </child>
- <child>
- <object class="GbpNewcomersProject">
- <property name="name" translatable="yes">Games</property>
- <property name="icon-name">org.gnome.Games</property>
- <property name="uri">https://gitlab.gnome.org/GNOME/gnome-games.git</property>
- <property name="visible">true</property>
- <property name="languages">C
-Vala</property>
- </object>
- </child>
- <child>
- <object class="GbpNewcomersProject">
- <property name="name" translatable="yes">Maps</property>
- <property name="icon-name">org.gnome.Maps</property>
- <property name="uri">https://gitlab.gnome.org/GNOME/gnome-maps.git</property>
- <property name="visible">true</property>
- <property name="languages">C
-JavaScript</property>
- </object>
- </child>
- <child>
- <object class="GbpNewcomersProject">
- <property name="name" translatable="yes">Music</property>
- <property name="icon-name">org.gnome.Music</property>
- <property name="uri">https://gitlab.gnome.org/GNOME/gnome-music.git</property>
- <property name="visible">true</property>
- <property name="languages">Python</property>
- </object>
- </child>
- <child>
- <object class="GbpNewcomersProject">
- <property name="name" translatable="yes">Todo</property>
- <property name="icon-name">org.gnome.Todo</property>
- <property name="uri">https://gitlab.gnome.org/GNOME/gnome-todo.git</property>
- <property name="visible">true</property>
- <property name="languages">C</property>
- </object>
- </child>
- <child>
- <object class="GbpNewcomersProject">
- <property name="name" translatable="yes">Nautilus</property>
- <property name="icon-name">org.gnome.Nautilus</property>
- <property name="uri">https://gitlab.gnome.org/GNOME/nautilus.git</property>
- <property name="visible">true</property>
- <property name="languages">C</property>
- </object>
- </child>
- <child>
- <object class="GbpNewcomersProject">
- <property name="name" translatable="yes">Photos</property>
- <property name="icon-name">org.gnome.Photos</property>
- <property name="uri">https://gitlab.gnome.org/GNOME/gnome-photos.git</property>
- <property name="visible">true</property>
- <property name="languages">C</property>
- </object>
- </child>
- <child>
- <object class="GbpNewcomersProject">
- <property name="name" translatable="yes">Calendar</property>
- <property name="icon-name">org.gnome.Calendar</property>
- <property name="uri">https://gitlab.gnome.org/GNOME/gnome-calendar.git</property>
- <property name="visible">true</property>
- <property name="languages">C</property>
- </object>
- </child>
- <child>
- <object class="GbpNewcomersProject">
- <property name="name" translatable="yes">Boxes</property>
- <property name="icon-name">org.gnome.Boxes</property>
- <property name="uri">https://gitlab.gnome.org/GNOME/gnome-boxes.git</property>
- <property name="visible">true</property>
- <property name="languages">Vala</property>
+ <property name="selection-mode">browse</property>
+ <child>
+ <object class="GbpNewcomersProject">
+ <property name="name" translatable="yes">Polari</property>
+ <property name="description" translatable="yes">An IRC Client for GNOME</property>
+ <property name="icon-name">org.gnome.Polari</property>
+ <property name="uri">https://gitlab.gnome.org/GNOME/polari.git</property>
+ <property name="visible">true</property>
+ <property name="languages">C
+ JavaScript</property>
+ </object>
+ </child>
+ <child>
+ <object class="GbpNewcomersProject">
+ <property name="name" translatable="yes">Games</property>
+ <property name="description" translatable="yes">Simple game launcher for GNOME</property>
+ <property name="icon-name">org.gnome.Games</property>
+ <property name="uri">https://gitlab.gnome.org/GNOME/gnome-games.git</property>
+ <property name="visible">true</property>
+ <property name="languages">C
+ Vala</property>
+ </object>
+ </child>
+ <child>
+ <object class="GbpNewcomersProject">
+ <property name="name" translatable="yes">Maps</property>
+ <property name="description" translatable="yes">A simple GNOME 3 maps
application</property>
+ <property name="icon-name">org.gnome.Maps</property>
+ <property name="uri">https://gitlab.gnome.org/GNOME/gnome-maps.git</property>
+ <property name="visible">true</property>
+ <property name="languages">C
+ JavaScript</property>
+ </object>
+ </child>
+ <child>
+ <object class="GbpNewcomersProject">
+ <property name="name" translatable="yes">Music</property>
+ <property name="description" translatable="yes">Music player and management
application</property>
+ <property name="icon-name">org.gnome.Music</property>
+ <property name="uri">https://gitlab.gnome.org/GNOME/gnome-music.git</property>
+ <property name="visible">true</property>
+ <property name="languages">Python</property>
+ </object>
+ </child>
+ <child>
+ <object class="GbpNewcomersProject">
+ <property name="name" translatable="yes">Todo</property>
+ <property name="description" translatable="yes">Task manager for GNOME</property>
+ <property name="icon-name">org.gnome.Todo</property>
+ <property name="uri">https://gitlab.gnome.org/GNOME/gnome-todo.git</property>
+ <property name="visible">true</property>
+ <property name="languages">C</property>
+ </object>
+ </child>
+ <child>
+ <object class="GbpNewcomersProject">
+ <property name="name" translatable="yes">Nautilus</property>
+ <property name="description" translatable="yes">Default file manager for GNOME</property>
+ <property name="icon-name">org.gnome.Nautilus</property>
+ <property name="uri">https://gitlab.gnome.org/GNOME/nautilus.git</property>
+ <property name="visible">true</property>
+ <property name="languages">C</property>
+ </object>
+ </child>
+ <child>
+ <object class="GbpNewcomersProject">
+ <property name="name" translatable="yes">Photos</property>
+ <property name="description" translatable="yes">Access, organize and share your photos
on GNOME</property>
+ <property name="icon-name">org.gnome.Photos</property>
+ <property name="uri">https://gitlab.gnome.org/GNOME/gnome-photos.git</property>
+ <property name="visible">true</property>
+ <property name="languages">C</property>
+ </object>
+ </child>
+ <child>
+ <object class="GbpNewcomersProject">
+ <property name="name" translatable="yes">Calendar</property>
+ <property name="description" translatable="yes">Calendar application for GNOME</property>
+ <property name="icon-name">org.gnome.Calendar</property>
+ <property name="uri">https://gitlab.gnome.org/GNOME/gnome-calendar.git</property>
+ <property name="visible">true</property>
+ <property name="languages">C</property>
+ </object>
+ </child>
+ <child>
+ <object class="GbpNewcomersProject">
+ <property name="name" translatable="yes">Boxes</property>
+ <property name="description" translatable="yes">A simple GNOME 3 application to access
remote or virtual systems</property>
+ <property name="icon-name">org.gnome.Boxes</property>
+ <property name="uri">https://gitlab.gnome.org/GNOME/gnome-boxes.git</property>
+ <property name="visible">true</property>
+ <property name="languages">Vala</property>
+ </object>
+ </child>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]