[metacity/wip/gtk-theme: 49/51] prefs: add use-metacity-theme preference
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity/wip/gtk-theme: 49/51] prefs: add use-metacity-theme preference
- Date: Thu, 1 Jan 2015 20:43:22 +0000 (UTC)
commit 144d0d843982ef68b85ee4f70d37200e208341c5
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Thu Jan 1 22:11:06 2015 +0200
prefs: add use-metacity-theme preference
Add preference to allow switch between metacity and GTK+ themes.
By default metacity will use GTK+ theme.
src/core/main.c | 1 +
src/core/prefs.c | 19 +++++++++++++++++++
src/include/prefs.h | 5 ++++-
src/org.gnome.metacity.gschema.xml.in | 10 +++++++++-
src/ui/frames.c | 4 ++--
src/ui/theme.c | 22 +++++++++++-----------
src/ui/ui.c | 2 +-
7 files changed, 47 insertions(+), 16 deletions(-)
---
diff --git a/src/core/main.c b/src/core/main.c
index 6758ae7..866ccda 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -649,6 +649,7 @@ prefs_changed_callback (MetaPreference pref,
switch (pref)
{
case META_PREF_THEME:
+ case META_PREF_USE_METACITY_THEME:
meta_ui_set_current_theme (meta_prefs_get_theme (), FALSE);
meta_display_retheme_all ();
break;
diff --git a/src/core/prefs.c b/src/core/prefs.c
index 133f424..f7b4fb3 100644
--- a/src/core/prefs.c
+++ b/src/core/prefs.c
@@ -97,6 +97,8 @@ static MetaButtonLayout button_layout;
static MetaPlacementMode placement_mode = META_PLACEMENT_MODE_SMART;
+static gboolean use_metacity_theme = FALSE;
+
/* NULL-terminated array */
static char **workspace_names = NULL;
@@ -363,6 +365,14 @@ static MetaBoolPreference preferences_bool[] =
&edge_tiling,
FALSE,
},
+ {
+ { "use-metacity-theme",
+ SCHEMA_METACITY,
+ META_PREF_USE_METACITY_THEME,
+ },
+ &use_metacity_theme,
+ FALSE,
+ },
{ { NULL, 0, 0 }, NULL, FALSE },
};
@@ -1442,6 +1452,9 @@ meta_preference_to_string (MetaPreference pref)
case META_PREF_PLACEMENT_MODE:
return "PLACEMENT_MODE";
+
+ case META_PREF_USE_METACITY_THEME:
+ return "USE_METACITY_THEME";
}
return "(unknown)";
@@ -1864,6 +1877,12 @@ meta_prefs_get_placement_mode (void)
return placement_mode;
}
+gboolean
+meta_prefs_get_use_metacity_theme (void)
+{
+ return use_metacity_theme;
+}
+
void
meta_prefs_set_compositing_manager (gboolean whether)
{
diff --git a/src/include/prefs.h b/src/include/prefs.h
index 621ad5b..25e97e5 100644
--- a/src/include/prefs.h
+++ b/src/include/prefs.h
@@ -61,7 +61,8 @@ typedef enum
META_PREF_RESIZE_WITH_RIGHT_BUTTON,
META_PREF_EDGE_TILING,
META_PREF_FORCE_FULLSCREEN,
- META_PREF_PLACEMENT_MODE
+ META_PREF_PLACEMENT_MODE,
+ META_PREF_USE_METACITY_THEME,
} MetaPreference;
typedef enum
@@ -130,6 +131,8 @@ gboolean meta_prefs_get_force_fullscreen (void);
MetaPlacementMode meta_prefs_get_placement_mode (void);
+gboolean meta_prefs_get_use_metacity_theme (void);
+
/**
* Sets whether the compositor is turned on.
*
diff --git a/src/org.gnome.metacity.gschema.xml.in b/src/org.gnome.metacity.gschema.xml.in
index 6b4eb0d..4102740 100644
--- a/src/org.gnome.metacity.gschema.xml.in
+++ b/src/org.gnome.metacity.gschema.xml.in
@@ -53,7 +53,15 @@
workspaces, or "random" to place new windows at random locations within
their workspaces.
</_description>
- </key>
+ </key>
+ <key name="use-metacity-theme" type="b">
+ <default>false</default>
+ <_summary>Use Metacity theme</_summary>
+ <_description>
+ Metacity is following mutter and now use GTK+ theme. If enabled, metacity
+ will load old themes.
+ </_description>
+ </key>
</schema>
</schemalist>
diff --git a/src/ui/frames.c b/src/ui/frames.c
index 9aaf78b..22d7706 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -480,7 +480,7 @@ meta_frames_style_updated (GtkWidget *widget)
g_hash_table_foreach (frames->frames,
reattach_style_func, frames);
- if (g_getenv ("USE_METACITY_THEME") != NULL)
+ if (meta_prefs_get_use_metacity_theme ())
{
/* not needed for metacity theme */
}
@@ -540,7 +540,7 @@ meta_frames_ensure_layout (MetaFrames *frames,
pango_layout_set_auto_dir (frame->text_layout, FALSE);
pango_layout_set_single_paragraph_mode (frame->text_layout, TRUE);
- if (g_getenv ("USE_METACITY_THEME") != NULL)
+ if (meta_prefs_get_use_metacity_theme ())
{
double scale;
diff --git a/src/ui/theme.c b/src/ui/theme.c
index 11f9a47..fcf094c 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -662,7 +662,7 @@ meta_frame_layout_sync_with_style (MetaFrameLayout *layout,
int border_radius, max_radius;
/* We don't want GTK+ info for metacity theme */
- if (g_getenv ("USE_METACITY_THEME") != NULL)
+ if (meta_prefs_get_use_metacity_theme ())
return;
meta_style_info_set_flags (style_info, flags);
@@ -890,7 +890,7 @@ meta_frame_layout_calc_geometry (MetaFrameLayout *layout,
space_used_by_buttons += button_width * n_left;
space_used_by_buttons += (button_width * 0.75) * n_left_spacers;
- if (g_getenv ("USE_METACITY_THEME") != NULL)
+ if (meta_prefs_get_use_metacity_theme ())
{
space_used_by_buttons += layout->button_border.left * n_left;
space_used_by_buttons += layout->button_border.right * n_left;
@@ -900,7 +900,7 @@ meta_frame_layout_calc_geometry (MetaFrameLayout *layout,
space_used_by_buttons += button_width * n_right;
space_used_by_buttons += (button_width * 0.75) * n_right_spacers;
- if (g_getenv ("USE_METACITY_THEME") != NULL)
+ if (meta_prefs_get_use_metacity_theme ())
{
space_used_by_buttons += layout->button_border.left * n_right;
space_used_by_buttons += layout->button_border.right * n_right;
@@ -1003,7 +1003,7 @@ meta_frame_layout_calc_geometry (MetaFrameLayout *layout,
break;
rect = right_func_rects[i];
- if (g_getenv ("USE_METACITY_THEME") != NULL)
+ if (meta_prefs_get_use_metacity_theme ())
rect->visible.x = x - layout->button_border.right - button_width;
else
rect->visible.x = x - button_width;
@@ -1025,7 +1025,7 @@ meta_frame_layout_calc_geometry (MetaFrameLayout *layout,
if (i == n_right - 1)
{
- if (g_getenv ("USE_METACITY_THEME") != NULL)
+ if (meta_prefs_get_use_metacity_theme ())
rect->clickable.width += layout->right_titlebar_edge + layout->right_width +
layout->button_border.right;
else
rect->clickable.width += layout->right_titlebar_edge + layout->right_width;
@@ -1037,7 +1037,7 @@ meta_frame_layout_calc_geometry (MetaFrameLayout *layout,
*(right_bg_rects[i]) = rect->visible;
- if (g_getenv ("USE_METACITY_THEME") != NULL)
+ if (meta_prefs_get_use_metacity_theme ())
x = rect->visible.x - layout->button_border.left;
else
{
@@ -1063,7 +1063,7 @@ meta_frame_layout_calc_geometry (MetaFrameLayout *layout,
rect = left_func_rects[i];
- if (g_getenv ("USE_METACITY_THEME") != NULL)
+ if (meta_prefs_get_use_metacity_theme ())
rect->visible.x = x + layout->button_border.left;
else
rect->visible.x = x;
@@ -1081,7 +1081,7 @@ meta_frame_layout_calc_geometry (MetaFrameLayout *layout,
else
g_memmove (&(rect->clickable), &(rect->visible), sizeof(rect->clickable));
- if (g_getenv ("USE_METACITY_THEME") != NULL)
+ if (meta_prefs_get_use_metacity_theme ())
x = rect->visible.x + rect->visible.width + layout->button_border.right;
else
{
@@ -5368,7 +5368,7 @@ theme_set_current_metacity (const gchar *name,
if (!force_reload &&
meta_current_theme &&
- strcmp (name, meta_current_theme->name) == 0)
+ g_strcmp0 (name, meta_current_theme->name) == 0)
return;
err = NULL;
@@ -5470,7 +5470,7 @@ void
meta_theme_set_current (const char *name,
gboolean force_reload)
{
- if (g_getenv ("USE_METACITY_THEME") != NULL)
+ if (meta_prefs_get_use_metacity_theme ())
{
theme_set_current_metacity (name, force_reload);
}
@@ -6060,7 +6060,7 @@ meta_theme_draw_frame (MetaTheme *theme,
&fgeom,
theme);
- if (g_getenv ("USE_METACITY_THEME") != NULL)
+ if (meta_prefs_get_use_metacity_theme ())
{
meta_frame_style_draw_with_style (style,
style_info,
diff --git a/src/ui/ui.c b/src/ui/ui.c
index 2cc78ec..f5fbddd 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -691,7 +691,7 @@ meta_ui_theme_get_frame_borders (MetaUI *ui,
if (!font_desc)
{
- if (g_getenv ("USE_METACITY_THEME") != NULL)
+ if (meta_prefs_get_use_metacity_theme ())
{
GtkStyleContext *style = NULL;
GtkWidgetPath *widget_path;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]