[Xfce4-commits] <thunar:master> Put reload button in location entry.

Nick Schermer noreply at xfce.org
Tue Oct 23 21:44:01 CEST 2012


Updating branch refs/heads/master
         to f828a952f77e842ce4ccb5e5773d9dbe1d730422 (commit)
       from b63fd6bcc745744ff2f3d89f5da9ee820b0b3111 (commit)

commit f828a952f77e842ce4ccb5e5773d9dbe1d730422
Author: Nick Schermer <nick at xfce.org>
Date:   Tue Oct 23 21:39:54 2012 +0200

    Put reload button in location entry.
    
    Gives some more space on the toolbar and reload is
    not requently used anyway.

 thunar/thunar-location-entry.c |  100 ++++++++++++++++++++++++++++++---------
 thunar/thunar-window-ui.xml    |    1 -
 2 files changed, 77 insertions(+), 24 deletions(-)

diff --git a/thunar/thunar-location-entry.c b/thunar/thunar-location-entry.c
index 4c27b87..d9f7be4 100644
--- a/thunar/thunar-location-entry.c
+++ b/thunar/thunar-location-entry.c
@@ -56,26 +56,32 @@ enum
 
 
 
-static void        thunar_location_entry_component_init        (ThunarComponentIface     *iface);
-static void        thunar_location_entry_navigator_init        (ThunarNavigatorIface     *iface);
-static void        thunar_location_entry_location_bar_init     (ThunarLocationBarIface   *iface);
-static void        thunar_location_entry_finalize              (GObject                  *object);
-static void        thunar_location_entry_get_property          (GObject                  *object,
-                                                                guint                     prop_id,
-                                                                GValue                   *value,
-                                                                GParamSpec               *pspec);
-static void        thunar_location_entry_set_property          (GObject                  *object,
-                                                                guint                     prop_id,
-                                                                const GValue             *value,
-                                                                GParamSpec               *pspec);
-static ThunarFile *thunar_location_entry_get_current_directory (ThunarNavigator          *navigator);
-static void        thunar_location_entry_set_current_directory (ThunarNavigator          *navigator,
-                                                                ThunarFile               *current_directory);
-static gboolean    thunar_location_entry_accept_focus          (ThunarLocationBar        *location_bar,
-                                                                const gchar              *initial_text);
-static void        thunar_location_entry_activate              (GtkWidget                *path_entry,
-                                                                ThunarLocationEntry      *location_entry);
-static gboolean    thunar_location_entry_reset                 (ThunarLocationEntry      *location_entry);
+static void        thunar_location_entry_component_init           (ThunarComponentIface     *iface);
+static void        thunar_location_entry_navigator_init           (ThunarNavigatorIface     *iface);
+static void        thunar_location_entry_location_bar_init        (ThunarLocationBarIface   *iface);
+static void        thunar_location_entry_finalize                 (GObject                  *object);
+static void        thunar_location_entry_get_property             (GObject                  *object,
+                                                                   guint                     prop_id,
+                                                                   GValue                   *value,
+                                                                   GParamSpec               *pspec);
+static void        thunar_location_entry_set_property             (GObject                  *object,
+                                                                   guint                     prop_id,
+                                                                   const GValue             *value,
+                                                                   GParamSpec               *pspec);
+static ThunarFile *thunar_location_entry_get_current_directory    (ThunarNavigator          *navigator);
+static void        thunar_location_entry_set_current_directory    (ThunarNavigator          *navigator,
+                                                                   ThunarFile               *current_directory);
+static void        thunar_location_entry_component_set_ui_manager (ThunarComponent          *component,
+                                                                   GtkUIManager             *ui_manager);
+static gboolean    thunar_location_entry_accept_focus             (ThunarLocationBar        *location_bar,
+                                                                   const gchar              *initial_text);
+static void        thunar_location_entry_activate                 (GtkWidget                *path_entry,
+                                                                   ThunarLocationEntry      *location_entry);
+static gboolean    thunar_location_entry_reset                    (ThunarLocationEntry      *location_entry);
+static void        thunar_location_entry_reload                   (GtkEntry                 *entry,
+                                                                   GtkEntryIconPosition      icon_pos,
+                                                                   GdkEvent                 *event,
+                                                                   ThunarLocationEntry      *location_entry);
 
 
 
@@ -91,8 +97,9 @@ struct _ThunarLocationEntry
 {
   GtkHBox __parent__;
 
-  ThunarFile *current_directory;
-  GtkWidget  *path_entry;
+  ThunarFile   *current_directory;
+  GtkWidget    *path_entry;
+  GtkUIManager *ui_manager;
 };
 
 
@@ -154,7 +161,7 @@ thunar_location_entry_component_init (ThunarComponentIface *iface)
   iface->get_selected_files = (gpointer) exo_noop_null;
   iface->set_selected_files = (gpointer) exo_noop;
   iface->get_ui_manager = (gpointer) exo_noop_null;
-  iface->set_ui_manager = (gpointer) exo_noop;
+  iface->set_ui_manager = thunar_location_entry_component_set_ui_manager;
 }
 
 
@@ -187,6 +194,14 @@ thunar_location_entry_init (ThunarLocationEntry *location_entry)
   g_signal_connect_after (G_OBJECT (location_entry->path_entry), "activate", G_CALLBACK (thunar_location_entry_activate), location_entry);
   gtk_box_pack_start (GTK_BOX (location_entry), location_entry->path_entry, TRUE, TRUE, 0);
   gtk_widget_show (location_entry->path_entry);
+
+  /* put reload button in entry */
+  gtk_entry_set_icon_from_icon_name (GTK_ENTRY (location_entry->path_entry),
+                                     GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_REFRESH);
+  gtk_entry_set_icon_tooltip_text (GTK_ENTRY (location_entry->path_entry),
+                                   GTK_ENTRY_ICON_SECONDARY, _("Reload the current folder"));
+  g_signal_connect (G_OBJECT (location_entry->path_entry), "icon-release",
+                    G_CALLBACK (thunar_location_entry_reload), location_entry);
 }
 
 
@@ -297,6 +312,24 @@ thunar_location_entry_set_current_directory (ThunarNavigator *navigator,
 
 
 
+static void
+thunar_location_entry_component_set_ui_manager (ThunarComponent *component,
+                                                GtkUIManager    *ui_manager)
+{
+  ThunarLocationEntry *location_entry = THUNAR_LOCATION_ENTRY (component);
+
+  if (location_entry->ui_manager != NULL)
+    {
+      g_object_unref (location_entry->ui_manager);
+      location_entry->ui_manager = NULL;
+    }
+
+  if (ui_manager != NULL)
+    location_entry->ui_manager = g_object_ref (ui_manager);
+}
+
+
+
 static gboolean
 thunar_location_entry_accept_focus (ThunarLocationBar *location_bar,
                                     const gchar       *initial_text)
@@ -432,3 +465,24 @@ thunar_location_entry_reset (ThunarLocationEntry *location_entry)
 
   return TRUE;
 }
+
+
+
+static void
+thunar_location_entry_reload (GtkEntry            *entry,
+                              GtkEntryIconPosition icon_pos,
+                              GdkEvent            *event,
+                              ThunarLocationEntry *location_entry)
+{
+  GtkAction *action;
+
+  _thunar_return_if_fail (THUNAR_IS_LOCATION_ENTRY (location_entry));
+
+  if (icon_pos == GTK_ENTRY_ICON_SECONDARY
+      && location_entry->ui_manager != NULL)
+    {
+      action = gtk_ui_manager_get_action (location_entry->ui_manager, "/main-menu/view-menu/reload");
+      _thunar_return_if_fail (GTK_IS_ACTION (action));
+      gtk_action_activate (action);
+    }
+}
diff --git a/thunar/thunar-window-ui.xml b/thunar/thunar-window-ui.xml
index 017c8d6..e37b493 100644
--- a/thunar/thunar-window-ui.xml
+++ b/thunar/thunar-window-ui.xml
@@ -114,7 +114,6 @@
     <toolitem action="back" />
     <toolitem action="forward" />
     <toolitem action="open-parent" />
-    <toolitem action="reload" />
     <separator />
     <toolitem action="open-home" />
   </toolbar>


More information about the Xfce4-commits mailing list