Skip to content

Commit

Permalink
Add option to disable or enable content type detection of mounted med…
Browse files Browse the repository at this point in the history
…ia. (#2913)
  • Loading branch information
patlefort authored May 22, 2022
1 parent c271a6b commit 12081f4
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 7 deletions.
16 changes: 16 additions & 0 deletions gresources/nemo-file-management-properties.glade
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 +1494,22 @@ along with . If not, see <http://www.gnu.org/licenses/>.
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="media_detect_content_checkbutton">
<property name="label" translatable="yes">Detect content of media and suggest application to open</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">4</property>
</packing>
</child>
</object>
</child>
</object>
Expand Down
7 changes: 4 additions & 3 deletions libnemo-private/nemo-global-preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,10 @@ typedef enum

/* media handling */

#define GNOME_DESKTOP_MEDIA_HANDLING_AUTOMOUNT "automount"
#define GNOME_DESKTOP_MEDIA_HANDLING_AUTOMOUNT_OPEN "automount-open"
#define GNOME_DESKTOP_MEDIA_HANDLING_AUTORUN "autorun-never"
#define GNOME_DESKTOP_MEDIA_HANDLING_AUTOMOUNT "automount"
#define GNOME_DESKTOP_MEDIA_HANDLING_AUTOMOUNT_OPEN "automount-open"
#define GNOME_DESKTOP_MEDIA_HANDLING_AUTORUN "autorun-never"
#define NEMO_PREFERENCES_MEDIA_HANDLING_DETECT_CONTENT "detect-content"

/* Terminal */
#define GNOME_DESKTOP_TERMINAL_EXEC "exec"
Expand Down
4 changes: 4 additions & 0 deletions libnemo-private/org.nemo.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,10 @@
<default>false</default>
<summary>Suppress any safeguards when running nemo/nemo-desktop as the root user. For some systems there is only a root user.</summary>
</key>
<key name="detect-content" type="b">
<default>true</default>
<summary>If true, enable detection of the type of content of a mounted media and display a suggested application to open the media.</summary>
</key>
</schema>

<schema id="org.nemo.icon-view" path="/org/nemo/icon-view/" gettext-domain="nemo">
Expand Down
5 changes: 5 additions & 0 deletions src/nemo-file-management-properties.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
#define NEMO_FILE_MANAGEMENT_PROPERTIES_AUTOMOUNT_MEDIA_WIDGET "media_automount_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_AUTOOPEN_MEDIA_WIDGET "media_autoopen_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_AUTORUN_MEDIA_WIDGET "media_autorun_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_DETECT_CONTENT_MEDIA_WIDGET "media_detect_content_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_SHOW_ADVANCED_PERMISSIONS_WIDGET "show_advanced_permissions_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_START_WITH_DUAL_PANE_WIDGET "start_with_dual_pane_checkbutton"
#define NEMO_FILE_MANAGEMENT_PROPERTIES_IGNORE_VIEW_METADATA_WIDGET "ignore_view_metadata_checkbutton"
Expand Down Expand Up @@ -997,6 +998,10 @@ nemo_file_management_properties_dialog_setup (GtkBuilder *builder,
NEMO_FILE_MANAGEMENT_PROPERTIES_AUTORUN_MEDIA_WIDGET,
GNOME_DESKTOP_MEDIA_HANDLING_AUTORUN);

bind_builder_bool (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_DETECT_CONTENT_MEDIA_WIDGET,
NEMO_PREFERENCES_MEDIA_HANDLING_DETECT_CONTENT);

bind_builder_bool (builder, nemo_preferences,
NEMO_FILE_MANAGEMENT_PROPERTIES_CLOSE_DEVICE_VIEW_ON_EJECT_WIDGET,
NEMO_PREFERENCES_CLOSE_DEVICE_VIEW_ON_EJECT);
Expand Down
12 changes: 8 additions & 4 deletions src/nemo-window-manage-views.c
Original file line number Diff line number Diff line change
Expand Up @@ -1439,10 +1439,14 @@ found_mount_cb (GObject *source_object,
NULL);
if (mount != NULL) {
data->mount = mount;
nemo_get_x_content_types_for_mount_async (mount,
found_content_type_cb,
data->cancellable,
data);

if (g_settings_get_boolean (nemo_preferences, NEMO_PREFERENCES_MEDIA_HANDLING_DETECT_CONTENT)) {
nemo_get_x_content_types_for_mount_async (mount,
found_content_type_cb,
data->cancellable,
data);
}

return;
}

Expand Down

0 comments on commit 12081f4

Please sign in to comment.