Commit b418bf3a authored by James M. Cape's avatar James M. Cape Committed by James M. Cape
Browse files

Use a GtkComboBox in SELECT_FOLDER mode (#157726).

2004-12-15  James M. Cape  <jcape@ignore-your.tv>

        * gtk/gtkfilechooserbutton.c (struct _GtkFileChooserButtonPrivate)
        (gtk_file_chooser_button_init)
        (gtk_file_chooser_button_file_chooser_iface_init)
        (gtk_file_chooser_button_add_shortcut_folder)
        (gtk_file_chooser_button_remove_shortcut_folder)
        (gtk_file_chooser_button_constructor)
        (gtk_file_chooser_button_set_property)
        (gtk_file_chooser_button_destroy)
        (gtk_file_chooser_button_finalize)
        (get_icon_theme) (get_display_name_for_path) (model_get_type_position)
        (model_free_row_data) (model_add_special) (model_add_other)
        (model_add_volumes) (model_add_bookmarks)
        (model_update_current_folder) (model_remove_rows)
        (filter_model_visible_func) (combo_box_row_separator_func)
        (name_cell_data_func) (update_combo_box) (fs_volumes_changed_cb)
        (fs_bookmarks_changed_cb) (combo_box_changed_cb)
        (change_icon_size): Use a GtkComboBox in SELECT_FOLDER mode (#157726).

        * gtk/gtkfilechooserbutton.c:
        * gtk/gtkfilechooserbutton.h (gtk_file_chooser_button_new)
        (gtk_file_chooser_button_new_with_backend): Add @action to constructors
        to match other GtkFileChooser impls. API CHANGE.

        * docs/tools/widgets.c (create_file_button):
        * tests/testfilechooserbutton.c (main): Update callers.

        * docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml: Reflect API
        change.

        * tests/testfilechooserbutton.c: Add LGPL license.
        (main): Added GOption parser for --backend and --right-to-left cmd line
        args.
        (add_pwds_parent_as_shortcut_clicked_cb)
        (del_pwds_parent_as_shortcut_clicked_cb) (tests_button_clicked_cb):
        Add shortcut_folders test.
        (chooser_current_folder_changed_cb) (chooser_selection_changed_cb)
        (chooser_file_activated_cb) (chooser_update_preview_cb): Print URIS,
        not filenames.
parent 43f85261
2004-12-15 James M. Cape <jcape@ignore-your.tv>
* gtk/gtkfilechooserbutton.c (struct _GtkFileChooserButtonPrivate)
(gtk_file_chooser_button_init)
(gtk_file_chooser_button_file_chooser_iface_init)
(gtk_file_chooser_button_add_shortcut_folder)
(gtk_file_chooser_button_remove_shortcut_folder)
(gtk_file_chooser_button_constructor)
(gtk_file_chooser_button_set_property)
(gtk_file_chooser_button_destroy)
(gtk_file_chooser_button_finalize)
(get_icon_theme) (get_display_name_for_path) (model_get_type_position)
(model_free_row_data) (model_add_special) (model_add_other)
(model_add_volumes) (model_add_bookmarks)
(model_update_current_folder) (model_remove_rows)
(filter_model_visible_func) (combo_box_row_separator_func)
(name_cell_data_func) (update_combo_box) (fs_volumes_changed_cb)
(fs_bookmarks_changed_cb) (combo_box_changed_cb)
(change_icon_size): Use a GtkComboBox in SELECT_FOLDER mode (#157726).
* gtk/gtkfilechooserbutton.c:
* gtk/gtkfilechooserbutton.h (gtk_file_chooser_button_new)
(gtk_file_chooser_button_new_with_backend): Add @action to constructors
to match other GtkFileChooser impls. API CHANGE.
* docs/tools/widgets.c (create_file_button):
* tests/testfilechooserbutton.c (main): Update callers.
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml: Reflect API
change.
* tests/testfilechooserbutton.c: Add LGPL license.
(main): Added GOption parser for --backend and --right-to-left cmd line
args.
(add_pwds_parent_as_shortcut_clicked_cb)
(del_pwds_parent_as_shortcut_clicked_cb) (tests_button_clicked_cb):
Add shortcut_folders test.
(chooser_current_folder_changed_cb) (chooser_selection_changed_cb)
(chooser_file_activated_cb) (chooser_update_preview_cb): Print URIS,
not filenames.
2004-12-15 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilechooserdefault.c (get_is_file_filtered): Don't
......
2004-12-15 James M. Cape <jcape@ignore-your.tv>
* gtk/gtkfilechooserbutton.c (struct _GtkFileChooserButtonPrivate)
(gtk_file_chooser_button_init)
(gtk_file_chooser_button_file_chooser_iface_init)
(gtk_file_chooser_button_add_shortcut_folder)
(gtk_file_chooser_button_remove_shortcut_folder)
(gtk_file_chooser_button_constructor)
(gtk_file_chooser_button_set_property)
(gtk_file_chooser_button_destroy)
(gtk_file_chooser_button_finalize)
(get_icon_theme) (get_display_name_for_path) (model_get_type_position)
(model_free_row_data) (model_add_special) (model_add_other)
(model_add_volumes) (model_add_bookmarks)
(model_update_current_folder) (model_remove_rows)
(filter_model_visible_func) (combo_box_row_separator_func)
(name_cell_data_func) (update_combo_box) (fs_volumes_changed_cb)
(fs_bookmarks_changed_cb) (combo_box_changed_cb)
(change_icon_size): Use a GtkComboBox in SELECT_FOLDER mode (#157726).
* gtk/gtkfilechooserbutton.c:
* gtk/gtkfilechooserbutton.h (gtk_file_chooser_button_new)
(gtk_file_chooser_button_new_with_backend): Add @action to constructors
to match other GtkFileChooser impls. API CHANGE.
* docs/tools/widgets.c (create_file_button):
* tests/testfilechooserbutton.c (main): Update callers.
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml: Reflect API
change.
* tests/testfilechooserbutton.c: Add LGPL license.
(main): Added GOption parser for --backend and --right-to-left cmd line
args.
(add_pwds_parent_as_shortcut_clicked_cb)
(del_pwds_parent_as_shortcut_clicked_cb) (tests_button_clicked_cb):
Add shortcut_folders test.
(chooser_current_folder_changed_cb) (chooser_selection_changed_cb)
(chooser_file_activated_cb) (chooser_update_preview_cb): Print URIS,
not filenames.
2004-12-15 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilechooserdefault.c (get_is_file_filtered): Don't
......
2004-12-15 James M. Cape <jcape@ignore-your.tv>
* gtk/gtkfilechooserbutton.c (struct _GtkFileChooserButtonPrivate)
(gtk_file_chooser_button_init)
(gtk_file_chooser_button_file_chooser_iface_init)
(gtk_file_chooser_button_add_shortcut_folder)
(gtk_file_chooser_button_remove_shortcut_folder)
(gtk_file_chooser_button_constructor)
(gtk_file_chooser_button_set_property)
(gtk_file_chooser_button_destroy)
(gtk_file_chooser_button_finalize)
(get_icon_theme) (get_display_name_for_path) (model_get_type_position)
(model_free_row_data) (model_add_special) (model_add_other)
(model_add_volumes) (model_add_bookmarks)
(model_update_current_folder) (model_remove_rows)
(filter_model_visible_func) (combo_box_row_separator_func)
(name_cell_data_func) (update_combo_box) (fs_volumes_changed_cb)
(fs_bookmarks_changed_cb) (combo_box_changed_cb)
(change_icon_size): Use a GtkComboBox in SELECT_FOLDER mode (#157726).
* gtk/gtkfilechooserbutton.c:
* gtk/gtkfilechooserbutton.h (gtk_file_chooser_button_new)
(gtk_file_chooser_button_new_with_backend): Add @action to constructors
to match other GtkFileChooser impls. API CHANGE.
* docs/tools/widgets.c (create_file_button):
* tests/testfilechooserbutton.c (main): Update callers.
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml: Reflect API
change.
* tests/testfilechooserbutton.c: Add LGPL license.
(main): Added GOption parser for --backend and --right-to-left cmd line
args.
(add_pwds_parent_as_shortcut_clicked_cb)
(del_pwds_parent_as_shortcut_clicked_cb) (tests_button_clicked_cb):
Add shortcut_folders test.
(chooser_current_folder_changed_cb) (chooser_selection_changed_cb)
(chooser_file_activated_cb) (chooser_update_preview_cb): Print URIS,
not filenames.
2004-12-15 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilechooserdefault.c (get_is_file_filtered): Don't
......
2004-12-15 James M. Cape <jcape@ignore-your.tv>
* gtk/gtkfilechooserbutton.c (struct _GtkFileChooserButtonPrivate)
(gtk_file_chooser_button_init)
(gtk_file_chooser_button_file_chooser_iface_init)
(gtk_file_chooser_button_add_shortcut_folder)
(gtk_file_chooser_button_remove_shortcut_folder)
(gtk_file_chooser_button_constructor)
(gtk_file_chooser_button_set_property)
(gtk_file_chooser_button_destroy)
(gtk_file_chooser_button_finalize)
(get_icon_theme) (get_display_name_for_path) (model_get_type_position)
(model_free_row_data) (model_add_special) (model_add_other)
(model_add_volumes) (model_add_bookmarks)
(model_update_current_folder) (model_remove_rows)
(filter_model_visible_func) (combo_box_row_separator_func)
(name_cell_data_func) (update_combo_box) (fs_volumes_changed_cb)
(fs_bookmarks_changed_cb) (combo_box_changed_cb)
(change_icon_size): Use a GtkComboBox in SELECT_FOLDER mode (#157726).
* gtk/gtkfilechooserbutton.c:
* gtk/gtkfilechooserbutton.h (gtk_file_chooser_button_new)
(gtk_file_chooser_button_new_with_backend): Add @action to constructors
to match other GtkFileChooser impls. API CHANGE.
* docs/tools/widgets.c (create_file_button):
* tests/testfilechooserbutton.c (main): Update callers.
* docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml: Reflect API
change.
* tests/testfilechooserbutton.c: Add LGPL license.
(main): Added GOption parser for --backend and --right-to-left cmd line
args.
(add_pwds_parent_as_shortcut_clicked_cb)
(del_pwds_parent_as_shortcut_clicked_cb) (tests_button_clicked_cb):
Add shortcut_folders test.
(chooser_current_folder_changed_cb) (chooser_selection_changed_cb)
(chooser_file_activated_cb) (chooser_update_preview_cb): Print URIS,
not filenames.
2004-12-15 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkfilechooserdefault.c (get_is_file_filtered): Don't
......
......@@ -74,6 +74,7 @@ This should not be accessed directly. Use the accessor functions below.
</para>
@title:
@action:
@Returns:
......@@ -83,6 +84,7 @@ This should not be accessed directly. Use the accessor functions below.
</para>
@title:
@action:
@backend:
@Returns:
......
......@@ -444,13 +444,14 @@ create_file_button (void)
vbox = gtk_vbox_new (FALSE, 12);
vbox2 = gtk_vbox_new (FALSE, 3);
align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
picker = gtk_file_chooser_button_new ("File Chooser Button");
picker = gtk_file_chooser_button_new ("File Chooser Button",
GTK_FILE_CHOOSER_ACTION_OPEN);
gtk_widget_set_size_request (picker, 150, -1);
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (picker), "/etc/yum.conf");
gtk_container_add (GTK_CONTAINER (align), picker);
gtk_box_pack_start (GTK_BOX (vbox2), align, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox2),
gtk_label_new ("File Button (Open)"),
gtk_label_new ("File Button (Files)"),
FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox),
......@@ -461,15 +462,14 @@ create_file_button (void)
vbox2 = gtk_vbox_new (FALSE, 3);
align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
picker = gtk_file_chooser_button_new ("File Chooser Button");
gtk_file_chooser_set_action (GTK_FILE_CHOOSER (picker),
GTK_FILE_CHOOSER_ACTION_SAVE);
picker = gtk_file_chooser_button_new ("File Chooser Button",
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
gtk_widget_set_size_request (picker, 150, -1);
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (picker), "/etc/yum.conf");
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (picker), "/");
gtk_container_add (GTK_CONTAINER (align), picker);
gtk_box_pack_start (GTK_BOX (vbox2), align, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox2),
gtk_label_new ("File Button (Save)"),
gtk_label_new ("File Button (Select Folder)"),
FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox),
vbox2, TRUE, TRUE, 0);
......
......@@ -33,12 +33,15 @@
#include "gtkalias.h"
#include "gtkintl.h"
#include "gtkbutton.h"
#include "gtkcombobox.h"
#include "gtkdnd.h"
#include "gtkicontheme.h"
#include "gtkiconfactory.h"
#include "gtkimage.h"
#include "gtklabel.h"
#include "gtkliststore.h"
#include "gtkstock.h"
#include "gtktreemodelfilter.h"
#include "gtkvseparator.h"
#include "gtkfilechooserdialog.h"
#include "gtkfilechooserprivate.h"
......@@ -53,11 +56,12 @@
#define GTK_FILE_CHOOSER_BUTTON_GET_PRIVATE(object) (GTK_FILE_CHOOSER_BUTTON ((object))->priv)
#define DEFAULT_FILENAME N_("(None)")
#define MIN_LABEL_WIDTH 100
#define ENTRY_BUTTON_SPACING 0
#define FALLBACK_ICON_SIZE 20
#define HOME_DISPLAY_NAME N_("Home")
#define DESKTOP_DISPLAY_NAME N_("Desktop")
#define FALLBACK_DISPLAY_NAME N_("(None)")
#define FALLBACK_ICON_NAME "stock_unknown"
#define FALLBACK_ICON_SIZE 20
/* ********************** *
* Private Enumerations *
......@@ -73,6 +77,33 @@ enum
PROP_WIDTH_CHARS
};
/* TreeModel Columns */
enum
{
ICON_COLUMN,
DISPLAY_NAME_COLUMN,
TYPE_COLUMN,
DATA_COLUMN,
NUM_COLUMNS
};
/* TreeModel Row Types */
typedef enum
{
ROW_TYPE_SPECIAL,
ROW_TYPE_VOLUME,
ROW_TYPE_SHORTCUT,
ROW_TYPE_BOOKMARK_SEPARATOR,
ROW_TYPE_BOOKMARK,
ROW_TYPE_CURRENT_FOLDER_SEPARATOR,
ROW_TYPE_CURRENT_FOLDER,
ROW_TYPE_OTHER_SEPARATOR,
ROW_TYPE_OTHER,
ROW_TYPE_INVALID = -1
}
RowType;
/* ******************** *
* Private Structures *
......@@ -84,16 +115,37 @@ struct _GtkFileChooserButtonPrivate
GtkWidget *button;
GtkWidget *image;
GtkWidget *label;
GtkWidget *combo_box;
GtkCellRenderer *icon_cell;
GtkCellRenderer *name_cell;
GtkTreeModel *model;
GtkTreeModel *filter_model;
GtkFilePath *old_path;
gchar *backend;
GtkFileSystem *fs;
GtkFilePath *old_path;
gulong combo_box_changed_id;
gulong dialog_file_activated_id;
gulong dialog_folder_changed_id;
gulong dialog_selection_changed_id;
gulong fs_volumes_changed_id;
gulong fs_bookmarks_changed_id;
gint icon_size;
guint8 n_special;
guint8 n_volumes;
guint8 n_shortcuts;
guint8 n_bookmarks;
guint8 has_bookmark_separator : 1;
guint8 has_current_folder_separator : 1;
guint8 has_current_folder : 1;
guint8 has_other_separator : 1;
/* Used for hiding/showing the dialog when the button is hidden */
guint8 active : 1;
guint8 active : 1;
};
......@@ -107,10 +159,20 @@ enum
TEXT_URI_LIST
};
/* ********************* *
* Function Prototypes *
* ********************* */
/* GtkFileChooserIface Functions */
static void gtk_file_chooser_button_file_chooser_iface_init (GtkFileChooserIface *iface);
static gboolean gtk_file_chooser_button_add_shortcut_folder (GtkFileChooser *chooser,
const GtkFilePath *path,
GError **error);
static gboolean gtk_file_chooser_button_remove_shortcut_folder (GtkFileChooser *chooser,
const GtkFilePath *path,
GError **error);
/* GObject Functions */
static GObject *gtk_file_chooser_button_constructor (GType type,
guint n_params,
......@@ -123,6 +185,7 @@ static void gtk_file_chooser_button_get_property (GObject *ob
guint param_id,
GValue *value,
GParamSpec *pspec);
static void gtk_file_chooser_button_finalize (GObject *object);
/* GtkObject Functions */
static void gtk_file_chooser_button_destroy (GtkObject *object);
......@@ -146,30 +209,72 @@ static void gtk_file_chooser_button_style_set (GtkWidget *wi
static void gtk_file_chooser_button_screen_changed (GtkWidget *widget,
GdkScreen *old_screen);
/* Child Widget Callbacks */
static void dialog_update_preview_cb (GtkFileChooser *dialog,
gpointer user_data);
static void dialog_selection_changed_cb (GtkFileChooser *dialog,
gpointer user_data);
static void dialog_file_activated_cb (GtkFileChooser *dialog,
gpointer user_data);
static void dialog_current_folder_changed_cb (GtkFileChooser *dialog,
gpointer user_data);
static void dialog_notify_cb (GObject *dialog,
GParamSpec *pspec,
gpointer user_data);
static gboolean dialog_delete_event_cb (GtkWidget *dialog,
GdkEvent *event,
gpointer user_data);
static void dialog_response_cb (GtkDialog *dialog,
gint response,
gpointer user_data);
static void button_clicked_cb (GtkButton *real_button,
gpointer user_data);
/* Utility Functions */
static void update_label_and_image (GtkFileChooserButton *button);
static GtkIconTheme *get_icon_theme (GtkWidget *widget);
static gchar *get_display_name_for_path (GtkFileSystem *fs,
const GtkFilePath *path);
static gint model_get_type_position (GtkFileChooserButton *button,
RowType row_type);
static void model_free_row_data (GtkFileChooserButton *button,
GtkTreeIter *iter);
static inline void model_add_special (GtkFileChooserButton *button);
static inline void model_add_other (GtkFileChooserButton *button);
static void model_add_volumes (GtkFileChooserButton *button,
GSList *volumes);
static void model_add_bookmarks (GtkFileChooserButton *button,
GSList *bookmarks);
static void model_update_current_folder (GtkFileChooserButton *button,
const GtkFilePath *path);
static void model_remove_rows (GtkFileChooserButton *button,
gint pos,
gint n_rows);
static gboolean filter_model_visible_func (GtkTreeModel *model,
GtkTreeIter *iter,
gpointer user_data);
static gboolean combo_box_row_separator_func (GtkTreeModel *model,
GtkTreeIter *iter,
gpointer user_data);
static void name_cell_data_func (GtkCellLayout *layout,
GtkCellRenderer *cell,
GtkTreeModel *model,
GtkTreeIter *iter,
gpointer user_data);
static void open_dialog (GtkFileChooserButton *button);
static void update_combo_box (GtkFileChooserButton *button);
static void update_label_and_image (GtkFileChooserButton *button);
/* Child Object Callbacks */
static void fs_volumes_changed_cb (GtkFileSystem *fs,
gpointer user_data);
static void fs_bookmarks_changed_cb (GtkFileSystem *fs,
gpointer user_data);
static void combo_box_changed_cb (GtkComboBox *combo_box,
gpointer user_data);
static void button_clicked_cb (GtkButton *real_button,
gpointer user_data);
static void dialog_update_preview_cb (GtkFileChooser *dialog,
gpointer user_data);
static void dialog_selection_changed_cb (GtkFileChooser *dialog,
gpointer user_data);
static void dialog_file_activated_cb (GtkFileChooser *dialog,
gpointer user_data);
static void dialog_current_folder_changed_cb (GtkFileChooser *dialog,
gpointer user_data);
static void dialog_notify_cb (GObject *dialog,
GParamSpec *pspec,
gpointer user_data);
static gboolean dialog_delete_event_cb (GtkWidget *dialog,
GdkEvent *event,
gpointer user_data);
static void dialog_response_cb (GtkDialog *dialog,
gint response,
gpointer user_data);
/* ******************* *
......@@ -177,7 +282,7 @@ static void update_label_and_image (GtkFileChooserButton
* ******************* */
G_DEFINE_TYPE_WITH_CODE (GtkFileChooserButton, gtk_file_chooser_button, GTK_TYPE_HBOX, { \
G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_CHOOSER, _gtk_file_chooser_delegate_iface_init) \
G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_CHOOSER, gtk_file_chooser_button_file_chooser_iface_init) \
});
......@@ -199,6 +304,7 @@ gtk_file_chooser_button_class_init (GtkFileChooserButtonClass * class)
gobject_class->constructor = gtk_file_chooser_button_constructor;
gobject_class->set_property = gtk_file_chooser_button_set_property;
gobject_class->get_property = gtk_file_chooser_button_get_property;
gobject_class->finalize = gtk_file_chooser_button_finalize;
gtkobject_class->destroy = gtk_file_chooser_button_destroy;
......@@ -259,7 +365,6 @@ gtk_file_chooser_button_class_init (GtkFileChooserButtonClass * class)
g_type_class_add_private (class, sizeof (GtkFileChooserButtonPrivate));
}
static void
gtk_file_chooser_button_init (GtkFileChooserButton *button)
{
......@@ -275,6 +380,7 @@ gtk_file_chooser_button_init (GtkFileChooserButton *button)
gtk_widget_push_composite_child ();
/* Button */
priv->button = gtk_button_new ();
g_signal_connect (priv->button, "clicked", G_CALLBACK (button_clicked_cb),
button);
......@@ -289,8 +395,8 @@ gtk_file_chooser_button_init (GtkFileChooserButton *button)
gtk_box_pack_start (GTK_BOX (box), priv->image, FALSE, FALSE, 0);
gtk_widget_show (priv->image);
priv->label = gtk_label_new (_(DEFAULT_FILENAME));
gtk_label_set_ellipsize (GTK_LABEL (priv->label), PANGO_ELLIPSIZE_START);
priv->label = gtk_label_new (_(FALLBACK_DISPLAY_NAME));
gtk_label_set_ellipsize (GTK_LABEL (priv->label), PANGO_ELLIPSIZE_END);
gtk_misc_set_alignment (GTK_MISC (priv->label), 0.0, 0.5);
gtk_container_add (GTK_CONTAINER (box), priv->label);
gtk_widget_show (priv->label);
......@@ -304,6 +410,36 @@ gtk_file_chooser_button_init (GtkFileChooserButton *button)
gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0);
gtk_widget_show (image);
/* Combo Box */
/* Keep in sync with columns enum, line 88 */
priv->model =
GTK_TREE_MODEL (gtk_list_store_new (NUM_COLUMNS,
GDK_TYPE_PIXBUF, /* Icon */
G_TYPE_STRING, /* Display Name */
G_TYPE_CHAR, /* Row Type */
G_TYPE_POINTER /* Volume || Path */));
priv->combo_box = gtk_combo_box_new ();
priv->combo_box_changed_id =
g_signal_connect (priv->combo_box, "changed",
G_CALLBACK (combo_box_changed_cb), button);
gtk_container_add (GTK_CONTAINER (button), priv->combo_box);
priv->icon_cell = gtk_cell_renderer_pixbuf_new ();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (priv->combo_box),
priv->icon_cell, FALSE);
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (priv->combo_box),
priv->icon_cell, "pixbuf", ICON_COLUMN);
priv->name_cell = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (priv->combo_box),
priv->name_cell, TRUE);
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (priv->combo_box),
priv->name_cell, "text", DISPLAY_NAME_COLUMN);
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (priv->combo_box),
priv->name_cell, name_cell_data_func,
NULL, NULL);
gtk_widget_pop_composite_child ();
/* DnD */
......@@ -319,6 +455,123 @@ gtk_file_chooser_button_init (GtkFileChooserButton *button)
}
/* ******************************* *
* GtkFileChooserIface Functions *
* ******************************* */
static void
gtk_file_chooser_button_file_chooser_iface_init (GtkFileChooserIface *iface)
{
_gtk_file_chooser_delegate_iface_init (iface);
iface->add_shortcut_folder = gtk_file_chooser_button_add_shortcut_folder;
iface->remove_shortcut_folder = gtk_file_chooser_button_remove_shortcut_folder;
}
static gboolean
gtk_file_chooser_button_add_shortcut_folder (GtkFileChooser *chooser,
const GtkFilePath *path,
GError **error)
{
GtkFileChooser *delegate;
gboolean retval;
delegate = g_object_get_qdata (G_OBJECT (chooser),
GTK_FILE_CHOOSER_DELEGATE_QUARK);
retval = _gtk_file_chooser_add_shortcut_folder (delegate, path, error);
if (retval)
{
GtkFileChooserButtonPrivate *priv;
GtkTreeIter iter;
gint pos;
GdkPixbuf *pixbuf;
gchar *display_name;
priv = GTK_FILE_CHOOSER_BUTTON_GET_PRIVATE (chooser);
pos = model_get_type_position (GTK_FILE_CHOOSER_BUTTON (chooser),
ROW_TYPE_SHORTCUT);
pos += priv->n_shortcuts;
pixbuf = gtk_file_system_render_icon (priv->fs, path,
GTK_WIDGET (chooser),
priv->icon_size, NULL);
display_name = get_display_name_for_path (priv->fs, path);
gtk_list_store_insert (GTK_LIST_STORE (priv->model), &iter, pos);
gtk_list_store_set (GTK_LIST_STORE (priv->model), &iter,
ICON_COLUMN, pixbuf,
DISPLAY_NAME_COLUMN, display_name,
TYPE_COLUMN, ROW_TYPE_SHORTCUT,
DATA_COLUMN, gtk_file_path_copy (path),
-1);
priv->n_shortcuts++;
if (pixbuf)
g_object_unref (pixbuf);
g_free (display_name);
gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (priv->filter_model));
}
return retval;
}