summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberts Muktupāvels <alberts.muktupavels@gmail.com>2017-04-28 13:47:28 +0300
committerAlberts Muktupāvels <alberts.muktupavels@gmail.com>2017-04-28 13:47:28 +0300
commit398219bd80bae76629f3bf2931ba367a0d9ecf7d (patch)
treebaa2672d784e824e004099b6692fe55ec32affe9
parentdeee5b17fc4e93025cd3412f1e3b4a71cb9e9ba6 (diff)
downloadlibwnck-398219bd80bae76629f3bf2931ba367a0d9ecf7d.tar.gz
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.
-rw-r--r--libwnck/Makefile.am1
-rw-r--r--libwnck/private.h2
-rw-r--r--libwnck/util.c57
-rw-r--r--libwnck/wnck.css3
-rw-r--r--libwnck/wnck.gresource.xml1
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>