From 88f84760a484b9de29271bb9a9ee11a6d46c0b03 Mon Sep 17 00:00:00 2001 From: youarefunny Date: Mon, 23 May 2011 10:51:14 -0400 Subject: [PATCH 1/2] Added a setting on how showing hidden files are shown in new windows. --- thunar/thunar-preferences-dialog.c | 73 ++++++++++++++++++++++++++++++++++-- thunar/thunar-preferences.c | 23 +++++++++-- thunar/thunar-window.c | 68 +++++++++++++++++++-------------- 3 files changed, 127 insertions(+), 37 deletions(-) diff --git a/thunar/thunar-preferences-dialog.c b/thunar/thunar-preferences-dialog.c index 504db2c..a1f4f6e 100644 --- a/thunar/thunar-preferences-dialog.c +++ b/thunar/thunar-preferences-dialog.c @@ -41,7 +41,7 @@ static void thunar_preferences_dialog_finalize (GObject *object); static void thunar_preferences_dialog_response (GtkDialog *dialog, gint response); -static void thunar_preferences_dialog_configure (ThunarPreferencesDialog *dialog); +static void thunar_preferences_dialog_configure (ThunarPreferencesDialog *dialog); @@ -148,6 +148,56 @@ transform_view_index_to_string (const GValue *src_value, +static gboolean +transform_hidden_string_to_index (const GValue *src_value, + GValue *dst_value, + gpointer user_data) +{ + char *type = g_value_get_string (src_value); + + if ( strcmp(type, "hidden") == 0 ) + g_value_set_int (dst_value, 0); + else if ( strcmp(type, "last") == 0 ) + g_value_set_int (dst_value, 1); + else if ( strcmp(type, "show") == 0 ) + g_value_set_int (dst_value, 2); + else + g_value_set_int (dst_value, 3); + + return TRUE; +} + + + +static gboolean +transform_hidden_index_to_string (const GValue *src_value, + GValue *dst_value, + gpointer user_data) +{ + switch (g_value_get_int (src_value)) + { + case 0: + g_value_set_static_string (dst_value, "hidden"); + break; + + case 1: + g_value_set_static_string (dst_value, "last"); + break; + + case 2: + g_value_set_static_string (dst_value, "show"); + break; + + default: + g_value_set_static_string (dst_value, g_type_name (G_TYPE_NONE)); + break; + } + + return TRUE; +} + + + static void thunar_preferences_dialog_class_init (ThunarPreferencesDialogClass *klass) { @@ -221,7 +271,7 @@ thunar_preferences_dialog_init (ThunarPreferencesDialog *dialog) gtk_frame_set_label_widget (GTK_FRAME (frame), label); gtk_widget_show (label); - table = gtk_table_new (3, 2, FALSE); + table = gtk_table_new (4, 2, FALSE); gtk_table_set_row_spacings (GTK_TABLE (table), 6); gtk_table_set_col_spacings (GTK_TABLE (table), 12); gtk_container_set_border_width (GTK_CONTAINER (table), 12); @@ -244,17 +294,32 @@ thunar_preferences_dialog_init (ThunarPreferencesDialog *dialog) gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo); gtk_widget_show (combo); + label = gtk_label_new_with_mnemonic (_("Wether to show hidden files in new windows")); + gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0); + gtk_widget_show (label); + + combo = gtk_combo_box_new_text (); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Hidden")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Last State")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Visible")); + exo_mutual_binding_new_full (G_OBJECT (dialog->preferences), "default-show-hidden", G_OBJECT (combo), "active", + transform_hidden_string_to_index, transform_hidden_index_to_string, NULL, NULL); + gtk_table_attach (GTK_TABLE (table), combo, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); + thunar_gtk_label_set_a11y_relation (GTK_LABEL (label), combo); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo); + gtk_widget_show (combo); + button = gtk_check_button_new_with_mnemonic (_("Sort _folders before files")); exo_mutual_binding_new (G_OBJECT (dialog->preferences), "misc-folders-first", G_OBJECT (button), "active"); gtk_widget_set_tooltip_text (button, _("Select this option to list folders before files when you sort a folder.")); - gtk_table_attach (GTK_TABLE (table), button, 0, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), button, 0, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (button); button = gtk_check_button_new_with_mnemonic (_("_Show thumbnails")); exo_mutual_binding_new (G_OBJECT (dialog->preferences), "misc-show-thumbnails", G_OBJECT (button), "active"); gtk_widget_set_tooltip_text (button, _("Select this option to display previewable files within a " "folder as automatically generated thumbnail icons.")); - gtk_table_attach (GTK_TABLE (table), button, 0, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); + gtk_table_attach (GTK_TABLE (table), button, 0, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (button); frame = g_object_new (GTK_TYPE_FRAME, "border-width", 0, "shadow-type", GTK_SHADOW_NONE, NULL); diff --git a/thunar/thunar-preferences.c b/thunar/thunar-preferences.c index 84d1f9b..cad1ea1 100644 --- a/thunar/thunar-preferences.c +++ b/thunar/thunar-preferences.c @@ -50,6 +50,7 @@ enum { PROP_0, PROP_DEFAULT_VIEW, + PROP_DEFAULT_SHOW_HIDDEN, PROP_LAST_COMPACT_VIEW_ZOOM_LEVEL, PROP_LAST_DETAILS_VIEW_COLUMN_ORDER, PROP_LAST_DETAILS_VIEW_COLUMN_WIDTHS, @@ -294,7 +295,7 @@ thunar_preferences_class_init (ThunarPreferencesClass *klass) /** * ThunarPreferences:last-show-hidden: * - * Whether to show hidden files by default in new windows. + * Last state of showing hidden files. **/ g_object_class_install_property (gobject_class, PROP_LAST_SHOW_HIDDEN, @@ -305,6 +306,20 @@ thunar_preferences_class_init (ThunarPreferencesClass *klass) EXO_PARAM_READWRITE)); /** + * ThunarPreferences:default-show-hidden: + * + * Whether to show hidden files by default in new windows. + **/ + g_object_class_install_property (gobject_class, + PROP_LAST_SIDE_PANE, + g_param_spec_string ("default-show-hidden", + "defaultShowHidden", + "default-show-hidden", + "last", + EXO_PARAM_READWRITE)); + + + /** * ThunarPreferences:last-side-pane: * * The name of the widget class, which should be used for the @@ -400,7 +415,7 @@ thunar_preferences_class_init (ThunarPreferencesClass *klass) "last-window-width", 1, G_MAXINT, 640, EXO_PARAM_READWRITE)); - + /** * ThunarPreferences:last-window-maximized: * @@ -769,7 +784,7 @@ static void thunar_preferences_suspend_monitor (ThunarPreferences *preferences) { /* verify that the monitor is active */ - if (G_LIKELY (preferences->monitor != NULL + if (G_LIKELY (preferences->monitor != NULL && !g_file_monitor_is_cancelled (preferences->monitor))) { /* disconnect the handle from the monitor */ @@ -793,7 +808,7 @@ thunar_preferences_monitor (GFileMonitor *monitor, _thunar_return_if_fail (preferences->monitor == monitor); /* schedule a reload whenever the file is created/changed */ - if (event_type == G_FILE_MONITOR_EVENT_CHANGED + if (event_type == G_FILE_MONITOR_EVENT_CHANGED || event_type == G_FILE_MONITOR_EVENT_CREATED) { thunar_preferences_queue_load (preferences); diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c index d258d8f..7769187 100644 --- a/thunar/thunar-window.c +++ b/thunar/thunar-window.c @@ -3,18 +3,18 @@ * Copyright (c) 2005-2007 Benedikt Meurer * Copyright (c) 2009-2011 Jannis Pohlmann * - * This program is free software; you can redistribute it and/or + * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of + * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the Free + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the Free * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ @@ -593,14 +593,14 @@ static void thunar_window_setup_user_dir_menu_entries (ThunarWindow *window) { static const gchar *callback_names[] = { - "open-desktop", - "open-documents", - "open-downloads", + "open-desktop", + "open-documents", + "open-downloads", "open-music", - "open-pictures", - "open-public", - "open-templates", - "open-videos", + "open-pictures", + "open-public", + "open-templates", + "open-videos", NULL }; GtkAction *action; @@ -671,6 +671,7 @@ thunar_window_init (ThunarWindow *window) GtkWidget *item; GtkAction *action; gboolean show_hidden; + gchar *default_show_hidden; gboolean visible; GSList *group; gchar *type_name; @@ -713,7 +714,16 @@ thunar_window_init (ThunarWindow *window) /* initialize the "show-hidden" action using the last value from the preferences */ action = gtk_action_group_get_action (window->action_group, "show-hidden"); - g_object_get (G_OBJECT (window->preferences), "last-show-hidden", &show_hidden, NULL); + g_object_get (G_OBJECT (window->preferences), "default-show-hidden", &default_show_hidden, NULL); + printf("%s\n", default_show_hidden); + if ( strcmp(default_show_hidden, "hidden") == 0 ) + show_hidden = FALSE; + else if ( strcmp(default_show_hidden, "last") == 0 ) + g_object_get (G_OBJECT (window->preferences), "last-show-hidden", &show_hidden, NULL); + else if ( strcmp(default_show_hidden, "show") == 0 ) + show_hidden = TRUE; + else + show_hidden = FALSE; gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), show_hidden); /* synchronize the "show-hidden" state with the "last-show-hidden" preference */ @@ -770,7 +780,7 @@ thunar_window_init (ThunarWindow *window) /* determine the default window size from the preferences */ g_object_get (G_OBJECT (window->preferences), "last-window-width", &width, "last-window-height", &height, "last-window-maximized", &maximized, NULL); gtk_window_set_default_size (GTK_WINDOW (window), width, height); - + /* restore the maxized state of the window */ if (G_UNLIKELY (maximized)) gtk_window_maximize (GTK_WINDOW (window)); @@ -1438,7 +1448,7 @@ thunar_window_merge_go_actions (ThunarWindow *window) if (thunar_g_vfs_is_uri_scheme_supported ("network")) { /* create the network action */ - action = gtk_action_new ("open-network", _("Network"), _("Browse the network"), + action = gtk_action_new ("open-network", _("Network"), _("Browse the network"), GTK_STOCK_NETWORK); g_signal_connect (action, "activate", G_CALLBACK (thunar_window_action_open_network), window); @@ -1503,7 +1513,7 @@ thunar_window_poke_file_finish (ThunarBrowser *browser, } else { - thunar_dialogs_show_error (GTK_WIDGET (browser), error, + thunar_dialogs_show_error (GTK_WIDGET (browser), error, _("Failed to open \"%s\""), thunar_file_get_display_name (file)); } @@ -1517,7 +1527,7 @@ thunar_window_start_open_location (ThunarWindow *window, { ThunarFile *selected_file; GtkWidget *dialog; - + _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); /* bring up the "Open Location"-dialog if the window has no location bar or the location bar @@ -1530,9 +1540,9 @@ thunar_window_start_open_location (ThunarWindow *window, gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE); gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window)); - thunar_location_dialog_set_working_directory (THUNAR_LOCATION_DIALOG (dialog), + thunar_location_dialog_set_working_directory (THUNAR_LOCATION_DIALOG (dialog), thunar_window_get_current_directory (window)); - thunar_location_dialog_set_selected_file (THUNAR_LOCATION_DIALOG (dialog), + thunar_location_dialog_set_selected_file (THUNAR_LOCATION_DIALOG (dialog), thunar_window_get_current_directory (window)); /* setup the initial text (if any) */ @@ -1555,7 +1565,7 @@ thunar_window_start_open_location (ThunarWindow *window, selected_file = thunar_location_dialog_get_selected_file (THUNAR_LOCATION_DIALOG (dialog)); if (selected_file != NULL) { - thunar_browser_poke_file (THUNAR_BROWSER (window), selected_file, window, + thunar_browser_poke_file (THUNAR_BROWSER (window), selected_file, window, thunar_window_poke_file_finish, NULL); } } @@ -1648,7 +1658,7 @@ thunar_window_action_preferences (GtkAction *action, /* allocate and display a preferences dialog */; dialog = thunar_preferences_dialog_new (GTK_WINDOW (window)); - gtk_widget_show (dialog); + gtk_widget_show (dialog); /* ...and let the application take care of it */ application = thunar_application_get (); @@ -1794,7 +1804,7 @@ thunar_window_action_statusbar_changed (GtkToggleAction *action, /* determine the new state of the action */ active = gtk_toggle_action_get_active (action); - + /* check if we should drop the statusbar */ if (!active && window->statusbar != NULL) { @@ -2453,7 +2463,7 @@ thunar_window_current_directory_destroy (ThunarFile *current_directory, { /* determine the parent of the directory */ tmp = g_file_get_parent (path); - + /* if there's no parent this means that we've found no parent * that still exists at all. Fall back to $HOME then */ if (tmp == NULL) @@ -2593,7 +2603,7 @@ thunar_window_notify_loading (ThunarView *view, } } } - + static void @@ -2731,7 +2741,7 @@ thunar_window_new (void) /** * thunar_window_get_current_directory: * @window : a #ThunarWindow instance. - * + * * Queries the #ThunarFile instance, which represents the directory * currently displayed within @window. %NULL is returned if @window * is not currently associated with any directory. @@ -2762,7 +2772,7 @@ thunar_window_set_current_directory (ThunarWindow *window, _thunar_return_if_fail (THUNAR_IS_WINDOW (window)); _thunar_return_if_fail (current_directory == NULL || THUNAR_IS_FILE (current_directory)); - + /* check if we already display the requested directory */ if (G_UNLIKELY (window->current_directory == current_directory)) return; @@ -2793,7 +2803,7 @@ thunar_window_set_current_directory (ThunarWindow *window, g_signal_connect (G_OBJECT (current_directory), "changed", G_CALLBACK (thunar_window_current_directory_changed), window); g_signal_connect (G_OBJECT (current_directory), "destroy", G_CALLBACK (thunar_window_current_directory_destroy), window); g_object_ref (G_OBJECT (current_directory)); - + /* update window icon and title */ thunar_window_current_directory_changed (current_directory, window); @@ -2827,7 +2837,7 @@ thunar_window_set_current_directory (ThunarWindow *window, selected_files.data = NULL; selected_files.prev = NULL; selected_files.next = NULL; - + /* determine the next file in the history */ selected_file = thunar_history_peek_forward (window->history); if (selected_file != NULL) @@ -2844,7 +2854,7 @@ thunar_window_set_current_directory (ThunarWindow *window, selected_file = thunar_history_peek_back (window->history); if (selected_file != NULL) { - /* mark the file from history for selection if it is inside the + /* mark the file from history for selection if it is inside the * new directory */ if (thunar_file_is_parent (window->current_directory, selected_file)) selected_files.data = selected_file; -- 1.7.5.2 From 6b08b35987dcc10cdfb2ba5006ce30c73526a409 Mon Sep 17 00:00:00 2001 From: youarefunny Date: Mon, 23 May 2011 11:09:57 -0400 Subject: [PATCH 2/2] fixed message for setting --- thunar/thunar-preferences-dialog.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/thunar/thunar-preferences-dialog.c b/thunar/thunar-preferences-dialog.c index a1f4f6e..024aa93 100644 --- a/thunar/thunar-preferences-dialog.c +++ b/thunar/thunar-preferences-dialog.c @@ -294,7 +294,7 @@ thunar_preferences_dialog_init (ThunarPreferencesDialog *dialog) gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo); gtk_widget_show (combo); - label = gtk_label_new_with_mnemonic (_("Wether to show hidden files in new windows")); + label = gtk_label_new_with_mnemonic (_("Hidden files in new windows should be:")); gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (label); -- 1.7.5.2