summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergios - Anestis Kefalidis <sergioskefalidis@gmail.com>2021-06-17 01:27:37 +0300
committerAlexander Schwinn <alexxcons@xfce.org>2021-06-17 20:16:13 +0000
commit93daf1b7f19bec95bb92af828e7bca13127c1e88 (patch)
tree6448d624acbfa53ef3763590e043eaef558b53cf
parent5705dd43e554246c0c4a905a74ef37993c8c3215 (diff)
downloadthunar-93daf1b7f19bec95bb92af828e7bca13127c1e88.tar.gz
Add zoom-level as a per-directory setting (Issue #418)
MR !114 Issue #418
-rw-r--r--thunar/thunar-enum-types.c40
-rw-r--r--thunar/thunar-enum-types.h3
-rw-r--r--thunar/thunar-file.c7
-rw-r--r--thunar/thunar-preferences-dialog.c2
-rw-r--r--thunar/thunar-standard-view.c22
-rw-r--r--thunarx/thunarx-file-info.h4
6 files changed, 74 insertions, 4 deletions
diff --git a/thunar/thunar-enum-types.c b/thunar/thunar-enum-types.c
index 8dc826b9..0db00b44 100644
--- a/thunar/thunar-enum-types.c
+++ b/thunar/thunar-enum-types.c
@@ -284,6 +284,46 @@ thunar_zoom_level_to_thumbnail_size (ThunarZoomLevel zoom_level)
+const gchar*
+thunar_zoom_level_string_from_value (ThunarZoomLevel zoom_level)
+{
+ GEnumClass *enum_class;
+ GEnumValue *enum_value;
+
+ enum_class = g_type_class_ref (THUNAR_TYPE_ZOOM_LEVEL);
+ enum_value = g_enum_get_value (enum_class, zoom_level);
+
+ g_type_class_unref (enum_class);
+
+ if (enum_value == NULL)
+ return NULL;
+
+ return enum_value->value_name;
+}
+
+
+
+gboolean
+thunar_zoom_level_value_from_string (const gchar *value_string,
+ gint *value)
+{
+ GEnumClass *enum_class;
+ GEnumValue *enum_value;
+
+ enum_class = g_type_class_ref (THUNAR_TYPE_ZOOM_LEVEL);
+ enum_value = g_enum_get_value_by_name (enum_class, value_string);
+
+ g_type_class_unref (enum_class);
+
+ if (enum_value == NULL)
+ return FALSE;
+
+ *value = enum_value->value;
+ return TRUE;
+}
+
+
+
GType
thunar_thumbnail_mode_get_type (void)
{
diff --git a/thunar/thunar-enum-types.h b/thunar/thunar-enum-types.h
index 176fe95e..e6dacc88 100644
--- a/thunar/thunar-enum-types.h
+++ b/thunar/thunar-enum-types.h
@@ -251,6 +251,9 @@ typedef enum
GType thunar_zoom_level_get_type (void) G_GNUC_CONST;
ThunarThumbnailSize thunar_zoom_level_to_thumbnail_size (ThunarZoomLevel zoom_level) G_GNUC_CONST;
+const gchar* thunar_zoom_level_string_from_value (ThunarZoomLevel zoom_level);
+gboolean thunar_zoom_level_value_from_string (const gchar *value_string,
+ gint *value);
#define THUNAR_TYPE_JOB_RESPONSE (thunar_job_response_get_type ())
diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c
index 5c21da60..41125486 100644
--- a/thunar/thunar-file.c
+++ b/thunar/thunar-file.c
@@ -4553,7 +4553,7 @@ thunar_file_set_metadata_setting_finish (GObject *source_object,
g_warning ("Failed to set metadata: %s", error->message);
g_error_free (error);
}
-
+
thunar_file_changed (file);
}
@@ -4619,6 +4619,7 @@ thunar_file_clear_directory_specific_settings (ThunarFile *file)
g_file_info_remove_attribute (file->info, "metadata::thunar-view-type");
g_file_info_remove_attribute (file->info, "metadata::thunar-sort-column");
g_file_info_remove_attribute (file->info, "metadata::thunar-sort-order");
+ g_file_info_remove_attribute (file->info, "metadata::thunar-zoom-level");
g_file_set_attribute (file->gfile, "metadata::thunar-view-type", G_FILE_ATTRIBUTE_TYPE_INVALID,
NULL, G_FILE_QUERY_INFO_NONE, NULL, NULL);
@@ -4626,6 +4627,8 @@ thunar_file_clear_directory_specific_settings (ThunarFile *file)
NULL, G_FILE_QUERY_INFO_NONE, NULL, NULL);
g_file_set_attribute (file->gfile, "metadata::thunar-sort-order", G_FILE_ATTRIBUTE_TYPE_INVALID,
NULL, G_FILE_QUERY_INFO_NONE, NULL, NULL);
+ g_file_set_attribute (file->gfile, "metadata::thunar-zoom-level", G_FILE_ATTRIBUTE_TYPE_INVALID,
+ NULL, G_FILE_QUERY_INFO_NONE, NULL, NULL);
thunar_file_changed (file);
}
@@ -4654,6 +4657,8 @@ thunar_file_has_directory_specific_settings (ThunarFile *file)
return TRUE;
if (g_file_info_has_attribute (file->info, "metadata::thunar-sort-order"))
return TRUE;
+ if (g_file_info_has_attribute (file->info, "metadata::thunar-zoom-level"))
+ return TRUE;
return FALSE;
}
diff --git a/thunar/thunar-preferences-dialog.c b/thunar/thunar-preferences-dialog.c
index 5253f595..6c664a5f 100644
--- a/thunar/thunar-preferences-dialog.c
+++ b/thunar/thunar-preferences-dialog.c
@@ -402,7 +402,7 @@ thunar_preferences_dialog_init (ThunarPreferencesDialog *dialog)
"active",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
gtk_widget_set_tooltip_text (button,
- _("Select this option to remember view type, sort column, and sort order individually for each folder"));
+ _("Select this option to remember view type, zoom level, sort column, and sort order individually for each folder"));
gtk_widget_set_hexpand (button, TRUE);
gtk_grid_attach (GTK_GRID (grid), button, 0, 2, 1, 1);
gtk_widget_show (button);
diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c
index 493dba48..1a12f0f2 100644
--- a/thunar/thunar-standard-view.c
+++ b/thunar/thunar-standard-view.c
@@ -1621,6 +1621,16 @@ thunar_standard_view_set_zoom_level (ThunarView *view,
/* check if we have a new zoom-level here */
if (G_LIKELY (standard_view->priv->zoom_level != zoom_level))
{
+ if (standard_view->priv->directory_specific_settings)
+ {
+ const gchar *zoom_level_name;
+
+ /* save the zoom level name */
+ zoom_level_name = thunar_zoom_level_string_from_value (zoom_level);
+ if (zoom_level_name != NULL)
+ thunar_file_set_metadata_setting (standard_view->priv->current_directory, "zoom-level", zoom_level_name);
+ }
+
if (thunar_zoom_level_to_thumbnail_size (zoom_level) != thunar_zoom_level_to_thumbnail_size (standard_view->priv->zoom_level))
newThumbnailSize = TRUE;
@@ -1660,8 +1670,10 @@ thunar_standard_view_apply_directory_specific_settings (ThunarStandardView *stan
{
const gchar *sort_column_name;
const gchar *sort_order_name;
+ const gchar *zoom_level_name;
gint sort_column;
GtkSortType sort_order;
+ gint zoom_level;
/* get the default sort column and sort order */
g_object_get (G_OBJECT (standard_view->preferences), "last-sort-column", &sort_column, "last-sort-order", &sort_order, NULL);
@@ -1669,6 +1681,7 @@ thunar_standard_view_apply_directory_specific_settings (ThunarStandardView *stan
/* get the stored directory specific settings (if any) */
sort_column_name = thunar_file_get_metadata_setting (directory, "sort-column");
sort_order_name = thunar_file_get_metadata_setting (directory, "sort-order");
+ zoom_level_name = thunar_file_get_metadata_setting (directory, "zoom-level");
/* convert the sort column name to a value */
if (sort_column_name != NULL)
@@ -1683,6 +1696,15 @@ thunar_standard_view_apply_directory_specific_settings (ThunarStandardView *stan
sort_order = GTK_SORT_DESCENDING;
}
+ /* convert the sort column name to a value */
+ if (zoom_level_name != NULL)
+ {
+ if (thunar_zoom_level_value_from_string (zoom_level_name, &zoom_level) == TRUE)
+ thunar_standard_view_set_zoom_level (THUNAR_VIEW (standard_view), zoom_level);
+ }
+ else
+ thunar_standard_view_reset_zoom_level (THUNAR_VIEW (standard_view));
+
/* thunar_standard_view_sort_column_changed saves the directory specific settings to the directory, but we do not
* want that behaviour here so we disconnect the signal before calling gtk_tree_sortable_set_sort_column_id */
g_signal_handlers_disconnect_by_func (G_OBJECT (standard_view->model),
diff --git a/thunarx/thunarx-file-info.h b/thunarx/thunarx-file-info.h
index 949d3527..57de0ff5 100644
--- a/thunarx/thunarx-file-info.h
+++ b/thunarx/thunarx-file-info.h
@@ -49,8 +49,8 @@ G_BEGIN_DECLS
"unix::gid,unix::uid,unix::mode," \
"metadata::emblems," \
"metadata::thunar-view-type," \
- "metadata::thunar-sort-column,metadata::thunar-sort-order"
-
+ "metadata::thunar-sort-column,metadata::thunar-sort-order," \
+ "metadata::thunar-zoom-level"
/*