Revert "filechoosercell: Store type_format in filechoosercell"
authorCorey Berla <corey@berla.me>
Fri, 21 Apr 2023 03:18:58 +0000 (20:18 -0700)
committerCorey Berla <corey@berla.me>
Fri, 21 Apr 2023 15:14:14 +0000 (08:14 -0700)
This reverts commit dd407dab000dc4de7d078c6270c93d303a1c18c6.

This fix was incomplete, the actual fix is to use signal factory.

gtk/gtkfilechoosercell.c
gtk/gtkfilechoosercellprivate.h
gtk/gtkfilechooserwidget.c

index 3098d7a2e9a95741b55b00f60d4b07e385017037..873b8970eb79971123d9019936dfb564e28b1bac 100644 (file)
@@ -41,7 +41,6 @@ struct _GtkFileChooserCell
   GtkColumnViewCell *list_item;
 
   gboolean date_column;
-  guint type_format;
 
   gboolean show_time;
 };
@@ -64,12 +63,6 @@ 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,
@@ -195,11 +188,6 @@ 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);
index dfe9792e7cf63953a3bd2069d78d8de1c7a15420..55c52e9c46d8ff8c5f5923bde44202a5302619ec 100644 (file)
@@ -31,7 +31,5 @@ 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
 
index 51607dfe873b34540407cdd6c57d48604868b8a9..8c8fcbb7c5d66e6bcd21ee94b1b7a6316f83180e 100644 (file)
@@ -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         (TypeFormat type_format,
-                                              GFileInfo *info);
+static char *   get_type_information         (GtkFileChooserWidget *impl,
+                                              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)
 {
-  GtkFileChooserCell *child;
+  GtkFileChooserWidget *impl;
 
   if (!info || _gtk_file_info_consider_as_directory (info))
     return NULL;
 
-  child = GTK_FILE_CHOOSER_CELL (gtk_column_view_cell_get_child (cell));
-
-  if (!child)
+  impl = GTK_FILE_CHOOSER_WIDGET (gtk_widget_get_ancestor (gtk_column_view_cell_get_child (cell),
+                                                           GTK_TYPE_FILE_CHOOSER_WIDGET));
+  if (!impl)
     return NULL;
 
-  return get_type_information (gtk_file_chooser_cell_get_type_format (child), info);
+  return get_type_information (impl, info);
 }
 
 static void
@@ -3284,6 +3284,7 @@ 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 */
@@ -3946,8 +3947,8 @@ get_category_from_content_type (const char *content_type)
 }
 
 static char *
-get_type_information (TypeFormat type_format,
-                      GFileInfo *info)
+get_type_information (GtkFileChooserWidget *impl,
+                      GFileInfo            *info)
 {
   const char *content_type;
   char *mime_type;
@@ -3959,7 +3960,7 @@ get_type_information (TypeFormat type_format,
   if (!content_type)
     goto end;
 
-  switch (type_format)
+  switch (impl->type_format)
     {
     case TYPE_FORMAT_MIME:
       mime_type = g_content_type_get_mime_type (content_type);
@@ -7082,8 +7083,8 @@ type_sort_func (gconstpointer a,
   GtkOrdering result;
 
   /* FIXME: use sortkeys for these */
-  key_a = get_type_information (impl->type_format, (GFileInfo *)a);
-  key_b = get_type_information (impl->type_format, (GFileInfo *)b);
+  key_a = get_type_information (impl, (GFileInfo *)a);
+  key_b = get_type_information (impl, (GFileInfo *)b);
 
   result = g_strcmp0 (key_a, key_b);