[metacity] theme: move get_current and set_current to libmetacity



commit 725a5438e72c95ce9b784c8a60a3c1a6e7bb192a
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Thu Feb 4 00:24:08 2016 +0200

    theme: move get_current and set_current to libmetacity

 libmetacity/meta-theme.c |   63 ++++++++++++++++++++++++++++++++++++++++++++++
 libmetacity/meta-theme.h |    7 +++++
 po/POTFILES.in           |    1 +
 src/ui/theme.c           |   62 ---------------------------------------------
 src/ui/theme.h           |    6 ----
 5 files changed, 71 insertions(+), 68 deletions(-)
---
diff --git a/libmetacity/meta-theme.c b/libmetacity/meta-theme.c
index ef88cdc..66eb854 100644
--- a/libmetacity/meta-theme.c
+++ b/libmetacity/meta-theme.c
@@ -17,6 +17,7 @@
 
 #include "config.h"
 
+#include <glib/gi18n-lib.h>
 #include <string.h>
 
 #include "meta-enum-types.h"
@@ -595,3 +596,65 @@ meta_theme_draw_frame (MetaTheme              *theme,
                                                        mini_icon,
                                                        icon);
 }
+
+/**
+ * The current theme. (Themes are singleton.)
+ */
+static MetaTheme *meta_current_theme = NULL;
+
+MetaTheme*
+meta_theme_get_current (void)
+{
+  return meta_current_theme;
+}
+
+void
+meta_theme_set_current (const gchar                *name,
+                        gboolean                    force_reload,
+                        gboolean                    composited,
+                        const PangoFontDescription *titlebar_font)
+{
+  MetaTheme *new_theme;
+  GError *error;
+
+  g_debug ("Setting current theme to '%s'", name);
+
+  if (!force_reload && meta_current_theme)
+    {
+      gchar *theme_name;
+
+      theme_name = meta_theme_get_name (meta_current_theme);
+      if (g_strcmp0 (name, theme_name) == 0)
+        {
+          g_free (theme_name);
+          return;
+        }
+
+      g_free (theme_name);
+    }
+
+  if (name != NULL && strcmp (name, "") != 0)
+    new_theme = meta_theme_new (META_THEME_TYPE_METACITY);
+  else
+    new_theme = meta_theme_new (META_THEME_TYPE_GTK);
+
+  meta_theme_set_composited (new_theme, composited);
+  meta_theme_set_titlebar_font (new_theme, titlebar_font);
+
+  error = NULL;
+  if (!meta_theme_load (new_theme, name, &error))
+    {
+      g_warning (_("Failed to load theme '%s': %s"), name, error->message);
+      g_error_free (error);
+
+      g_object_unref (new_theme);
+    }
+  else
+    {
+      if (meta_current_theme)
+        g_object_unref (meta_current_theme);
+      meta_current_theme = new_theme;
+
+      g_debug ("New theme is '%s'", name);
+    }
+}
diff --git a/libmetacity/meta-theme.h b/libmetacity/meta-theme.h
index cab6655..1c95ab0 100644
--- a/libmetacity/meta-theme.h
+++ b/libmetacity/meta-theme.h
@@ -224,6 +224,13 @@ void                  meta_theme_draw_frame                (MetaTheme
                                                             GdkPixbuf                   *mini_icon,
                                                             GdkPixbuf                   *icon);
 
+MetaTheme            *meta_theme_get_current               (void);
+
+void                  meta_theme_set_current               (const gchar                 *name,
+                                                            gboolean                    force_reload,
+                                                            gboolean                    composited,
+                                                            const PangoFontDescription *titlebar_font);
+
 G_END_DECLS
 
 #endif
diff --git a/po/POTFILES.in b/po/POTFILES.in
index fe30edc..a3f87c6 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -6,6 +6,7 @@ libmetacity/meta-draw-spec.c
 libmetacity/meta-frame-layout.c
 libmetacity/meta-frame-style.c
 libmetacity/meta-gradient-spec.c
+libmetacity/meta-theme.c
 libmetacity/meta-theme-impl.c
 libmetacity/meta-theme-metacity.c
 src/50-metacity-navigation.xml.in
diff --git a/src/ui/theme.c b/src/ui/theme.c
index 918f8d4..f59a263 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -60,65 +60,3 @@
 #define __USE_XOPEN
 #include <stdarg.h>
 #include <math.h>
-
-/**
- * The current theme. (Themes are singleton.)
- */
-static MetaTheme *meta_current_theme = NULL;
-
-MetaTheme*
-meta_theme_get_current (void)
-{
-  return meta_current_theme;
-}
-
-void
-meta_theme_set_current (const gchar                *name,
-                        gboolean                    force_reload,
-                        gboolean                    composited,
-                        const PangoFontDescription *titlebar_font)
-{
-  MetaTheme *new_theme;
-  GError *error;
-
-  g_debug ("Setting current theme to '%s'", name);
-
-  if (!force_reload && meta_current_theme)
-    {
-      gchar *theme_name;
-
-      theme_name = meta_theme_get_name (meta_current_theme);
-      if (g_strcmp0 (name, theme_name) == 0)
-        {
-          g_free (theme_name);
-          return;
-        }
-
-      g_free (theme_name);
-    }
-
-  if (name != NULL && strcmp (name, "") != 0)
-    new_theme = meta_theme_new (META_THEME_TYPE_METACITY);
-  else
-    new_theme = meta_theme_new (META_THEME_TYPE_GTK);
-
-  meta_theme_set_composited (new_theme, composited);
-  meta_theme_set_titlebar_font (new_theme, titlebar_font);
-
-  error = NULL;
-  if (!meta_theme_load (new_theme, name, &error))
-    {
-      g_warning (_("Failed to load theme '%s': %s"), name, error->message);
-      g_error_free (error);
-
-      g_object_unref (new_theme);
-    }
-  else
-    {
-      if (meta_current_theme)
-        g_object_unref (meta_current_theme);
-      meta_current_theme = new_theme;
-
-      g_debug ("New theme is '%s'", name);
-    }
-}
diff --git a/src/ui/theme.h b/src/ui/theme.h
index e9ae007..97c97af 100644
--- a/src/ui/theme.h
+++ b/src/ui/theme.h
@@ -25,10 +25,4 @@
 #include <gtk/gtk.h>
 #include <libmetacity/meta-theme.h>
 
-MetaTheme* meta_theme_get_current (void);
-void       meta_theme_set_current (const char                 *name,
-                                   gboolean                    force_reload,
-                                   gboolean                    composited,
-                                   const PangoFontDescription *titlebar_font);
-
 #endif


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