[recipes] Refine the bio section on the list page
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Refine the bio section on the list page
- Date: Wed, 14 Dec 2016 02:13:00 +0000 (UTC)
commit d84140c5181cbb18b5b9d3b65051b5b416815323
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Dec 13 21:11:53 2016 -0500
Refine the bio section on the list page
This is along the lines of Jakub's latest mockup.
src/gr-list-page.c | 53 +++++++++++++++++++++++++++++++++++++-------------
src/gr-list-page.ui | 40 ++++++++++---------------------------
src/gr-window.c | 2 +-
3 files changed, 51 insertions(+), 44 deletions(-)
---
diff --git a/src/gr-list-page.c b/src/gr-list-page.c
index 21cb512..4fd68e8 100644
--- a/src/gr-list-page.c
+++ b/src/gr-list-page.c
@@ -47,10 +47,9 @@ struct _GrListPage
GtkWidget *empty_title;
GtkWidget *empty_subtitle;
- GtkWidget *chef_box;
+ GtkWidget *chef_grid;
GtkWidget *chef_image;
GtkWidget *chef_fullname;
- GtkWidget *chef_name;
GtkWidget *chef_description;
GtkWidget *heading;
GtkWidget *diet_description;
@@ -101,10 +100,9 @@ gr_list_page_class_init (GrListPageClass *klass)
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrListPage, list_stack);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrListPage, empty_title);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrListPage, empty_subtitle);
- gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrListPage, chef_box);
+ gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrListPage, chef_grid);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrListPage, chef_image);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrListPage, chef_fullname);
- gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrListPage, chef_name);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrListPage, chef_description);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrListPage, heading);
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (klass), GrListPage, diet_description);
@@ -163,7 +161,7 @@ gr_list_page_populate_from_diet (GrListPage *self,
clear_data (self);
self->diet = diet;
- gtk_widget_hide (self->chef_box);
+ gtk_widget_hide (self->chef_grid);
gtk_widget_show (self->diet_description);
gtk_widget_show (self->heading);
@@ -212,29 +210,56 @@ gr_list_page_populate_from_chef (GrListPage *self,
int i;
gboolean filled;
char *tmp;
- g_autoptr(GdkPixbuf) pixbuf = NULL;
+ const char *image_path;
+ GtkStyleContext *context;
+ g_autofree char *css = NULL;
+ g_autoptr(GtkCssProvider) provider = NULL;
g_object_ref (chef);
clear_data (self);
self->chef = chef;
- gtk_widget_show (self->chef_box);
+ gtk_widget_show (self->chef_grid);
gtk_widget_show (self->heading);
gtk_widget_hide (self->diet_description);
gtk_label_set_label (GTK_LABEL (self->chef_fullname), gr_chef_get_fullname (chef));
- gtk_label_set_label (GTK_LABEL (self->chef_name), gr_chef_get_name (chef));
gtk_label_set_label (GTK_LABEL (self->chef_description), gr_chef_get_description (chef));
- pixbuf = load_pixbuf_fit_size (gr_chef_get_image (chef), 0, 64, 64, FALSE);
- gtk_image_set_from_pixbuf (GTK_IMAGE (self->chef_image), pixbuf);
- tmp = g_strdup_printf (_("Recipes by %s"), gr_chef_get_name (chef));
+
+ image_path = gr_chef_get_image (chef);
+
+ if (image_path != NULL && image_path[0] != '\0')
+ css = g_strdup_printf ("image.chef {\n"
+ " background: url('%s');\n"
+ " background-size: 64px;\n"
+ " min-width: 64px;\n"
+ " min-height: 64px;\n"
+ "}", image_path);
+ else
+ css = g_strdup_printf ("image.chef {\n"
+ " background: rgb(%d,%d,%d);\n"
+ " min-width: 64px;\n"
+ " min-height: 64px;\n"
+ "}",
+ g_random_int_range (0, 255),
+ g_random_int_range (0, 255),
+ g_random_int_range (0, 255));
+
+ provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (provider, css, -1, NULL);
+ context = gtk_widget_get_style_context (self->chef_image);
+ gtk_style_context_add_provider (context,
+ GTK_STYLE_PROVIDER (provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+
+ tmp = g_strdup_printf (_("Recipes by %s"), gr_chef_get_nickname (chef));
gtk_label_set_label (GTK_LABEL (self->heading), tmp);
g_free (tmp);
store = gr_app_get_recipe_store (GR_APP (g_application_get_default ()));
container_remove_all (GTK_CONTAINER (self->flow_box));
- tmp = g_strdup_printf (_("No recipes by chef %s found"), gr_chef_get_name (chef));
+ tmp = g_strdup_printf (_("No recipes by chef %s found"), gr_chef_get_nickname (chef));
gtk_label_set_label (GTK_LABEL (self->empty_title), tmp);
g_free (tmp);
if (g_strcmp0 (gr_chef_get_name (chef), gr_recipe_store_get_user_key (store)) == 0)
@@ -284,7 +309,7 @@ gr_list_page_populate_from_season (GrListPage *self,
clear_data (self);
self->season = tmp;
- gtk_widget_hide (self->chef_box);
+ gtk_widget_hide (self->chef_grid);
gtk_widget_hide (self->heading);
gtk_widget_hide (self->diet_description);
@@ -329,7 +354,7 @@ gr_list_page_populate_from_favorites (GrListPage *self)
clear_data (self);
self->favorites = TRUE;
- gtk_widget_hide (self->chef_box);
+ gtk_widget_hide (self->chef_grid);
gtk_widget_hide (self->heading);
gtk_widget_hide (self->diet_description);
diff --git a/src/gr-list-page.ui b/src/gr-list-page.ui
index b4f2035..ed985e4 100644
--- a/src/gr-list-page.ui
+++ b/src/gr-list-page.ui
@@ -65,17 +65,21 @@
<property name="margin-start">80</property>
<property name="margin-end">80</property>
<child>
- <object class="GtkBox" id="chef_box">
- <property name="margin-top">20</property>
- <property name="spacing">20</property>
- <child>
- <object class="GtkGrid" id="chef_grid">
+ <object class="GtkGrid" id="chef_grid">
<property name="visible">1</property>
+ <property name="margin-top">20</property>
<property name="column-spacing">20</property>
<property name="row-spacing">20</property>
<child>
<object class="GtkImage" id="chef_image">
<property name="visible">1</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <style>
+ <class name="image-button"/>
+ <class name="circular"/>
+ <class name="chef"/>
+ </style>
</object>
<packing>
<property name="left-attach">0</property>
@@ -97,38 +101,16 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="chef_name">
+ <object class="GtkLabel" id="chef_description">
<property name="visible">1</property>
<property name="xalign">0</property>
+ <property name="wrap">1</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
</packing>
</child>
- </object>
- <packing>
- <property name="expand">1</property>
- </packing>
- </child>
- <child type="center">
- <object class="GtkSeparator">
- <property name="visible">1</property>
- <property name="orientation">vertical</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="chef_description">
- <property name="visible">1</property>
- <property name="valign">start</property>
- <property name="xalign">0</property>
- <property name="wrap">1</property>
- </object>
- <packing>
- <property name="expand">1</property>
- <property name="pack-type">end</property>
- </packing>
- </child>
</object>
</child>
<child>
diff --git a/src/gr-window.c b/src/gr-window.c
index e23cfa5..f31ac22 100644
--- a/src/gr-window.c
+++ b/src/gr-window.c
@@ -521,7 +521,7 @@ gr_window_show_chef (GrWindow *window,
gr_list_page_populate_from_chef (GR_LIST_PAGE (window->list_page), chef);
- title = g_strdup_printf (_("Chef %s"), gr_chef_get_name (chef));
+ title = g_strdup_printf (_("Chefs: %s"), gr_chef_get_fullname (chef));
gtk_header_bar_set_title (GTK_HEADER_BAR (window->header), title);
gtk_stack_set_visible_child_name (GTK_STACK (window->header_start_stack), "back");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]