diff options
Diffstat (limited to 'thunar')
-rw-r--r-- | thunar/thunar-enum-types.c | 35 | ||||
-rw-r--r-- | thunar/thunar-enum-types.h | 15 | ||||
-rw-r--r-- | thunar/thunar-list-model.c | 146 | ||||
-rw-r--r-- | thunar/thunar-preferences.c | 15 | ||||
-rw-r--r-- | thunar/thunar-standard-view.c | 3 | ||||
-rw-r--r-- | thunar/thunar-standard-view.h | 2 | ||||
-rw-r--r-- | thunar/thunar-statusbar.c | 179 | ||||
-rw-r--r-- | thunar/thunar-statusbar.h | 12 | ||||
-rw-r--r-- | thunar/thunar-window.c | 15 | ||||
-rw-r--r-- | thunar/thunar-window.h | 1 |
10 files changed, 363 insertions, 60 deletions
diff --git a/thunar/thunar-enum-types.c b/thunar/thunar-enum-types.c index 4bf6457a..37d57fa1 100644 --- a/thunar/thunar-enum-types.c +++ b/thunar/thunar-enum-types.c @@ -571,3 +571,38 @@ thunar_verify_file_get_type (void) return type; } + + + +/** + * thunar_status_bar_info_toggle_bit: + * @info : a #guint. + * @mask : a #ThunarStatusBarInfo (can be a combination using |) + * + * Flips the bits of @info when there is a matching info bit in @mask. + * Used to enable/disable information in the statusbar. + * + * Return value: @info XOR @mask. + **/ +guint +thunar_status_bar_info_toggle_bit (guint info, + ThunarStatusBarInfo mask) +{ + return info ^ mask; +} + + + +/** + * thunar_status_bar_info_check_active: + * @info : a #guint. + * @mask : a #ThunarStatusBarInfo (can be a combination using |) + * + * Return value: TRUE if the fields specified in @mask are active, otherwise FALSE. + **/ +gboolean +thunar_status_bar_info_check_active (guint info, + ThunarStatusBarInfo mask) +{ + return (info & mask) > 0 ? TRUE : FALSE; +} diff --git a/thunar/thunar-enum-types.h b/thunar/thunar-enum-types.h index d9b35b35..3757e478 100644 --- a/thunar/thunar-enum-types.h +++ b/thunar/thunar-enum-types.h @@ -382,6 +382,21 @@ typedef enum THUNAR_NEW_TAB_BEHAVIOR_STAY } ThunarNewTabBehavior; + + +typedef enum +{ + THUNAR_STATUS_BAR_INFO_SIZE = 1 << 0, + THUNAR_STATUS_BAR_INFO_SIZE_IN_BYTES = 1 << 1, + THUNAR_STATUS_BAR_INFO_FILETYPE = 1 << 2, + THUNAR_STATUS_BAR_INFO_DISPLAY_NAME = 1 << 3, +} ThunarStatusBarInfo; + +guint thunar_status_bar_info_toggle_bit (guint info, + ThunarStatusBarInfo mask); +gboolean thunar_status_bar_info_check_active (guint info, + ThunarStatusBarInfo mask); + G_END_DECLS; #endif /* !__THUNAR_ENUM_TYPES_H__ */ diff --git a/thunar/thunar-list-model.c b/thunar/thunar-list-model.c index 4e403d22..0228afdf 100644 --- a/thunar/thunar-list-model.c +++ b/thunar/thunar-list-model.c @@ -2615,14 +2615,23 @@ static gchar* thunar_list_model_get_statusbar_text_for_files (GList *files, gboolean show_file_size_binary_format) { - guint64 size_summary = 0; - gint folder_count = 0; - gint non_folder_count = 0; - GList *lp; - gchar *size_string; - gchar *text; - gchar *folder_text = NULL; - gchar *non_folder_text = NULL; + guint64 size_summary = 0; + gint folder_count = 0; + gint non_folder_count = 0; + GList *lp; + gchar *size_string = NULL; + gchar *text = ""; + gchar *folder_text = NULL; + gchar *non_folder_text = NULL; + ThunarPreferences *preferences; + guint active; + gboolean show_size, show_size_in_bytes; + + preferences = thunar_preferences_get (); + g_object_get (G_OBJECT (preferences), "misc-status-bar-active-info", &active, NULL); + show_size = thunar_status_bar_info_check_active (active, THUNAR_STATUS_BAR_INFO_SIZE); + show_size_in_bytes = thunar_status_bar_info_check_active (active, THUNAR_STATUS_BAR_INFO_SIZE_IN_BYTES); + g_object_unref (preferences); /* analyze files */ for (lp = files; lp != NULL; lp = lp->next) @@ -2641,11 +2650,27 @@ thunar_list_model_get_statusbar_text_for_files (GList *files, if (non_folder_count > 0) { - size_string = g_format_size_full (size_summary, G_FORMAT_SIZE_LONG_FORMAT | (show_file_size_binary_format ? G_FORMAT_SIZE_IEC_UNITS : G_FORMAT_SIZE_DEFAULT)); - non_folder_text = g_strdup_printf (ngettext ("%d file: %s", - "%d files: %s", - non_folder_count), non_folder_count, size_string); - g_free (size_string); + if (show_size == TRUE) + { + if (show_size_in_bytes == TRUE) + { + size_string = g_format_size_full (size_summary, G_FORMAT_SIZE_LONG_FORMAT + | (show_file_size_binary_format ? G_FORMAT_SIZE_IEC_UNITS + : G_FORMAT_SIZE_DEFAULT)); + } + else + { + size_string = g_format_size_full (size_summary, show_file_size_binary_format ? G_FORMAT_SIZE_IEC_UNITS + : G_FORMAT_SIZE_DEFAULT); + } + non_folder_text = g_strdup_printf (ngettext ("%d file: %s", + "%d files: %s", + non_folder_count), non_folder_count, size_string); + g_free (size_string); + } + else + non_folder_text = g_strdup_printf (ngettext ("%d file", "%d files", non_folder_count), non_folder_count); + } if (folder_count > 0) @@ -2708,24 +2733,33 @@ thunar_list_model_get_statusbar_text (ThunarListModel *store, GList *lp; gchar *absolute_path; gchar *fspace_string; - gchar *display_name; + gchar *display_name = ""; gchar *size_string; + gchar *filetype_string = ""; gchar *text; gchar *s; gint height; gint width; - gchar *description; GSequenceIter *row; GSequenceIter *end; ThunarPreferences *preferences; gboolean show_image_size; gboolean show_file_size_binary_format; GList *relevant_files = NULL; + guint active; + gboolean show_size, show_size_in_bytes, show_filetype, show_display_name; _thunar_return_val_if_fail (THUNAR_IS_LIST_MODEL (store), NULL); show_file_size_binary_format = thunar_list_model_get_file_size_binary(store); + preferences = thunar_preferences_get (); + g_object_get (G_OBJECT (preferences), "misc-status-bar-active-info", &active, NULL); + show_size = thunar_status_bar_info_check_active (active, THUNAR_STATUS_BAR_INFO_SIZE); + show_size_in_bytes = thunar_status_bar_info_check_active (active, THUNAR_STATUS_BAR_INFO_SIZE_IN_BYTES); + show_filetype = thunar_status_bar_info_check_active (active, THUNAR_STATUS_BAR_INFO_FILETYPE); + show_display_name = thunar_status_bar_info_check_active (active, THUNAR_STATUS_BAR_INFO_DISPLAY_NAME); + if (selected_items == NULL) /* nothing selected */ { /* build a GList of all files */ @@ -2747,7 +2781,10 @@ thunar_list_model_get_statusbar_text (ThunarListModel *store, /* humanize the free space */ fspace_string = g_format_size_full (size, show_file_size_binary_format ? G_FORMAT_SIZE_IEC_UNITS : G_FORMAT_SIZE_DEFAULT); - text = g_strdup_printf (_("%s, Free space: %s"), size_string, fspace_string); + if (size_string[0] != '\0') + text = g_strdup_printf (_("%s, Free space: %s"), size_string, fspace_string); + else + text = g_strdup_printf (_("Free space: %s"), fspace_string); /* cleanup */ g_free (size_string); @@ -2770,43 +2807,51 @@ thunar_list_model_get_statusbar_text (ThunarListModel *store, /* determine the content type of the file */ content_type = thunar_file_get_content_type (file); - if (G_UNLIKELY (content_type != NULL && g_str_equal (content_type, "inode/symlink"))) - { - text = g_strdup_printf (_("\"%s\": broken link"), thunar_file_get_display_name (file)); - } - else if (G_UNLIKELY (thunar_file_is_symlink (file))) + if (show_filetype == TRUE) { - size_string = thunar_file_get_size_string_long (file, show_file_size_binary_format); - text = g_strdup_printf (_("\"%s\": %s link to %s"), thunar_file_get_display_name (file), - size_string, thunar_file_get_symlink_target (file)); - g_free (size_string); - } - else if (G_UNLIKELY (thunar_file_get_kind (file) == G_FILE_TYPE_SHORTCUT)) - { - text = g_strdup_printf (_("\"%s\": shortcut"), thunar_file_get_display_name (file)); - } - else if (G_UNLIKELY (thunar_file_get_kind (file) == G_FILE_TYPE_MOUNTABLE)) - { - text = g_strdup_printf (_("\"%s\": mountable"), thunar_file_get_display_name (file)); + if (G_UNLIKELY (content_type != NULL && g_str_equal (content_type, "inode/symlink"))) + filetype_string = g_strdup ("broken link"); + else if (G_UNLIKELY (thunar_file_is_symlink (file))) + filetype_string = g_strdup_printf (_("link to %s"), thunar_file_get_symlink_target (file)); + else if (G_UNLIKELY (thunar_file_get_kind (file) == G_FILE_TYPE_SHORTCUT)) + filetype_string = g_strdup ("shortcut"); + else if (G_UNLIKELY (thunar_file_get_kind (file) == G_FILE_TYPE_MOUNTABLE)) + filetype_string = g_strdup ("mountable"); + else + filetype_string = g_strdup_printf (_("%s"), g_content_type_get_description (content_type)); } - else if (thunar_file_is_regular (file)) + + if (show_display_name == TRUE) + display_name = g_strdup_printf (_("\"%s\":"), thunar_file_get_display_name (file)); + + if (thunar_file_is_regular (file) || G_UNLIKELY (thunar_file_is_symlink (file))) { - description = g_content_type_get_description (content_type); - size_string = thunar_file_get_size_string_long (file, show_file_size_binary_format); - /* I18N, first %s is the display name of the file, 2nd the file size, 3rd the content type */ - text = g_strdup_printf (_("\"%s\": %s %s"), thunar_file_get_display_name (file), - size_string, description); - g_free (description); - g_free (size_string); + if (show_size == TRUE) + { + if (show_size_in_bytes == TRUE) + size_string = thunar_file_get_size_string_long (file, show_file_size_binary_format); + else + size_string = thunar_file_get_size_string_formatted (file, show_file_size_binary_format); + + /* I18N, first %s is the display name of the file, 2nd the file size, 3rd the content type */ + text = g_strdup_printf (_("%s %s %s"), display_name, size_string, filetype_string); + g_free (size_string); + } + else + text = g_strdup_printf (_("%s %s"), display_name, filetype_string); } else { - description = g_content_type_get_description (content_type); /* I18N, first %s is the display name of the file, second the content type */ - text = g_strdup_printf (_("\"%s\": %s"), thunar_file_get_display_name (file), description); - g_free (description); + text = g_strdup_printf (_("%s %s"), display_name, filetype_string); } + if (show_display_name == TRUE) + g_free (display_name); + + if (show_filetype == TRUE) + g_free (filetype_string); + /* append the original path (if any) */ original_path = thunar_file_get_original_path (file); if (G_UNLIKELY (original_path != NULL)) @@ -2824,9 +2869,7 @@ thunar_list_model_get_statusbar_text (ThunarListModel *store, { /* check if the size should be visible in the statusbar, disabled by * default to avoid high i/o */ - preferences = thunar_preferences_get (); g_object_get (preferences, "misc-image-size-in-statusbar", &show_image_size, NULL); - g_object_unref (preferences); if (show_image_size) { @@ -2853,11 +2896,16 @@ thunar_list_model_get_statusbar_text (ThunarListModel *store, relevant_files = g_list_append (relevant_files, g_sequence_get (iter.user_data)); } - size_string = thunar_list_model_get_statusbar_text_for_files (relevant_files, show_file_size_binary_format); - text = g_strdup_printf (_("Selection: %s"), size_string); - g_free (size_string); + s = thunar_list_model_get_statusbar_text_for_files (relevant_files, show_file_size_binary_format); + if (s[0] != '\0') + text = g_strdup_printf (_("Selection: %s"), s); + else + text = g_strdup (""); + g_free (s); g_list_free (relevant_files); } + g_object_unref (preferences); + return text; } diff --git a/thunar/thunar-preferences.c b/thunar/thunar-preferences.c index f504fcd4..364353e0 100644 --- a/thunar/thunar-preferences.c +++ b/thunar/thunar-preferences.c @@ -105,6 +105,7 @@ enum PROP_MISC_THUMBNAIL_MAX_FILE_SIZE, PROP_MISC_FILE_SIZE_BINARY, PROP_MISC_CONFIRM_CLOSE_MULTIPLE_TABS, + PROP_MISC_STATUS_BAR_ACTIVE_INFO, PROP_MISC_PARALLEL_COPY_MODE, PROP_MISC_WINDOW_ICON, PROP_MISC_TRANSFER_USE_PARTIAL, @@ -941,6 +942,20 @@ thunar_preferences_class_init (ThunarPreferencesClass *klass) EXO_PARAM_READWRITE); /** + * ThunarPreferences:misc-status-bar-active-info: + * + * What kind of info is presented in the statusbar.. + **/ + preferences_props[PROP_MISC_STATUS_BAR_ACTIVE_INFO] = + g_param_spec_uint ("misc-status-bar-active-info", + "MiscStatusBarActiveInfo", + NULL, + 0, G_MAXUINT, + THUNAR_STATUS_BAR_INFO_DISPLAY_NAME | THUNAR_STATUS_BAR_INFO_FILETYPE | THUNAR_STATUS_BAR_INFO_SIZE + | THUNAR_STATUS_BAR_INFO_SIZE_IN_BYTES, + EXO_PARAM_READWRITE); + + /** * ThunarPreferences:shortcuts-icon-emblems: * * Whether to display emblems for file icons (if defined) in the diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c index f05c6969..0f9ca4e6 100644 --- a/thunar/thunar-standard-view.c +++ b/thunar/thunar-standard-view.c @@ -158,7 +158,6 @@ static ThunarFile *thunar_standard_view_get_drop_file (Thu gint x, gint y, GtkTreePath **path_return); -static void thunar_standard_view_update_statusbar_text (ThunarStandardView *standard_view); static void thunar_standard_view_current_directory_destroy (ThunarFile *current_directory, ThunarStandardView *standard_view); static void thunar_standard_view_current_directory_changed (ThunarFile *current_directory, @@ -2046,7 +2045,7 @@ THUNAR_THREADS_LEAVE -static void +void thunar_standard_view_update_statusbar_text (ThunarStandardView *standard_view) { /* stop pending timeout */ diff --git a/thunar/thunar-standard-view.h b/thunar/thunar-standard-view.h index 990166f7..00d12e1e 100644 --- a/thunar/thunar-standard-view.h +++ b/thunar/thunar-standard-view.h @@ -182,6 +182,8 @@ void thunar_standard_view_set_searching (ThunarStandardView gchar *search_query); gchar *thunar_standard_view_get_search_query (ThunarStandardView *standard_view); +void thunar_standard_view_update_statusbar_text (ThunarStandardView *standard_view); + G_END_DECLS; #endif /* !__THUNAR_STANDARD_VIEW_H__ */ diff --git a/thunar/thunar-statusbar.c b/thunar/thunar-statusbar.c index fba2bb79..fdfdfc80 100644 --- a/thunar/thunar-statusbar.c +++ b/thunar/thunar-statusbar.c @@ -24,10 +24,15 @@ #endif #include <exo/exo.h> +#include <libxfce4ui/libxfce4ui.h> #include <thunar/thunar-gobject-extensions.h> #include <thunar/thunar-private.h> #include <thunar/thunar-statusbar.h> +#include <thunar/thunar-gtk-extensions.h> +#include <thunar/thunar-preferences.h> +#include <thunar/thunar-application.h> +#include <thunar/thunar-window.h> @@ -39,12 +44,22 @@ enum -static void thunar_statusbar_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void thunar_statusbar_set_text (ThunarStatusbar *statusbar, - const gchar *text); +static void thunar_statusbar_finalize (GObject *object); +static void thunar_statusbar_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void thunar_statusbar_set_text (ThunarStatusbar *statusbar, + const gchar *text); +static GtkWidget* thunar_statusbar_context_menu (ThunarStatusbar *statusbar); +static gboolean thunar_statusbar_button_press_event (GtkWidget *widget, + GdkEventButton *event, + ThunarStatusbar *statusbar); +static void thunar_statusbar_action_show_size (ThunarStatusbar *statusbar); +static void thunar_statusbar_action_show_size_bytes (ThunarStatusbar *statusbar); +static void thunar_statusbar_action_show_filetype (ThunarStatusbar *statusbar); +static void thunar_statusbar_action_show_display_name (ThunarStatusbar *statusbar); +static void thunar_statusbar_update_all (void); struct _ThunarStatusbarClass @@ -54,10 +69,21 @@ struct _ThunarStatusbarClass struct _ThunarStatusbar { - GtkStatusbar __parent__; - guint context_id; + GtkStatusbar __parent__; + guint context_id; + + ThunarPreferences *preferences; }; +static XfceGtkActionEntry thunar_status_bar_action_entries[] = + { + { THUNAR_STATUS_BAR_ACTION_TOGGLE_SIZE, "<Actions>/ThunarStatusBar/toggle-size", "", XFCE_GTK_CHECK_MENU_ITEM, N_ ("Size"), N_ ("Show size"), NULL, G_CALLBACK (thunar_statusbar_action_show_size), }, + { THUNAR_STATUS_BAR_ACTION_TOGGLE_SIZE_IN_BYTES, "<Actions>/ThunarStatusBar/toggle-size-in-bytes", "", XFCE_GTK_CHECK_MENU_ITEM, N_ ("Size in bytes"), N_ ("Show size in bytes"), NULL, G_CALLBACK (thunar_statusbar_action_show_size_bytes), }, + { THUNAR_STATUS_BAR_ACTION_TOGGLE_FILETYPE, "<Actions>/ThunarStatusBar/toggle-filetype", "", XFCE_GTK_CHECK_MENU_ITEM, N_ ("Filetype"), N_ ("Show filetype"), NULL, G_CALLBACK (thunar_statusbar_action_show_filetype), }, + { THUNAR_STATUS_BAR_ACTION_TOGGLE_DISPLAY_NAME, "<Actions>/ThunarStatusBar/toggle-display-name", "", XFCE_GTK_CHECK_MENU_ITEM, N_ ("Display Name"), N_ ("Show display name"), NULL, G_CALLBACK (thunar_statusbar_action_show_display_name), }, + }; + +#define get_action_entry(id) xfce_gtk_get_action_entry_by_id (thunar_status_bar_action_entries, G_N_ELEMENTS (thunar_status_bar_action_entries) ,id) G_DEFINE_TYPE (ThunarStatusbar, thunar_statusbar, GTK_TYPE_STATUSBAR) @@ -73,6 +99,7 @@ thunar_statusbar_class_init (ThunarStatusbarClass *klass) gobject_class = G_OBJECT_CLASS (klass); gobject_class->set_property = thunar_statusbar_set_property; + gobject_class->finalize = thunar_statusbar_finalize; /** * ThunarStatusbar:text: @@ -111,6 +138,50 @@ thunar_statusbar_init (ThunarStatusbar *statusbar) /* make the status thinner */ gtk_widget_set_margin_top (GTK_WIDGET (statusbar), 0); gtk_widget_set_margin_bottom (GTK_WIDGET (statusbar), 0); + + statusbar->preferences = thunar_preferences_get (); +} + + + +static void +thunar_statusbar_finalize (GObject *object) +{ + ThunarStatusbar *statusbar = THUNAR_STATUSBAR (object); + + g_object_unref (statusbar->preferences); +} + + + +/** + * thunar_statusbar_setup_event: + * @statusbar : a #ThunarStatusbar instance. + * @event_box : a #GtkWidget instance (actually a GtkEventBox passed as a GtkWidget). + * + * Sets the statusbar's GtkEventBox and uses it to receive signals. + **/ +void +thunar_statusbar_setup_event (ThunarStatusbar *statusbar, + GtkWidget *event_box) +{ + g_signal_connect (G_OBJECT (event_box), "button-press-event", G_CALLBACK (thunar_statusbar_button_press_event), G_OBJECT (statusbar)); +} + + + +static gboolean +thunar_statusbar_button_press_event (GtkWidget *widget, + GdkEventButton *event, + ThunarStatusbar *statusbar) +{ + if (event->type == GDK_BUTTON_PRESS && event->button == 3) + { + thunar_gtk_menu_run (GTK_MENU (thunar_statusbar_context_menu (statusbar))); + return TRUE; + } + + return FALSE; } @@ -157,6 +228,98 @@ thunar_statusbar_set_text (ThunarStatusbar *statusbar, +static GtkWidget* +thunar_statusbar_context_menu (ThunarStatusbar *statusbar) +{ + GtkWidget *context_menu = gtk_menu_new(); + GtkWidget *widget; + guint active; + gboolean show_size, show_size_in_bytes, show_filetype, show_display_name; + + g_object_get (G_OBJECT (statusbar->preferences), "misc-status-bar-active-info", &active, NULL); + show_size = active & THUNAR_STATUS_BAR_INFO_SIZE; + show_size_in_bytes = active & THUNAR_STATUS_BAR_INFO_SIZE_IN_BYTES; + show_filetype = active & THUNAR_STATUS_BAR_INFO_FILETYPE; + show_display_name = active & THUNAR_STATUS_BAR_INFO_DISPLAY_NAME; + + xfce_gtk_toggle_menu_item_new_from_action_entry (get_action_entry (THUNAR_STATUS_BAR_ACTION_TOGGLE_SIZE), G_OBJECT (statusbar), show_size, GTK_MENU_SHELL (context_menu)); + widget = xfce_gtk_toggle_menu_item_new_from_action_entry (get_action_entry (THUNAR_STATUS_BAR_ACTION_TOGGLE_SIZE_IN_BYTES), G_OBJECT (statusbar), show_size_in_bytes, GTK_MENU_SHELL (context_menu)); + if (show_size == FALSE) + gtk_widget_set_sensitive (widget, FALSE); + xfce_gtk_toggle_menu_item_new_from_action_entry (get_action_entry (THUNAR_STATUS_BAR_ACTION_TOGGLE_FILETYPE), G_OBJECT (statusbar), show_filetype, GTK_MENU_SHELL (context_menu)); + xfce_gtk_toggle_menu_item_new_from_action_entry (get_action_entry (THUNAR_STATUS_BAR_ACTION_TOGGLE_DISPLAY_NAME), G_OBJECT (statusbar), show_display_name, GTK_MENU_SHELL (context_menu)); + + gtk_widget_show_all (GTK_WIDGET (context_menu)); + + return context_menu; +} + + + +static void +thunar_statusbar_action_show_size (ThunarStatusbar *statusbar) +{ + guint active; + + g_object_get (G_OBJECT (statusbar->preferences), "misc-status-bar-active-info", &active, NULL); + g_object_set (G_OBJECT (statusbar->preferences), "misc-status-bar-active-info", thunar_status_bar_info_toggle_bit (active, THUNAR_STATUS_BAR_INFO_SIZE), NULL); + thunar_statusbar_update_all (); +} + + + +static void +thunar_statusbar_action_show_size_bytes (ThunarStatusbar *statusbar) +{ + guint active; + + g_object_get (G_OBJECT (statusbar->preferences), "misc-status-bar-active-info", &active, NULL); + g_object_set (G_OBJECT (statusbar->preferences), "misc-status-bar-active-info", thunar_status_bar_info_toggle_bit (active, THUNAR_STATUS_BAR_INFO_SIZE_IN_BYTES), NULL); + thunar_statusbar_update_all (); +} + + + +static void +thunar_statusbar_action_show_filetype (ThunarStatusbar *statusbar) +{ + guint active; + + g_object_get (G_OBJECT (statusbar->preferences), "misc-status-bar-active-info", &active, NULL); + g_object_set (G_OBJECT (statusbar->preferences), "misc-status-bar-active-info", thunar_status_bar_info_toggle_bit (active, THUNAR_STATUS_BAR_INFO_FILETYPE), NULL); + thunar_statusbar_update_all (); +} + + + +static void +thunar_statusbar_action_show_display_name (ThunarStatusbar *statusbar) +{ + guint active; + + g_object_get (G_OBJECT (statusbar->preferences), "misc-status-bar-active-info", &active, NULL); + g_object_set (G_OBJECT (statusbar->preferences), "misc-status-bar-active-info", thunar_status_bar_info_toggle_bit (active, THUNAR_STATUS_BAR_INFO_DISPLAY_NAME), NULL); + thunar_statusbar_update_all (); +} + + + +static void +thunar_statusbar_update_all (void) +{ + ThunarApplication *app = thunar_application_get (); + GList *windows = thunar_application_get_windows (app); + GList *lp; + + for (lp = windows; lp != NULL; lp = lp->next) + thunar_window_update_statusbar (THUNAR_WINDOW (lp->data)); + + g_list_free (windows); + g_object_unref (app); +} + + + /** * thunar_statusbar_new: * diff --git a/thunar/thunar-statusbar.h b/thunar/thunar-statusbar.h index 55ff7e0c..1ca0285b 100644 --- a/thunar/thunar-statusbar.h +++ b/thunar/thunar-statusbar.h @@ -34,10 +34,22 @@ typedef struct _ThunarStatusbar ThunarStatusbar; #define THUNAR_IS_STATUSBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), THUNAR_TYPE_STATUSBAR)) #define THUNAR_STATUSBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THUNAR_TYPE_STATUSBAR, ThunarStatusbarClass)) +/* #XfceGtkActionEntrys provided by this widget */ +typedef enum +{ + THUNAR_STATUS_BAR_ACTION_TOGGLE_SIZE, + THUNAR_STATUS_BAR_ACTION_TOGGLE_SIZE_IN_BYTES, + THUNAR_STATUS_BAR_ACTION_TOGGLE_FILETYPE, + THUNAR_STATUS_BAR_ACTION_TOGGLE_DISPLAY_NAME, +} ThunarStatusBarAction; + GType thunar_statusbar_get_type (void) G_GNUC_CONST; GtkWidget *thunar_statusbar_new (void); +void thunar_statusbar_setup_event (ThunarStatusbar *statusbar, + GtkWidget *event_box); + G_END_DECLS; #endif /* !__THUNAR_STATUSBAR_H__ */ diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c index 27cd22f7..b27520d0 100644 --- a/thunar/thunar-window.c +++ b/thunar/thunar-window.c @@ -674,6 +674,7 @@ thunar_window_init (ThunarWindow *window) GtkWidget *infobar; GtkWidget *item; GtkWidget *button; + GtkWidget *event_box; gboolean last_menubar_visible; gchar *last_location_bar; gchar *last_side_pane; @@ -926,12 +927,16 @@ thunar_window_init (ThunarWindow *window) gtk_widget_hide (window->catfish_search_button); /* setup a new statusbar */ + event_box = gtk_event_box_new (); window->statusbar = thunar_statusbar_new (); gtk_widget_set_hexpand (window->statusbar, TRUE); - gtk_grid_attach (GTK_GRID (window->view_box), window->statusbar, 0, 4, 1, 1); + gtk_container_add (GTK_CONTAINER (event_box), window->statusbar); + gtk_grid_attach (GTK_GRID (window->view_box), event_box, 0, 4, 1, 1); if (last_statusbar_visible) gtk_widget_show (window->statusbar); + gtk_widget_show (event_box); + thunar_statusbar_setup_event (THUNAR_STATUSBAR (window->statusbar), event_box); if (G_LIKELY (window->view != NULL)) thunar_window_binding_create (window, window->view, "statusbar-text", window->statusbar, "text", G_BINDING_SYNC_CREATE); @@ -5016,3 +5021,11 @@ thunar_window_catfish_dialog_configure (GtkWidget *entry) g_free (display); } + + + +void +thunar_window_update_statusbar (ThunarWindow *window) +{ + thunar_standard_view_update_statusbar_text (THUNAR_STANDARD_VIEW (window->view)); +} diff --git a/thunar/thunar-window.h b/thunar/thunar-window.h index 1215325d..c8d3c027 100644 --- a/thunar/thunar-window.h +++ b/thunar/thunar-window.h @@ -146,6 +146,7 @@ void thunar_window_show_and_select_files (Thu void thunar_window_update_search (ThunarWindow *window); void thunar_window_action_cancel_search (ThunarWindow *window); void thunar_window_action_search (ThunarWindow *window); +void thunar_window_update_statusbar (ThunarWindow *window); G_END_DECLS; |