[libwnck/wip/warnings3: 2/12] util: avoid deprecated gtk_widget_override_font
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libwnck/wip/warnings3: 2/12] util: avoid deprecated gtk_widget_override_font
- Date: Fri, 5 May 2017 09:46:54 +0000 (UTC)
commit 9498e7afbd40548dc03dd47d74c610d5f4608746
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Fri Apr 28 13:47:28 2017 +0300
util: avoid deprecated gtk_widget_override_font
This introduces new css class - wnck-needs-attention that theme
authors can use to style label for windows that needs attention.
By default label will be made bold.
libwnck/Makefile.am | 1 +
libwnck/private.h | 2 +
libwnck/util.c | 57 +++++++++++++++++++++++--------------------
libwnck/wnck.css | 3 ++
libwnck/wnck.gresource.xml | 1 +
5 files changed, 37 insertions(+), 27 deletions(-)
---
diff --git a/libwnck/Makefile.am b/libwnck/Makefile.am
index d293092..5c025cc 100644
--- a/libwnck/Makefile.am
+++ b/libwnck/Makefile.am
@@ -166,6 +166,7 @@ CLEANFILES = \
EXTRA_DIST = \
default_icon.png \
+ wnck.css \
wnck.gresource.xml \
version.h.in \
$(NULL)
diff --git a/libwnck/private.h b/libwnck/private.h
index 3398d38..1122f34 100644
--- a/libwnck/private.h
+++ b/libwnck/private.h
@@ -147,6 +147,8 @@ void _make_gtk_label_normal (GtkLabel *label);
void _wnck_selector_set_window_icon (GtkWidget *image,
WnckWindow *window);
+void _wnck_ensure_fallback_style (void);
+
G_END_DECLS
#endif /* WNCK_PRIVATE_H */
diff --git a/libwnck/util.c b/libwnck/util.c
index e10086e..c19a85a 100644
--- a/libwnck/util.c
+++ b/libwnck/util.c
@@ -740,41 +740,21 @@ _wnck_get_default_mini_icon_size (void)
void
_make_gtk_label_bold (GtkLabel *label)
{
- PangoFontDescription *font_desc;
+ GtkStyleContext *context;
- font_desc = pango_font_description_new ();
+ _wnck_ensure_fallback_style ();
- pango_font_description_set_weight (font_desc,
- PANGO_WEIGHT_BOLD);
-
- /* This will only affect the weight of the font, the rest is
- * from the current state of the widget, which comes from the
- * theme or user prefs, since the font desc only has the
- * weight flag turned on.
- */
- gtk_widget_override_font (GTK_WIDGET (label), font_desc);
-
- pango_font_description_free (font_desc);
+ context = gtk_widget_get_style_context (GTK_WIDGET (label));
+ gtk_style_context_add_class (context, "wnck-needs-attention");
}
void
_make_gtk_label_normal (GtkLabel *label)
{
- PangoFontDescription *font_desc;
-
- font_desc = pango_font_description_new ();
-
- pango_font_description_set_weight (font_desc,
- PANGO_WEIGHT_NORMAL);
+ GtkStyleContext *context;
- /* This will only affect the weight of the font, the rest is
- * from the current state of the widget, which comes from the
- * theme or user prefs, since the font desc only has the
- * weight flag turned on.
- */
- gtk_widget_override_font (GTK_WIDGET (label), font_desc);
-
- pango_font_description_free (font_desc);
+ context = gtk_widget_get_style_context (GTK_WIDGET (label));
+ gtk_style_context_remove_class (context, "wnck-needs-attention");
}
#ifdef HAVE_STARTUP_NOTIFICATION
@@ -867,3 +847,26 @@ wnck_shutdown (void)
wnck_pid_read_resource_usage_destroy_hash_table (NULL);
#endif
}
+
+void
+_wnck_ensure_fallback_style (void)
+{
+ static gboolean css_loaded = FALSE;
+ GtkCssProvider *provider;
+ guint priority;
+
+ if (css_loaded)
+ return;
+
+ provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_resource (provider, "/org/gnome/libwnck/wnck.css");
+
+ priority = GTK_STYLE_PROVIDER_PRIORITY_FALLBACK;
+ gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
+ GTK_STYLE_PROVIDER (provider),
+ priority);
+
+ g_object_unref (provider);
+
+ css_loaded = TRUE;
+}
diff --git a/libwnck/wnck.css b/libwnck/wnck.css
new file mode 100644
index 0000000..9e658b1
--- /dev/null
+++ b/libwnck/wnck.css
@@ -0,0 +1,3 @@
+.wnck-needs-attention {
+ font-weight: bold;
+}
diff --git a/libwnck/wnck.gresource.xml b/libwnck/wnck.gresource.xml
index a1eb536..2dd9737 100644
--- a/libwnck/wnck.gresource.xml
+++ b/libwnck/wnck.gresource.xml
@@ -2,5 +2,6 @@
<gresources>
<gresource prefix="/org/gnome/libwnck">
<file>default_icon.png</file>
+ <file>wnck.css</file>
</gresource>
</gresources>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]