filebrowser plugin: first connect to settings, then read them.

fixes the issue with GLib >= 2.43,
https://git.gnome.org/browse/glib/commit/?id=8ff5668a458344da22d30491e3ce726d861b3619

Closes https://github.com/mate-desktop/pluma/pull/109
This commit is contained in:
Monsta 2015-03-19 17:24:55 +03:00 committed by Stefano Karapetsas
parent dc5a473cbe
commit aac60a7008
1 changed files with 30 additions and 24 deletions

View File

@ -312,6 +312,18 @@ on_confirm_trash_changed (GSettings *settings,
data->confirm_trash = enable; data->confirm_trash = enable;
} }
static gboolean
have_click_policy (void)
{
GSettings *settings = g_settings_new (CAJA_SCHEMA);
gchar *pref = g_settings_get_string (settings, CAJA_CLICK_POLICY_KEY);
gboolean result = (pref != NULL);
g_free (pref);
g_object_unref (settings);
return result;
}
static void static void
install_caja_prefs (PlumaFileBrowserPluginData *data) install_caja_prefs (PlumaFileBrowserPluginData *data)
{ {
@ -320,41 +332,35 @@ install_caja_prefs (PlumaFileBrowserPluginData *data)
PlumaFileBrowserViewClickPolicy policy; PlumaFileBrowserViewClickPolicy policy;
PlumaFileBrowserView *view; PlumaFileBrowserView *view;
/* Get click_policy */ if (have_click_policy ()) {
pref = g_settings_get_string (data->caja_settings, CAJA_CLICK_POLICY_KEY);
policy = click_policy_from_string (pref);
view = pluma_file_browser_widget_get_browser_view (data->tree_widget);
pluma_file_browser_view_set_click_policy (view, policy);
if (pref) {
g_signal_connect (data->caja_settings, g_signal_connect (data->caja_settings,
"changed::" CAJA_CLICK_POLICY_KEY, "changed::" CAJA_CLICK_POLICY_KEY,
G_CALLBACK (on_click_policy_changed), G_CALLBACK (on_click_policy_changed),
data); data);
g_free (pref);
} }
/* Get enable_delete */
prefb = g_settings_get_boolean (data->caja_settings, CAJA_ENABLE_DELETE_KEY);
g_object_set (G_OBJECT (data->tree_widget), "enable-delete", prefb, NULL);
g_signal_connect (data->caja_settings, g_signal_connect (data->caja_settings,
"changed::" CAJA_ENABLE_DELETE_KEY, "changed::" CAJA_ENABLE_DELETE_KEY,
G_CALLBACK (on_enable_delete_changed), G_CALLBACK (on_enable_delete_changed),
data); data);
/* Get confirm_trash */
prefb = g_settings_get_boolean (data->caja_settings, CAJA_CONFIRM_TRASH_KEY);
data->confirm_trash = prefb;
g_signal_connect (data->caja_settings, g_signal_connect (data->caja_settings,
"changed::" CAJA_CONFIRM_TRASH_KEY, "changed::" CAJA_CONFIRM_TRASH_KEY,
G_CALLBACK (on_confirm_trash_changed), G_CALLBACK (on_confirm_trash_changed),
data); data);
pref = g_settings_get_string (data->caja_settings, CAJA_CLICK_POLICY_KEY);
policy = click_policy_from_string (pref);
g_free (pref);
view = pluma_file_browser_widget_get_browser_view (data->tree_widget);
pluma_file_browser_view_set_click_policy (view, policy);
prefb = g_settings_get_boolean (data->caja_settings, CAJA_ENABLE_DELETE_KEY);
g_object_set (G_OBJECT (data->tree_widget), "enable-delete", prefb, NULL);
prefb = g_settings_get_boolean (data->caja_settings, CAJA_CONFIRM_TRASH_KEY);
data->confirm_trash = prefb;
} }
static void static void