[metacity] libmetacity: add MetaThemeImpl, MetaThemeGtk and MetaThemeMetacity
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] libmetacity: add MetaThemeImpl, MetaThemeGtk and MetaThemeMetacity
- Date: Thu, 28 Jan 2016 16:10:07 +0000 (UTC)
commit 6ebd4348c0ec6413fe8d566af1f2e251d41f5f51
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Thu Jan 28 12:13:36 2016 +0200
libmetacity: add MetaThemeImpl, MetaThemeGtk and MetaThemeMetacity
libmetacity/Makefile.am | 6 ++++++
libmetacity/meta-theme-gtk.c | 37 +++++++++++++++++++++++++++++++++++++
libmetacity/meta-theme-gtk.h | 31 +++++++++++++++++++++++++++++++
libmetacity/meta-theme-impl.c | 32 ++++++++++++++++++++++++++++++++
libmetacity/meta-theme-impl.h | 36 ++++++++++++++++++++++++++++++++++++
libmetacity/meta-theme-metacity.c | 37 +++++++++++++++++++++++++++++++++++++
libmetacity/meta-theme-metacity.h | 31 +++++++++++++++++++++++++++++++
libmetacity/meta-theme.h | 13 +++++++++++++
src/ui/theme-parser.c | 2 +-
src/ui/theme-private.h | 3 +++
src/ui/theme.c | 16 +++++++++++++---
src/ui/theme.h | 2 +-
12 files changed, 241 insertions(+), 5 deletions(-)
---
diff --git a/libmetacity/Makefile.am b/libmetacity/Makefile.am
index bc2fc5c..e852d0e 100644
--- a/libmetacity/Makefile.am
+++ b/libmetacity/Makefile.am
@@ -17,6 +17,12 @@ libmetacity_la_SOURCES = \
meta-hsla-private.h \
meta-theme.c \
meta-theme.h \
+ meta-theme-gtk.c \
+ meta-theme-gtk.h \
+ meta-theme-impl.c \
+ meta-theme-impl.h \
+ meta-theme-metacity.c \
+ meta-theme-metacity.h \
$(NULL)
libmetacity_la_CPPFLAGS = \
diff --git a/libmetacity/meta-theme-gtk.c b/libmetacity/meta-theme-gtk.c
new file mode 100644
index 0000000..4bde7b6
--- /dev/null
+++ b/libmetacity/meta-theme-gtk.c
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2016 Alberts Muktupāvels
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "meta-theme-gtk.h"
+
+struct _MetaThemeGtk
+{
+ MetaThemeImpl parent;
+};
+
+G_DEFINE_TYPE (MetaThemeGtk, meta_theme_gtk, META_TYPE_THEME_IMPL)
+
+static void
+meta_theme_gtk_class_init (MetaThemeGtkClass *gtk_class)
+{
+}
+
+static void
+meta_theme_gtk_init (MetaThemeGtk *gtk)
+{
+}
diff --git a/libmetacity/meta-theme-gtk.h b/libmetacity/meta-theme-gtk.h
new file mode 100644
index 0000000..11e5bfe
--- /dev/null
+++ b/libmetacity/meta-theme-gtk.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2016 Alberts Muktupāvels
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef META_THEME_GTK_H
+#define META_THEME_GTK_H
+
+#include "meta-theme-impl.h"
+
+G_BEGIN_DECLS
+
+#define META_TYPE_THEME_GTK meta_theme_gtk_get_type ()
+G_DECLARE_FINAL_TYPE (MetaThemeGtk, meta_theme_gtk,
+ META, THEME_GTK, MetaThemeImpl)
+
+G_END_DECLS
+
+#endif
diff --git a/libmetacity/meta-theme-impl.c b/libmetacity/meta-theme-impl.c
new file mode 100644
index 0000000..67de193
--- /dev/null
+++ b/libmetacity/meta-theme-impl.c
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2016 Alberts Muktupāvels
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "meta-theme-impl.h"
+
+G_DEFINE_TYPE (MetaThemeImpl, meta_theme_impl, G_TYPE_OBJECT)
+
+static void
+meta_theme_impl_class_init (MetaThemeImplClass *impl_class)
+{
+}
+
+static void
+meta_theme_impl_init (MetaThemeImpl *impl)
+{
+}
diff --git a/libmetacity/meta-theme-impl.h b/libmetacity/meta-theme-impl.h
new file mode 100644
index 0000000..6268df2
--- /dev/null
+++ b/libmetacity/meta-theme-impl.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2016 Alberts Muktupāvels
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef META_THEME_IMPL_H
+#define META_THEME_IMPL_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define META_TYPE_THEME_IMPL meta_theme_impl_get_type ()
+G_DECLARE_DERIVABLE_TYPE (MetaThemeImpl, meta_theme_impl,
+ META, THEME_IMPL, GObject)
+
+struct _MetaThemeImplClass
+{
+ GObjectClass parent_class;
+};
+
+G_END_DECLS
+
+#endif
diff --git a/libmetacity/meta-theme-metacity.c b/libmetacity/meta-theme-metacity.c
new file mode 100644
index 0000000..baad9c2
--- /dev/null
+++ b/libmetacity/meta-theme-metacity.c
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2016 Alberts Muktupāvels
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "meta-theme-metacity.h"
+
+struct _MetaThemeMetacity
+{
+ MetaThemeImpl parent;
+};
+
+G_DEFINE_TYPE (MetaThemeMetacity, meta_theme_metacity, META_TYPE_THEME_IMPL)
+
+static void
+meta_theme_metacity_class_init (MetaThemeMetacityClass *metacity_class)
+{
+}
+
+static void
+meta_theme_metacity_init (MetaThemeMetacity *metacity)
+{
+}
diff --git a/libmetacity/meta-theme-metacity.h b/libmetacity/meta-theme-metacity.h
new file mode 100644
index 0000000..d1f057d
--- /dev/null
+++ b/libmetacity/meta-theme-metacity.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2016 Alberts Muktupāvels
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef META_THEME_METACITY_H
+#define META_THEME_METACITY_H
+
+#include "meta-theme-impl.h"
+
+G_BEGIN_DECLS
+
+#define META_TYPE_THEME_METACITY meta_theme_metacity_get_type ()
+G_DECLARE_FINAL_TYPE (MetaThemeMetacity, meta_theme_metacity,
+ META, THEME_METACITY, MetaThemeImpl)
+
+G_END_DECLS
+
+#endif
diff --git a/libmetacity/meta-theme.h b/libmetacity/meta-theme.h
index 303fe2a..d6977c2 100644
--- a/libmetacity/meta-theme.h
+++ b/libmetacity/meta-theme.h
@@ -55,6 +55,19 @@ typedef enum
META_THEME_ERROR_FAILED
} MetaThemeError;
+/**
+ * MetaThemeType:
+ * @META_THEME_TYPE_GTK:
+ * @META_THEME_TYPE_METACITY:
+ *
+ * Theme types.
+ */
+typedef enum
+{
+ META_THEME_TYPE_GTK,
+ META_THEME_TYPE_METACITY,
+} MetaThemeType;
+
GQuark meta_theme_error_quark (void);
G_END_DECLS
diff --git a/src/ui/theme-parser.c b/src/ui/theme-parser.c
index 7b9e290..e51d874 100644
--- a/src/ui/theme-parser.c
+++ b/src/ui/theme-parser.c
@@ -3546,7 +3546,7 @@ start_element_handler (GMarkupParseContext *context,
case STATE_START:
if (strcmp (element_name, "metacity_theme") == 0)
{
- info->theme = meta_theme_new ();
+ info->theme = meta_theme_new (META_THEME_TYPE_METACITY);
info->theme->name = g_strdup (info->theme_name);
info->theme->filename = g_strdup (info->theme_file);
info->theme->dirname = g_strdup (info->theme_dir);
diff --git a/src/ui/theme-private.h b/src/ui/theme-private.h
index 1586655..d472d6b 100644
--- a/src/ui/theme-private.h
+++ b/src/ui/theme-private.h
@@ -20,6 +20,7 @@
#include <libmetacity/meta-color-spec.h>
#include <libmetacity/meta-gradient-spec.h>
+#include <libmetacity/meta-theme-impl.h>
#include "boxes.h"
#include "theme.h"
@@ -663,6 +664,8 @@ struct _MetaTheme
GHashTable *style_sets_by_name;
MetaFrameStyleSet *style_sets_by_type[META_FRAME_TYPE_LAST];
+
+ MetaThemeImpl *impl;
};
MetaFrameLayout *meta_frame_layout_new (void);
diff --git a/src/ui/theme.c b/src/ui/theme.c
index 2cdd3c2..2e89152 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -55,6 +55,8 @@
#include "util.h"
#include <gtk/gtk.h>
#include <libmetacity/meta-color.h>
+#include <libmetacity/meta-theme-gtk.h>
+#include <libmetacity/meta-theme-metacity.h>
#include <string.h>
#include <stdlib.h>
#define __USE_XOPEN
@@ -4823,7 +4825,7 @@ theme_set_current_gtk (const gchar *name,
if (force_reload && meta_current_theme)
meta_theme_free (meta_current_theme);
- meta_current_theme = meta_theme_new ();
+ meta_current_theme = meta_theme_new (META_THEME_TYPE_GTK);
meta_current_theme->is_gtk_theme = TRUE;
meta_current_theme->composited = composited;
@@ -4909,7 +4911,7 @@ meta_theme_set_current (const gchar *name,
}
MetaTheme*
-meta_theme_new (void)
+meta_theme_new (MetaThemeType type)
{
MetaTheme *theme;
@@ -4948,10 +4950,16 @@ meta_theme_new (void)
g_free,
(GDestroyNotify) meta_frame_style_set_unref);
+ if (type == META_THEME_TYPE_GTK)
+ theme->impl = g_object_new (META_TYPE_THEME_GTK, NULL);
+ else if (type == META_THEME_TYPE_METACITY)
+ theme->impl = g_object_new (META_TYPE_THEME_METACITY, NULL);
+ else
+ g_assert_not_reached ();
+
return theme;
}
-
void
meta_theme_free (MetaTheme *theme)
{
@@ -4988,6 +4996,8 @@ meta_theme_free (MetaTheme *theme)
if (theme->style_sets_by_type[i])
meta_frame_style_set_unref (theme->style_sets_by_type[i]);
+ g_clear_object (&theme->impl);
+
DEBUG_FILL_STRUCT (theme);
g_free (theme);
}
diff --git a/src/ui/theme.h b/src/ui/theme.h
index e985538..581a304 100644
--- a/src/ui/theme.h
+++ b/src/ui/theme.h
@@ -164,7 +164,7 @@ void meta_theme_set_current (const char *name,
gboolean composited,
const PangoFontDescription *titlebar_font);
-MetaTheme* meta_theme_new (void);
+MetaTheme* meta_theme_new (MetaThemeType type);
void meta_theme_free (MetaTheme *theme);
MetaTheme* meta_theme_load (const char *theme_name,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]