2006-11-08 19:46:56 +00:00
|
|
|
/* -*- Mode: C; c-file-style: "gnu"; tab-width: 8 -*- */
|
2004-09-26 05:47:11 +00:00
|
|
|
/* gtkpathbar.c
|
2004-02-20 01:10:28 +00:00
|
|
|
* Copyright (C) 2004 Red Hat, Inc., Jonathan Blandford <jrb@gnome.org>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2004-02-20 01:10:28 +00:00
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
2010-09-09 13:35:58 +00:00
|
|
|
|
2004-02-20 01:10:28 +00:00
|
|
|
#include "gtkpathbar.h"
|
2010-09-09 13:35:58 +00:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2012-03-03 18:22:22 +00:00
|
|
|
#include "gtkbox.h"
|
2016-01-26 13:13:18 +00:00
|
|
|
#include "gtkcssnodeprivate.h"
|
2004-11-20 04:52:57 +00:00
|
|
|
#include "gtkdnd.h"
|
2015-11-22 04:26:08 +00:00
|
|
|
#include "gtkdragsource.h"
|
2012-03-03 18:22:22 +00:00
|
|
|
#include "gtkicontheme.h"
|
2004-03-08 09:56:34 +00:00
|
|
|
#include "gtkimage.h"
|
|
|
|
#include "gtkintl.h"
|
2004-02-20 01:10:28 +00:00
|
|
|
#include "gtklabel.h"
|
2004-02-23 07:11:31 +00:00
|
|
|
#include "gtkmain.h"
|
|
|
|
#include "gtkmarshalers.h"
|
2012-03-03 18:22:22 +00:00
|
|
|
#include "gtksettings.h"
|
|
|
|
#include "gtktogglebutton.h"
|
2012-03-16 19:01:50 +00:00
|
|
|
#include "gtkwidgetpath.h"
|
2012-03-21 08:37:09 +00:00
|
|
|
#include "gtkwidgetprivate.h"
|
2010-07-09 17:22:23 +00:00
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
struct _GtkPathBarPrivate
|
|
|
|
{
|
|
|
|
GtkFileSystem *file_system;
|
|
|
|
GFile *root_file;
|
|
|
|
GFile *home_file;
|
|
|
|
GFile *desktop_file;
|
|
|
|
|
|
|
|
GCancellable *get_info_cancellable;
|
|
|
|
|
2015-09-04 06:09:43 +00:00
|
|
|
GIcon *root_icon;
|
|
|
|
GIcon *home_icon;
|
|
|
|
GIcon *desktop_icon;
|
2013-03-30 07:35:39 +00:00
|
|
|
|
|
|
|
GList *button_list;
|
|
|
|
GList *first_scrolled_button;
|
|
|
|
GList *fake_root;
|
|
|
|
GtkWidget *up_slider_button;
|
|
|
|
GtkWidget *down_slider_button;
|
|
|
|
guint settings_signal_id;
|
|
|
|
gint16 slider_width;
|
|
|
|
gint16 button_offset;
|
|
|
|
guint timer;
|
|
|
|
guint slider_visible : 1;
|
|
|
|
guint need_timer : 1;
|
|
|
|
guint ignore_click : 1;
|
|
|
|
guint scrolling_up : 1;
|
|
|
|
guint scrolling_down : 1;
|
|
|
|
};
|
2004-02-23 07:11:31 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
PATH_CLICKED,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2004-03-08 09:56:34 +00:00
|
|
|
typedef enum {
|
|
|
|
NORMAL_BUTTON,
|
|
|
|
ROOT_BUTTON,
|
|
|
|
HOME_BUTTON,
|
2004-03-10 06:20:48 +00:00
|
|
|
DESKTOP_BUTTON
|
2004-03-08 09:56:34 +00:00
|
|
|
} ButtonType;
|
|
|
|
|
2004-03-09 21:29:59 +00:00
|
|
|
#define BUTTON_DATA(x) ((ButtonData *)(x))
|
|
|
|
|
2005-11-22 12:40:15 +00:00
|
|
|
#define SCROLL_DELAY_FACTOR 5
|
2013-07-09 20:44:04 +00:00
|
|
|
#define TIMEOUT_INITIAL 500
|
|
|
|
#define TIMEOUT_REPEAT 50
|
2004-09-26 05:47:11 +00:00
|
|
|
|
2004-02-23 07:11:31 +00:00
|
|
|
static guint path_bar_signals [LAST_SIGNAL] = { 0 };
|
|
|
|
|
Support changes in icon themes.
Wed Mar 10 02:41:05 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtkpathbar.c: (gtk_path_bar_init), (gtk_path_bar_class_init),
(remove_settings_signal), (gtk_path_bar_dispose),
(gtk_path_bar_style_set), (gtk_path_bar_screen_changed),
(gtk_path_bar_scroll_up), (reload_icons), (change_icon_theme),
(settings_notify_cb), (gtk_path_bar_check_icon_theme),
(get_button_image), (gtk_path_bar_update_button_appearance),
(make_directory_button), (gtk_path_bar_check_parent_path): Support
changes in icon themes.
* gtk/gtkpathbar.h: add two elements
* tests/testfilechooser.c: (main): use gnome-vfs method again to
get more testing.
2004-03-10 07:42:20 +00:00
|
|
|
/* Icon size for if we can't get it from the theme */
|
2005-02-11 17:30:33 +00:00
|
|
|
#define FALLBACK_ICON_SIZE 16
|
2004-03-08 09:56:34 +00:00
|
|
|
|
2004-03-09 21:29:59 +00:00
|
|
|
typedef struct _ButtonData ButtonData;
|
|
|
|
|
|
|
|
struct _ButtonData
|
|
|
|
{
|
|
|
|
GtkWidget *button;
|
|
|
|
ButtonType type;
|
|
|
|
char *dir_name;
|
2008-06-10 00:39:35 +00:00
|
|
|
GFile *file;
|
2004-03-09 21:29:59 +00:00
|
|
|
GtkWidget *image;
|
|
|
|
GtkWidget *label;
|
2008-06-10 00:39:35 +00:00
|
|
|
GCancellable *cancellable;
|
2004-10-28 15:00:05 +00:00
|
|
|
guint ignore_changes : 1;
|
|
|
|
guint file_is_hidden : 1;
|
2004-03-09 21:29:59 +00:00
|
|
|
};
|
2005-06-13 19:18:54 +00:00
|
|
|
/* This macro is used to check if a button can be used as a fake root.
|
|
|
|
* All buttons in front of a fake root are automatically hidden when in a
|
|
|
|
* directory below a fake root and replaced with the "<" arrow button.
|
|
|
|
*/
|
|
|
|
#define BUTTON_IS_FAKE_ROOT(button) ((button)->type == HOME_BUTTON)
|
2004-02-20 01:10:28 +00:00
|
|
|
|
2013-06-27 19:02:52 +00:00
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GtkPathBar, gtk_path_bar, GTK_TYPE_CONTAINER)
|
2004-02-20 01:10:28 +00:00
|
|
|
|
Support changes in icon themes.
Wed Mar 10 02:41:05 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtkpathbar.c: (gtk_path_bar_init), (gtk_path_bar_class_init),
(remove_settings_signal), (gtk_path_bar_dispose),
(gtk_path_bar_style_set), (gtk_path_bar_screen_changed),
(gtk_path_bar_scroll_up), (reload_icons), (change_icon_theme),
(settings_notify_cb), (gtk_path_bar_check_icon_theme),
(get_button_image), (gtk_path_bar_update_button_appearance),
(make_directory_button), (gtk_path_bar_check_parent_path): Support
changes in icon themes.
* gtk/gtkpathbar.h: add two elements
* tests/testfilechooser.c: (main): use gnome-vfs method again to
get more testing.
2004-03-10 07:42:20 +00:00
|
|
|
static void gtk_path_bar_finalize (GObject *object);
|
|
|
|
static void gtk_path_bar_dispose (GObject *object);
|
2016-10-22 14:06:14 +00:00
|
|
|
static void gtk_path_bar_measure (GtkWidget *widget,
|
|
|
|
GtkOrientation orientation,
|
|
|
|
int for_size,
|
|
|
|
int *minimum,
|
|
|
|
int *natural,
|
|
|
|
int *minimum_baseline,
|
|
|
|
int *natural_baseline);
|
2008-03-03 21:15:21 +00:00
|
|
|
static void gtk_path_bar_unmap (GtkWidget *widget);
|
2017-07-11 07:58:21 +00:00
|
|
|
static void gtk_path_bar_size_allocate (GtkWidget *widget,
|
|
|
|
const GtkAllocation *allocation,
|
|
|
|
int baseline,
|
|
|
|
GtkAllocation *out_clip);
|
Support changes in icon themes.
Wed Mar 10 02:41:05 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtkpathbar.c: (gtk_path_bar_init), (gtk_path_bar_class_init),
(remove_settings_signal), (gtk_path_bar_dispose),
(gtk_path_bar_style_set), (gtk_path_bar_screen_changed),
(gtk_path_bar_scroll_up), (reload_icons), (change_icon_theme),
(settings_notify_cb), (gtk_path_bar_check_icon_theme),
(get_button_image), (gtk_path_bar_update_button_appearance),
(make_directory_button), (gtk_path_bar_check_parent_path): Support
changes in icon themes.
* gtk/gtkpathbar.h: add two elements
* tests/testfilechooser.c: (main): use gnome-vfs method again to
get more testing.
2004-03-10 07:42:20 +00:00
|
|
|
static void gtk_path_bar_add (GtkContainer *container,
|
|
|
|
GtkWidget *widget);
|
|
|
|
static void gtk_path_bar_remove (GtkContainer *container,
|
|
|
|
GtkWidget *widget);
|
|
|
|
static void gtk_path_bar_forall (GtkContainer *container,
|
|
|
|
GtkCallback callback,
|
|
|
|
gpointer callback_data);
|
2008-03-03 21:15:21 +00:00
|
|
|
static gboolean gtk_path_bar_scroll (GtkWidget *widget,
|
|
|
|
GdkEventScroll *event);
|
|
|
|
static void gtk_path_bar_scroll_up (GtkPathBar *path_bar);
|
|
|
|
static void gtk_path_bar_scroll_down (GtkPathBar *path_bar);
|
2005-02-11 17:30:33 +00:00
|
|
|
static void gtk_path_bar_stop_scrolling (GtkPathBar *path_bar);
|
2007-05-16 17:42:53 +00:00
|
|
|
static gboolean gtk_path_bar_slider_up_defocus (GtkWidget *widget,
|
|
|
|
GdkEventButton *event,
|
|
|
|
GtkPathBar *path_bar);
|
|
|
|
static gboolean gtk_path_bar_slider_down_defocus (GtkWidget *widget,
|
|
|
|
GdkEventButton *event,
|
|
|
|
GtkPathBar *path_bar);
|
2004-09-26 05:47:11 +00:00
|
|
|
static gboolean gtk_path_bar_slider_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *event,
|
|
|
|
GtkPathBar *path_bar);
|
|
|
|
static gboolean gtk_path_bar_slider_button_release(GtkWidget *widget,
|
|
|
|
GdkEventButton *event,
|
|
|
|
GtkPathBar *path_bar);
|
|
|
|
static void gtk_path_bar_grab_notify (GtkWidget *widget,
|
|
|
|
gboolean was_grabbed);
|
2016-11-01 19:28:28 +00:00
|
|
|
static void gtk_path_bar_state_flags_changed (GtkWidget *widget,
|
|
|
|
GtkStateFlags previous_state);
|
2011-01-04 01:41:49 +00:00
|
|
|
static void gtk_path_bar_style_updated (GtkWidget *widget);
|
Support changes in icon themes.
Wed Mar 10 02:41:05 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtkpathbar.c: (gtk_path_bar_init), (gtk_path_bar_class_init),
(remove_settings_signal), (gtk_path_bar_dispose),
(gtk_path_bar_style_set), (gtk_path_bar_screen_changed),
(gtk_path_bar_scroll_up), (reload_icons), (change_icon_theme),
(settings_notify_cb), (gtk_path_bar_check_icon_theme),
(get_button_image), (gtk_path_bar_update_button_appearance),
(make_directory_button), (gtk_path_bar_check_parent_path): Support
changes in icon themes.
* gtk/gtkpathbar.h: add two elements
* tests/testfilechooser.c: (main): use gnome-vfs method again to
get more testing.
2004-03-10 07:42:20 +00:00
|
|
|
static void gtk_path_bar_screen_changed (GtkWidget *widget,
|
|
|
|
GdkScreen *previous_screen);
|
|
|
|
static void gtk_path_bar_check_icon_theme (GtkPathBar *path_bar);
|
|
|
|
static void gtk_path_bar_update_button_appearance (GtkPathBar *path_bar,
|
|
|
|
ButtonData *button_data,
|
|
|
|
gboolean current_dir);
|
2004-02-20 01:10:28 +00:00
|
|
|
|
2006-11-08 19:46:56 +00:00
|
|
|
static void
|
|
|
|
on_slider_unmap (GtkWidget *widget,
|
|
|
|
GtkPathBar *path_bar)
|
|
|
|
{
|
2013-03-30 07:35:39 +00:00
|
|
|
if (path_bar->priv->timer &&
|
|
|
|
((widget == path_bar->priv->up_slider_button && path_bar->priv->scrolling_up) ||
|
|
|
|
(widget == path_bar->priv->down_slider_button && path_bar->priv->scrolling_down)))
|
2006-11-09 16:51:05 +00:00
|
|
|
gtk_path_bar_stop_scrolling (path_bar);
|
2006-11-08 19:46:56 +00:00
|
|
|
}
|
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
static void
|
|
|
|
gtk_path_bar_init (GtkPathBar *path_bar)
|
2004-02-20 01:10:28 +00:00
|
|
|
{
|
2013-08-16 16:53:39 +00:00
|
|
|
GtkStyleContext *context;
|
|
|
|
|
2013-06-27 19:02:52 +00:00
|
|
|
path_bar->priv = gtk_path_bar_get_instance_private (path_bar);
|
2007-05-16 17:42:53 +00:00
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
gtk_widget_init_template (GTK_WIDGET (path_bar));
|
2004-02-20 01:10:28 +00:00
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
/* Add the children manually because GtkPathBar derives from an abstract class,
|
|
|
|
* Glade cannot edit a <template> in gtkpathbar.ui if it's only a GtkContainer.
|
|
|
|
*/
|
|
|
|
gtk_container_add (GTK_CONTAINER (path_bar), path_bar->priv->up_slider_button);
|
2016-01-26 13:13:18 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (path_bar), path_bar->priv->down_slider_button);
|
2004-02-20 01:10:28 +00:00
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
/* GtkBuilder wont let us connect 'swapped' without specifying the signal's
|
|
|
|
* user data in the .ui file
|
|
|
|
*/
|
|
|
|
g_signal_connect_swapped (path_bar->priv->up_slider_button, "clicked",
|
|
|
|
G_CALLBACK (gtk_path_bar_scroll_up), path_bar);
|
|
|
|
g_signal_connect_swapped (path_bar->priv->down_slider_button, "clicked",
|
|
|
|
G_CALLBACK (gtk_path_bar_scroll_down), path_bar);
|
2011-11-28 19:41:02 +00:00
|
|
|
|
2010-03-06 10:29:31 +00:00
|
|
|
gtk_widget_set_has_window (GTK_WIDGET (path_bar), FALSE);
|
2004-02-20 01:10:28 +00:00
|
|
|
gtk_widget_set_redraw_on_allocate (GTK_WIDGET (path_bar), FALSE);
|
|
|
|
|
2013-08-16 16:53:39 +00:00
|
|
|
context = gtk_widget_get_style_context (GTK_WIDGET (path_bar));
|
2014-07-17 10:48:36 +00:00
|
|
|
gtk_style_context_add_class (context, "path-bar");
|
2013-08-16 16:53:39 +00:00
|
|
|
gtk_style_context_add_class (context, GTK_STYLE_CLASS_LINKED);
|
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
path_bar->priv->get_info_cancellable = NULL;
|
2004-02-20 01:10:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_path_bar_class_init (GtkPathBarClass *path_bar_class)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GtkWidgetClass *widget_class;
|
|
|
|
GtkContainerClass *container_class;
|
|
|
|
|
|
|
|
gobject_class = (GObjectClass *) path_bar_class;
|
|
|
|
widget_class = (GtkWidgetClass *) path_bar_class;
|
|
|
|
container_class = (GtkContainerClass *) path_bar_class;
|
|
|
|
|
2004-02-23 07:11:31 +00:00
|
|
|
gobject_class->finalize = gtk_path_bar_finalize;
|
Support changes in icon themes.
Wed Mar 10 02:41:05 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtkpathbar.c: (gtk_path_bar_init), (gtk_path_bar_class_init),
(remove_settings_signal), (gtk_path_bar_dispose),
(gtk_path_bar_style_set), (gtk_path_bar_screen_changed),
(gtk_path_bar_scroll_up), (reload_icons), (change_icon_theme),
(settings_notify_cb), (gtk_path_bar_check_icon_theme),
(get_button_image), (gtk_path_bar_update_button_appearance),
(make_directory_button), (gtk_path_bar_check_parent_path): Support
changes in icon themes.
* gtk/gtkpathbar.h: add two elements
* tests/testfilechooser.c: (main): use gnome-vfs method again to
get more testing.
2004-03-10 07:42:20 +00:00
|
|
|
gobject_class->dispose = gtk_path_bar_dispose;
|
2004-02-20 01:10:28 +00:00
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
widget_class->measure = gtk_path_bar_measure;
|
2005-03-22 17:36:41 +00:00
|
|
|
widget_class->unmap = gtk_path_bar_unmap;
|
2004-02-20 01:10:28 +00:00
|
|
|
widget_class->size_allocate = gtk_path_bar_size_allocate;
|
2011-01-04 01:41:49 +00:00
|
|
|
widget_class->style_updated = gtk_path_bar_style_updated;
|
Support changes in icon themes.
Wed Mar 10 02:41:05 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtkpathbar.c: (gtk_path_bar_init), (gtk_path_bar_class_init),
(remove_settings_signal), (gtk_path_bar_dispose),
(gtk_path_bar_style_set), (gtk_path_bar_screen_changed),
(gtk_path_bar_scroll_up), (reload_icons), (change_icon_theme),
(settings_notify_cb), (gtk_path_bar_check_icon_theme),
(get_button_image), (gtk_path_bar_update_button_appearance),
(make_directory_button), (gtk_path_bar_check_parent_path): Support
changes in icon themes.
* gtk/gtkpathbar.h: add two elements
* tests/testfilechooser.c: (main): use gnome-vfs method again to
get more testing.
2004-03-10 07:42:20 +00:00
|
|
|
widget_class->screen_changed = gtk_path_bar_screen_changed;
|
2004-09-26 05:47:11 +00:00
|
|
|
widget_class->grab_notify = gtk_path_bar_grab_notify;
|
2016-11-01 19:28:28 +00:00
|
|
|
widget_class->state_flags_changed = gtk_path_bar_state_flags_changed;
|
2008-03-03 21:15:21 +00:00
|
|
|
widget_class->scroll_event = gtk_path_bar_scroll;
|
2004-02-20 01:10:28 +00:00
|
|
|
|
|
|
|
container_class->add = gtk_path_bar_add;
|
|
|
|
container_class->forall = gtk_path_bar_forall;
|
|
|
|
container_class->remove = gtk_path_bar_remove;
|
2004-02-20 23:21:01 +00:00
|
|
|
/* FIXME: */
|
|
|
|
/* container_class->child_type = gtk_path_bar_child_type;*/
|
2004-02-23 07:11:31 +00:00
|
|
|
|
|
|
|
path_bar_signals [PATH_CLICKED] =
|
2005-09-01 05:11:46 +00:00
|
|
|
g_signal_new (I_("path-clicked"),
|
2010-09-18 23:55:42 +00:00
|
|
|
G_OBJECT_CLASS_TYPE (gobject_class),
|
2004-02-23 07:11:31 +00:00
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GtkPathBarClass, path_clicked),
|
|
|
|
NULL, NULL,
|
2005-11-10 15:17:40 +00:00
|
|
|
_gtk_marshal_VOID__POINTER_POINTER_BOOLEAN,
|
|
|
|
G_TYPE_NONE, 3,
|
|
|
|
G_TYPE_POINTER,
|
2004-04-02 00:35:07 +00:00
|
|
|
G_TYPE_POINTER,
|
|
|
|
G_TYPE_BOOLEAN);
|
2013-03-30 07:35:39 +00:00
|
|
|
|
|
|
|
/* Bind class to template
|
|
|
|
*/
|
|
|
|
gtk_widget_class_set_template_from_resource (widget_class,
|
2014-01-23 23:59:20 +00:00
|
|
|
"/org/gtk/libgtk/ui/gtkpathbar.ui");
|
2013-03-30 07:35:39 +00:00
|
|
|
|
2013-07-26 20:29:12 +00:00
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkPathBar, up_slider_button);
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkPathBar, down_slider_button);
|
2013-07-26 17:49:49 +00:00
|
|
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, gtk_path_bar_slider_button_press);
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, gtk_path_bar_slider_button_release);
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, gtk_path_bar_slider_up_defocus);
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, gtk_path_bar_slider_down_defocus);
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, gtk_path_bar_scroll_up);
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, gtk_path_bar_scroll_down);
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, on_slider_unmap);
|
2004-02-20 01:10:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2004-02-23 07:11:31 +00:00
|
|
|
gtk_path_bar_finalize (GObject *object)
|
2004-02-20 01:10:28 +00:00
|
|
|
{
|
|
|
|
GtkPathBar *path_bar;
|
|
|
|
|
|
|
|
path_bar = GTK_PATH_BAR (object);
|
2005-02-11 17:30:33 +00:00
|
|
|
|
|
|
|
gtk_path_bar_stop_scrolling (path_bar);
|
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
g_list_free (path_bar->priv->button_list);
|
2015-09-04 06:09:43 +00:00
|
|
|
g_clear_object (&path_bar->priv->root_file);
|
|
|
|
g_clear_object (&path_bar->priv->home_file);
|
|
|
|
g_clear_object (&path_bar->priv->desktop_file);
|
|
|
|
|
|
|
|
g_clear_object (&path_bar->priv->root_icon);
|
|
|
|
g_clear_object (&path_bar->priv->home_icon);
|
|
|
|
g_clear_object (&path_bar->priv->desktop_icon);
|
|
|
|
|
|
|
|
g_clear_object (&path_bar->priv->file_system);
|
2004-02-20 01:10:28 +00:00
|
|
|
|
2004-02-23 07:31:44 +00:00
|
|
|
G_OBJECT_CLASS (gtk_path_bar_parent_class)->finalize (object);
|
2004-02-20 01:10:28 +00:00
|
|
|
}
|
|
|
|
|
Support changes in icon themes.
Wed Mar 10 02:41:05 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtkpathbar.c: (gtk_path_bar_init), (gtk_path_bar_class_init),
(remove_settings_signal), (gtk_path_bar_dispose),
(gtk_path_bar_style_set), (gtk_path_bar_screen_changed),
(gtk_path_bar_scroll_up), (reload_icons), (change_icon_theme),
(settings_notify_cb), (gtk_path_bar_check_icon_theme),
(get_button_image), (gtk_path_bar_update_button_appearance),
(make_directory_button), (gtk_path_bar_check_parent_path): Support
changes in icon themes.
* gtk/gtkpathbar.h: add two elements
* tests/testfilechooser.c: (main): use gnome-vfs method again to
get more testing.
2004-03-10 07:42:20 +00:00
|
|
|
/* Removes the settings signal handler. It's safe to call multiple times */
|
|
|
|
static void
|
|
|
|
remove_settings_signal (GtkPathBar *path_bar,
|
|
|
|
GdkScreen *screen)
|
|
|
|
{
|
2013-03-30 07:35:39 +00:00
|
|
|
if (path_bar->priv->settings_signal_id)
|
Support changes in icon themes.
Wed Mar 10 02:41:05 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtkpathbar.c: (gtk_path_bar_init), (gtk_path_bar_class_init),
(remove_settings_signal), (gtk_path_bar_dispose),
(gtk_path_bar_style_set), (gtk_path_bar_screen_changed),
(gtk_path_bar_scroll_up), (reload_icons), (change_icon_theme),
(settings_notify_cb), (gtk_path_bar_check_icon_theme),
(get_button_image), (gtk_path_bar_update_button_appearance),
(make_directory_button), (gtk_path_bar_check_parent_path): Support
changes in icon themes.
* gtk/gtkpathbar.h: add two elements
* tests/testfilechooser.c: (main): use gnome-vfs method again to
get more testing.
2004-03-10 07:42:20 +00:00
|
|
|
{
|
|
|
|
GtkSettings *settings;
|
|
|
|
|
|
|
|
settings = gtk_settings_get_for_screen (screen);
|
|
|
|
g_signal_handler_disconnect (settings,
|
2013-03-30 07:35:39 +00:00
|
|
|
path_bar->priv->settings_signal_id);
|
|
|
|
path_bar->priv->settings_signal_id = 0;
|
Support changes in icon themes.
Wed Mar 10 02:41:05 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtkpathbar.c: (gtk_path_bar_init), (gtk_path_bar_class_init),
(remove_settings_signal), (gtk_path_bar_dispose),
(gtk_path_bar_style_set), (gtk_path_bar_screen_changed),
(gtk_path_bar_scroll_up), (reload_icons), (change_icon_theme),
(settings_notify_cb), (gtk_path_bar_check_icon_theme),
(get_button_image), (gtk_path_bar_update_button_appearance),
(make_directory_button), (gtk_path_bar_check_parent_path): Support
changes in icon themes.
* gtk/gtkpathbar.h: add two elements
* tests/testfilechooser.c: (main): use gnome-vfs method again to
get more testing.
2004-03-10 07:42:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_path_bar_dispose (GObject *object)
|
|
|
|
{
|
2006-05-01 21:41:12 +00:00
|
|
|
GtkPathBar *path_bar = GTK_PATH_BAR (object);
|
|
|
|
|
|
|
|
remove_settings_signal (path_bar, gtk_widget_get_screen (GTK_WIDGET (object)));
|
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
if (path_bar->priv->get_info_cancellable)
|
|
|
|
g_cancellable_cancel (path_bar->priv->get_info_cancellable);
|
|
|
|
path_bar->priv->get_info_cancellable = NULL;
|
Support changes in icon themes.
Wed Mar 10 02:41:05 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtkpathbar.c: (gtk_path_bar_init), (gtk_path_bar_class_init),
(remove_settings_signal), (gtk_path_bar_dispose),
(gtk_path_bar_style_set), (gtk_path_bar_screen_changed),
(gtk_path_bar_scroll_up), (reload_icons), (change_icon_theme),
(settings_notify_cb), (gtk_path_bar_check_icon_theme),
(get_button_image), (gtk_path_bar_update_button_appearance),
(make_directory_button), (gtk_path_bar_check_parent_path): Support
changes in icon themes.
* gtk/gtkpathbar.h: add two elements
* tests/testfilechooser.c: (main): use gnome-vfs method again to
get more testing.
2004-03-10 07:42:20 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (gtk_path_bar_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2004-02-20 01:10:28 +00:00
|
|
|
/* Size requisition:
|
|
|
|
*
|
|
|
|
* Ideally, our size is determined by another widget, and we are just filling
|
|
|
|
* available space.
|
|
|
|
*/
|
2016-10-22 14:06:14 +00:00
|
|
|
|
2004-02-20 01:10:28 +00:00
|
|
|
static void
|
2016-10-22 14:06:14 +00:00
|
|
|
gtk_path_bar_measure (GtkWidget *widget,
|
|
|
|
GtkOrientation orientation,
|
|
|
|
int for_size,
|
|
|
|
int *minimum,
|
|
|
|
int *natural,
|
|
|
|
int *minimum_baseline,
|
|
|
|
int *natural_baseline)
|
2004-02-20 01:10:28 +00:00
|
|
|
{
|
2016-10-22 14:06:14 +00:00
|
|
|
GtkPathBar *path_bar = GTK_PATH_BAR (widget);
|
2004-03-09 21:29:59 +00:00
|
|
|
ButtonData *button_data;
|
2004-02-20 01:10:28 +00:00
|
|
|
GList *list;
|
2016-10-22 14:06:14 +00:00
|
|
|
int child_size;
|
|
|
|
int size = 0;
|
|
|
|
int child_min, child_nat;
|
2004-02-20 01:10:28 +00:00
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
*minimum = 0;
|
|
|
|
*natural = 0;
|
2004-02-20 01:10:28 +00:00
|
|
|
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
2004-02-20 01:10:28 +00:00
|
|
|
{
|
2016-10-22 14:06:14 +00:00
|
|
|
for (list = path_bar->priv->button_list; list; list = list->next)
|
2010-10-27 13:13:26 +00:00
|
|
|
{
|
2016-10-22 14:06:14 +00:00
|
|
|
button_data = BUTTON_DATA (list->data);
|
2017-03-05 07:48:01 +00:00
|
|
|
gtk_widget_measure (button_data->button, GTK_ORIENTATION_HORIZONTAL, -1,
|
|
|
|
&child_min, &child_nat, NULL, NULL);
|
|
|
|
gtk_widget_measure (button_data->button, GTK_ORIENTATION_VERTICAL, -1,
|
|
|
|
&child_size, NULL, NULL, NULL);
|
2016-10-22 14:06:14 +00:00
|
|
|
size = MAX (size, child_size);
|
|
|
|
|
|
|
|
if (button_data->type == NORMAL_BUTTON)
|
|
|
|
{
|
|
|
|
/* Use 2*Height as button width because of ellipsized label. */
|
|
|
|
child_min = MAX (child_min, child_size * 2);
|
|
|
|
child_nat = MAX (child_min, child_size * 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
*minimum = MAX (*minimum, child_min);
|
|
|
|
*natural = *natural + child_nat;
|
2010-10-27 13:13:26 +00:00
|
|
|
}
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
/* Add space for slider, if we have more than one path */
|
|
|
|
/* Theoretically, the slider could be bigger than the other button. But we're
|
|
|
|
* not going to worry about that now.
|
|
|
|
*/
|
|
|
|
path_bar->priv->slider_width = 0;
|
2004-02-20 01:10:28 +00:00
|
|
|
|
2017-03-05 07:48:01 +00:00
|
|
|
gtk_widget_measure (path_bar->priv->up_slider_button, GTK_ORIENTATION_HORIZONTAL, -1,
|
|
|
|
&child_min, &child_nat, NULL, NULL);
|
2016-10-22 14:06:14 +00:00
|
|
|
if (path_bar->priv->button_list && path_bar->priv->button_list->next != NULL)
|
|
|
|
{
|
|
|
|
*minimum += child_min;
|
|
|
|
*natural += child_nat;
|
|
|
|
}
|
|
|
|
path_bar->priv->slider_width = MAX (path_bar->priv->slider_width, child_min);
|
2016-03-14 03:05:54 +00:00
|
|
|
|
2017-03-05 07:48:01 +00:00
|
|
|
gtk_widget_measure (path_bar->priv->down_slider_button, GTK_ORIENTATION_HORIZONTAL, -1,
|
|
|
|
&child_min, &child_nat, NULL, NULL);
|
2016-10-22 14:06:14 +00:00
|
|
|
if (path_bar->priv->button_list && path_bar->priv->button_list->next != NULL)
|
|
|
|
{
|
|
|
|
*minimum += child_min;
|
|
|
|
*natural += child_nat;
|
|
|
|
}
|
|
|
|
path_bar->priv->slider_width = MAX (path_bar->priv->slider_width, child_min);
|
2016-03-14 03:05:54 +00:00
|
|
|
|
|
|
|
}
|
2016-10-22 14:06:14 +00:00
|
|
|
else /* VERTICAL */
|
|
|
|
{
|
|
|
|
for (list = path_bar->priv->button_list; list; list = list->next)
|
|
|
|
{
|
|
|
|
button_data = BUTTON_DATA (list->data);
|
2017-03-05 07:48:01 +00:00
|
|
|
gtk_widget_measure (button_data->button, GTK_ORIENTATION_VERTICAL, -1,
|
|
|
|
&child_min, &child_nat, NULL, NULL);
|
2010-10-27 13:13:26 +00:00
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
*minimum = MAX (*minimum, child_min);
|
|
|
|
*natural = MAX (*natural, child_nat);
|
|
|
|
}
|
2010-10-27 13:13:26 +00:00
|
|
|
|
2017-03-05 07:48:01 +00:00
|
|
|
gtk_widget_measure (path_bar->priv->up_slider_button, GTK_ORIENTATION_VERTICAL, -1,
|
|
|
|
&child_min, &child_nat, NULL, NULL);
|
2016-10-22 14:06:14 +00:00
|
|
|
*minimum = MAX (*minimum, child_min);
|
|
|
|
*natural = MAX (*natural, child_nat);
|
2010-10-27 13:13:26 +00:00
|
|
|
|
2017-03-05 07:48:01 +00:00
|
|
|
gtk_widget_measure (path_bar->priv->up_slider_button, GTK_ORIENTATION_VERTICAL, -1,
|
|
|
|
&child_min, &child_nat, NULL, NULL);
|
2010-10-27 13:13:26 +00:00
|
|
|
*minimum = MAX (*minimum, child_min);
|
|
|
|
*natural = MAX (*natural, child_nat);
|
|
|
|
}
|
2004-02-20 01:10:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_path_bar_update_slider_buttons (GtkPathBar *path_bar)
|
|
|
|
{
|
2013-03-30 07:35:39 +00:00
|
|
|
if (path_bar->priv->button_list)
|
2004-02-20 01:10:28 +00:00
|
|
|
{
|
|
|
|
GtkWidget *button;
|
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
button = BUTTON_DATA (path_bar->priv->button_list->data)->button;
|
2004-02-20 01:10:28 +00:00
|
|
|
if (gtk_widget_get_child_visible (button))
|
2005-11-21 15:00:57 +00:00
|
|
|
{
|
|
|
|
gtk_path_bar_stop_scrolling (path_bar);
|
2013-03-30 07:35:39 +00:00
|
|
|
gtk_widget_set_sensitive (path_bar->priv->down_slider_button, FALSE);
|
2005-11-21 15:00:57 +00:00
|
|
|
}
|
2004-02-20 01:10:28 +00:00
|
|
|
else
|
2013-03-30 07:35:39 +00:00
|
|
|
gtk_widget_set_sensitive (path_bar->priv->down_slider_button, TRUE);
|
2004-02-20 01:10:28 +00:00
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
button = BUTTON_DATA (g_list_last (path_bar->priv->button_list)->data)->button;
|
2004-02-20 01:10:28 +00:00
|
|
|
if (gtk_widget_get_child_visible (button))
|
2005-11-21 15:00:57 +00:00
|
|
|
{
|
|
|
|
gtk_path_bar_stop_scrolling (path_bar);
|
2013-03-30 07:35:39 +00:00
|
|
|
gtk_widget_set_sensitive (path_bar->priv->up_slider_button, FALSE);
|
2005-11-21 15:00:57 +00:00
|
|
|
}
|
2004-02-20 01:10:28 +00:00
|
|
|
else
|
2013-03-30 07:35:39 +00:00
|
|
|
gtk_widget_set_sensitive (path_bar->priv->up_slider_button, TRUE);
|
2004-02-20 01:10:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-22 17:36:41 +00:00
|
|
|
static void
|
|
|
|
gtk_path_bar_unmap (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
gtk_path_bar_stop_scrolling (GTK_PATH_BAR (widget));
|
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (gtk_path_bar_parent_class)->unmap (widget);
|
|
|
|
}
|
|
|
|
|
2004-02-20 01:10:28 +00:00
|
|
|
/* This is a tad complicated
|
|
|
|
*/
|
|
|
|
static void
|
2017-07-11 07:58:21 +00:00
|
|
|
gtk_path_bar_size_allocate (GtkWidget *widget,
|
|
|
|
const GtkAllocation *allocation,
|
|
|
|
int baseline,
|
|
|
|
GtkAllocation *out_clip)
|
2004-02-20 01:10:28 +00:00
|
|
|
{
|
|
|
|
GtkWidget *child;
|
|
|
|
GtkPathBar *path_bar = GTK_PATH_BAR (widget);
|
|
|
|
GtkTextDirection direction;
|
|
|
|
GtkAllocation child_allocation;
|
|
|
|
GList *list, *first_button;
|
|
|
|
gint width;
|
|
|
|
gint allocation_width;
|
2016-01-24 21:29:40 +00:00
|
|
|
gboolean need_sliders = TRUE;
|
2004-02-20 01:10:28 +00:00
|
|
|
gint up_slider_offset = 0;
|
2013-08-25 03:17:09 +00:00
|
|
|
gint down_slider_offset = 0;
|
2010-04-20 04:33:20 +00:00
|
|
|
GtkRequisition child_requisition;
|
2017-06-18 10:25:39 +00:00
|
|
|
GtkAllocation child_clip;
|
2004-02-20 01:10:28 +00:00
|
|
|
|
|
|
|
/* No path is set; we don't have to allocate anything. */
|
2013-03-30 07:35:39 +00:00
|
|
|
if (path_bar->priv->button_list == NULL)
|
2017-07-11 07:58:21 +00:00
|
|
|
return;
|
2004-02-20 01:10:28 +00:00
|
|
|
|
|
|
|
direction = gtk_widget_get_direction (widget);
|
2010-10-08 14:25:27 +00:00
|
|
|
allocation_width = allocation->width;
|
2004-02-20 01:10:28 +00:00
|
|
|
|
|
|
|
/* First, we check to see if we need the scrollbars. */
|
2013-03-30 07:35:39 +00:00
|
|
|
if (path_bar->priv->fake_root)
|
2013-08-25 02:55:23 +00:00
|
|
|
width = path_bar->priv->slider_width;
|
2005-06-13 19:18:54 +00:00
|
|
|
else
|
2010-04-20 04:33:20 +00:00
|
|
|
width = 0;
|
2005-06-13 19:18:54 +00:00
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
for (list = path_bar->priv->button_list; list; list = list->next)
|
2004-02-20 01:10:28 +00:00
|
|
|
{
|
2004-03-09 21:29:59 +00:00
|
|
|
child = BUTTON_DATA (list->data)->button;
|
2004-02-20 01:10:28 +00:00
|
|
|
|
2010-09-21 14:35:17 +00:00
|
|
|
gtk_widget_get_preferred_size (child, &child_requisition, NULL);
|
2010-04-20 04:33:20 +00:00
|
|
|
|
2013-08-25 02:55:23 +00:00
|
|
|
width += child_requisition.width;
|
2013-03-30 07:35:39 +00:00
|
|
|
if (list == path_bar->priv->fake_root)
|
2005-06-13 19:18:54 +00:00
|
|
|
break;
|
2004-02-20 01:10:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (width <= allocation_width)
|
|
|
|
{
|
2013-03-30 07:35:39 +00:00
|
|
|
if (path_bar->priv->fake_root)
|
|
|
|
first_button = path_bar->priv->fake_root;
|
2005-06-13 19:18:54 +00:00
|
|
|
else
|
2013-03-30 07:35:39 +00:00
|
|
|
first_button = g_list_last (path_bar->priv->button_list);
|
2004-02-20 01:10:28 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gboolean reached_end = FALSE;
|
2013-08-25 02:55:23 +00:00
|
|
|
gint slider_space = 2 * path_bar->priv->slider_width;
|
2004-02-20 01:10:28 +00:00
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
if (path_bar->priv->first_scrolled_button)
|
|
|
|
first_button = path_bar->priv->first_scrolled_button;
|
2004-02-20 23:21:01 +00:00
|
|
|
else
|
2013-03-30 07:35:39 +00:00
|
|
|
first_button = path_bar->priv->button_list;
|
2004-02-20 01:10:28 +00:00
|
|
|
need_sliders = TRUE;
|
2016-01-24 21:29:40 +00:00
|
|
|
|
2004-02-20 01:10:28 +00:00
|
|
|
/* To see how much space we have, and how many buttons we can display.
|
|
|
|
* We start at the first button, count forward until hit the new
|
|
|
|
* button, then count backwards.
|
|
|
|
*/
|
|
|
|
/* Count down the path chain towards the end. */
|
2010-09-21 14:35:17 +00:00
|
|
|
gtk_widget_get_preferred_size (BUTTON_DATA (first_button->data)->button,
|
|
|
|
&child_requisition, NULL);
|
2010-04-20 04:33:20 +00:00
|
|
|
|
|
|
|
width = child_requisition.width;
|
2004-02-20 01:10:28 +00:00
|
|
|
list = first_button->prev;
|
|
|
|
while (list && !reached_end)
|
|
|
|
{
|
2004-03-09 21:29:59 +00:00
|
|
|
child = BUTTON_DATA (list->data)->button;
|
2004-02-20 01:10:28 +00:00
|
|
|
|
2010-09-21 14:35:17 +00:00
|
|
|
gtk_widget_get_preferred_size (child, &child_requisition, NULL);
|
2010-04-20 04:33:20 +00:00
|
|
|
|
2013-08-25 02:55:23 +00:00
|
|
|
if (width + child_requisition.width + slider_space > allocation_width)
|
2004-02-20 01:10:28 +00:00
|
|
|
reached_end = TRUE;
|
2013-03-30 07:35:39 +00:00
|
|
|
else if (list == path_bar->priv->fake_root)
|
2005-06-13 19:18:54 +00:00
|
|
|
break;
|
2004-02-20 01:10:28 +00:00
|
|
|
else
|
2013-08-25 02:55:23 +00:00
|
|
|
width += child_requisition.width;
|
2004-02-20 01:10:28 +00:00
|
|
|
|
|
|
|
list = list->prev;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Finally, we walk up, seeing how many of the previous buttons we can
|
|
|
|
* add */
|
2005-06-13 19:18:54 +00:00
|
|
|
while (first_button->next && !reached_end)
|
2004-02-20 01:10:28 +00:00
|
|
|
{
|
2004-03-09 21:29:59 +00:00
|
|
|
child = BUTTON_DATA (first_button->next->data)->button;
|
2004-02-20 01:10:28 +00:00
|
|
|
|
2010-09-21 14:35:17 +00:00
|
|
|
gtk_widget_get_preferred_size (child, &child_requisition, NULL);
|
2010-04-20 04:33:20 +00:00
|
|
|
|
2013-08-25 02:55:23 +00:00
|
|
|
if (width + child_requisition.width + slider_space > allocation_width)
|
2004-02-20 01:10:28 +00:00
|
|
|
{
|
|
|
|
reached_end = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-08-25 02:55:23 +00:00
|
|
|
width += child_requisition.width;
|
2013-03-30 07:35:39 +00:00
|
|
|
if (first_button == path_bar->priv->fake_root)
|
2005-06-13 19:18:54 +00:00
|
|
|
break;
|
2004-02-20 01:10:28 +00:00
|
|
|
first_button = first_button->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now, we allocate space to the buttons */
|
2010-10-08 14:25:27 +00:00
|
|
|
child_allocation.y = allocation->y;
|
|
|
|
child_allocation.height = allocation->height;
|
2004-02-20 01:10:28 +00:00
|
|
|
|
|
|
|
if (direction == GTK_TEXT_DIR_RTL)
|
|
|
|
{
|
2010-10-08 14:25:27 +00:00
|
|
|
child_allocation.x = allocation->x + allocation->width;
|
2013-03-30 07:35:39 +00:00
|
|
|
if (need_sliders || path_bar->priv->fake_root)
|
2004-02-20 01:10:28 +00:00
|
|
|
{
|
2013-08-25 02:55:23 +00:00
|
|
|
child_allocation.x -= path_bar->priv->slider_width;
|
2013-03-30 07:35:39 +00:00
|
|
|
up_slider_offset = allocation->width - path_bar->priv->slider_width;
|
2004-02-20 01:10:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-10-08 14:25:27 +00:00
|
|
|
child_allocation.x = allocation->x;
|
2013-03-30 07:35:39 +00:00
|
|
|
if (need_sliders || path_bar->priv->fake_root)
|
2004-02-20 01:10:28 +00:00
|
|
|
{
|
2010-10-08 14:25:27 +00:00
|
|
|
up_slider_offset = 0;
|
2013-08-25 02:55:23 +00:00
|
|
|
child_allocation.x += path_bar->priv->slider_width;
|
2004-02-20 01:10:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (list = first_button; list; list = list->prev)
|
|
|
|
{
|
2010-08-11 21:05:51 +00:00
|
|
|
GtkAllocation widget_allocation;
|
2009-06-05 19:07:10 +00:00
|
|
|
ButtonData *button_data;
|
|
|
|
|
|
|
|
button_data = BUTTON_DATA (list->data);
|
|
|
|
child = button_data->button;
|
|
|
|
|
2010-09-21 14:35:17 +00:00
|
|
|
gtk_widget_get_preferred_size (child, &child_requisition, NULL);
|
2010-04-20 04:33:20 +00:00
|
|
|
|
|
|
|
child_allocation.width = MIN (child_requisition.width,
|
2013-08-25 02:55:23 +00:00
|
|
|
allocation_width - 2 * path_bar->priv->slider_width);
|
2004-02-20 01:10:28 +00:00
|
|
|
|
2004-02-20 23:21:01 +00:00
|
|
|
if (direction == GTK_TEXT_DIR_RTL)
|
|
|
|
child_allocation.x -= child_allocation.width;
|
2004-02-20 01:10:28 +00:00
|
|
|
|
|
|
|
/* Check to see if we've don't have any more space to allocate buttons */
|
|
|
|
if (need_sliders && direction == GTK_TEXT_DIR_RTL)
|
|
|
|
{
|
2010-08-11 21:05:51 +00:00
|
|
|
gtk_widget_get_allocation (widget, &widget_allocation);
|
2013-08-25 02:55:23 +00:00
|
|
|
if (child_allocation.x - path_bar->priv->slider_width < widget_allocation.x)
|
2004-02-20 01:10:28 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (need_sliders && direction == GTK_TEXT_DIR_LTR)
|
|
|
|
{
|
2010-08-11 21:05:51 +00:00
|
|
|
gtk_widget_get_allocation (widget, &widget_allocation);
|
2013-08-25 02:55:23 +00:00
|
|
|
if (child_allocation.x + child_allocation.width + path_bar->priv->slider_width >
|
2010-10-08 14:25:27 +00:00
|
|
|
widget_allocation.x + allocation_width)
|
2004-02-20 01:10:28 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-04-20 04:33:20 +00:00
|
|
|
if (child_allocation.width < child_requisition.width)
|
2009-06-05 19:07:10 +00:00
|
|
|
{
|
|
|
|
if (!gtk_widget_get_has_tooltip (child))
|
|
|
|
gtk_widget_set_tooltip_text (child, button_data->dir_name);
|
|
|
|
}
|
|
|
|
else if (gtk_widget_get_has_tooltip (child))
|
|
|
|
gtk_widget_set_tooltip_text (child, NULL);
|
|
|
|
|
|
|
|
gtk_widget_set_child_visible (child, TRUE);
|
2017-07-11 07:58:21 +00:00
|
|
|
gtk_widget_size_allocate (child, &child_allocation, baseline, &child_clip);
|
|
|
|
gdk_rectangle_union (out_clip, &child_clip, out_clip);
|
2004-02-20 01:10:28 +00:00
|
|
|
|
2013-08-25 03:17:09 +00:00
|
|
|
if (direction == GTK_TEXT_DIR_RTL)
|
|
|
|
{
|
|
|
|
down_slider_offset = child_allocation.x - allocation->x - path_bar->priv->slider_width;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
down_slider_offset += child_allocation.width;
|
|
|
|
child_allocation.x += child_allocation.width;
|
|
|
|
}
|
2004-02-20 01:10:28 +00:00
|
|
|
}
|
|
|
|
/* Now we go hide all the widgets that don't fit */
|
|
|
|
while (list)
|
|
|
|
{
|
2012-05-02 15:49:40 +00:00
|
|
|
child = BUTTON_DATA (list->data)->button;
|
|
|
|
gtk_widget_set_child_visible (child, FALSE);
|
2004-02-20 01:10:28 +00:00
|
|
|
list = list->prev;
|
|
|
|
}
|
|
|
|
for (list = first_button->next; list; list = list->next)
|
|
|
|
{
|
2012-05-02 15:49:40 +00:00
|
|
|
child = BUTTON_DATA (list->data)->button;
|
|
|
|
gtk_widget_set_child_visible (child, FALSE);
|
2004-02-20 01:10:28 +00:00
|
|
|
}
|
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
if (need_sliders || path_bar->priv->fake_root)
|
2004-02-20 01:10:28 +00:00
|
|
|
{
|
2013-03-30 07:35:39 +00:00
|
|
|
child_allocation.width = path_bar->priv->slider_width;
|
2004-02-20 01:10:28 +00:00
|
|
|
child_allocation.x = up_slider_offset + allocation->x;
|
2017-07-11 07:58:21 +00:00
|
|
|
gtk_widget_size_allocate (path_bar->priv->up_slider_button,
|
|
|
|
&child_allocation,
|
|
|
|
-1, &child_clip);
|
|
|
|
gdk_rectangle_union (out_clip, &child_clip, out_clip);
|
2004-02-20 01:10:28 +00:00
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
gtk_widget_set_child_visible (path_bar->priv->up_slider_button, TRUE);
|
2017-01-19 09:02:04 +00:00
|
|
|
gtk_widget_show (path_bar->priv->up_slider_button);
|
2013-08-25 03:17:09 +00:00
|
|
|
|
|
|
|
if (direction == GTK_TEXT_DIR_LTR)
|
|
|
|
down_slider_offset += path_bar->priv->slider_width;
|
2005-06-13 19:18:54 +00:00
|
|
|
}
|
|
|
|
else
|
2012-05-02 03:08:19 +00:00
|
|
|
{
|
2013-03-30 07:35:39 +00:00
|
|
|
gtk_widget_set_child_visible (path_bar->priv->up_slider_button, FALSE);
|
2012-05-02 03:08:19 +00:00
|
|
|
}
|
2016-01-24 21:29:40 +00:00
|
|
|
|
2005-06-13 19:18:54 +00:00
|
|
|
if (need_sliders)
|
|
|
|
{
|
2013-03-30 07:35:39 +00:00
|
|
|
child_allocation.width = path_bar->priv->slider_width;
|
2013-08-25 03:17:09 +00:00
|
|
|
child_allocation.x = down_slider_offset + allocation->x;
|
2009-06-05 19:07:10 +00:00
|
|
|
|
2017-07-11 07:58:21 +00:00
|
|
|
gtk_widget_size_allocate (path_bar->priv->down_slider_button,
|
|
|
|
&child_allocation,
|
|
|
|
-1, &child_clip);
|
|
|
|
gdk_rectangle_union (out_clip, &child_clip, out_clip);
|
2004-02-20 01:10:28 +00:00
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
gtk_widget_set_child_visible (path_bar->priv->down_slider_button, TRUE);
|
2017-01-19 09:02:04 +00:00
|
|
|
gtk_widget_show (path_bar->priv->down_slider_button);
|
2004-02-20 01:10:28 +00:00
|
|
|
gtk_path_bar_update_slider_buttons (path_bar);
|
|
|
|
}
|
|
|
|
else
|
2012-05-02 03:08:19 +00:00
|
|
|
{
|
2013-03-30 07:35:39 +00:00
|
|
|
gtk_widget_set_child_visible (path_bar->priv->down_slider_button, FALSE);
|
2012-05-02 03:08:19 +00:00
|
|
|
}
|
2004-02-20 01:10:28 +00:00
|
|
|
}
|
|
|
|
|
Support changes in icon themes.
Wed Mar 10 02:41:05 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtkpathbar.c: (gtk_path_bar_init), (gtk_path_bar_class_init),
(remove_settings_signal), (gtk_path_bar_dispose),
(gtk_path_bar_style_set), (gtk_path_bar_screen_changed),
(gtk_path_bar_scroll_up), (reload_icons), (change_icon_theme),
(settings_notify_cb), (gtk_path_bar_check_icon_theme),
(get_button_image), (gtk_path_bar_update_button_appearance),
(make_directory_button), (gtk_path_bar_check_parent_path): Support
changes in icon themes.
* gtk/gtkpathbar.h: add two elements
* tests/testfilechooser.c: (main): use gnome-vfs method again to
get more testing.
2004-03-10 07:42:20 +00:00
|
|
|
static void
|
2011-01-04 01:41:49 +00:00
|
|
|
gtk_path_bar_style_updated (GtkWidget *widget)
|
Support changes in icon themes.
Wed Mar 10 02:41:05 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtkpathbar.c: (gtk_path_bar_init), (gtk_path_bar_class_init),
(remove_settings_signal), (gtk_path_bar_dispose),
(gtk_path_bar_style_set), (gtk_path_bar_screen_changed),
(gtk_path_bar_scroll_up), (reload_icons), (change_icon_theme),
(settings_notify_cb), (gtk_path_bar_check_icon_theme),
(get_button_image), (gtk_path_bar_update_button_appearance),
(make_directory_button), (gtk_path_bar_check_parent_path): Support
changes in icon themes.
* gtk/gtkpathbar.h: add two elements
* tests/testfilechooser.c: (main): use gnome-vfs method again to
get more testing.
2004-03-10 07:42:20 +00:00
|
|
|
{
|
2011-01-04 01:41:49 +00:00
|
|
|
GTK_WIDGET_CLASS (gtk_path_bar_parent_class)->style_updated (widget);
|
Support changes in icon themes.
Wed Mar 10 02:41:05 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtkpathbar.c: (gtk_path_bar_init), (gtk_path_bar_class_init),
(remove_settings_signal), (gtk_path_bar_dispose),
(gtk_path_bar_style_set), (gtk_path_bar_screen_changed),
(gtk_path_bar_scroll_up), (reload_icons), (change_icon_theme),
(settings_notify_cb), (gtk_path_bar_check_icon_theme),
(get_button_image), (gtk_path_bar_update_button_appearance),
(make_directory_button), (gtk_path_bar_check_parent_path): Support
changes in icon themes.
* gtk/gtkpathbar.h: add two elements
* tests/testfilechooser.c: (main): use gnome-vfs method again to
get more testing.
2004-03-10 07:42:20 +00:00
|
|
|
|
|
|
|
gtk_path_bar_check_icon_theme (GTK_PATH_BAR (widget));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_path_bar_screen_changed (GtkWidget *widget,
|
|
|
|
GdkScreen *previous_screen)
|
|
|
|
{
|
|
|
|
if (GTK_WIDGET_CLASS (gtk_path_bar_parent_class)->screen_changed)
|
|
|
|
GTK_WIDGET_CLASS (gtk_path_bar_parent_class)->screen_changed (widget, previous_screen);
|
|
|
|
|
|
|
|
/* We might nave a new settings, so we remove the old one */
|
|
|
|
if (previous_screen)
|
|
|
|
remove_settings_signal (GTK_PATH_BAR (widget), previous_screen);
|
|
|
|
|
|
|
|
gtk_path_bar_check_icon_theme (GTK_PATH_BAR (widget));
|
|
|
|
}
|
|
|
|
|
2008-03-03 21:15:21 +00:00
|
|
|
static gboolean
|
|
|
|
gtk_path_bar_scroll (GtkWidget *widget,
|
|
|
|
GdkEventScroll *event)
|
|
|
|
{
|
|
|
|
switch (event->direction)
|
|
|
|
{
|
|
|
|
case GDK_SCROLL_RIGHT:
|
|
|
|
case GDK_SCROLL_DOWN:
|
|
|
|
gtk_path_bar_scroll_down (GTK_PATH_BAR (widget));
|
|
|
|
break;
|
|
|
|
case GDK_SCROLL_LEFT:
|
|
|
|
case GDK_SCROLL_UP:
|
|
|
|
gtk_path_bar_scroll_up (GTK_PATH_BAR (widget));
|
|
|
|
break;
|
2012-03-03 03:09:28 +00:00
|
|
|
case GDK_SCROLL_SMOOTH:
|
|
|
|
break;
|
2008-03-03 21:15:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-02-20 01:10:28 +00:00
|
|
|
static void
|
|
|
|
gtk_path_bar_add (GtkContainer *container,
|
|
|
|
GtkWidget *widget)
|
2011-09-05 16:12:13 +00:00
|
|
|
|
2004-02-20 01:10:28 +00:00
|
|
|
{
|
|
|
|
gtk_widget_set_parent (widget, GTK_WIDGET (container));
|
|
|
|
}
|
|
|
|
|
2004-03-17 15:29:06 +00:00
|
|
|
static void
|
|
|
|
gtk_path_bar_remove_1 (GtkContainer *container,
|
|
|
|
GtkWidget *widget)
|
|
|
|
{
|
2010-03-01 06:47:38 +00:00
|
|
|
gboolean was_visible = gtk_widget_get_visible (widget);
|
2004-03-17 15:29:06 +00:00
|
|
|
gtk_widget_unparent (widget);
|
|
|
|
if (was_visible)
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (container));
|
|
|
|
}
|
|
|
|
|
2004-02-20 01:10:28 +00:00
|
|
|
static void
|
|
|
|
gtk_path_bar_remove (GtkContainer *container,
|
|
|
|
GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GtkPathBar *path_bar;
|
|
|
|
GList *children;
|
|
|
|
|
|
|
|
path_bar = GTK_PATH_BAR (container);
|
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
if (widget == path_bar->priv->up_slider_button)
|
2004-03-17 15:29:06 +00:00
|
|
|
{
|
|
|
|
gtk_path_bar_remove_1 (container, widget);
|
2013-03-30 07:35:39 +00:00
|
|
|
path_bar->priv->up_slider_button = NULL;
|
2004-03-17 15:29:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
if (widget == path_bar->priv->down_slider_button)
|
2004-03-17 15:29:06 +00:00
|
|
|
{
|
|
|
|
gtk_path_bar_remove_1 (container, widget);
|
2013-03-30 07:35:39 +00:00
|
|
|
path_bar->priv->down_slider_button = NULL;
|
2004-03-17 15:29:06 +00:00
|
|
|
return;
|
|
|
|
}
|
2004-02-20 01:10:28 +00:00
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
children = path_bar->priv->button_list;
|
2004-02-20 01:10:28 +00:00
|
|
|
while (children)
|
|
|
|
{
|
2004-03-09 21:29:59 +00:00
|
|
|
if (widget == BUTTON_DATA (children->data)->button)
|
2004-02-20 01:10:28 +00:00
|
|
|
{
|
2004-03-17 15:29:06 +00:00
|
|
|
gtk_path_bar_remove_1 (container, widget);
|
2013-03-30 07:35:39 +00:00
|
|
|
path_bar->priv->button_list = g_list_remove_link (path_bar->priv->button_list, children);
|
2004-02-20 01:10:28 +00:00
|
|
|
g_list_free (children);
|
2004-03-17 15:29:06 +00:00
|
|
|
return;
|
2004-02-20 01:10:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
children = children->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_path_bar_forall (GtkContainer *container,
|
|
|
|
GtkCallback callback,
|
|
|
|
gpointer callback_data)
|
|
|
|
{
|
|
|
|
GtkPathBar *path_bar;
|
|
|
|
GList *children;
|
|
|
|
|
|
|
|
g_return_if_fail (callback != NULL);
|
|
|
|
path_bar = GTK_PATH_BAR (container);
|
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
children = path_bar->priv->button_list;
|
2004-02-20 01:10:28 +00:00
|
|
|
while (children)
|
|
|
|
{
|
|
|
|
GtkWidget *child;
|
2004-03-09 21:29:59 +00:00
|
|
|
child = BUTTON_DATA (children->data)->button;
|
2004-02-20 01:10:28 +00:00
|
|
|
children = children->next;
|
|
|
|
|
|
|
|
(* callback) (child, callback_data);
|
|
|
|
}
|
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
if (path_bar->priv->up_slider_button)
|
|
|
|
(* callback) (path_bar->priv->up_slider_button, callback_data);
|
2004-03-17 15:29:06 +00:00
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
if (path_bar->priv->down_slider_button)
|
|
|
|
(* callback) (path_bar->priv->down_slider_button, callback_data);
|
2004-02-20 01:10:28 +00:00
|
|
|
}
|
|
|
|
|
2004-02-20 23:21:01 +00:00
|
|
|
static void
|
2008-03-03 21:15:21 +00:00
|
|
|
gtk_path_bar_scroll_down (GtkPathBar *path_bar)
|
2004-02-20 23:21:01 +00:00
|
|
|
{
|
2010-08-11 21:05:51 +00:00
|
|
|
GtkAllocation allocation, button_allocation;
|
2004-02-20 23:21:01 +00:00
|
|
|
GList *list;
|
2004-02-23 07:11:31 +00:00
|
|
|
GList *down_button = NULL;
|
2004-02-20 23:21:01 +00:00
|
|
|
gint space_available;
|
2004-09-26 05:47:11 +00:00
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
if (path_bar->priv->ignore_click)
|
2004-09-26 05:47:11 +00:00
|
|
|
{
|
2013-03-30 07:35:39 +00:00
|
|
|
path_bar->priv->ignore_click = FALSE;
|
2004-09-26 05:47:11 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
if (gtk_widget_get_child_visible (BUTTON_DATA (path_bar->priv->button_list->data)->button))
|
2008-03-03 21:15:21 +00:00
|
|
|
{
|
|
|
|
/* Return if the last button is already visible */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-03-15 18:12:51 +00:00
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (path_bar));
|
|
|
|
|
2004-02-20 23:21:01 +00:00
|
|
|
/* We find the button at the 'down' end that we have to make
|
|
|
|
* visible */
|
2013-03-30 07:35:39 +00:00
|
|
|
for (list = path_bar->priv->button_list; list; list = list->next)
|
2004-02-20 23:21:01 +00:00
|
|
|
{
|
2004-03-09 21:29:59 +00:00
|
|
|
if (list->next && gtk_widget_get_child_visible (BUTTON_DATA (list->next->data)->button))
|
2004-02-20 23:21:01 +00:00
|
|
|
{
|
|
|
|
down_button = list;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-11 21:05:51 +00:00
|
|
|
gtk_widget_get_allocation (GTK_WIDGET (path_bar), &allocation);
|
|
|
|
gtk_widget_get_allocation (BUTTON_DATA (down_button->data)->button, &button_allocation);
|
|
|
|
|
|
|
|
space_available = (allocation.width
|
2013-08-25 02:55:23 +00:00
|
|
|
- 2 * path_bar->priv->slider_width
|
2010-08-11 21:05:51 +00:00
|
|
|
- button_allocation.width);
|
2013-03-30 07:35:39 +00:00
|
|
|
path_bar->priv->first_scrolled_button = down_button;
|
2009-06-05 19:07:10 +00:00
|
|
|
|
|
|
|
/* We have space_available free space that's not being used.
|
|
|
|
* So we walk down from the end, adding buttons until we use all free space.
|
2007-06-04 18:17:14 +00:00
|
|
|
*/
|
2009-06-05 19:07:10 +00:00
|
|
|
while (space_available > 0)
|
2004-02-20 23:21:01 +00:00
|
|
|
{
|
2013-03-30 07:35:39 +00:00
|
|
|
path_bar->priv->first_scrolled_button = down_button;
|
2009-06-05 19:07:10 +00:00
|
|
|
down_button = down_button->next;
|
|
|
|
if (!down_button)
|
|
|
|
break;
|
2013-08-25 02:55:23 +00:00
|
|
|
space_available -= button_allocation.width;
|
2004-02-20 23:21:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-03-03 21:15:21 +00:00
|
|
|
gtk_path_bar_scroll_up (GtkPathBar *path_bar)
|
2004-02-20 23:21:01 +00:00
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
if (path_bar->priv->ignore_click)
|
2004-09-26 05:47:11 +00:00
|
|
|
{
|
2013-03-30 07:35:39 +00:00
|
|
|
path_bar->priv->ignore_click = FALSE;
|
2004-09-26 05:47:11 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
list = g_list_last (path_bar->priv->button_list);
|
2008-03-03 21:15:21 +00:00
|
|
|
|
|
|
|
if (gtk_widget_get_child_visible (BUTTON_DATA (list->data)->button))
|
|
|
|
{
|
|
|
|
/* Return if the first button is already visible */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-03-15 18:12:51 +00:00
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (path_bar));
|
|
|
|
|
2008-03-03 21:15:21 +00:00
|
|
|
for ( ; list; list = list->prev)
|
2004-02-20 23:21:01 +00:00
|
|
|
{
|
2004-03-09 21:29:59 +00:00
|
|
|
if (list->prev && gtk_widget_get_child_visible (BUTTON_DATA (list->prev->data)->button))
|
2004-02-20 23:21:01 +00:00
|
|
|
{
|
2013-03-30 07:35:39 +00:00
|
|
|
if (list->prev == path_bar->priv->fake_root)
|
|
|
|
path_bar->priv->fake_root = NULL;
|
|
|
|
path_bar->priv->first_scrolled_button = list;
|
2004-02-20 23:21:01 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-09-26 05:47:11 +00:00
|
|
|
static gboolean
|
|
|
|
gtk_path_bar_scroll_timeout (GtkPathBar *path_bar)
|
|
|
|
{
|
|
|
|
gboolean retval = FALSE;
|
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
if (path_bar->priv->timer)
|
2004-09-26 05:47:11 +00:00
|
|
|
{
|
2013-03-30 07:35:39 +00:00
|
|
|
if (path_bar->priv->scrolling_up)
|
2008-03-03 21:15:21 +00:00
|
|
|
gtk_path_bar_scroll_up (path_bar);
|
2013-03-30 07:35:39 +00:00
|
|
|
else if (path_bar->priv->scrolling_down)
|
2008-03-03 21:15:21 +00:00
|
|
|
gtk_path_bar_scroll_down (path_bar);
|
2004-09-26 05:47:11 +00:00
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
if (path_bar->priv->need_timer)
|
2004-09-26 05:47:11 +00:00
|
|
|
{
|
2013-03-30 07:35:39 +00:00
|
|
|
path_bar->priv->need_timer = FALSE;
|
2004-09-26 05:47:11 +00:00
|
|
|
|
2013-07-09 20:44:04 +00:00
|
|
|
path_bar->priv->timer = gdk_threads_add_timeout (TIMEOUT_REPEAT * SCROLL_DELAY_FACTOR,
|
2004-09-26 05:47:11 +00:00
|
|
|
(GSourceFunc)gtk_path_bar_scroll_timeout,
|
|
|
|
path_bar);
|
2013-10-22 13:43:43 +00:00
|
|
|
g_source_set_name_by_id (path_bar->priv->timer, "[gtk+] gtk_path_bar_scroll_timeout");
|
2004-09-26 05:47:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
retval = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_path_bar_stop_scrolling (GtkPathBar *path_bar)
|
|
|
|
{
|
2013-03-30 07:35:39 +00:00
|
|
|
if (path_bar->priv->timer)
|
2004-09-26 05:47:11 +00:00
|
|
|
{
|
2013-03-30 07:35:39 +00:00
|
|
|
g_source_remove (path_bar->priv->timer);
|
|
|
|
path_bar->priv->timer = 0;
|
|
|
|
path_bar->priv->need_timer = FALSE;
|
2004-09-26 05:47:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-16 17:42:53 +00:00
|
|
|
static gboolean
|
|
|
|
gtk_path_bar_slider_up_defocus (GtkWidget *widget,
|
|
|
|
GdkEventButton *event,
|
|
|
|
GtkPathBar *path_bar)
|
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
GList *up_button = NULL;
|
|
|
|
|
|
|
|
if (event->type != GDK_FOCUS_CHANGE)
|
|
|
|
return FALSE;
|
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
for (list = g_list_last (path_bar->priv->button_list); list; list = list->prev)
|
2007-05-16 17:42:53 +00:00
|
|
|
{
|
|
|
|
if (gtk_widget_get_child_visible (BUTTON_DATA (list->data)->button))
|
|
|
|
{
|
|
|
|
up_button = list;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* don't let the focus vanish */
|
2013-03-30 07:35:39 +00:00
|
|
|
if ((!gtk_widget_is_sensitive (path_bar->priv->up_slider_button)) ||
|
|
|
|
(!gtk_widget_get_child_visible (path_bar->priv->up_slider_button)))
|
2007-05-16 17:42:53 +00:00
|
|
|
gtk_widget_grab_focus (BUTTON_DATA (up_button->data)->button);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gtk_path_bar_slider_down_defocus (GtkWidget *widget,
|
|
|
|
GdkEventButton *event,
|
|
|
|
GtkPathBar *path_bar)
|
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
GList *down_button = NULL;
|
|
|
|
|
|
|
|
if (event->type != GDK_FOCUS_CHANGE)
|
|
|
|
return FALSE;
|
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
for (list = path_bar->priv->button_list; list; list = list->next)
|
2007-05-16 17:42:53 +00:00
|
|
|
{
|
|
|
|
if (gtk_widget_get_child_visible (BUTTON_DATA (list->data)->button))
|
|
|
|
{
|
|
|
|
down_button = list;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* don't let the focus vanish */
|
2013-03-30 07:35:39 +00:00
|
|
|
if ((!gtk_widget_is_sensitive (path_bar->priv->down_slider_button)) ||
|
|
|
|
(!gtk_widget_get_child_visible (path_bar->priv->down_slider_button)))
|
2007-05-16 17:42:53 +00:00
|
|
|
gtk_widget_grab_focus (BUTTON_DATA (down_button->data)->button);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-09-26 05:47:11 +00:00
|
|
|
static gboolean
|
|
|
|
gtk_path_bar_slider_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *event,
|
|
|
|
GtkPathBar *path_bar)
|
|
|
|
{
|
2012-01-25 17:44:55 +00:00
|
|
|
if (event->type != GDK_BUTTON_PRESS || event->button != GDK_BUTTON_PRIMARY)
|
2004-09-26 05:47:11 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
path_bar->priv->ignore_click = FALSE;
|
2004-09-26 05:47:11 +00:00
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
if (widget == path_bar->priv->up_slider_button)
|
2005-11-07 20:10:04 +00:00
|
|
|
{
|
2013-03-30 07:35:39 +00:00
|
|
|
path_bar->priv->scrolling_down = FALSE;
|
|
|
|
path_bar->priv->scrolling_up = TRUE;
|
2008-03-03 21:15:21 +00:00
|
|
|
gtk_path_bar_scroll_up (path_bar);
|
2005-11-07 20:10:04 +00:00
|
|
|
}
|
2013-03-30 07:35:39 +00:00
|
|
|
else if (widget == path_bar->priv->down_slider_button)
|
2005-11-07 20:10:04 +00:00
|
|
|
{
|
2013-03-30 07:35:39 +00:00
|
|
|
path_bar->priv->scrolling_up = FALSE;
|
|
|
|
path_bar->priv->scrolling_down = TRUE;
|
2008-03-03 21:15:21 +00:00
|
|
|
gtk_path_bar_scroll_down (path_bar);
|
2005-11-07 20:10:04 +00:00
|
|
|
}
|
2004-09-26 05:47:11 +00:00
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
if (!path_bar->priv->timer)
|
2004-09-26 05:47:11 +00:00
|
|
|
{
|
2013-03-30 07:35:39 +00:00
|
|
|
path_bar->priv->need_timer = TRUE;
|
2013-07-09 20:44:04 +00:00
|
|
|
path_bar->priv->timer = gdk_threads_add_timeout (TIMEOUT_INITIAL,
|
2004-09-26 05:47:11 +00:00
|
|
|
(GSourceFunc)gtk_path_bar_scroll_timeout,
|
|
|
|
path_bar);
|
2013-10-22 13:43:43 +00:00
|
|
|
g_source_set_name_by_id (path_bar->priv->timer, "[gtk+] gtk_path_bar_scroll_timeout");
|
2004-09-26 05:47:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gtk_path_bar_slider_button_release (GtkWidget *widget,
|
|
|
|
GdkEventButton *event,
|
|
|
|
GtkPathBar *path_bar)
|
|
|
|
{
|
|
|
|
if (event->type != GDK_BUTTON_RELEASE)
|
|
|
|
return FALSE;
|
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
path_bar->priv->ignore_click = TRUE;
|
2004-09-26 05:47:11 +00:00
|
|
|
gtk_path_bar_stop_scrolling (path_bar);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_path_bar_grab_notify (GtkWidget *widget,
|
|
|
|
gboolean was_grabbed)
|
|
|
|
{
|
|
|
|
if (!was_grabbed)
|
|
|
|
gtk_path_bar_stop_scrolling (GTK_PATH_BAR (widget));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-11-01 19:28:28 +00:00
|
|
|
gtk_path_bar_state_flags_changed (GtkWidget *widget,
|
|
|
|
GtkStateFlags previous_state)
|
2004-09-26 05:47:11 +00:00
|
|
|
{
|
2010-02-27 04:24:24 +00:00
|
|
|
if (!gtk_widget_is_sensitive (widget))
|
2004-09-26 05:47:11 +00:00
|
|
|
gtk_path_bar_stop_scrolling (GTK_PATH_BAR (widget));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Support changes in icon themes.
Wed Mar 10 02:41:05 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtkpathbar.c: (gtk_path_bar_init), (gtk_path_bar_class_init),
(remove_settings_signal), (gtk_path_bar_dispose),
(gtk_path_bar_style_set), (gtk_path_bar_screen_changed),
(gtk_path_bar_scroll_up), (reload_icons), (change_icon_theme),
(settings_notify_cb), (gtk_path_bar_check_icon_theme),
(get_button_image), (gtk_path_bar_update_button_appearance),
(make_directory_button), (gtk_path_bar_check_parent_path): Support
changes in icon themes.
* gtk/gtkpathbar.h: add two elements
* tests/testfilechooser.c: (main): use gnome-vfs method again to
get more testing.
2004-03-10 07:42:20 +00:00
|
|
|
/* Changes the icons wherever it is needed */
|
|
|
|
static void
|
|
|
|
reload_icons (GtkPathBar *path_bar)
|
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
|
2015-09-04 06:09:43 +00:00
|
|
|
g_clear_object (&path_bar->priv->root_icon);
|
|
|
|
g_clear_object (&path_bar->priv->home_icon);
|
|
|
|
g_clear_object (&path_bar->priv->desktop_icon);
|
Support changes in icon themes.
Wed Mar 10 02:41:05 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtkpathbar.c: (gtk_path_bar_init), (gtk_path_bar_class_init),
(remove_settings_signal), (gtk_path_bar_dispose),
(gtk_path_bar_style_set), (gtk_path_bar_screen_changed),
(gtk_path_bar_scroll_up), (reload_icons), (change_icon_theme),
(settings_notify_cb), (gtk_path_bar_check_icon_theme),
(get_button_image), (gtk_path_bar_update_button_appearance),
(make_directory_button), (gtk_path_bar_check_parent_path): Support
changes in icon themes.
* gtk/gtkpathbar.h: add two elements
* tests/testfilechooser.c: (main): use gnome-vfs method again to
get more testing.
2004-03-10 07:42:20 +00:00
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
for (list = path_bar->priv->button_list; list; list = list->next)
|
Support changes in icon themes.
Wed Mar 10 02:41:05 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtkpathbar.c: (gtk_path_bar_init), (gtk_path_bar_class_init),
(remove_settings_signal), (gtk_path_bar_dispose),
(gtk_path_bar_style_set), (gtk_path_bar_screen_changed),
(gtk_path_bar_scroll_up), (reload_icons), (change_icon_theme),
(settings_notify_cb), (gtk_path_bar_check_icon_theme),
(get_button_image), (gtk_path_bar_update_button_appearance),
(make_directory_button), (gtk_path_bar_check_parent_path): Support
changes in icon themes.
* gtk/gtkpathbar.h: add two elements
* tests/testfilechooser.c: (main): use gnome-vfs method again to
get more testing.
2004-03-10 07:42:20 +00:00
|
|
|
{
|
|
|
|
ButtonData *button_data;
|
|
|
|
gboolean current_dir;
|
|
|
|
|
|
|
|
button_data = BUTTON_DATA (list->data);
|
|
|
|
if (button_data->type != NORMAL_BUTTON)
|
|
|
|
{
|
|
|
|
current_dir = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_data->button));
|
|
|
|
gtk_path_bar_update_button_appearance (path_bar, button_data, current_dir);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
change_icon_theme (GtkPathBar *path_bar)
|
|
|
|
{
|
|
|
|
reload_icons (path_bar);
|
|
|
|
}
|
2014-08-13 13:29:40 +00:00
|
|
|
|
Support changes in icon themes.
Wed Mar 10 02:41:05 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtkpathbar.c: (gtk_path_bar_init), (gtk_path_bar_class_init),
(remove_settings_signal), (gtk_path_bar_dispose),
(gtk_path_bar_style_set), (gtk_path_bar_screen_changed),
(gtk_path_bar_scroll_up), (reload_icons), (change_icon_theme),
(settings_notify_cb), (gtk_path_bar_check_icon_theme),
(get_button_image), (gtk_path_bar_update_button_appearance),
(make_directory_button), (gtk_path_bar_check_parent_path): Support
changes in icon themes.
* gtk/gtkpathbar.h: add two elements
* tests/testfilechooser.c: (main): use gnome-vfs method again to
get more testing.
2004-03-10 07:42:20 +00:00
|
|
|
/* Callback used when a GtkSettings value changes */
|
|
|
|
static void
|
|
|
|
settings_notify_cb (GObject *object,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GtkPathBar *path_bar)
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
name = g_param_spec_get_name (pspec);
|
|
|
|
|
2013-06-26 22:01:22 +00:00
|
|
|
if (strcmp (name, "gtk-icon-theme-name") == 0)
|
Support changes in icon themes.
Wed Mar 10 02:41:05 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtkpathbar.c: (gtk_path_bar_init), (gtk_path_bar_class_init),
(remove_settings_signal), (gtk_path_bar_dispose),
(gtk_path_bar_style_set), (gtk_path_bar_screen_changed),
(gtk_path_bar_scroll_up), (reload_icons), (change_icon_theme),
(settings_notify_cb), (gtk_path_bar_check_icon_theme),
(get_button_image), (gtk_path_bar_update_button_appearance),
(make_directory_button), (gtk_path_bar_check_parent_path): Support
changes in icon themes.
* gtk/gtkpathbar.h: add two elements
* tests/testfilechooser.c: (main): use gnome-vfs method again to
get more testing.
2004-03-10 07:42:20 +00:00
|
|
|
change_icon_theme (path_bar);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_path_bar_check_icon_theme (GtkPathBar *path_bar)
|
|
|
|
{
|
2014-08-13 13:29:40 +00:00
|
|
|
if (path_bar->priv->settings_signal_id == 0)
|
|
|
|
{
|
|
|
|
GtkSettings *settings;
|
Support changes in icon themes.
Wed Mar 10 02:41:05 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtkpathbar.c: (gtk_path_bar_init), (gtk_path_bar_class_init),
(remove_settings_signal), (gtk_path_bar_dispose),
(gtk_path_bar_style_set), (gtk_path_bar_screen_changed),
(gtk_path_bar_scroll_up), (reload_icons), (change_icon_theme),
(settings_notify_cb), (gtk_path_bar_check_icon_theme),
(get_button_image), (gtk_path_bar_update_button_appearance),
(make_directory_button), (gtk_path_bar_check_parent_path): Support
changes in icon themes.
* gtk/gtkpathbar.h: add two elements
* tests/testfilechooser.c: (main): use gnome-vfs method again to
get more testing.
2004-03-10 07:42:20 +00:00
|
|
|
|
2014-08-13 13:29:40 +00:00
|
|
|
settings = gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (path_bar)));
|
|
|
|
path_bar->priv->settings_signal_id = g_signal_connect (settings, "notify",
|
|
|
|
G_CALLBACK (settings_notify_cb), path_bar);
|
|
|
|
}
|
Support changes in icon themes.
Wed Mar 10 02:41:05 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtkpathbar.c: (gtk_path_bar_init), (gtk_path_bar_class_init),
(remove_settings_signal), (gtk_path_bar_dispose),
(gtk_path_bar_style_set), (gtk_path_bar_screen_changed),
(gtk_path_bar_scroll_up), (reload_icons), (change_icon_theme),
(settings_notify_cb), (gtk_path_bar_check_icon_theme),
(get_button_image), (gtk_path_bar_update_button_appearance),
(make_directory_button), (gtk_path_bar_check_parent_path): Support
changes in icon themes.
* gtk/gtkpathbar.h: add two elements
* tests/testfilechooser.c: (main): use gnome-vfs method again to
get more testing.
2004-03-10 07:42:20 +00:00
|
|
|
|
|
|
|
change_icon_theme (path_bar);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Public functions and their helpers */
|
2004-02-20 01:10:28 +00:00
|
|
|
static void
|
|
|
|
gtk_path_bar_clear_buttons (GtkPathBar *path_bar)
|
|
|
|
{
|
2013-03-30 07:35:39 +00:00
|
|
|
while (path_bar->priv->button_list != NULL)
|
2004-02-20 01:10:28 +00:00
|
|
|
{
|
2013-03-30 07:35:39 +00:00
|
|
|
gtk_container_remove (GTK_CONTAINER (path_bar), BUTTON_DATA (path_bar->priv->button_list->data)->button);
|
2004-02-20 01:10:28 +00:00
|
|
|
}
|
2013-03-30 07:35:39 +00:00
|
|
|
path_bar->priv->first_scrolled_button = NULL;
|
|
|
|
path_bar->priv->fake_root = NULL;
|
2004-02-20 01:10:28 +00:00
|
|
|
}
|
|
|
|
|
2004-02-23 07:11:31 +00:00
|
|
|
static void
|
|
|
|
button_clicked_cb (GtkWidget *button,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2004-03-09 21:29:59 +00:00
|
|
|
ButtonData *button_data;
|
2004-04-02 00:35:07 +00:00
|
|
|
GtkPathBar *path_bar;
|
|
|
|
GList *button_list;
|
|
|
|
gboolean child_is_hidden;
|
2008-06-10 00:39:35 +00:00
|
|
|
GFile *child_file;
|
2004-03-09 21:29:59 +00:00
|
|
|
|
|
|
|
button_data = BUTTON_DATA (data);
|
|
|
|
if (button_data->ignore_changes)
|
|
|
|
return;
|
2004-02-20 01:10:28 +00:00
|
|
|
|
2010-08-11 21:05:51 +00:00
|
|
|
path_bar = GTK_PATH_BAR (gtk_widget_get_parent (button));
|
2004-04-02 00:35:07 +00:00
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
button_list = g_list_find (path_bar->priv->button_list, button_data);
|
2004-04-02 00:35:07 +00:00
|
|
|
g_assert (button_list != NULL);
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
g_signal_handlers_block_by_func (button,
|
|
|
|
G_CALLBACK (button_clicked_cb), data);
|
2004-03-04 06:47:54 +00:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
2006-05-01 21:41:12 +00:00
|
|
|
g_signal_handlers_unblock_by_func (button,
|
|
|
|
G_CALLBACK (button_clicked_cb), data);
|
2004-03-04 06:47:54 +00:00
|
|
|
|
2004-04-02 00:35:07 +00:00
|
|
|
if (button_list->prev)
|
|
|
|
{
|
|
|
|
ButtonData *child_data;
|
|
|
|
|
|
|
|
child_data = BUTTON_DATA (button_list->prev->data);
|
2008-06-10 00:39:35 +00:00
|
|
|
child_file = child_data->file;
|
2004-04-02 00:35:07 +00:00
|
|
|
child_is_hidden = child_data->file_is_hidden;
|
|
|
|
}
|
|
|
|
else
|
2005-11-10 15:17:40 +00:00
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
child_file = NULL;
|
2005-11-10 15:17:40 +00:00
|
|
|
child_is_hidden = FALSE;
|
|
|
|
}
|
2004-04-02 00:35:07 +00:00
|
|
|
|
2005-11-10 15:17:40 +00:00
|
|
|
g_signal_emit (path_bar, path_bar_signals [PATH_CLICKED], 0,
|
2008-06-10 00:39:35 +00:00
|
|
|
button_data->file, child_file, child_is_hidden);
|
2004-02-23 07:11:31 +00:00
|
|
|
}
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
struct SetButtonImageData
|
|
|
|
{
|
|
|
|
GtkPathBar *path_bar;
|
|
|
|
ButtonData *button_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2008-06-10 00:39:35 +00:00
|
|
|
set_button_image_get_info_cb (GCancellable *cancellable,
|
|
|
|
GFileInfo *info,
|
|
|
|
const GError *error,
|
|
|
|
gpointer user_data)
|
2006-05-01 21:41:12 +00:00
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
|
2015-09-04 06:09:43 +00:00
|
|
|
GIcon *icon;
|
2006-05-01 21:41:12 +00:00
|
|
|
struct SetButtonImageData *data = user_data;
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
if (cancellable != data->button_data->cancellable)
|
2006-05-01 21:41:12 +00:00
|
|
|
goto out;
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
data->button_data->cancellable = NULL;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
2006-09-04 19:32:13 +00:00
|
|
|
if (!data->button_data->button)
|
|
|
|
{
|
|
|
|
g_free (data->button_data);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
if (cancelled || error)
|
|
|
|
goto out;
|
|
|
|
|
2015-09-04 06:09:43 +00:00
|
|
|
icon = g_file_info_get_symbolic_icon (info);
|
|
|
|
gtk_image_set_from_gicon (GTK_IMAGE (data->button_data->image), icon, GTK_ICON_SIZE_BUTTON);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
|
|
switch (data->button_data->type)
|
|
|
|
{
|
|
|
|
case HOME_BUTTON:
|
2015-09-04 06:09:43 +00:00
|
|
|
g_set_object (&data->path_bar->priv->home_icon, icon);
|
2006-05-01 21:41:12 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DESKTOP_BUTTON:
|
2015-09-04 06:09:43 +00:00
|
|
|
g_set_object (&data->path_bar->priv->desktop_icon, icon);
|
2006-05-01 21:41:12 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
|
|
|
|
out:
|
|
|
|
g_free (data);
|
2008-06-10 00:39:35 +00:00
|
|
|
g_object_unref (cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_button_image (GtkPathBar *path_bar,
|
|
|
|
ButtonData *button_data)
|
2004-03-08 09:56:34 +00:00
|
|
|
{
|
2004-03-10 06:20:48 +00:00
|
|
|
GtkFileSystemVolume *volume;
|
2006-05-01 21:41:12 +00:00
|
|
|
struct SetButtonImageData *data;
|
2004-03-10 06:20:48 +00:00
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
switch (button_data->type)
|
2004-03-08 09:56:34 +00:00
|
|
|
{
|
2004-03-10 06:20:48 +00:00
|
|
|
case ROOT_BUTTON:
|
2004-03-08 09:56:34 +00:00
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
if (path_bar->priv->root_icon != NULL)
|
2006-05-01 21:41:12 +00:00
|
|
|
{
|
2015-09-04 06:09:43 +00:00
|
|
|
gtk_image_set_from_gicon (GTK_IMAGE (button_data->image), path_bar->priv->root_icon, GTK_ICON_SIZE_BUTTON);
|
2006-05-01 21:41:12 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-06-10 00:39:35 +00:00
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
volume = _gtk_file_system_get_volume_for_file (path_bar->priv->file_system, path_bar->priv->root_file);
|
2004-03-08 09:56:34 +00:00
|
|
|
if (volume == NULL)
|
2006-05-01 21:41:12 +00:00
|
|
|
return;
|
2004-03-08 09:56:34 +00:00
|
|
|
|
2015-09-04 06:09:43 +00:00
|
|
|
path_bar->priv->root_icon = _gtk_file_system_volume_get_symbolic_icon (volume);
|
2010-03-09 04:56:43 +00:00
|
|
|
_gtk_file_system_volume_unref (volume);
|
2015-09-04 06:09:43 +00:00
|
|
|
gtk_image_set_from_gicon (GTK_IMAGE (button_data->image), path_bar->priv->root_icon, GTK_ICON_SIZE_BUTTON);
|
2004-03-08 09:56:34 +00:00
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
break;
|
|
|
|
|
2004-03-10 06:20:48 +00:00
|
|
|
case HOME_BUTTON:
|
2013-03-30 07:35:39 +00:00
|
|
|
if (path_bar->priv->home_icon != NULL)
|
2006-05-01 21:41:12 +00:00
|
|
|
{
|
2015-09-04 06:09:43 +00:00
|
|
|
gtk_image_set_from_gicon (GTK_IMAGE (button_data->image), path_bar->priv->home_icon, GTK_ICON_SIZE_BUTTON);
|
2006-05-01 21:41:12 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
data = g_new0 (struct SetButtonImageData, 1);
|
|
|
|
data->path_bar = path_bar;
|
|
|
|
data->button_data = button_data;
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
if (button_data->cancellable)
|
|
|
|
g_cancellable_cancel (button_data->cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
button_data->cancellable =
|
2013-03-30 07:35:39 +00:00
|
|
|
_gtk_file_system_get_info (path_bar->priv->file_system,
|
|
|
|
path_bar->priv->home_file,
|
2014-07-23 17:39:38 +00:00
|
|
|
"standard::symbolic-icon",
|
2008-06-13 16:47:41 +00:00
|
|
|
set_button_image_get_info_cb,
|
|
|
|
data);
|
2006-05-01 21:41:12 +00:00
|
|
|
break;
|
|
|
|
|
2004-03-10 06:20:48 +00:00
|
|
|
case DESKTOP_BUTTON:
|
2013-03-30 07:35:39 +00:00
|
|
|
if (path_bar->priv->desktop_icon != NULL)
|
2006-05-01 21:41:12 +00:00
|
|
|
{
|
2015-09-04 06:09:43 +00:00
|
|
|
gtk_image_set_from_gicon (GTK_IMAGE (button_data->image), path_bar->priv->desktop_icon, GTK_ICON_SIZE_BUTTON);
|
2006-05-01 21:41:12 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
data = g_new0 (struct SetButtonImageData, 1);
|
|
|
|
data->path_bar = path_bar;
|
|
|
|
data->button_data = button_data;
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
if (button_data->cancellable)
|
|
|
|
g_cancellable_cancel (button_data->cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
button_data->cancellable =
|
2013-03-30 07:35:39 +00:00
|
|
|
_gtk_file_system_get_info (path_bar->priv->file_system,
|
|
|
|
path_bar->priv->desktop_file,
|
2014-07-23 17:39:38 +00:00
|
|
|
"standard::symbolic-icon",
|
2008-06-13 16:47:41 +00:00
|
|
|
set_button_image_get_info_cb,
|
|
|
|
data);
|
2006-05-01 21:41:12 +00:00
|
|
|
break;
|
2004-03-10 06:20:48 +00:00
|
|
|
default:
|
2006-05-01 21:41:12 +00:00
|
|
|
break;
|
2004-03-08 09:56:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-09 21:29:59 +00:00
|
|
|
static void
|
|
|
|
button_data_free (ButtonData *button_data)
|
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
if (button_data->file)
|
|
|
|
g_object_unref (button_data->file);
|
|
|
|
button_data->file = NULL;
|
2006-09-04 19:32:13 +00:00
|
|
|
|
2007-03-09 21:57:37 +00:00
|
|
|
g_free (button_data->dir_name);
|
2006-09-04 19:32:13 +00:00
|
|
|
button_data->dir_name = NULL;
|
|
|
|
|
|
|
|
button_data->button = NULL;
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
if (button_data->cancellable)
|
|
|
|
g_cancellable_cancel (button_data->cancellable);
|
2006-09-04 19:32:13 +00:00
|
|
|
else
|
|
|
|
g_free (button_data);
|
2004-03-09 21:29:59 +00:00
|
|
|
}
|
|
|
|
|
2004-04-13 20:56:50 +00:00
|
|
|
static const char *
|
|
|
|
get_dir_name (ButtonData *button_data)
|
|
|
|
{
|
2005-10-04 20:08:32 +00:00
|
|
|
return button_data->dir_name;
|
2004-04-13 20:56:50 +00:00
|
|
|
}
|
|
|
|
|
2004-03-04 06:47:54 +00:00
|
|
|
static void
|
Support changes in icon themes.
Wed Mar 10 02:41:05 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtkpathbar.c: (gtk_path_bar_init), (gtk_path_bar_class_init),
(remove_settings_signal), (gtk_path_bar_dispose),
(gtk_path_bar_style_set), (gtk_path_bar_screen_changed),
(gtk_path_bar_scroll_up), (reload_icons), (change_icon_theme),
(settings_notify_cb), (gtk_path_bar_check_icon_theme),
(get_button_image), (gtk_path_bar_update_button_appearance),
(make_directory_button), (gtk_path_bar_check_parent_path): Support
changes in icon themes.
* gtk/gtkpathbar.h: add two elements
* tests/testfilechooser.c: (main): use gnome-vfs method again to
get more testing.
2004-03-10 07:42:20 +00:00
|
|
|
gtk_path_bar_update_button_appearance (GtkPathBar *path_bar,
|
|
|
|
ButtonData *button_data,
|
|
|
|
gboolean current_dir)
|
2004-02-20 01:10:28 +00:00
|
|
|
{
|
2004-04-13 20:56:50 +00:00
|
|
|
const gchar *dir_name = get_dir_name (button_data);
|
2014-07-23 16:42:27 +00:00
|
|
|
GtkStyleContext *context;
|
|
|
|
|
|
|
|
context = gtk_widget_get_style_context (button_data->button);
|
|
|
|
|
|
|
|
gtk_style_context_remove_class (context, "text-button");
|
|
|
|
gtk_style_context_remove_class (context, "image-button");
|
2004-03-08 09:56:34 +00:00
|
|
|
|
2004-03-09 21:29:59 +00:00
|
|
|
if (button_data->label != NULL)
|
2004-02-20 01:10:28 +00:00
|
|
|
{
|
2013-08-31 21:20:50 +00:00
|
|
|
gtk_label_set_text (GTK_LABEL (button_data->label), dir_name);
|
2014-07-23 16:42:27 +00:00
|
|
|
if (button_data->image == NULL)
|
|
|
|
gtk_style_context_add_class (context, "text-button");
|
2004-02-23 07:11:31 +00:00
|
|
|
}
|
2004-03-08 09:56:34 +00:00
|
|
|
|
2004-03-09 21:29:59 +00:00
|
|
|
if (button_data->image != NULL)
|
2004-02-23 07:11:31 +00:00
|
|
|
{
|
2006-05-01 21:41:12 +00:00
|
|
|
set_button_image (path_bar, button_data);
|
2014-07-23 16:42:27 +00:00
|
|
|
if (button_data->label == NULL)
|
|
|
|
gtk_style_context_add_class (context, "image-button");
|
2004-02-20 01:10:28 +00:00
|
|
|
}
|
|
|
|
|
2004-03-09 21:29:59 +00:00
|
|
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_data->button)) != current_dir)
|
2004-03-04 06:47:54 +00:00
|
|
|
{
|
2004-03-09 21:29:59 +00:00
|
|
|
button_data->ignore_changes = TRUE;
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button_data->button), current_dir);
|
|
|
|
button_data->ignore_changes = FALSE;
|
2004-03-04 06:47:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-10 06:20:48 +00:00
|
|
|
static ButtonType
|
|
|
|
find_button_type (GtkPathBar *path_bar,
|
2008-06-10 00:39:35 +00:00
|
|
|
GFile *file)
|
2004-03-10 06:20:48 +00:00
|
|
|
{
|
2013-03-30 07:35:39 +00:00
|
|
|
if (path_bar->priv->root_file != NULL &&
|
|
|
|
g_file_equal (file, path_bar->priv->root_file))
|
2004-03-10 06:20:48 +00:00
|
|
|
return ROOT_BUTTON;
|
2013-03-30 07:35:39 +00:00
|
|
|
if (path_bar->priv->home_file != NULL &&
|
|
|
|
g_file_equal (file, path_bar->priv->home_file))
|
2004-03-10 06:20:48 +00:00
|
|
|
return HOME_BUTTON;
|
2013-03-30 07:35:39 +00:00
|
|
|
if (path_bar->priv->desktop_file != NULL &&
|
|
|
|
g_file_equal (file, path_bar->priv->desktop_file))
|
2004-03-10 06:20:48 +00:00
|
|
|
return DESKTOP_BUTTON;
|
|
|
|
|
|
|
|
return NORMAL_BUTTON;
|
|
|
|
}
|
|
|
|
|
2004-11-20 04:52:57 +00:00
|
|
|
static void
|
2011-01-24 02:50:39 +00:00
|
|
|
button_drag_data_get_cb (GtkWidget *widget,
|
|
|
|
GdkDragContext *context,
|
|
|
|
GtkSelectionData *selection_data,
|
|
|
|
guint info,
|
|
|
|
guint time_,
|
|
|
|
gpointer data)
|
2004-11-20 04:52:57 +00:00
|
|
|
{
|
|
|
|
ButtonData *button_data;
|
2008-02-12 15:07:38 +00:00
|
|
|
char *uris[2];
|
2004-11-20 04:52:57 +00:00
|
|
|
|
|
|
|
button_data = data;
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
uris[0] = g_file_get_uri (button_data->file);
|
2008-02-12 15:07:38 +00:00
|
|
|
uris[1] = NULL;
|
2004-11-20 04:52:57 +00:00
|
|
|
|
2008-02-12 15:07:38 +00:00
|
|
|
gtk_selection_data_set_uris (selection_data, uris);
|
2011-01-24 02:50:39 +00:00
|
|
|
|
2008-02-12 15:07:38 +00:00
|
|
|
g_free (uris[0]);
|
2004-11-20 04:52:57 +00:00
|
|
|
}
|
|
|
|
|
2004-03-09 21:29:59 +00:00
|
|
|
static ButtonData *
|
2004-03-08 09:56:34 +00:00
|
|
|
make_directory_button (GtkPathBar *path_bar,
|
|
|
|
const char *dir_name,
|
2008-06-10 00:39:35 +00:00
|
|
|
GFile *file,
|
2004-04-02 00:35:07 +00:00
|
|
|
gboolean current_dir,
|
|
|
|
gboolean file_is_hidden)
|
2004-03-04 06:47:54 +00:00
|
|
|
{
|
2007-05-16 17:42:53 +00:00
|
|
|
AtkObject *atk_obj;
|
2004-03-08 09:56:34 +00:00
|
|
|
GtkWidget *child = NULL;
|
2004-03-09 21:29:59 +00:00
|
|
|
ButtonData *button_data;
|
2004-03-08 09:56:34 +00:00
|
|
|
|
2004-08-25 19:19:43 +00:00
|
|
|
file_is_hidden = !! file_is_hidden;
|
2004-03-08 09:56:34 +00:00
|
|
|
/* Is it a special button? */
|
2004-03-09 21:29:59 +00:00
|
|
|
button_data = g_new0 (ButtonData, 1);
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
button_data->type = find_button_type (path_bar, file);
|
2004-03-09 21:29:59 +00:00
|
|
|
button_data->button = gtk_toggle_button_new ();
|
2007-05-16 17:42:53 +00:00
|
|
|
atk_obj = gtk_widget_get_accessible (button_data->button);
|
2015-10-23 20:13:30 +00:00
|
|
|
gtk_widget_set_focus_on_click (button_data->button, FALSE);
|
2004-03-08 09:56:34 +00:00
|
|
|
|
2004-03-09 21:29:59 +00:00
|
|
|
switch (button_data->type)
|
2004-03-08 09:56:34 +00:00
|
|
|
{
|
|
|
|
case ROOT_BUTTON:
|
2004-03-09 21:29:59 +00:00
|
|
|
button_data->image = gtk_image_new ();
|
|
|
|
child = button_data->image;
|
2007-07-20 11:10:07 +00:00
|
|
|
button_data->label = NULL;
|
2007-05-16 17:42:53 +00:00
|
|
|
atk_object_set_name (atk_obj, _("File System Root"));
|
2004-03-08 09:56:34 +00:00
|
|
|
break;
|
|
|
|
case HOME_BUTTON:
|
2004-03-10 06:20:48 +00:00
|
|
|
case DESKTOP_BUTTON:
|
2004-03-09 21:29:59 +00:00
|
|
|
button_data->image = gtk_image_new ();
|
|
|
|
button_data->label = gtk_label_new (NULL);
|
2014-08-13 13:31:34 +00:00
|
|
|
child = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
2017-04-21 20:34:36 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (child), button_data->image);
|
|
|
|
gtk_box_pack_start (GTK_BOX (child), button_data->label);
|
2004-03-08 09:56:34 +00:00
|
|
|
break;
|
|
|
|
case NORMAL_BUTTON:
|
2004-03-10 06:20:48 +00:00
|
|
|
default:
|
2004-03-09 21:29:59 +00:00
|
|
|
button_data->label = gtk_label_new (NULL);
|
2011-06-07 16:59:11 +00:00
|
|
|
child = button_data->label;
|
2004-03-09 21:29:59 +00:00
|
|
|
button_data->image = NULL;
|
2004-03-08 09:56:34 +00:00
|
|
|
}
|
2004-03-04 06:47:54 +00:00
|
|
|
|
2004-03-09 21:29:59 +00:00
|
|
|
button_data->dir_name = g_strdup (dir_name);
|
2008-06-10 00:39:35 +00:00
|
|
|
button_data->file = g_object_ref (file);
|
2004-04-02 00:35:07 +00:00
|
|
|
button_data->file_is_hidden = file_is_hidden;
|
2008-06-10 00:39:35 +00:00
|
|
|
|
2004-03-09 21:29:59 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (button_data->button), child);
|
2004-02-20 01:10:28 +00:00
|
|
|
|
Support changes in icon themes.
Wed Mar 10 02:41:05 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtkpathbar.c: (gtk_path_bar_init), (gtk_path_bar_class_init),
(remove_settings_signal), (gtk_path_bar_dispose),
(gtk_path_bar_style_set), (gtk_path_bar_screen_changed),
(gtk_path_bar_scroll_up), (reload_icons), (change_icon_theme),
(settings_notify_cb), (gtk_path_bar_check_icon_theme),
(get_button_image), (gtk_path_bar_update_button_appearance),
(make_directory_button), (gtk_path_bar_check_parent_path): Support
changes in icon themes.
* gtk/gtkpathbar.h: add two elements
* tests/testfilechooser.c: (main): use gnome-vfs method again to
get more testing.
2004-03-10 07:42:20 +00:00
|
|
|
gtk_path_bar_update_button_appearance (path_bar, button_data, current_dir);
|
2004-03-04 06:47:54 +00:00
|
|
|
|
2004-03-09 21:29:59 +00:00
|
|
|
g_signal_connect (button_data->button, "clicked",
|
|
|
|
G_CALLBACK (button_clicked_cb),
|
|
|
|
button_data);
|
2004-03-10 06:20:48 +00:00
|
|
|
g_object_weak_ref (G_OBJECT (button_data->button),
|
|
|
|
(GWeakNotify) button_data_free, button_data);
|
2004-03-09 21:29:59 +00:00
|
|
|
|
2004-11-20 04:52:57 +00:00
|
|
|
gtk_drag_source_set (button_data->button,
|
|
|
|
GDK_BUTTON1_MASK,
|
2008-02-16 02:31:33 +00:00
|
|
|
NULL, 0,
|
2004-11-20 04:52:57 +00:00
|
|
|
GDK_ACTION_COPY);
|
2008-02-16 02:31:33 +00:00
|
|
|
gtk_drag_source_add_uri_targets (button_data->button);
|
2008-08-11 09:17:49 +00:00
|
|
|
g_signal_connect (button_data->button, "drag-data-get",
|
2004-11-20 04:52:57 +00:00
|
|
|
G_CALLBACK (button_drag_data_get_cb), button_data);
|
|
|
|
|
2004-03-09 21:29:59 +00:00
|
|
|
return button_data;
|
2004-02-20 01:10:28 +00:00
|
|
|
}
|
|
|
|
|
2004-03-04 06:47:54 +00:00
|
|
|
static gboolean
|
|
|
|
gtk_path_bar_check_parent_path (GtkPathBar *path_bar,
|
2011-11-28 17:34:37 +00:00
|
|
|
GFile *file)
|
2004-03-04 06:47:54 +00:00
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
GList *current_path = NULL;
|
2005-06-13 19:18:54 +00:00
|
|
|
gboolean need_new_fake_root = FALSE;
|
2004-03-04 06:47:54 +00:00
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
for (list = path_bar->priv->button_list; list; list = list->next)
|
2004-03-04 06:47:54 +00:00
|
|
|
{
|
2004-03-09 21:29:59 +00:00
|
|
|
ButtonData *button_data;
|
2004-03-04 06:47:54 +00:00
|
|
|
|
2004-03-09 21:29:59 +00:00
|
|
|
button_data = list->data;
|
2008-06-10 00:39:35 +00:00
|
|
|
if (g_file_equal (file, button_data->file))
|
2004-03-04 06:47:54 +00:00
|
|
|
{
|
|
|
|
current_path = list;
|
|
|
|
break;
|
|
|
|
}
|
2013-03-30 07:35:39 +00:00
|
|
|
if (list == path_bar->priv->fake_root)
|
2005-06-13 19:18:54 +00:00
|
|
|
need_new_fake_root = TRUE;
|
2004-03-04 06:47:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (current_path)
|
|
|
|
{
|
2005-06-13 19:18:54 +00:00
|
|
|
if (need_new_fake_root)
|
|
|
|
{
|
2013-03-30 07:35:39 +00:00
|
|
|
path_bar->priv->fake_root = NULL;
|
2005-06-13 19:18:54 +00:00
|
|
|
for (list = current_path; list; list = list->next)
|
|
|
|
{
|
|
|
|
ButtonData *button_data;
|
|
|
|
|
|
|
|
button_data = list->data;
|
|
|
|
if (BUTTON_IS_FAKE_ROOT (button_data))
|
|
|
|
{
|
2013-03-30 07:35:39 +00:00
|
|
|
path_bar->priv->fake_root = list;
|
2005-06-13 19:18:54 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
for (list = path_bar->priv->button_list; list; list = list->next)
|
2004-03-04 06:47:54 +00:00
|
|
|
{
|
Support changes in icon themes.
Wed Mar 10 02:41:05 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtkpathbar.c: (gtk_path_bar_init), (gtk_path_bar_class_init),
(remove_settings_signal), (gtk_path_bar_dispose),
(gtk_path_bar_style_set), (gtk_path_bar_screen_changed),
(gtk_path_bar_scroll_up), (reload_icons), (change_icon_theme),
(settings_notify_cb), (gtk_path_bar_check_icon_theme),
(get_button_image), (gtk_path_bar_update_button_appearance),
(make_directory_button), (gtk_path_bar_check_parent_path): Support
changes in icon themes.
* gtk/gtkpathbar.h: add two elements
* tests/testfilechooser.c: (main): use gnome-vfs method again to
get more testing.
2004-03-10 07:42:20 +00:00
|
|
|
gtk_path_bar_update_button_appearance (path_bar,
|
|
|
|
BUTTON_DATA (list->data),
|
|
|
|
(list == current_path) ? TRUE : FALSE);
|
2004-03-04 06:47:54 +00:00
|
|
|
}
|
2004-09-26 05:54:59 +00:00
|
|
|
|
2004-09-26 05:47:11 +00:00
|
|
|
if (!gtk_widget_get_child_visible (BUTTON_DATA (current_path->data)->button))
|
|
|
|
{
|
2013-03-30 07:35:39 +00:00
|
|
|
path_bar->priv->first_scrolled_button = current_path;
|
2004-09-26 05:47:11 +00:00
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (path_bar));
|
|
|
|
}
|
2004-09-26 05:54:59 +00:00
|
|
|
|
2004-03-04 06:47:54 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-02-23 07:11:31 +00:00
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
struct SetFileInfo
|
2004-02-20 01:10:28 +00:00
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
GFile *file;
|
|
|
|
GFile *parent_file;
|
2006-05-01 21:41:12 +00:00
|
|
|
GtkPathBar *path_bar;
|
|
|
|
GList *new_buttons;
|
|
|
|
GList *fake_root;
|
|
|
|
gboolean first_directory;
|
|
|
|
};
|
2004-03-08 22:53:35 +00:00
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
static void
|
2008-06-10 00:39:35 +00:00
|
|
|
gtk_path_bar_set_file_finish (struct SetFileInfo *info,
|
|
|
|
gboolean result)
|
2006-05-01 21:41:12 +00:00
|
|
|
{
|
|
|
|
if (result)
|
|
|
|
{
|
|
|
|
GList *l;
|
2016-01-26 13:13:18 +00:00
|
|
|
GtkCssNode *prev;
|
2004-02-20 01:10:28 +00:00
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
gtk_path_bar_clear_buttons (info->path_bar);
|
2013-03-30 07:35:39 +00:00
|
|
|
info->path_bar->priv->button_list = g_list_reverse (info->new_buttons);
|
|
|
|
info->path_bar->priv->fake_root = info->fake_root;
|
2016-03-17 12:50:05 +00:00
|
|
|
prev = gtk_widget_get_css_node (info->path_bar->priv->down_slider_button);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
for (l = info->path_bar->priv->button_list; l; l = l->next)
|
2004-02-23 07:11:31 +00:00
|
|
|
{
|
2006-05-01 21:41:12 +00:00
|
|
|
GtkWidget *button = BUTTON_DATA (l->data)->button;
|
2016-01-26 13:13:18 +00:00
|
|
|
GtkCssNode *node = gtk_widget_get_css_node (button);
|
|
|
|
|
2016-03-17 12:50:05 +00:00
|
|
|
gtk_css_node_insert_before (gtk_widget_get_css_node (GTK_WIDGET (info->path_bar)),
|
|
|
|
node,
|
|
|
|
prev);
|
2006-05-01 21:41:12 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (info->path_bar), button);
|
2016-01-26 13:13:18 +00:00
|
|
|
prev = node;
|
2004-02-23 07:11:31 +00:00
|
|
|
}
|
2006-05-01 21:41:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GList *l;
|
2004-02-20 01:10:28 +00:00
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
for (l = info->new_buttons; l; l = l->next)
|
2004-03-15 05:42:51 +00:00
|
|
|
{
|
2006-05-01 21:41:12 +00:00
|
|
|
ButtonData *button_data;
|
2004-02-23 20:24:01 +00:00
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
button_data = BUTTON_DATA (l->data);
|
|
|
|
gtk_widget_destroy (button_data->button);
|
2004-03-01 19:48:28 +00:00
|
|
|
}
|
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
g_list_free (info->new_buttons);
|
|
|
|
}
|
2004-02-20 01:10:28 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
if (info->file)
|
|
|
|
g_object_unref (info->file);
|
|
|
|
if (info->parent_file)
|
|
|
|
g_object_unref (info->parent_file);
|
2011-09-05 16:12:13 +00:00
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
g_free (info);
|
|
|
|
}
|
2004-02-23 07:11:31 +00:00
|
|
|
|
2006-05-01 21:41:12 +00:00
|
|
|
static void
|
2008-06-10 00:39:35 +00:00
|
|
|
gtk_path_bar_get_info_callback (GCancellable *cancellable,
|
|
|
|
GFileInfo *info,
|
|
|
|
const GError *error,
|
|
|
|
gpointer data)
|
2006-05-01 21:41:12 +00:00
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
|
|
|
|
struct SetFileInfo *file_info = data;
|
2006-05-01 21:41:12 +00:00
|
|
|
ButtonData *button_data;
|
|
|
|
const gchar *display_name;
|
|
|
|
gboolean is_hidden;
|
2004-03-08 09:56:34 +00:00
|
|
|
|
2015-01-19 16:57:10 +00:00
|
|
|
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
|
|
|
return;
|
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
if (cancellable != file_info->path_bar->priv->get_info_cancellable)
|
2006-05-01 21:41:12 +00:00
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
gtk_path_bar_set_file_finish (file_info, FALSE);
|
|
|
|
g_object_unref (cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
return;
|
2004-02-20 01:10:28 +00:00
|
|
|
}
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
g_object_unref (cancellable);
|
2013-03-30 07:35:39 +00:00
|
|
|
file_info->path_bar->priv->get_info_cancellable = NULL;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
if (cancelled || !info)
|
2004-03-08 16:16:26 +00:00
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
gtk_path_bar_set_file_finish (file_info, FALSE);
|
2006-05-01 21:41:12 +00:00
|
|
|
return;
|
|
|
|
}
|
2004-03-08 16:16:26 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
display_name = g_file_info_get_display_name (info);
|
2009-06-12 00:58:51 +00:00
|
|
|
is_hidden = g_file_info_get_is_hidden (info) || g_file_info_get_is_backup (info);
|
2004-03-08 16:16:26 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
button_data = make_directory_button (file_info->path_bar, display_name,
|
|
|
|
file_info->file,
|
|
|
|
file_info->first_directory, is_hidden);
|
|
|
|
g_object_unref (file_info->file);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
file_info->new_buttons = g_list_prepend (file_info->new_buttons, button_data);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
|
|
if (BUTTON_IS_FAKE_ROOT (button_data))
|
2008-06-10 00:39:35 +00:00
|
|
|
file_info->fake_root = file_info->new_buttons;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
2011-11-28 18:03:02 +00:00
|
|
|
/* We have assigned the info for the innermost button, i.e. the deepest directory.
|
|
|
|
* Now, go on to fetch the info for this directory's parent.
|
|
|
|
*/
|
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
file_info->file = file_info->parent_file;
|
|
|
|
file_info->first_directory = FALSE;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
if (!file_info->file)
|
2006-05-01 21:41:12 +00:00
|
|
|
{
|
2011-11-28 18:03:02 +00:00
|
|
|
/* No parent? Okay, we are done. */
|
2008-06-10 00:39:35 +00:00
|
|
|
gtk_path_bar_set_file_finish (file_info, TRUE);
|
2006-05-01 21:41:12 +00:00
|
|
|
return;
|
2004-03-08 16:16:26 +00:00
|
|
|
}
|
2006-05-01 21:41:12 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
file_info->parent_file = g_file_get_parent (file_info->file);
|
2004-02-25 08:55:48 +00:00
|
|
|
|
2011-11-28 18:03:02 +00:00
|
|
|
/* Recurse asynchronously */
|
2013-03-30 07:35:39 +00:00
|
|
|
file_info->path_bar->priv->get_info_cancellable =
|
|
|
|
_gtk_file_system_get_info (file_info->path_bar->priv->file_system,
|
2008-06-13 16:47:41 +00:00
|
|
|
file_info->file,
|
2009-06-12 00:58:51 +00:00
|
|
|
"standard::display-name,standard::is-hidden,standard::is-backup",
|
2008-06-13 16:47:41 +00:00
|
|
|
gtk_path_bar_get_info_callback,
|
|
|
|
file_info);
|
2006-05-01 21:41:12 +00:00
|
|
|
}
|
2004-04-06 01:23:26 +00:00
|
|
|
|
2011-11-29 21:07:01 +00:00
|
|
|
void
|
2015-02-19 13:44:56 +00:00
|
|
|
_gtk_path_bar_set_file (GtkPathBar *path_bar,
|
|
|
|
GFile *file,
|
|
|
|
gboolean keep_trail)
|
2006-05-01 21:41:12 +00:00
|
|
|
{
|
2008-06-10 00:39:35 +00:00
|
|
|
struct SetFileInfo *info;
|
2006-05-01 21:41:12 +00:00
|
|
|
|
2011-11-29 21:07:01 +00:00
|
|
|
g_return_if_fail (GTK_IS_PATH_BAR (path_bar));
|
|
|
|
g_return_if_fail (G_IS_FILE (file));
|
2006-05-01 21:41:12 +00:00
|
|
|
|
|
|
|
/* Check whether the new path is already present in the pathbar as buttons.
|
|
|
|
* This could be a parent directory or a previous selected subdirectory.
|
|
|
|
*/
|
2011-11-28 17:34:37 +00:00
|
|
|
if (keep_trail && gtk_path_bar_check_parent_path (path_bar, file))
|
2011-11-29 21:07:01 +00:00
|
|
|
return;
|
2004-03-08 16:16:26 +00:00
|
|
|
|
2008-06-10 00:39:35 +00:00
|
|
|
info = g_new0 (struct SetFileInfo, 1);
|
|
|
|
info->file = g_object_ref (file);
|
2006-05-01 21:41:12 +00:00
|
|
|
info->path_bar = path_bar;
|
|
|
|
info->first_directory = TRUE;
|
2008-06-10 00:39:35 +00:00
|
|
|
info->parent_file = g_file_get_parent (info->file);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
if (path_bar->priv->get_info_cancellable)
|
|
|
|
g_cancellable_cancel (path_bar->priv->get_info_cancellable);
|
2006-05-01 21:41:12 +00:00
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
path_bar->priv->get_info_cancellable =
|
|
|
|
_gtk_file_system_get_info (path_bar->priv->file_system,
|
2011-01-24 02:50:39 +00:00
|
|
|
info->file,
|
|
|
|
"standard::display-name,standard::is-hidden,standard::is-backup",
|
|
|
|
gtk_path_bar_get_info_callback,
|
|
|
|
info);
|
2015-01-19 16:57:10 +00:00
|
|
|
|
2004-02-20 01:10:28 +00:00
|
|
|
}
|
2004-03-04 06:47:54 +00:00
|
|
|
|
2004-03-08 09:56:34 +00:00
|
|
|
/* FIXME: This should be a construct-only property */
|
2004-03-04 06:47:54 +00:00
|
|
|
void
|
2004-03-08 09:56:34 +00:00
|
|
|
_gtk_path_bar_set_file_system (GtkPathBar *path_bar,
|
|
|
|
GtkFileSystem *file_system)
|
2004-03-04 06:47:54 +00:00
|
|
|
{
|
2004-03-08 09:56:34 +00:00
|
|
|
const char *home;
|
2004-03-10 06:20:48 +00:00
|
|
|
|
2004-03-04 06:47:54 +00:00
|
|
|
g_return_if_fail (GTK_IS_PATH_BAR (path_bar));
|
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
g_assert (path_bar->priv->file_system == NULL);
|
2004-03-04 06:47:54 +00:00
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
path_bar->priv->file_system = g_object_ref (file_system);
|
2004-03-08 09:56:34 +00:00
|
|
|
|
|
|
|
home = g_get_home_dir ();
|
2004-08-14 16:47:48 +00:00
|
|
|
if (home != NULL)
|
|
|
|
{
|
2008-01-09 17:02:50 +00:00
|
|
|
const gchar *desktop;
|
2007-06-07 04:23:10 +00:00
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
path_bar->priv->home_file = g_file_new_for_path (home);
|
2004-08-14 16:47:48 +00:00
|
|
|
/* FIXME: Need file system backend specific way of getting the
|
|
|
|
* Desktop path.
|
|
|
|
*/
|
2007-06-07 04:23:10 +00:00
|
|
|
desktop = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
|
|
|
|
if (desktop != NULL)
|
2013-03-30 07:35:39 +00:00
|
|
|
path_bar->priv->desktop_file = g_file_new_for_path (desktop);
|
2007-06-07 04:23:10 +00:00
|
|
|
else
|
2013-03-30 07:35:39 +00:00
|
|
|
path_bar->priv->desktop_file = NULL;
|
2004-08-14 16:47:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-03-30 07:35:39 +00:00
|
|
|
path_bar->priv->home_file = NULL;
|
|
|
|
path_bar->priv->desktop_file = NULL;
|
2004-08-14 16:47:48 +00:00
|
|
|
}
|
2013-03-30 07:35:39 +00:00
|
|
|
path_bar->priv->root_file = g_file_new_for_path ("/");
|
2004-03-04 06:47:54 +00:00
|
|
|
}
|
2004-03-15 02:12:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* _gtk_path_bar_up:
|
|
|
|
* @path_bar: a #GtkPathBar
|
|
|
|
*
|
2014-02-05 18:07:34 +00:00
|
|
|
* If the selected button in the pathbar is not the furthest button “up” (in the
|
2004-03-15 02:12:08 +00:00
|
|
|
* root direction), act as if the user clicked on the next button up.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
_gtk_path_bar_up (GtkPathBar *path_bar)
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
for (l = path_bar->priv->button_list; l; l = l->next)
|
2004-03-15 02:12:08 +00:00
|
|
|
{
|
|
|
|
GtkWidget *button = BUTTON_DATA (l->data)->button;
|
|
|
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
|
|
|
|
{
|
|
|
|
if (l->next)
|
|
|
|
{
|
|
|
|
GtkWidget *next_button = BUTTON_DATA (l->next->data)->button;
|
|
|
|
button_clicked_cb (next_button, l->next->data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* _gtk_path_bar_down:
|
|
|
|
* @path_bar: a #GtkPathBar
|
|
|
|
*
|
2014-02-05 18:07:34 +00:00
|
|
|
* If the selected button in the pathbar is not the furthest button “down” (in the
|
2004-03-15 02:12:08 +00:00
|
|
|
* leaf direction), act as if the user clicked on the next button down.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
_gtk_path_bar_down (GtkPathBar *path_bar)
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
|
2013-03-30 07:35:39 +00:00
|
|
|
for (l = path_bar->priv->button_list; l; l = l->next)
|
2004-03-15 02:12:08 +00:00
|
|
|
{
|
|
|
|
GtkWidget *button = BUTTON_DATA (l->data)->button;
|
|
|
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
|
|
|
|
{
|
|
|
|
if (l->prev)
|
|
|
|
{
|
|
|
|
GtkWidget *prev_button = BUTTON_DATA (l->prev->data)->button;
|
|
|
|
button_clicked_cb (prev_button, l->prev->data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|