[gimp] app: add gimp_button_set_suggested, destructive() to gimpwidgets-utils



commit f102ceb63f60e1b49346a4028dcad1f67434be7a
Author: Michael Natterer <mitch gimp org>
Date:   Thu May 17 12:52:13 2018 +0200

    app: add gimp_button_set_suggested,destructive() to gimpwidgets-utils
    
    which set/unset the "suggested-action" and "destructive-action" style
    classes and make sure the button relief is right.

 app/widgets/gimpwidgets-utils.c |   46 +++++++++++++++++++++++++++++++++++++++
 app/widgets/gimpwidgets-utils.h |    7 ++++++
 2 files changed, 53 insertions(+), 0 deletions(-)
---
diff --git a/app/widgets/gimpwidgets-utils.c b/app/widgets/gimpwidgets-utils.c
index 0a8375d..cff6383 100644
--- a/app/widgets/gimpwidgets-utils.c
+++ b/app/widgets/gimpwidgets-utils.c
@@ -1436,6 +1436,52 @@ gimp_widget_set_fully_opaque (GtkWidget *widget,
                             GINT_TO_POINTER (fully_opaque));
 }
 
+void
+gimp_button_set_suggested (GtkWidget      *button,
+                           gboolean        suggested,
+                           GtkReliefStyle  default_relief)
+{
+  GtkStyleContext *style;
+
+  g_return_if_fail (GTK_IS_BUTTON (button));
+
+  style = gtk_widget_get_style_context (button);
+
+  if (suggested)
+    {
+      gtk_style_context_add_class (style, "suggested-action");
+      gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NORMAL);
+    }
+  else
+    {
+      gtk_style_context_remove_class (style, "suggested-action");
+      gtk_button_set_relief (GTK_BUTTON (button), default_relief);
+    }
+}
+
+void
+gimp_button_set_destructive (GtkWidget      *button,
+                             gboolean        destructive,
+                             GtkReliefStyle  default_relief)
+{
+  GtkStyleContext *style;
+
+  g_return_if_fail (GTK_IS_BUTTON (button));
+
+  style = gtk_widget_get_style_context (button);
+
+  if (destructive)
+    {
+      gtk_style_context_add_class (style, "destructive-action");
+      gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NORMAL);
+    }
+  else
+    {
+      gtk_style_context_remove_class (style, "destructive-action");
+      gtk_button_set_relief (GTK_BUTTON (button), default_relief);
+    }
+}
+
 static gboolean
 gimp_print_event_free (gpointer data)
 {
diff --git a/app/widgets/gimpwidgets-utils.h b/app/widgets/gimpwidgets-utils.h
index f2f6453..71db2d8 100644
--- a/app/widgets/gimpwidgets-utils.h
+++ b/app/widgets/gimpwidgets-utils.h
@@ -107,6 +107,13 @@ gboolean          gimp_widget_get_fully_opaque     (GtkWidget            *widget
 void              gimp_widget_set_fully_opaque     (GtkWidget            *widget,
                                                     gboolean              fully_opaque);
 
+void              gimp_button_set_suggested        (GtkWidget            *button,
+                                                    gboolean              suggested,
+                                                    GtkReliefStyle        default_relief);
+void              gimp_button_set_destructive      (GtkWidget            *button,
+                                                    gboolean              suggestes,
+                                                    GtkReliefStyle        default_relief);
+
 const gchar     * gimp_print_event                 (const GdkEvent       *event);
 
 gboolean          gimp_color_profile_store_add_defaults


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