[empathy] Add empathy.css and helper code to use it



commit d62ff957e10bdfb92b99608310ae9b96676ea4fa
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Thu May 24 11:47:02 2012 +0200

    Add empathy.css and helper code to use it
    
    https://bugzilla.gnome.org/show_bug.cgi?id=669473

 data/Makefile.am                  |    5 +++++
 libempathy-gtk/empathy-ui-utils.c |   33 +++++++++++++++++++++++++++++++++
 libempathy-gtk/empathy-ui-utils.h |    2 ++
 3 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index ffef27b..8a61b5e 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -56,6 +56,11 @@ html_DATA = \
 	empathy-log-window.html \
 	$(NULL)
 
+cssdir = $(datadir)/empathy
+css_DATA = \
+	empathy.css \
+	$(NULL)
+
 EXTRA_DIST = 				\
 	$(convert_DATA)			\
 	$(desktop_in_files)		\
diff --git a/data/empathy.css b/data/empathy.css
new file mode 100644
index 0000000..e69de29
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c
index 23cff24..507f923 100644
--- a/libempathy-gtk/empathy-ui-utils.c
+++ b/libempathy-gtk/empathy-ui-utils.c
@@ -2307,3 +2307,36 @@ empathy_move_to_window_desktop (GtkWindow *window,
 out:
   gtk_window_present_with_time (window, timestamp);
 }
+
+void
+empathy_set_css_provider (GtkWidget *widget)
+{
+  GtkCssProvider *provider;
+  gchar *filename;
+  GError *error = NULL;
+  GdkScreen *screen;
+
+  filename = empathy_file_lookup ("empathy.css", "data");
+
+  provider = gtk_css_provider_new ();
+
+  if (!gtk_css_provider_load_from_path (provider, filename, &error))
+    {
+      g_warning ("Failed to load css file '%s': %s", filename, error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  if (widget != NULL)
+    screen = gtk_widget_get_screen (widget);
+  else
+    screen = gdk_screen_get_default ();
+
+  gtk_style_context_add_provider_for_screen (screen,
+      GTK_STYLE_PROVIDER (provider),
+      GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+
+out:
+  g_free (filename);
+  g_object_unref (provider);
+}
diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h
index 2ffbf2c..093890e 100644
--- a/libempathy-gtk/empathy-ui-utils.h
+++ b/libempathy-gtk/empathy-ui-utils.h
@@ -161,6 +161,8 @@ void empathy_launch_program (const gchar *dir,
     const gchar *name,
     const gchar *args);
 
+void empathy_set_css_provider (GtkWidget *widget);
+
 G_END_DECLS
 
 #endif /*  __EMPATHY_UI_UTILS_H__ */



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