[Xfce4-commits] [xfce/thunar] 01/01: Make change window icon opt-out (Bug #16501)

noreply at xfce.org noreply at xfce.org
Sun Mar 15 23:35:05 CET 2020


This is an automated email from the git hooks/post-receive script.

a   n   d   r   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/thunar.

commit e3b560e1866ae74b9a8e9de6146424c59f0b937b
Author: Andre Miranda <andreldm at xfce.org>
Date:   Sun Mar 15 19:32:03 2020 -0300

    Make change window icon opt-out (Bug #16501)
    
    This change also includes a UI toggle for this option.
---
 thunar/thunar-preferences-dialog.c | 29 ++++++++++++++++++++++++++---
 thunar/thunar-preferences.c        |  2 +-
 thunar/thunar-window.c             | 38 +++++++++++++++++++++++++++-----------
 3 files changed, 54 insertions(+), 15 deletions(-)

diff --git a/thunar/thunar-preferences-dialog.c b/thunar/thunar-preferences-dialog.c
index dc12bec..a87d10d 100644
--- a/thunar/thunar-preferences-dialog.c
+++ b/thunar/thunar-preferences-dialog.c
@@ -678,19 +678,42 @@ thunar_preferences_dialog_init (ThunarPreferencesDialog *dialog)
 
       grid = gtk_grid_new ();
       gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
-      gtk_grid_set_row_spacing (GTK_GRID (grid), 2);
-      gtk_container_set_border_width (GTK_CONTAINER (grid), 12);
+      gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
+      gtk_widget_set_margin_top (GTK_WIDGET (grid), 6);
+      gtk_widget_set_margin_start (GTK_WIDGET (grid), 12);
       gtk_container_add (GTK_CONTAINER (frame), grid);
       gtk_widget_show (grid);
 
       button = gtk_check_button_new_with_mnemonic (_("Show action to permanently delete files and folders"));
       exo_mutual_binding_new (G_OBJECT (dialog->preferences), "misc-show-delete-action", G_OBJECT (button), "active");
       gtk_widget_set_tooltip_text (button, _("Select this option to show the 'Delete' action in the context menu"));
-      gtk_widget_set_hexpand (button, TRUE);
       gtk_grid_attach (GTK_GRID (grid), button, 0, 0, 1, 1);
       gtk_widget_show (button);
     }
 
+  frame = g_object_new (GTK_TYPE_FRAME, "border-width", 0, "shadow-type", GTK_SHADOW_NONE, NULL);
+  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
+  gtk_widget_show (frame);
+
+  label = gtk_label_new (_("Window icon"));
+  gtk_label_set_attributes (GTK_LABEL (label), thunar_pango_attr_list_bold ());
+  gtk_frame_set_label_widget (GTK_FRAME (frame), label);
+  gtk_widget_show (label);
+
+  grid = gtk_grid_new ();
+  gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
+  gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
+  gtk_widget_set_margin_top (GTK_WIDGET (grid), 6);
+  gtk_widget_set_margin_start (GTK_WIDGET (grid), 12);
+  gtk_container_add (GTK_CONTAINER (frame), grid);
+  gtk_widget_show (grid);
+
+  button = gtk_check_button_new_with_mnemonic (_("Use current folder icon"));
+  exo_mutual_binding_new (G_OBJECT (dialog->preferences), "misc-change-window-icon", G_OBJECT (button), "active");
+  gtk_widget_set_tooltip_text (button, _("Select this option to use the current folder icon as window icon"));
+  gtk_grid_attach (GTK_GRID (grid), button, 0, 0, 1, 1);
+  gtk_widget_show (button);
+
   /*
      Advanced
    */
diff --git a/thunar/thunar-preferences.c b/thunar/thunar-preferences.c
index 78c9969..732d9a2 100644
--- a/thunar/thunar-preferences.c
+++ b/thunar/thunar-preferences.c
@@ -773,7 +773,7 @@ thunar_preferences_class_init (ThunarPreferencesClass *klass)
       g_param_spec_boolean ("misc-change-window-icon",
                             "MiscChangeWindowIcon",
                             NULL,
-                            FALSE,
+                            TRUE,
                             EXO_PARAM_READWRITE);
 
   /**
diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c
index 0c46c38..71ffae0 100644
--- a/thunar/thunar-window.c
+++ b/thunar/thunar-window.c
@@ -255,6 +255,7 @@ static gboolean thunar_window_save_geometry_timer         (gpointer
 static void     thunar_window_save_geometry_timer_destroy (gpointer                user_data);
 static void     thunar_window_set_zoom_level              (ThunarWindow           *window,
                                                            ThunarZoomLevel         zoom_level);
+static void     thunar_window_update_window_icon          (ThunarWindow           *window);
 
 
 
@@ -962,6 +963,9 @@ G_GNUC_END_IGNORE_DEPRECATIONS
   g_signal_connect_object (G_OBJECT (window->preferences), "notify::last-location-bar", G_CALLBACK (thunar_window_update_location_bar_visible), window, G_CONNECT_SWAPPED);
   thunar_window_update_location_bar_visible (window);
 
+  /* update window icon whenever preferences change */
+  g_signal_connect_object (G_OBJECT (window->preferences), "notify::misc-change-window-icon", G_CALLBACK (thunar_window_update_window_icon), window, G_CONNECT_SWAPPED);
+
   /* determine the selected side pane (FIXME: Should probably be last-shortcuts-visible and last-tree-visible preferences) */
   if (exo_str_is_equal (last_side_pane, g_type_name (THUNAR_TYPE_SHORTCUTS_PANE)))
     type = THUNAR_TYPE_SHORTCUTS_PANE;
@@ -2010,6 +2014,28 @@ thunar_window_update_location_bar_visible (ThunarWindow *window)
 
 
 static void
+thunar_window_update_window_icon (ThunarWindow *window)
+{
+  gboolean      change_window_icon;
+  GtkIconTheme *icon_theme;
+  const gchar  *icon_name = "folder";
+
+  g_object_get (window->preferences, "misc-change-window-icon", &change_window_icon, NULL);
+
+  if (change_window_icon)
+    {
+      icon_theme = gtk_icon_theme_get_for_screen (gtk_window_get_screen (GTK_WINDOW (window)));
+      icon_name = thunar_file_get_icon_name (window->current_directory,
+                                             THUNAR_FILE_ICON_STATE_DEFAULT,
+                                             icon_theme);
+    }
+
+  gtk_window_set_icon_name (GTK_WINDOW (window), icon_name);
+}
+
+
+
+static void
 thunar_window_handle_reload_request (ThunarWindow *window)
 {
   gboolean result;
@@ -3421,12 +3447,9 @@ static void
 thunar_window_current_directory_changed (ThunarFile   *current_directory,
                                          ThunarWindow *window)
 {
-  GtkIconTheme *icon_theme;
   GtkAction    *action;
-  const gchar  *icon_name;
   gchar        *title;
   gboolean      show_full_path;
-  gboolean      change_window_icon;
   gchar        *parse_name = NULL;
   const gchar  *name;
 
@@ -3455,14 +3478,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
   g_free (parse_name);
 
   /* set window icon */
-  icon_theme = gtk_icon_theme_get_for_screen (gtk_window_get_screen (GTK_WINDOW (window)));
-  icon_name = thunar_file_get_icon_name (current_directory,
-                                         THUNAR_FILE_ICON_STATE_DEFAULT,
-                                         icon_theme);
-
-  g_object_get (G_OBJECT (window->preferences), "misc-change-window-icon", &change_window_icon, NULL);
-  if (G_UNLIKELY (change_window_icon))
-    gtk_window_set_icon_name (GTK_WINDOW (window), icon_name);
+  thunar_window_update_window_icon (window);
 }
 
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list