[gnome-panel] libgnome-panel: add gp_add_text_color_class



commit 61f14512755f458525171b44f742bf5e8c38a4b0
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Mon Jan 22 16:36:43 2018 +0200

    libgnome-panel: add gp_add_text_color_class
    
    It will replace existing gp_applet_add_text_class() function.

 libgnome-panel/Makefile.am |    2 +
 libgnome-panel/gp-utils.c  |   49 ++++++++++++++++++++++++++++++++++++++++++++
 libgnome-panel/gp-utils.h  |   29 ++++++++++++++++++++++++++
 3 files changed, 80 insertions(+), 0 deletions(-)
---
diff --git a/libgnome-panel/Makefile.am b/libgnome-panel/Makefile.am
index 1ec1b00..efb1db3 100644
--- a/libgnome-panel/Makefile.am
+++ b/libgnome-panel/Makefile.am
@@ -17,6 +17,8 @@ libgnome_panel_la_SOURCES = \
        gp-module-private.h \
        gp-module.c \
        gp-module.h \
+       gp-utils.c \
+       gp-utils.h \
        $(BUILT_SOURCES) \
        $(NULL)
 
diff --git a/libgnome-panel/gp-utils.c b/libgnome-panel/gp-utils.c
new file mode 100644
index 0000000..c8dee20
--- /dev/null
+++ b/libgnome-panel/gp-utils.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2018 Alberts Muktupāvels
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+#include "gp-utils.h"
+
+/**
+ * gp_add_text_color_class:
+ * @widget: a #GtkWidget
+ *
+ * Use this function to add css class to widgets that are visible on
+ * panel and shows text. Typically this function should be used with
+ * #GtkLabel, #GtkMenuItem or #GtkButton as @widget.
+ */
+void
+gp_add_text_color_class (GtkWidget *widget)
+{
+  GtkStyleContext *context;
+
+  context = NULL;
+
+  if (GTK_IS_MENU_ITEM (widget) || GTK_IS_BUTTON (widget))
+    {
+      GtkWidget *child;
+
+      child = gtk_bin_get_child (GTK_BIN (widget));
+      if (GTK_IS_LABEL (child))
+        context = gtk_widget_get_style_context (child);
+    }
+
+  if (context == NULL)
+    context = gtk_widget_get_style_context (widget);
+
+  gtk_style_context_add_class (context, "gp-text-color");
+}
diff --git a/libgnome-panel/gp-utils.h b/libgnome-panel/gp-utils.h
new file mode 100644
index 0000000..324918f
--- /dev/null
+++ b/libgnome-panel/gp-utils.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2018 Alberts Muktupāvels
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#ifndef GP_UTILS_H
+#define GP_UTILS_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+void gp_add_text_color_class (GtkWidget *widget);
+
+G_END_DECLS
+
+#endif


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