[gnome-builder] colorpicker: add needs-attention to prefs list row



commit 032f14a6df6cb3580174ef586333b81c40e7f2cb
Author: Sebastien Lafargue <slafargue gnome org>
Date:   Mon Jul 25 23:18:49 2016 +0200

    colorpicker: add needs-attention to prefs list row
    
    property:
      needs-attention
    
    setter/getter:
      gb_color_picker_prefs_palette_row_set_needs_attention
      gb_color_picker_prefs_palette_row_get_needs_attention
    
    We also add the corresponding css

 .../gb-color-picker-prefs-palette-row.c            |   50 +++++++++++++++++++-
 .../gb-color-picker-prefs-palette-row.h            |    5 ++-
 plugins/color-picker/theme/shared.css              |   12 ++++-
 3 files changed, 63 insertions(+), 4 deletions(-)
---
diff --git a/plugins/color-picker/gb-color-picker-prefs-palette-row.c 
b/plugins/color-picker/gb-color-picker-prefs-palette-row.c
index 004972b..1793854 100644
--- a/plugins/color-picker/gb-color-picker-prefs-palette-row.c
+++ b/plugins/color-picker/gb-color-picker-prefs-palette-row.c
@@ -41,6 +41,7 @@ struct _GbColorPickerPrefsPaletteRow
 
   guint              updating : 1;
   guint              is_editing : 1;
+  guint              needs_attention : 1;
 };
 
 G_DEFINE_TYPE (GbColorPickerPrefsPaletteRow, gb_color_picker_prefs_palette_row, IDE_TYPE_PREFERENCES_BIN)
@@ -48,6 +49,7 @@ G_DEFINE_TYPE (GbColorPickerPrefsPaletteRow, gb_color_picker_prefs_palette_row,
 enum {
   PROP_0,
   PROP_KEY,
+  PROP_NEEDS_ATTENTION,
   PROP_IS_EDITING,
   PROP_TARGET,
   PROP_PALETTE_NAME,
@@ -309,6 +311,35 @@ gb_color_picker_prefs_palette_row_set_palette_name (GbColorPickerPrefsPaletteRow
     }
 }
 
+void
+gb_color_picker_prefs_palette_row_set_needs_attention (GbColorPickerPrefsPaletteRow *self,
+                                                       gboolean                      needs_attention)
+{
+  GtkStyleContext *context;
+
+  g_return_if_fail (GB_IS_COLOR_PICKER_PREFS_PALETTE_ROW (self));
+
+  if (self->needs_attention != needs_attention)
+    {
+      context = gtk_widget_get_style_context (GTK_WIDGET (self));
+      self->needs_attention = needs_attention;
+      if (needs_attention)
+        gtk_style_context_add_class (context, GTK_STYLE_CLASS_NEEDS_ATTENTION);
+      else
+       gtk_style_context_remove_class (context, GTK_STYLE_CLASS_NEEDS_ATTENTION);
+
+      g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_NEEDS_ATTENTION]);
+    }
+}
+
+gboolean
+gb_color_picker_prefs_palette_row_get_needs_attention (GbColorPickerPrefsPaletteRow *self)
+{
+  g_return_val_if_fail (GB_IS_COLOR_PICKER_PREFS_PALETTE_ROW (self), FALSE);
+
+  return self->needs_attention;
+}
+
 GbColorPickerPrefsPaletteRow *
 gb_color_picker_prefs_palette_row_new (void)
 {
@@ -344,6 +375,10 @@ gb_color_picker_prefs_palette_row_get_property (GObject    *object,
       g_value_set_string (value, self->key);
       break;
 
+    case PROP_NEEDS_ATTENTION:
+      g_value_set_boolean (value, gb_color_picker_prefs_palette_row_get_needs_attention (self));
+      break;
+
     case PROP_IS_EDITING:
       g_value_set_boolean (value, self->is_editing);
       break;
@@ -375,6 +410,10 @@ gb_color_picker_prefs_palette_row_set_property (GObject      *object,
       self->key = g_value_dup_string (value);
       break;
 
+    case PROP_NEEDS_ATTENTION:
+      gb_color_picker_prefs_palette_row_set_needs_attention (self, g_value_get_boolean (value));
+      break;
+
     case PROP_IS_EDITING:
       gb_color_picker_prefs_palette_row_set_edit (self, g_value_get_boolean (value));
       break;
@@ -428,12 +467,19 @@ gb_color_picker_prefs_palette_row_class_init (GbColorPickerPrefsPaletteRowClass
                          NULL,
                          (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
 
+  properties[PROP_NEEDS_ATTENTION] =
+    g_param_spec_boolean ("needs-attention",
+                          "Needs Attention",
+                          "Whether this row needs attention",
+                         FALSE,
+                         (G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
+
   properties [PROP_PALETTE_NAME] =
     g_param_spec_string ("palette-name",
                          "Palette name",
                          "Palette name",
                          NULL,
-                         (G_PARAM_READWRITE |G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
+                         (G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
 
   signals [ACTIVATED] =
     g_signal_new_class_handler ("activated",
@@ -477,6 +523,8 @@ gb_color_picker_prefs_palette_row_class_init (GbColorPickerPrefsPaletteRowClass
   gtk_widget_class_bind_template_child (widget_class, GbColorPickerPrefsPaletteRow, image);
   gtk_widget_class_bind_template_child (widget_class, GbColorPickerPrefsPaletteRow, event_box);
   gtk_widget_class_bind_template_child (widget_class, GbColorPickerPrefsPaletteRow, palette_name);
+
+  gtk_widget_class_set_css_name (widget_class, "colorpickerpaletterow");
 }
 
 static void
diff --git a/plugins/color-picker/gb-color-picker-prefs-palette-row.h 
b/plugins/color-picker/gb-color-picker-prefs-palette-row.h
index 92c892f..042328d 100644
--- a/plugins/color-picker/gb-color-picker-prefs-palette-row.h
+++ b/plugins/color-picker/gb-color-picker-prefs-palette-row.h
@@ -28,7 +28,10 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE (GbColorPickerPrefsPaletteRow, gb_color_picker_prefs_palette_row, GB, 
COLOR_PICKER_PREFS_PALETTE_ROW, IdePreferencesBin)
 
-GbColorPickerPrefsPaletteRow *gb_color_picker_prefs_palette_row_new (void);
+gboolean                           gb_color_picker_prefs_palette_row_get_needs_attention    
(GbColorPickerPrefsPaletteRow    *self);
+void                               gb_color_picker_prefs_palette_row_set_needs_attention    
(GbColorPickerPrefsPaletteRow    *self,
+                                                                                             gboolean        
                 needs_attention);
+GbColorPickerPrefsPaletteRow      *gb_color_picker_prefs_palette_row_new                    (void);
 
 G_END_DECLS
 
diff --git a/plugins/color-picker/theme/shared.css b/plugins/color-picker/theme/shared.css
index 32ccb59..6d57ace 100644
--- a/plugins/color-picker/theme/shared.css
+++ b/plugins/color-picker/theme/shared.css
@@ -217,8 +217,16 @@ gstyleslidein gbcolorpickerprefspalettelist row {
 }
 
 gstyleslidein gbcolorpickerprefslist preferencesbin > box,
-gstyleslidein gbcolorpickerprefspalettelist preferencesbin > box {
-  padding: 10px;
+gstyleslidein gbcolorpickerprefspalettelist colorpickerpaletterow > box {
+  padding: 10px 10px 10px 13px;
+}
+
+colorpickerpaletterow.needs-attention > box {
+  background-image: -gtk-gradient(radial, center center, 0, center center, 0.5, to(#4a90d9), 
to(transparent)),
+                    -gtk-gradient(radial, center center, 0, center center, 0.5, to(rgba(255, 255, 255, 
0.76923)), to(transparent));
+  background-size: 6px 6px, 6px 6px;
+  background-repeat: no-repeat;
+  background-position: 3px center;
 }
 
 gstyleslidein gbcolorpickerprefslist row:last-child,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]