[Xfce4-commits] <thunar:nick/gseal+clean> Drop the button from the entry toolbar.

Nick Schermer noreply at xfce.org
Sun Sep 16 20:17:02 CEST 2012


Updating branch refs/heads/nick/gseal+clean
         to f8232fb70d02acdd9d9591153c883769060f5385 (commit)
       from d97c66f4396de4b5d9d6a4bed4f6e21d54f25860 (commit)

commit f8232fb70d02acdd9d9591153c883769060f5385
Author: Nick Schermer <nick at xfce.org>
Date:   Sun May 27 10:42:21 2012 +0200

    Drop the button from the entry toolbar.

 thunar/thunar-location-entry.c |  346 ----------------------------------------
 thunar/thunar-location-entry.h |    2 -
 2 files changed, 0 insertions(+), 348 deletions(-)

diff --git a/thunar/thunar-location-entry.c b/thunar/thunar-location-entry.c
index d64dbc0..4c27b87 100644
--- a/thunar/thunar-location-entry.c
+++ b/thunar/thunar-location-entry.c
@@ -76,10 +76,6 @@ static gboolean    thunar_location_entry_accept_focus          (ThunarLocationBa
 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_button_clicked        (GtkWidget                *button,
-                                                                ThunarLocationEntry      *location_entry);
-static void        thunar_location_entry_item_activated        (GtkWidget                *item,
-                                                                ThunarLocationEntry      *location_entry);
 
 
 
@@ -184,34 +180,13 @@ thunar_location_entry_location_bar_init (ThunarLocationBarIface *iface)
 static void
 thunar_location_entry_init (ThunarLocationEntry *location_entry)
 {
-  GtkSizeGroup *size_group;
-  GtkWidget    *button;
-  GtkWidget    *arrow;
-
   gtk_box_set_spacing (GTK_BOX (location_entry), 0);
-  gtk_container_set_border_width (GTK_CONTAINER (location_entry), 4);
 
   location_entry->path_entry = thunar_path_entry_new ();
   exo_binding_new (G_OBJECT (location_entry), "current-directory", G_OBJECT (location_entry->path_entry), "current-file");
   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);
-
-  button = gtk_toggle_button_new ();
-  g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (thunar_location_entry_button_clicked), location_entry);
-  g_signal_connect (G_OBJECT (button), "pressed", G_CALLBACK (thunar_location_entry_button_clicked), location_entry);
-  gtk_box_pack_start (GTK_BOX (location_entry), button, FALSE, FALSE, 0);
-  gtk_widget_show (button);
-
-  arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
-  gtk_container_add (GTK_CONTAINER (button), arrow);
-  gtk_widget_show (arrow);
-
-  /* make sure the entry and the button request the same height */
-  size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
-  gtk_size_group_add_widget (size_group, location_entry->path_entry);
-  gtk_size_group_add_widget (size_group, button);
-  g_object_unref (G_OBJECT (size_group));
 }
 
 
@@ -426,8 +401,6 @@ thunar_location_entry_poke_file_finish (ThunarBrowser *browser,
 
 
 
-
-
 static void
 thunar_location_entry_activate (GtkWidget           *path_entry,
                                 ThunarLocationEntry *location_entry)
@@ -459,322 +432,3 @@ thunar_location_entry_reset (ThunarLocationEntry *location_entry)
 
   return TRUE;
 }
-
-
-
-static void
-menu_position (GtkMenu  *menu,
-               gint     *x,
-               gint     *y,
-               gboolean *push_in,
-               gpointer  entry)
-{
-  GtkRequisition entry_request;
-  GtkRequisition menu_request;
-  GdkRectangle   geometry;
-  GdkScreen     *screen;
-  GtkWidget     *toplevel = gtk_widget_get_toplevel (entry);
-  gint           monitor;
-  gint           x0;
-  gint           y0;
-
-  gtk_widget_translate_coordinates (GTK_WIDGET (entry), toplevel, 0, 0, &x0, &y0);
-
-  gtk_widget_size_request (GTK_WIDGET (entry), &entry_request);
-  gtk_widget_size_request (GTK_WIDGET (menu), &menu_request);
-
-  gdk_window_get_position (GTK_WIDGET (entry)->window, x, y);
-
-  *x += x0 + gtk_container_get_border_width (GTK_CONTAINER (entry));
-  *y += y0 + (entry_request.height - gtk_container_get_border_width (GTK_CONTAINER (entry)));
-
-  /* verify the the menu is on-screen */
-  screen = gtk_widget_get_screen (GTK_WIDGET (entry));
-  if (G_LIKELY (screen != NULL))
-    {
-      monitor = gdk_screen_get_monitor_at_point (screen, *x, *y);
-      gdk_screen_get_monitor_geometry (screen, monitor, &geometry);
-      if (*y + menu_request.height > geometry.y + geometry.height)
-        *y -= menu_request.height - entry_request.height;
-    }
-
-  *push_in = TRUE;
-}
-
-
-
-static void
-thunar_location_entry_button_clicked (GtkWidget           *button,
-                                      ThunarLocationEntry *location_entry)
-{
-  ThunarShortcutsModel *model;
-  ThunarIconFactory    *icon_factory;
-  GtkIconTheme         *icon_theme;
-  GtkTreeIter           iter;
-  ThunarFile           *file;
-  GtkWidget            *image;
-  GtkWidget            *item;
-  GtkWidget            *menu;
-  GdkPixbuf            *icon;
-  GVolume              *volume;
-  GIcon                *volume_icon;
-  gchar                *volume_name;
-  gint                  icon_size;
-  gint                  width;
-
-  _thunar_return_if_fail (THUNAR_IS_LOCATION_ENTRY (location_entry));
-  _thunar_return_if_fail (GTK_IS_TOGGLE_BUTTON (button));
-
-  /* allocate a new menu */
-  menu = gtk_menu_new ();
-
-  /* determine the icon theme and factory */
-  icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (button));
-  icon_factory = thunar_icon_factory_get_for_icon_theme (icon_theme);
-
-  /* determine the icon size for menus */
-  gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &icon_size, &icon_size);
-
-  /* load the menu items from the shortcuts model */
-  model = thunar_shortcuts_model_get_default ();
-  if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter))
-    {
-      do
-        {
-          /* determine the file and volume for the item */
-          gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
-                              THUNAR_SHORTCUTS_MODEL_COLUMN_FILE, &file,
-                              THUNAR_SHORTCUTS_MODEL_COLUMN_VOLUME, &volume,
-                              -1);
-
-          /* check if we have a separator here */
-          if (G_UNLIKELY (file == NULL && volume == NULL))
-            {
-              /* generate a separator the menu */
-              item = gtk_separator_menu_item_new ();
-            }
-          else if (G_UNLIKELY (volume != NULL))
-            {
-              /* generate an image menu item for the volume */
-              volume_name = g_volume_get_name (volume);
-              item = gtk_image_menu_item_new_with_label (volume_name);
-              g_free (volume_name);
-
-              /* generate an image for the menu item */
-              volume_icon = g_volume_get_icon (volume);
-              image = gtk_image_new_from_gicon (volume_icon, GTK_ICON_SIZE_MENU);
-              g_object_unref (volume_icon);
-              gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
-              gtk_widget_show (image);
-            }
-          else
-            {
-              /* generate an image menu item for the file */
-              item = gtk_image_menu_item_new_with_label (thunar_file_get_display_name (file));
-
-              /* load the icon for the file and generate the image for the menu item */
-              icon = thunar_icon_factory_load_file_icon (icon_factory, file, THUNAR_FILE_ICON_STATE_DEFAULT, icon_size);
-              image = gtk_image_new_from_pixbuf (icon);
-              gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
-              g_object_unref (icon);
-              gtk_widget_show (image);
-            }
-
-          /* connect the file and volume to the item */
-          g_object_set_data_full (G_OBJECT (item), I_("volume"), volume, g_object_unref);
-          g_object_set_data_full (G_OBJECT (item), I_("thunar-file"), file, g_object_unref);
-
-          /* append the new item to the menu */
-          g_signal_connect (item, "activate", G_CALLBACK (thunar_location_entry_item_activated), location_entry);
-          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-          gtk_widget_show (item);
-        }
-      while (gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter));
-    }
-
-  /* make sure the menu has atleast the same width as the location entry */
-  width = GTK_WIDGET (location_entry)->allocation.width - 2 * gtk_container_get_border_width (GTK_CONTAINER (location_entry));
-  if (G_LIKELY (menu->allocation.width < width))
-    gtk_widget_set_size_request (menu, width, -1);
-
-  /* select the first visible or selectable item in the menu */
-  gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), TRUE);
-
-  /* enable the button, making sure that we do not recurse on the "clicked" signal by temporarily blocking the handler */
-  g_signal_handlers_block_by_func (G_OBJECT (button), G_CALLBACK (thunar_location_entry_button_clicked), location_entry);
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
-  g_signal_handlers_unblock_by_func (G_OBJECT (button), G_CALLBACK (thunar_location_entry_button_clicked), location_entry);
-
-  /* run the menu, taking ownership over the menu object */
-  thunar_gtk_menu_run (GTK_MENU (menu), button, menu_position, location_entry, 1, gtk_get_current_event_time ());
-
-  /* disable the button, making sure that we do not recurse on the "clicked" signal by temporarily blocking the handler */
-  g_signal_handlers_block_by_func (G_OBJECT (button), G_CALLBACK (thunar_location_entry_button_clicked), location_entry);
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE);
-  g_signal_handlers_unblock_by_func (G_OBJECT (button), G_CALLBACK (thunar_location_entry_button_clicked), location_entry);
-
-  /* clean up */
-  g_object_unref (G_OBJECT (icon_factory));
-  g_object_unref (G_OBJECT (model));
-}
-
-
-
-static void
-thunar_location_entry_mount_finish (GObject      *object,
-                                    GAsyncResult *result,
-                                    gpointer      user_data)
-{
-  ThunarLocationEntry *location_entry = THUNAR_LOCATION_ENTRY (user_data);
-  ThunarFile          *file = NULL;
-  GtkWidget           *window;
-  GVolume             *volume = G_VOLUME (object);
-  GError              *error = NULL;
-  GMount              *mount;
-  GFile               *mount_point;
-  gchar               *volume_name;
-
-  _thunar_return_if_fail (G_IS_VOLUME (object));
-  _thunar_return_if_fail (THUNAR_IS_LOCATION_ENTRY (user_data));
-
-  if (!g_volume_mount_finish (volume, result, &error))
-    {
-      /* determine the toplevel window */
-      window = gtk_widget_get_toplevel (GTK_WIDGET (location_entry));
-
-      volume_name = g_volume_get_name (volume);
-      thunar_dialogs_show_error (window, error, _("Failed to mount \"%s\""), volume_name);
-      g_free (volume_name);
-    }
-  else
-    {
-      mount = g_volume_get_mount (volume);
-      if (mount != NULL)
-        {
-          mount_point = g_mount_get_root (mount);
-          file = thunar_file_get (mount_point, NULL);
-          g_object_unref (mount_point);
-
-          /* check if we have a file object now */
-          if (G_LIKELY (file != NULL))
-            {
-              /* make sure that this is actually a directory */
-              if (thunar_file_is_directory (file))
-                {
-                  /* open the new directory */
-                  thunar_navigator_change_directory (THUNAR_NAVIGATOR (location_entry), 
-                                                     file);
-                }
-
-              /* cleanup */
-              g_object_unref (file);
-            }
-
-          g_object_unref (mount);
-        }
-    }
-
-  g_object_unref (location_entry);
-}
-
-
-
-static void
-thunar_location_entry_item_activated (GtkWidget           *item,
-                                      ThunarLocationEntry *location_entry)
-{
-  GMountOperation *mount_operation;
-  ThunarFile      *file = NULL;
-  GtkWidget       *window;
-  GVolume         *volume;
-  GError          *error = NULL;
-  GMount          *mount;
-  GFile           *mount_point;
-  gchar           *volume_name;
-
-  _thunar_return_if_fail (GTK_IS_MENU_ITEM (item));
-  _thunar_return_if_fail (THUNAR_IS_LOCATION_ENTRY (location_entry));
-
-  /* determine the toplevel window */
-  window = gtk_widget_get_toplevel (GTK_WIDGET (location_entry));
-
-  /* check if the item corresponds to a volume */
-  volume = g_object_get_data (G_OBJECT (item), "volume");
-  if (G_UNLIKELY (volume != NULL))
-    {
-      /* check if the volume isn't already mounted */
-      if (G_LIKELY (!thunar_g_volume_is_mounted (volume)))
-        {
-          mount_operation = gtk_mount_operation_new (GTK_WINDOW (window));
-
-          g_volume_mount (volume, G_MOUNT_MOUNT_NONE, mount_operation, NULL,
-                          thunar_location_entry_mount_finish, 
-                          g_object_ref (location_entry));
-
-          g_object_unref (mount_operation);
-        }
-      else
-        {
-          mount = g_volume_get_mount (volume);
-          if (mount != NULL)
-            {
-              /* try to determine the mount point of the volume */
-              mount_point = g_mount_get_root (mount);
-              file = thunar_file_get (mount_point, &error);
-              g_object_unref (mount_point);
-              
-              if (G_UNLIKELY (file == NULL))
-                {
-                  /* display an error dialog to inform the user */
-                  volume_name = g_volume_get_name (volume);
-                  thunar_dialogs_show_error (window, error, 
-                                             _("Failed to determine the mount point of \"%s\""), 
-                                             volume_name);
-                  g_free (volume_name);
-                  g_error_free (error);
-                }
-
-              g_object_unref (mount);
-            }
-        }
-    }
-  else
-    {
-      /* determine the file from the item */
-      file = g_object_get_data (G_OBJECT (item), "thunar-file");
-      if (G_LIKELY (file != NULL))
-        g_object_ref (G_OBJECT (file));
-    }
-
-  /* check if we have a file object now */
-  if (G_LIKELY (file != NULL))
-    {
-      /* make sure that this is actually a directory */
-      if (thunar_file_is_directory (file))
-        {
-          /* open the new directory */
-          thunar_navigator_change_directory (THUNAR_NAVIGATOR (location_entry), file);
-        }
-
-      /* cleanup */
-      g_object_unref (G_OBJECT (file));
-    }
-}
-
-
-
-/**
- * thunar_location_entry_new:
- *
- * Allocates a new #ThunarLocationEntry instance.
- *
- * Return value: the newly allocated #ThunarLocationEntry.
- **/
-GtkWidget*
-thunar_location_entry_new (void)
-{
-  return g_object_new (THUNAR_TYPE_LOCATION_ENTRY, NULL);
-}
-
-
-
diff --git a/thunar/thunar-location-entry.h b/thunar/thunar-location-entry.h
index f892f01..f4f20ff 100644
--- a/thunar/thunar-location-entry.h
+++ b/thunar/thunar-location-entry.h
@@ -36,8 +36,6 @@ typedef struct _ThunarLocationEntry      ThunarLocationEntry;
 
 GType      thunar_location_entry_get_type (void) G_GNUC_CONST;
 
-GtkWidget *thunar_location_entry_new      (void);
-
 G_END_DECLS;
 
 #endif /* !__THUNAR_LOCATION_ENTRY_H__ */


More information about the Xfce4-commits mailing list