diff options
-rw-r--r-- | libcaja-private/caja-global-preferences.c | 29 | ||||
-rw-r--r-- | libcaja-private/caja-global-preferences.h | 2 | ||||
-rw-r--r-- | libcaja-private/caja-mime-actions.c | 8 | ||||
-rw-r--r-- | src/caja-file-management-properties.c | 85 |
4 files changed, 86 insertions, 38 deletions
diff --git a/libcaja-private/caja-global-preferences.c b/libcaja-private/caja-global-preferences.c index 98b96e46..00c1e743 100644 --- a/libcaja-private/caja-global-preferences.c +++ b/libcaja-private/caja-global-preferences.c @@ -118,25 +118,6 @@ static EelEnumerationEntry click_policy_enum_entries[] = } }; -static EelEnumerationEntry executable_text_activation_enum_entries[] = -{ - { - "launch", - N_("E_xecute files when they are clicked"), - CAJA_EXECUTABLE_TEXT_LAUNCH - }, - { - "display", - N_("Display _files when they are clicked"), - CAJA_EXECUTABLE_TEXT_DISPLAY - }, - { - "ask", - N_("_Ask each time"), - CAJA_EXECUTABLE_TEXT_ASK - } -}; - static EelEnumerationEntry search_bar_type_enum_entries[] = { { @@ -280,13 +261,6 @@ static const PreferenceDefault preference_defaults[] = "click_policy" }, { - CAJA_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION, - PREFERENCE_STRING, - "ask", - NULL, NULL, - "executable_text_activation" - }, - { CAJA_PREFERENCES_INSTALL_MIME_ACTIVATION, PREFERENCE_BOOLEAN, GINT_TO_POINTER (TRUE) @@ -607,9 +581,6 @@ global_preferences_register_enumerations (void) eel_enumeration_register ("default_zoom_level", default_zoom_level_enum_entries, G_N_ELEMENTS (default_zoom_level_enum_entries)); - eel_enumeration_register ("executable_text_activation", - executable_text_activation_enum_entries, - G_N_ELEMENTS (executable_text_activation_enum_entries)); eel_enumeration_register ("file_size", file_size_enum_entries, G_N_ELEMENTS (file_size_enum_entries)); diff --git a/libcaja-private/caja-global-preferences.h b/libcaja-private/caja-global-preferences.h index 03c02175..45efde91 100644 --- a/libcaja-private/caja-global-preferences.h +++ b/libcaja-private/caja-global-preferences.h @@ -97,7 +97,7 @@ G_BEGIN_DECLS #define CAJA_PREFERENCES_CLICK_POLICY "preferences/click_policy" /* Activating executable text files */ -#define CAJA_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION "preferences/executable_text_activation" +#define CAJA_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION "executable-text-activation" /* Installing new packages when unknown mime type activated */ #define CAJA_PREFERENCES_INSTALL_MIME_ACTIVATION "preferences/install_mime_activation" diff --git a/libcaja-private/caja-mime-actions.c b/libcaja-private/caja-mime-actions.c index 33897f5d..9cbc2f45 100644 --- a/libcaja-private/caja-mime-actions.c +++ b/libcaja-private/caja-mime-actions.c @@ -822,8 +822,8 @@ get_executable_text_file_action (GtkWindow *parent_window, CajaFile *file) g_assert (caja_file_contains_text (file)); - preferences_value = eel_preferences_get_enum - (CAJA_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION); + preferences_value = g_settings_get_enum (caja_preferences, + CAJA_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION); switch (preferences_value) { case CAJA_EXECUTABLE_TEXT_LAUNCH: @@ -881,8 +881,8 @@ get_default_executable_text_file_action (void) { int preferences_value; - preferences_value = eel_preferences_get_enum - (CAJA_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION); + preferences_value = g_settings_get_enum (caja_preferences, + CAJA_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION); switch (preferences_value) { case CAJA_EXECUTABLE_TEXT_LAUNCH: diff --git a/src/caja-file-management-properties.c b/src/caja-file-management-properties.c index 9369acaa..5dd9181d 100644 --- a/src/caja-file-management-properties.c +++ b/src/caja-file-management-properties.c @@ -760,6 +760,83 @@ bind_builder_enum (GtkBuilder *builder, enum_values, NULL); } +typedef struct { + GtkWidget *button; + const char *value; + const char *key; + GSettings *settings; +} RadioBinding; + +static void +radio_binding_setting_changed (GSettings *settings, + const gchar *key, + gpointer user_data) +{ + RadioBinding *binding = user_data; + char *value; + + value = g_settings_get_string (settings, key); + + if (strcmp (value, binding->value) == 0) { + /* This will unset the currently active, no need + to do that manually */ + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (binding->button), TRUE); + } + g_free (value); +} + +static void +radio_binding_button_toggled (GtkToggleButton *toggle_button, + RadioBinding *binding) +{ + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (binding->button))) { + g_settings_set_string (binding->settings, binding->key, binding->value); + } +} + +static void +free_radio_binding (gpointer data, + GClosure *closure) +{ + RadioBinding *binding = data; + + g_object_unref (binding->settings); + g_free (binding); +} + +static void +bind_builder_radio (GtkBuilder *builder, + GSettings *settings, + const char **widget_names, + const char *prefs, + const char **values) +{ + GtkWidget *button; + int i; + char *detailed_signal; + RadioBinding *binding; + + detailed_signal = g_strdup_printf ("changed::%s", prefs); + + for (i = 0; widget_names[i] != NULL; i++) { + button = GTK_WIDGET (gtk_builder_get_object (builder, widget_names[i])); + + binding = g_new (RadioBinding, 1); + binding->button = button; + binding->value = values[i]; + binding->key = prefs; + binding->settings = g_object_ref (settings); + + g_signal_connect (settings, detailed_signal, + G_CALLBACK(radio_binding_setting_changed), + binding); + + g_signal_connect_data (G_OBJECT (button), "toggled", + G_CALLBACK (radio_binding_button_toggled), + binding, free_radio_binding, 0); + } +} + static void caja_file_management_properties_dialog_setup (GtkBuilder *builder, GtkWindow *window) { @@ -875,10 +952,10 @@ caja_file_management_properties_dialog_setup (GtkBuilder *builder, GtkWindow *wi (const char **) click_behavior_components, CAJA_PREFERENCES_CLICK_POLICY, (const char **) click_behavior_values); - eel_preferences_builder_connect_string_enum_radio_button (builder, - (const char **) executable_text_components, - CAJA_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION, - (const char **) executable_text_values); + bind_builder_radio (builder, caja_preferences, + (const char **) executable_text_components, + CAJA_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION, + (const char **) executable_text_values); eel_preferences_builder_connect_uint_enum (builder, CAJA_FILE_MANAGEMENT_PROPERTIES_THUMBNAIL_LIMIT_WIDGET, |