prefs: Add dynamic-workspaces setting

We currently sync the number of workspaces with the corresponding
preference. This is not really useful with GNOME Shell's dynamic
handling of workspaces, not least as the setting is effectively
ignored. Worse, it will trigger writes to dconf on login, slowing
down startup, so add a setting to indicate that workspaces are managed
dynamically and really ignore the num-workspaces setting when set.

https://bugzilla.gnome.org/show_bug.cgi?id=671568
This commit is contained in:
Florian Müllner 2012-03-08 01:29:58 +01:00
parent 584cd3e684
commit 607dbf0f43
4 changed files with 35 additions and 3 deletions

View File

@ -82,6 +82,7 @@ static int num_workspaces = 4;
static GDesktopTitlebarAction action_double_click_titlebar = G_DESKTOP_TITLEBAR_ACTION_TOGGLE_MAXIMIZE;
static GDesktopTitlebarAction action_middle_click_titlebar = G_DESKTOP_TITLEBAR_ACTION_LOWER;
static GDesktopTitlebarAction action_right_click_titlebar = G_DESKTOP_TITLEBAR_ACTION_MENU;
static gboolean dynamic_workspaces = FALSE;
static gboolean application_based = FALSE;
static gboolean disable_workarounds = FALSE;
static gboolean auto_raise = FALSE;
@ -280,6 +281,13 @@ static MetaBoolPreference preferences_bool[] =
},
&use_system_font,
},
{
{ "dynamic-workspaces",
SCHEMA_MUTTER,
META_PREF_DYNAMIC_WORKSPACES,
},
&dynamic_workspaces,
},
{
{ "application-based",
SCHEMA_GENERAL,
@ -1498,6 +1506,12 @@ meta_prefs_get_num_workspaces (void)
return num_workspaces;
}
gboolean
meta_prefs_get_dynamic_workspaces (void)
{
return dynamic_workspaces;
}
gboolean
meta_prefs_get_application_based (void)
{

View File

@ -1173,7 +1173,9 @@ prefs_changed_callback (MetaPreference pref,
{
MetaScreen *screen = data;
if (pref == META_PREF_NUM_WORKSPACES)
if ((pref == META_PREF_NUM_WORKSPACES ||
pref == META_PREF_DYNAMIC_WORKSPACES) &&
!meta_prefs_get_dynamic_workspaces ())
{
/* GSettings doesn't provide timestamps, but luckily update_num_workspaces
* often doesn't need it...
@ -1483,7 +1485,9 @@ meta_screen_remove_workspace (MetaScreen *screen, MetaWorkspace *workspace,
new_num = g_list_length (screen->workspaces);
set_number_of_spaces_hint (screen, new_num);
meta_prefs_set_num_workspaces (new_num);
if (!meta_prefs_get_dynamic_workspaces ())
meta_prefs_set_num_workspaces (new_num);
/* If deleting a workspace before the current workspace, the active
* workspace index changes, so we need to update that hint */
@ -1538,7 +1542,9 @@ meta_screen_append_new_workspace (MetaScreen *screen, gboolean activate,
new_num = g_list_length (screen->workspaces);
set_number_of_spaces_hint (screen, new_num);
meta_prefs_set_num_workspaces (new_num);
if (!meta_prefs_get_dynamic_workspaces ())
meta_prefs_set_num_workspaces (new_num);
meta_screen_queue_workarea_recalc (screen);

View File

@ -47,6 +47,7 @@ typedef enum
META_PREF_THEME,
META_PREF_TITLEBAR_FONT,
META_PREF_NUM_WORKSPACES,
META_PREF_DYNAMIC_WORKSPACES,
META_PREF_APPLICATION_BASED,
META_PREF_KEYBINDINGS,
META_PREF_DISABLE_WORKAROUNDS,
@ -94,6 +95,7 @@ const char* meta_prefs_get_theme (void);
/* returns NULL if GTK default should be used */
const PangoFontDescription* meta_prefs_get_titlebar_font (void);
int meta_prefs_get_num_workspaces (void);
gboolean meta_prefs_get_dynamic_workspaces (void);
gboolean meta_prefs_get_application_based (void);
gboolean meta_prefs_get_disable_workarounds (void);
gboolean meta_prefs_get_auto_raise (void);

View File

@ -45,6 +45,16 @@
</_description>
</key>
<key name="dynamic-workspaces" type="b">
<default>false</default>
<_summary>Workspaces are managed dynamically</_summary>
<_description>
Determines whether workspaces are managed dynamically or
whether there's a static number of workspaces (determined
by the num-workspaces key in org.gnome.desktop.wm.preferences).
</_description>
</key>
<key name="workspaces-only-on-primary" type="b">
<default>false</default>
<_summary>Workspaces only on primary</_summary>