diff options
-rw-r--r-- | gtk/gtkfilechoosercell.c | 13 | ||||
-rw-r--r-- | gtk/gtkfilechoosercellprivate.h | 2 | ||||
-rw-r--r-- | gtk/gtkfilechooserwidget.c | 25 |
3 files changed, 27 insertions, 13 deletions
diff --git a/gtk/gtkfilechoosercell.c b/gtk/gtkfilechoosercell.c index ee97002d6c..090d17d1ee 100644 --- a/gtk/gtkfilechoosercell.c +++ b/gtk/gtkfilechoosercell.c @@ -39,6 +39,8 @@ struct _GtkFileChooserCell GFileInfo *item; GtkColumnViewCell *list_item; + guint type_format; + gboolean show_time; }; @@ -59,6 +61,12 @@ enum #define ICON_SIZE 16 +guint +gtk_file_chooser_cell_get_type_format (GtkFileChooserCell *self) +{ + return self->type_format; +} + static void popup_menu (GtkFileChooserCell *self, double x, @@ -167,6 +175,11 @@ gtk_file_chooser_cell_init (GtkFileChooserCell *self) { GtkGesture *gesture; GtkDragSource *drag_source; + GSettings *settings; + + settings = _gtk_file_chooser_get_settings_for_widget (GTK_WIDGET (self)); + + self->type_format = g_settings_get_enum (settings, SETTINGS_KEY_TYPE_FORMAT); gesture = gtk_gesture_click_new (); gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), GDK_BUTTON_SECONDARY); diff --git a/gtk/gtkfilechoosercellprivate.h b/gtk/gtkfilechoosercellprivate.h index 55c52e9c46..dfe9792e7c 100644 --- a/gtk/gtkfilechoosercellprivate.h +++ b/gtk/gtkfilechoosercellprivate.h @@ -31,5 +31,7 @@ G_DECLARE_FINAL_TYPE (GtkFileChooserCell, gtk_file_chooser_cell, GTK, FILE_CHOOS GtkFileChooserCell * gtk_file_chooser_cell_new (void); +guint gtk_file_chooser_cell_get_type_format (GtkFileChooserCell *self); + G_END_DECLS diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c index ab368fc926..92ec6c7ad2 100644 --- a/gtk/gtkfilechooserwidget.c +++ b/gtk/gtkfilechooserwidget.c @@ -505,8 +505,8 @@ static void set_model_filter (GtkFileChooserWidget *impl, static void switch_to_home_dir (GtkFileChooserWidget *impl); static void set_show_hidden (GtkFileChooserWidget *impl, gboolean show_hidden); -static char * get_type_information (GtkFileChooserWidget *impl, - GFileInfo *info); +static char * get_type_information (TypeFormat type_format, + GFileInfo *info); static char * my_g_format_date_for_display (GtkFileChooserWidget *impl, glong secs); static char * my_g_format_time_for_display (GtkFileChooserWidget *impl, @@ -2011,17 +2011,17 @@ static char * column_view_get_file_type (GtkColumnViewCell *cell, GFileInfo *info) { - GtkFileChooserWidget *impl; + GtkFileChooserCell *child; if (!info || _gtk_file_info_consider_as_directory (info)) return NULL; - impl = GTK_FILE_CHOOSER_WIDGET (gtk_widget_get_ancestor (gtk_list_item_get_child (item), - GTK_TYPE_FILE_CHOOSER_WIDGET)); - if (!impl) + child = GTK_FILE_CHOOSER_CELL (gtk_column_view_cell_get_child (cell)); + + if (!child) return NULL; - return get_type_information (impl, info); + return get_type_information (gtk_file_chooser_cell_get_type_format (child), info); } static void @@ -3284,7 +3284,6 @@ settings_save (GtkFileChooserWidget *impl) g_settings_set_int (settings, SETTINGS_KEY_SIDEBAR_WIDTH, gtk_paned_get_position (GTK_PANED (impl->browse_widgets_hpaned))); g_settings_set_enum (settings, SETTINGS_KEY_DATE_FORMAT, impl->show_time ? DATE_FORMAT_WITH_TIME : DATE_FORMAT_REGULAR); - g_settings_set_enum (settings, SETTINGS_KEY_TYPE_FORMAT, impl->type_format); g_settings_set_enum (settings, SETTINGS_KEY_VIEW_TYPE, impl->view_type); /* Now apply the settings */ @@ -3947,8 +3946,8 @@ get_category_from_content_type (const char *content_type) } static char * -get_type_information (GtkFileChooserWidget *impl, - GFileInfo *info) +get_type_information (TypeFormat type_format, + GFileInfo *info) { const char *content_type; char *mime_type; @@ -3960,7 +3959,7 @@ get_type_information (GtkFileChooserWidget *impl, if (!content_type) goto end; - switch (impl->type_format) + switch (type_format) { case TYPE_FORMAT_MIME: mime_type = g_content_type_get_mime_type (content_type); @@ -7085,8 +7084,8 @@ type_sort_func (gconstpointer a, GtkOrdering result; /* FIXME: use sortkeys for these */ - key_a = get_type_information (impl, (GFileInfo *)a); - key_b = get_type_information (impl, (GFileInfo *)b); + key_a = get_type_information (impl->type_format, (GFileInfo *)a); + key_b = get_type_information (impl->type_format, (GFileInfo *)b); result = g_strcmp0 (key_a, key_b); |