[recipes] Add a biographical section to the top of chef pages
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Add a biographical section to the top of chef pages
- Date: Mon, 12 Dec 2016 14:40:01 +0000 (UTC)
commit 5533ef27065a0dde8dd1453a5e75f0eaf929c270
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Dec 11 20:44:55 2016 -0500
Add a biographical section to the top of chef pages
This is useful to let us see the information we have about our
beloved chefs.
src/gr-list-page.c | 35 ++++++++++++++++++
src/gr-list-page.ui | 100 ++++++++++++++++++++++++++++++++++++++++++++++----
src/gr-window.c | 2 +-
3 files changed, 128 insertions(+), 9 deletions(-)
---
diff --git a/src/gr-list-page.c b/src/gr-list-page.c
index 3bbce57..fa6d451 100644
--- a/src/gr-list-page.c
+++ b/src/gr-list-page.c
@@ -45,6 +45,13 @@ struct _GrListPage
GtkWidget *flow_box;
GtkWidget *empty_title;
GtkWidget *empty_subtitle;
+
+ GtkWidget *chef_box;
+ GtkWidget *chef_image;
+ GtkWidget *chef_fullname;
+ GtkWidget *chef_name;
+ GtkWidget *chef_description;
+ GtkWidget *chef_heading;
};
G_DEFINE_TYPE (GrListPage, gr_list_page, GTK_TYPE_BOX)
@@ -92,6 +99,12 @@ 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_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, chef_heading);
}
GtkWidget *
@@ -147,6 +160,9 @@ 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_heading);
+
container_remove_all (GTK_CONTAINER (self->flow_box));
tmp = g_strdup_printf (_("No %s found"), get_category_title (diet));
gtk_label_set_label (GTK_LABEL (self->empty_title), tmp);
@@ -189,11 +205,24 @@ gr_list_page_populate_from_chef (GrListPage *self,
int i;
gboolean filled;
char *tmp;
+ g_autoptr(GdkPixbuf) pixbuf = NULL;
g_object_ref (chef);
clear_data (self);
self->chef = chef;
+ gtk_widget_show (self->chef_box);
+ gtk_widget_show (self->chef_heading);
+
+ 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));
+ gtk_label_set_label (GTK_LABEL (self->chef_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));
@@ -247,6 +276,9 @@ 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_heading);
+
container_remove_all (GTK_CONTAINER (self->flow_box));
tmp = g_strdup_printf (_("No recipes for %s found"), gr_season_get_title (self->season));
gtk_label_set_label (GTK_LABEL (self->empty_title), tmp);
@@ -288,6 +320,9 @@ 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_heading);
+
container_remove_all (GTK_CONTAINER (self->flow_box));
gtk_label_set_label (GTK_LABEL (self->empty_title), _("No favorite recipes found"));
gtk_label_set_label (GTK_LABEL (self->empty_subtitle), _("Use the “Cook later” button to mark
recipes as favorites."));
diff --git a/src/gr-list-page.ui b/src/gr-list-page.ui
index 2d9b5f2..3a35641 100644
--- a/src/gr-list-page.ui
+++ b/src/gr-list-page.ui
@@ -57,19 +57,103 @@
<property name="expand">1</property>
<property name="hscrollbar-policy">never</property>
<child>
- <object class="GtkFlowBox" id="flow_box">
+ <object class="GtkBox">
<property name="visible">1</property>
+ <property name="orientation">vertical</property>
<property name="halign">center</property>
<property name="valign">start</property>
- <property name="column-spacing">20</property>
- <property name="row-spacing">20</property>
- <property name="margin-top">20</property>
- <property name="margin-bottom">20</property>
<property name="margin-start">80</property>
<property name="margin-end">80</property>
- <property name="selection-mode">none</property>
- <property name="min-children-per-line">3</property>
- <property name="max-children-per-line">3</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">
+ <property name="visible">1</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>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">0</property>
+ <property name="height">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="chef_fullname">
+ <property name="visible">1</property>
+ <property name="xalign">0</property>
+ <attributes>
+ <attribute name="scale" value="1.44"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="chef_name">
+ <property name="visible">1</property>
+ <property name="xalign">0</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>
+ <object class="GtkLabel" id="chef_heading">
+ <property name="visible">1</property>
+ <property name="xalign">0</property>
+ <style>
+ <class name="heading"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkFlowBox" id="flow_box">
+ <property name="visible">1</property>
+ <property name="halign">center</property>
+ <property name="valign">start</property>
+ <property name="column-spacing">20</property>
+ <property name="row-spacing">20</property>
+ <property name="margin-top">20</property>
+ <property name="margin-bottom">20</property>
+ <property name="selection-mode">none</property>
+ <property name="min-children-per-line">3</property>
+ <property name="max-children-per-line">3</property>
+ </object>
+ </child>
</object>
</child>
</object>
diff --git a/src/gr-window.c b/src/gr-window.c
index eed30a6..e23cfa5 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 (_("Recipes by %s"), gr_chef_get_name (chef));
+ title = g_strdup_printf (_("Chef %s"), gr_chef_get_name (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]