[recipes] Improve the notes UI
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Improve the notes UI
- Date: Thu, 26 Jan 2017 16:12:55 +0000 (UTC)
commit f96b4deef7b3bfc50175f4d0fcca32e11b840899
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Jan 25 23:49:03 2017 +0100
Improve the notes UI
src/gr-details-page.c | 32 +++++++++----
src/gr-details-page.ui | 118 +++++++++++++++++++++++++++++++----------------
src/recipes.css | 23 +++++++++
3 files changed, 124 insertions(+), 49 deletions(-)
---
diff --git a/src/gr-details-page.c b/src/gr-details-page.c
index 12e39ae..a6fdd73 100644
--- a/src/gr-details-page.c
+++ b/src/gr-details-page.c
@@ -147,6 +147,8 @@ struct _GrDetailsPage
GtkWidget *edit_button;
GtkWidget *delete_button;
GtkWidget *notes_field;
+ GtkWidget *notes_box;
+ GtkWidget *notes_label;
GtkWidget *description_label;
GtkWidget *export_button;
GtkWidget *error_label;
@@ -524,11 +526,19 @@ shop_it (GrDetailsPage *page)
gr_recipe_store_remove_from_shopping (store, page->recipe);
}
+static gboolean save_notes (gpointer data);
+
static void
details_page_finalize (GObject *object)
{
GrDetailsPage *self = GR_DETAILS_PAGE (object);
+ if (self->save_timeout) {
+ g_source_remove (self->save_timeout);
+ self->save_timeout = 0;
+ save_notes (object);
+ }
+
g_clear_object (&self->recipe);
g_clear_object (&self->chef);
g_clear_object (&self->ingredients);
@@ -537,11 +547,6 @@ details_page_finalize (GObject *object)
g_clear_pointer (&self->cooking, g_hash_table_unref);
g_clear_pointer (&self->uri, g_free);
- if (self->save_timeout) {
- g_source_remove (self->save_timeout);
- self->save_timeout = 0;
- }
-
G_OBJECT_CLASS (gr_details_page_parent_class)->finalize (object);
}
@@ -601,7 +606,7 @@ save_notes (gpointer data)
store = gr_app_get_recipe_store (GR_APP (g_application_get_default ()));
if (!gr_recipe_store_update_recipe (store, page->recipe, id, &error)) {
- g_print ("Error: %s\n", error->message);
+ g_message ("Error: %s", error->message);
}
out:
@@ -618,7 +623,7 @@ schedule_save (GtkTextBuffer *buffer, GrDetailsPage *page)
page->save_timeout = 0;
}
- page->save_timeout = g_timeout_add (250, save_notes, page);
+ page->save_timeout = g_timeout_add (500, save_notes, page);
}
static gboolean
@@ -750,6 +755,8 @@ gr_details_page_class_init (GrDetailsPageClass *klass)
gtk_widget_class_bind_template_child (widget_class, GrDetailsPage, edit_button);
gtk_widget_class_bind_template_child (widget_class, GrDetailsPage, delete_button);
gtk_widget_class_bind_template_child (widget_class, GrDetailsPage, notes_field);
+ gtk_widget_class_bind_template_child (widget_class, GrDetailsPage, notes_box);
+ gtk_widget_class_bind_template_child (widget_class, GrDetailsPage, notes_label);
gtk_widget_class_bind_template_child (widget_class, GrDetailsPage, description_label);
gtk_widget_class_bind_template_child (widget_class, GrDetailsPage, export_button);
gtk_widget_class_bind_template_child (widget_class, GrDetailsPage, error_label);
@@ -978,8 +985,15 @@ gr_details_page_set_recipe (GrDetailsPage *page,
gtk_widget_hide (page->chef_label);
}
- gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (page->notes_field)),
- notes ? notes : "", -1);
+ if (notes && notes[0]) {
+ gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (page->notes_field)),
notes, -1);
+ gtk_label_set_label (GTK_LABEL (page->notes_label), notes);
+ gtk_widget_show (page->notes_box);
+ }
+ else {
+ gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (page->notes_field)), "",
-1);
+ gtk_widget_hide (page->notes_box);
+ }
if (description && description[0]) {
gtk_label_set_label (GTK_LABEL (page->description_label), description);
diff --git a/src/gr-details-page.ui b/src/gr-details-page.ui
index dd9a55d..2d1ede2 100644
--- a/src/gr-details-page.ui
+++ b/src/gr-details-page.ui
@@ -332,6 +332,7 @@ followed</property>
<property name="xalign">0</property>
<property name="wrap">1</property>
<property name="max-width-chars">45</property>
+ <property name="margin-bottom">15</property>
</object>
<packing>
<property name="left-attach">0</property>
@@ -340,6 +341,51 @@ followed</property>
</packing>
</child>
<child>
+ <object class="GtkBox" id="notes_box">
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">1</property>
+ <property name="orientation">horizontal</property>
+ <style>
+ <class name="note"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">1</property>
+ <property name="icon-name">dialog-warning-symbolic</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">1</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Note</property>
+ </object>
+ <packing>
+ <property name="expand">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="notes_label">
+ <property name="visible">1</property>
+ <property name="xalign">0</property>
+ <style>
+ <class name="note"/>
+ <class name="content"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">4</property>
+ <property name="width">2</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkLabel">
<property name="visible">1</property>
<property name="label" translatable="yes">Directions</property>
@@ -350,7 +396,7 @@ followed</property>
</object>
<packing>
<property name="left-attach">0</property>
- <property name="top-attach">4</property>
+ <property name="top-attach">5</property>
<property name="width">2</property>
</packing>
</child>
@@ -367,7 +413,7 @@ followed</property>
</object>
<packing>
<property name="left-attach">0</property>
- <property name="top-attach">5</property>
+ <property name="top-attach">6</property>
<property name="width">2</property>
</packing>
</child>
@@ -380,48 +426,10 @@ followed</property>
</object>
<packing>
<property name="left-attach">0</property>
- <property name="top-attach">6</property>
- <property name="width">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible">1</property>
- <property name="label" translatable="yes">Notes</property>
- <property name="xalign">0</property>
- <style>
- <class name="heading"/>
- </style>
- </object>
- <packing>
- <property name="left-attach">0</property>
<property name="top-attach">7</property>
<property name="width">2</property>
</packing>
</child>
- <child>
- <object class="GtkScrolledWindow">
- <property name="visible">1</property>
- <property name="shadow-type">in</property>
- <property name="hscrollbar-policy">never</property>
- <property name="min-content-height">240</property>
- <child>
- <object class="GtkTextView" id="notes_field">
- <property name="visible">1</property>
- <property name="wrap-mode">word</property>
- <property name="top-margin">10</property>
- <property name="left-margin">10</property>
- <property name="right-margin">10</property>
- <property name="bottom-margin">10</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="left-attach">0</property>
- <property name="top-attach">8</property>
- <property name="width">2</property>
- </packing>
- </child>
</object>
</child>
</object>
@@ -436,6 +444,16 @@ followed</property>
<object class="GtkActionBar">
<property name="visible">1</property>
<child>
+ <object class="GtkMenuButton" id="notes_button">
+ <property name="visible">1</property>
+ <property name="use-underline">1</property>
+ <property name="focus-on-click">0</property>
+ <property name="label" translatable="yes">_Notes</property>
+ <property name="popover">notes_popover</property>
+ <property name="direction">up</property>
+ </object>
+ </child>
+ <child>
<object class="GtkButton" id="edit_button">
<property name="visible">1</property>
<property name="use-underline">1</property>
@@ -611,4 +629,24 @@ followed</property>
<property name="step-increment">60</property>
<property name="page-increment">900</property>
</object>
+ <object class="GtkPopover" id="notes_popover">
+ <child>
+ <object class="GtkScrolledWindow">
+ <property name="visible">1</property>
+ <property name="shadow-type">in</property>
+ <property name="margin">5</property>
+ <property name="height-request">300</property>
+ <property name="width-request">400</property>
+ <child>
+ <object class="GtkTextView" id="notes_field">
+ <property name="visible">1</property>
+ <property name="left-margin">10</property>
+ <property name="right-margin">10</property>
+ <property name="top-margin">10</property>
+ <property name="bottom-margin">10</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
</interface>
diff --git a/src/recipes.css b/src/recipes.css
index f5f60b4..25ff3f1 100644
--- a/src/recipes.css
+++ b/src/recipes.css
@@ -267,3 +267,26 @@ flowbox flowboxchild {
.image-page .content {
border: 1px solid white;
}
+
+.note {
+ background: #8091c4;
+}
+
+.note label,
+.note image {
+ color: white;
+ margin: 5px 0 5px 10px;
+}
+
+.note.content {
+ background: #a8c3e1;
+ padding: 10px;
+}
+
+.note:backdrop {
+ background: #b1b6c4;
+}
+
+.note.content:backdrop {
+ background: #cbd6e1;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]