Autogenerate settings flags and use them.

Now that gsettings allow to autogenate flags and provides methods
to use them. Let's not do the flags conversion and use them directly.
See that the settings compiler compiles the settings by alphabetic order
so we need to change the settings file in order to get the flags built
first.
parent 1103e435
......@@ -409,7 +409,7 @@ plugins/changecase/Makefile
plugins/checkupdate/org.gnome.gedit.checkupdate.gschema.xml.in
plugins/checkupdate/Makefile
plugins/docinfo/Makefile
plugins/filebrowser/org.gnome.gedit.file-browser.gschema.xml.in
plugins/filebrowser/org.gnome.gedit.plugins.filebrowser.gschema.xml.in
plugins/filebrowser/Makefile
plugins/modelines/Makefile
plugins/pythonconsole/Makefile
......
......@@ -65,9 +65,12 @@ gedit-file-browser-marshal.c: gedit-file-browser-marshal.list $(GLIB_GENMARSHAL)
plugin_DATA = $(plugin_in_files:.gedit-plugin.desktop.in=.gedit-plugin)
gsettings_SCHEMAS = org.gnome.gedit.file-browser.gschema.xml
gsettings_ENUM_NAMESPACE = org.gnome.gedit.plugins.filebrowser
gsettings_ENUM_FILES = $(NOINST_H_FILES)
gsettings_SCHEMAS = org.gnome.gedit.plugins.filebrowser.gschema.xml
@INTLTOOL_XML_NOMERGE_RULE@
@GSETTINGS_RULES@
EXTRA_DIST = \
......
......@@ -95,9 +95,6 @@ static void on_model_set_cb (GeditFileBrowserView *widget,
static void on_virtual_root_changed_cb (GeditFileBrowserStore *model,
GParamSpec *param,
GeditFileBrowserPlugin *plugin);
static void on_filter_mode_changed_cb (GeditFileBrowserStore *model,
GParamSpec *param,
GeditFileBrowserPlugin *plugin);
static void on_rename_cb (GeditFileBrowserStore *model,
GFile *oldfile,
GFile *newfile,
......@@ -265,44 +262,14 @@ static void
restore_filter (GeditFileBrowserPlugin *plugin)
{
GeditFileBrowserPluginPrivate *priv = plugin->priv;
gchar *filter_mode;
GeditFileBrowserStoreFilterMode mode;
gchar *pattern;
/* Get filter_mode */
filter_mode = g_settings_get_string (priv->settings,
FILEBROWSER_FILTER_MODE);
/* Filter mode */
mode = gedit_file_browser_store_filter_mode_get_default ();
if (filter_mode != NULL)
{
if (strcmp (filter_mode, "hidden") == 0)
mode = GEDIT_FILE_BROWSER_STORE_FILTER_MODE_HIDE_HIDDEN;
else if (strcmp (filter_mode, "binary") == 0)
mode = GEDIT_FILE_BROWSER_STORE_FILTER_MODE_HIDE_BINARY;
else if (strcmp (filter_mode, "hidden-and-binary") == 0 ||
strcmp (filter_mode, "binary-and-hidden") == 0)
mode = GEDIT_FILE_BROWSER_STORE_FILTER_MODE_HIDE_HIDDEN |
GEDIT_FILE_BROWSER_STORE_FILTER_MODE_HIDE_BINARY;
else if (strcmp (filter_mode, "none") == 0 ||
*filter_mode == '\0')
mode = GEDIT_FILE_BROWSER_STORE_FILTER_MODE_NONE;
}
/* Set the filter mode */
gedit_file_browser_store_set_filter_mode (
gedit_file_browser_widget_get_browser_store (priv->tree_widget),
mode);
pattern = g_settings_get_string (priv->settings,
FILEBROWSER_FILTER_PATTERN);
gedit_file_browser_widget_set_filter_pattern (priv->tree_widget,
pattern);
g_free (filter_mode);
g_free (pattern);
}
......@@ -705,6 +672,7 @@ gedit_file_browser_plugin_activate (GeditWindowActivatable *activatable,
add_popup_ui (window, plugin);
/* Restore filter options */
/* TODO: bind with gsettings? */
restore_filter (plugin);
/* Install nautilus preferences */
......@@ -717,16 +685,18 @@ gedit_file_browser_plugin_activate (GeditWindowActivatable *activatable,
plugin);
store = gedit_file_browser_widget_get_browser_store (priv->tree_widget);
g_settings_bind (plugin->priv->settings,
"filter-mode",
store,
"filter-mode",
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
g_signal_connect (store,
"notify::virtual-root",
G_CALLBACK (on_virtual_root_changed_cb),
plugin);
g_signal_connect (store,
"notify::filter-mode",
G_CALLBACK (on_filter_mode_changed_cb),
plugin);
g_signal_connect (store,
"rename",
G_CALLBACK (on_rename_cb),
......@@ -894,43 +864,6 @@ on_model_set_cb (GeditFileBrowserView *widget,
GEDIT_IS_FILE_BROWSER_STORE (model));
}
static void
on_filter_mode_changed_cb (GeditFileBrowserStore *model,
GParamSpec *param,
GeditFileBrowserPlugin *plugin)
{
GeditFileBrowserPluginPrivate *priv = plugin->priv;
GeditFileBrowserStoreFilterMode mode;
mode = gedit_file_browser_store_get_filter_mode (model);
if ((mode & GEDIT_FILE_BROWSER_STORE_FILTER_MODE_HIDE_HIDDEN) &&
(mode & GEDIT_FILE_BROWSER_STORE_FILTER_MODE_HIDE_BINARY))
{
g_settings_set_string (priv->settings,
FILEBROWSER_FILTER_MODE,
"hidden-and-binary");
}
else if (mode & GEDIT_FILE_BROWSER_STORE_FILTER_MODE_HIDE_HIDDEN)
{
g_settings_set_string (priv->settings,
FILEBROWSER_FILTER_MODE,
"hidden");
}
else if (mode & GEDIT_FILE_BROWSER_STORE_FILTER_MODE_HIDE_BINARY)
{
g_settings_set_string (priv->settings,
FILEBROWSER_FILTER_MODE,
"binary");
}
else
{
g_settings_set_string (priv->settings,
FILEBROWSER_FILTER_MODE,
"none");
}
}
static void
on_rename_cb (GeditFileBrowserStore *store,
GFile *oldfile,
......
......@@ -25,10 +25,10 @@
<_summary>Set Location to First Document</_summary>
<_description>If TRUE the file browser plugin will view the directory of the first opened document given that the file browser hasn't been used yet. (Thus this generally applies to opening a document from the command line or opening it with Nautilus, etc.)</_description>
</key>
<key name="filter-mode" type="s">
<default>'hidden-and-binary'</default>
<key name="filter-mode" flags="org.gnome.gedit.plugins.filebrowser.GeditFileBrowserStoreFilterMode">
<default>['hide-hidden', 'hide-binary']</default>
<_summary>File Browser Filter Mode</_summary>
<_description>This value determines what files get filtered from the file browser. Valid values are: none (filter nothing), hidden (filter hidden files), binary (filter binary files) and hidden_and_binary (filter both hidden and binary files).</_description>
<_description>This value determines what files get filtered from the file browser. Valid values are: none (filter nothing), hide-hidden (filter hidden files) and hide-binary (filter binary files).</_description>
</key>
<key name="filter-pattern" type="s">
<default>''</default>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment