[gnome-todo] task-row: reflect task priority in background
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-todo] task-row: reflect task priority in background
- Date: Sun, 5 Jul 2015 21:00:48 +0000 (UTC)
commit 4df657078c5a21790d978f378975faaccaa8c39a
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sun Jul 5 17:59:14 2015 -0300
task-row: reflect task priority in background
Instead of showing a simplistic circle representing the
task priority, paint the background of the row with a
subtle variant of the color.
It works good with many list colors, but it still needs
some testing and design team input.
data/theme/Adwaita.css | 26 ++++++++++++++----
data/ui/task-row.ui | 8 -----
src/gtd-task-row.c | 69 +++++-------------------------------------------
3 files changed, 27 insertions(+), 76 deletions(-)
---
diff --git a/data/theme/Adwaita.css b/data/theme/Adwaita.css
index 2ac4b36..e090a83 100644
--- a/data/theme/Adwaita.css
+++ b/data/theme/Adwaita.css
@@ -43,14 +43,28 @@ GtkLabel.main-title {
}
/* priority icons */
-GtkImage.priority-low {
- background-color: #4e9a06;
+GtdTaskRow.priority-low {
+ background-color: alpha(#3465a4, 0.2);
}
-GtkImage.priority-medium {
- background-color: #edd400;
+GtdTaskRow.priority-low:hover {
+ background-color: alpha(#3465a4, 0.3);
}
-GtkImage.priority-hight {
- background-color: #a40000;
+
+GtdTaskRow.priority-medium {
+ background-color: alpha(#f57900, 0.2);
+}
+
+GtdTaskRow.priority-medium:hover {
+ background-color: alpha(#f57900, 0.3);
+}
+
+
+GtdTaskRow.priority-hight {
+ background-color: alpha(#cc0000, 0.2);
+}
+
+GtdTaskRow.priority-hight:hover {
+ background-color: alpha(#cc0000, 0.3);
}
diff --git a/data/ui/task-row.ui b/data/ui/task-row.ui
index 6827444..1f63613 100644
--- a/data/ui/task-row.ui
+++ b/data/ui/task-row.ui
@@ -61,14 +61,6 @@
</object>
</child>
<child>
- <object class="GtkImage" id="priority_icon">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">center</property>
- <property name="valign">center</property>
- </object>
- </child>
- <child>
<object class="GtkSpinner" id="task_loading_spinner">
<property name="visible">False</property>
<property name="can_focus">False</property>
diff --git a/src/gtd-task-row.c b/src/gtd-task-row.c
index 6e0e796..adc0d6b 100644
--- a/src/gtd-task-row.c
+++ b/src/gtd-task-row.c
@@ -36,7 +36,6 @@ typedef struct
GtkStack *new_task_stack;
/* task widgets */
- GtkImage *priority_icon;
GtkEntry *title_entry;
GtkLabel *task_date_label;
GtkLabel *task_list_label;
@@ -77,54 +76,6 @@ enum {
static guint signals[NUM_SIGNALS] = { 0, };
-/*
- * Code partially stolen from GNOME Calendar (gcal-utils.c)
- */
-GdkPixbuf*
-generate_priority_icon (GtdTaskRow *row)
-{
- GtdTaskRowPrivate *priv;
- GtkStyleContext *context;
- cairo_surface_t *surface;
- GdkPixbuf *pix;
- cairo_t *cr;
-
- g_return_val_if_fail (GTD_IS_TASK_ROW (row), NULL);
-
- priv = row->priv;
- context = gtk_widget_get_style_context (GTK_WIDGET (priv->priority_icon));
-
- surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
- PRIORITY_ICON_SIZE,
- PRIORITY_ICON_SIZE);
- cr = cairo_create (surface);
-
- cairo_arc (cr,
- PRIORITY_ICON_SIZE / 2.0,
- PRIORITY_ICON_SIZE / 2.0,
- PRIORITY_ICON_SIZE / 2.0,
- 0.,
- 2 * M_PI);
- cairo_clip (cr);
-
- /* Use the given GtkContext to draw the background */
- gtk_render_background (context,
- cr,
- 0,
- 0,
- PRIORITY_ICON_SIZE,
- PRIORITY_ICON_SIZE);
-
- cairo_destroy (cr);
- pix = gdk_pixbuf_get_from_surface (surface,
- 0,
- 0,
- PRIORITY_ICON_SIZE,
- PRIORITY_ICON_SIZE);
- cairo_surface_destroy (surface);
- return pix;
-}
-
static void
gtd_task_row__priority_changed_cb (GtdTaskRow *row,
GParamSpec *spec,
@@ -132,16 +83,18 @@ gtd_task_row__priority_changed_cb (GtdTaskRow *row,
{
GtdTaskRowPrivate *priv;
GtkStyleContext *context;
- GdkPixbuf *icon;
gint priority;
g_return_if_fail (GTD_IS_TASK_ROW (row));
priv = row->priv;
- context = gtk_widget_get_style_context (GTK_WIDGET (priv->priority_icon));
+ context = gtk_widget_get_style_context (GTK_WIDGET (row));
priority = gtd_task_get_priority (GTD_TASK (object));
- gtk_style_context_save (context);
+ /* remove all styles */
+ gtk_style_context_remove_class (context, "priority-low");
+ gtk_style_context_remove_class (context, "priority-medium");
+ gtk_style_context_remove_class (context, "priority-hight");
switch (priority)
{
@@ -161,15 +114,8 @@ gtd_task_row__priority_changed_cb (GtdTaskRow *row,
break;
}
- /* Set the new icon */
- icon = generate_priority_icon (row);
-
- gtk_image_set_from_pixbuf (priv->priority_icon, icon);
- gtk_widget_set_visible (GTK_WIDGET (priv->priority_icon), priority != 0);
-
- gtk_style_context_restore (context);
-
- g_object_unref (icon);
+ /* redraw background according to the new applied style */
+ gtk_widget_queue_draw (GTK_WIDGET (row));
}
static gboolean
@@ -512,7 +458,6 @@ gtd_task_row_class_init (GtdTaskRowClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GtdTaskRow, stack);
gtk_widget_class_bind_template_child_private (widget_class, GtdTaskRow, new_task_entry);
gtk_widget_class_bind_template_child_private (widget_class, GtdTaskRow, new_task_stack);
- gtk_widget_class_bind_template_child_private (widget_class, GtdTaskRow, priority_icon);
gtk_widget_class_bind_template_child_private (widget_class, GtdTaskRow, revealer);
gtk_widget_class_bind_template_child_private (widget_class, GtdTaskRow, task_date_label);
gtk_widget_class_bind_template_child_private (widget_class, GtdTaskRow, task_list_label);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]