forked from AuroraMiddleware/gtk
new function to consolidate creating the path_bar.
Mon Mar 8 04:50:12 2004 Jonathan Blandford <jrb@gnome.org> * gtk/gtkfilechooserdefault.c (create_path_bar): new function to consolidate creating the path_bar. (gtk_file_chooser_default_set_current_folder): no longer need to pass in the filesystem. * gtk/gtkpathbar.h: Removed unused set_pixbuf functions in favor of just setting the filesystem. * gtk/gtkpathbar.c (gtk_path_bar_finalize): Free root path and home_dir. (get_button_image): Add images to path_bar. (update_button_appearance): use images (make_directory_button): Clasify buttons based upon location. (_gtk_path_bar_set_path): no longer need a file-system. Also, add rerooting, #135845, #135914 * tests/testfilechooser.c: Fix reused error handling.
This commit is contained in:
parent
683eff48dc
commit
59938d927c
20
ChangeLog
20
ChangeLog
@ -1,3 +1,23 @@
|
|||||||
|
Mon Mar 8 04:50:12 2004 Jonathan Blandford <jrb@gnome.org>
|
||||||
|
|
||||||
|
* gtk/gtkfilechooserdefault.c (create_path_bar): new function to
|
||||||
|
consolidate creating the path_bar.
|
||||||
|
(gtk_file_chooser_default_set_current_folder): no longer need to
|
||||||
|
pass in the filesystem.
|
||||||
|
|
||||||
|
* gtk/gtkpathbar.h: Removed unused set_pixbuf functions in favor
|
||||||
|
of just setting the filesystem.
|
||||||
|
|
||||||
|
* gtk/gtkpathbar.c (gtk_path_bar_finalize): Free root path and
|
||||||
|
home_dir.
|
||||||
|
(get_button_image): Add images to path_bar.
|
||||||
|
(update_button_appearance): use images
|
||||||
|
(make_directory_button): Clasify buttons based upon location.
|
||||||
|
(_gtk_path_bar_set_path): no longer need a file-system. Also, add
|
||||||
|
rerooting, #135845, #135914
|
||||||
|
|
||||||
|
* tests/testfilechooser.c: Fix reused error handling.
|
||||||
|
|
||||||
2004-03-08 Anders Carlsson <andersca@gnome.org>
|
2004-03-08 Anders Carlsson <andersca@gnome.org>
|
||||||
|
|
||||||
* gtk/gtkfilesystemunix.c: (get_icon_for_directory),
|
* gtk/gtkfilesystemunix.c: (get_icon_for_directory),
|
||||||
|
@ -1,3 +1,23 @@
|
|||||||
|
Mon Mar 8 04:50:12 2004 Jonathan Blandford <jrb@gnome.org>
|
||||||
|
|
||||||
|
* gtk/gtkfilechooserdefault.c (create_path_bar): new function to
|
||||||
|
consolidate creating the path_bar.
|
||||||
|
(gtk_file_chooser_default_set_current_folder): no longer need to
|
||||||
|
pass in the filesystem.
|
||||||
|
|
||||||
|
* gtk/gtkpathbar.h: Removed unused set_pixbuf functions in favor
|
||||||
|
of just setting the filesystem.
|
||||||
|
|
||||||
|
* gtk/gtkpathbar.c (gtk_path_bar_finalize): Free root path and
|
||||||
|
home_dir.
|
||||||
|
(get_button_image): Add images to path_bar.
|
||||||
|
(update_button_appearance): use images
|
||||||
|
(make_directory_button): Clasify buttons based upon location.
|
||||||
|
(_gtk_path_bar_set_path): no longer need a file-system. Also, add
|
||||||
|
rerooting, #135845, #135914
|
||||||
|
|
||||||
|
* tests/testfilechooser.c: Fix reused error handling.
|
||||||
|
|
||||||
2004-03-08 Anders Carlsson <andersca@gnome.org>
|
2004-03-08 Anders Carlsson <andersca@gnome.org>
|
||||||
|
|
||||||
* gtk/gtkfilesystemunix.c: (get_icon_for_directory),
|
* gtk/gtkfilesystemunix.c: (get_icon_for_directory),
|
||||||
|
@ -1,3 +1,23 @@
|
|||||||
|
Mon Mar 8 04:50:12 2004 Jonathan Blandford <jrb@gnome.org>
|
||||||
|
|
||||||
|
* gtk/gtkfilechooserdefault.c (create_path_bar): new function to
|
||||||
|
consolidate creating the path_bar.
|
||||||
|
(gtk_file_chooser_default_set_current_folder): no longer need to
|
||||||
|
pass in the filesystem.
|
||||||
|
|
||||||
|
* gtk/gtkpathbar.h: Removed unused set_pixbuf functions in favor
|
||||||
|
of just setting the filesystem.
|
||||||
|
|
||||||
|
* gtk/gtkpathbar.c (gtk_path_bar_finalize): Free root path and
|
||||||
|
home_dir.
|
||||||
|
(get_button_image): Add images to path_bar.
|
||||||
|
(update_button_appearance): use images
|
||||||
|
(make_directory_button): Clasify buttons based upon location.
|
||||||
|
(_gtk_path_bar_set_path): no longer need a file-system. Also, add
|
||||||
|
rerooting, #135845, #135914
|
||||||
|
|
||||||
|
* tests/testfilechooser.c: Fix reused error handling.
|
||||||
|
|
||||||
2004-03-08 Anders Carlsson <andersca@gnome.org>
|
2004-03-08 Anders Carlsson <andersca@gnome.org>
|
||||||
|
|
||||||
* gtk/gtkfilesystemunix.c: (get_icon_for_directory),
|
* gtk/gtkfilesystemunix.c: (get_icon_for_directory),
|
||||||
|
@ -1,3 +1,23 @@
|
|||||||
|
Mon Mar 8 04:50:12 2004 Jonathan Blandford <jrb@gnome.org>
|
||||||
|
|
||||||
|
* gtk/gtkfilechooserdefault.c (create_path_bar): new function to
|
||||||
|
consolidate creating the path_bar.
|
||||||
|
(gtk_file_chooser_default_set_current_folder): no longer need to
|
||||||
|
pass in the filesystem.
|
||||||
|
|
||||||
|
* gtk/gtkpathbar.h: Removed unused set_pixbuf functions in favor
|
||||||
|
of just setting the filesystem.
|
||||||
|
|
||||||
|
* gtk/gtkpathbar.c (gtk_path_bar_finalize): Free root path and
|
||||||
|
home_dir.
|
||||||
|
(get_button_image): Add images to path_bar.
|
||||||
|
(update_button_appearance): use images
|
||||||
|
(make_directory_button): Clasify buttons based upon location.
|
||||||
|
(_gtk_path_bar_set_path): no longer need a file-system. Also, add
|
||||||
|
rerooting, #135845, #135914
|
||||||
|
|
||||||
|
* tests/testfilechooser.c: Fix reused error handling.
|
||||||
|
|
||||||
2004-03-08 Anders Carlsson <andersca@gnome.org>
|
2004-03-08 Anders Carlsson <andersca@gnome.org>
|
||||||
|
|
||||||
* gtk/gtkfilesystemunix.c: (get_icon_for_directory),
|
* gtk/gtkfilesystemunix.c: (get_icon_for_directory),
|
||||||
|
@ -1,3 +1,23 @@
|
|||||||
|
Mon Mar 8 04:50:12 2004 Jonathan Blandford <jrb@gnome.org>
|
||||||
|
|
||||||
|
* gtk/gtkfilechooserdefault.c (create_path_bar): new function to
|
||||||
|
consolidate creating the path_bar.
|
||||||
|
(gtk_file_chooser_default_set_current_folder): no longer need to
|
||||||
|
pass in the filesystem.
|
||||||
|
|
||||||
|
* gtk/gtkpathbar.h: Removed unused set_pixbuf functions in favor
|
||||||
|
of just setting the filesystem.
|
||||||
|
|
||||||
|
* gtk/gtkpathbar.c (gtk_path_bar_finalize): Free root path and
|
||||||
|
home_dir.
|
||||||
|
(get_button_image): Add images to path_bar.
|
||||||
|
(update_button_appearance): use images
|
||||||
|
(make_directory_button): Clasify buttons based upon location.
|
||||||
|
(_gtk_path_bar_set_path): no longer need a file-system. Also, add
|
||||||
|
rerooting, #135845, #135914
|
||||||
|
|
||||||
|
* tests/testfilechooser.c: Fix reused error handling.
|
||||||
|
|
||||||
2004-03-08 Anders Carlsson <andersca@gnome.org>
|
2004-03-08 Anders Carlsson <andersca@gnome.org>
|
||||||
|
|
||||||
* gtk/gtkfilesystemunix.c: (get_icon_for_directory),
|
* gtk/gtkfilesystemunix.c: (get_icon_for_directory),
|
||||||
|
@ -208,7 +208,7 @@ typedef enum {
|
|||||||
} ShortcutsIndex;
|
} ShortcutsIndex;
|
||||||
|
|
||||||
/* Standard icon size */
|
/* Standard icon size */
|
||||||
/* FIXME: maybe this should correspond to the font size in the tree views... */
|
/* FIXME: this should correspond to gtk_icon_size_lookup_for_settings */
|
||||||
#define ICON_SIZE 20
|
#define ICON_SIZE 20
|
||||||
#define PREVIEW_HBOX_SPACING 12
|
#define PREVIEW_HBOX_SPACING 12
|
||||||
#define NUM_LINES 40
|
#define NUM_LINES 40
|
||||||
@ -1993,6 +1993,17 @@ create_filename_entry_and_filter_combo (GtkFileChooserDefault *impl)
|
|||||||
return hbox;
|
return hbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GtkWidget *
|
||||||
|
create_path_bar (GtkFileChooserDefault *impl)
|
||||||
|
{
|
||||||
|
GtkWidget *path_bar;
|
||||||
|
|
||||||
|
path_bar = g_object_new (GTK_TYPE_PATH_BAR, NULL);
|
||||||
|
_gtk_path_bar_set_file_system (GTK_PATH_BAR (path_bar), impl->file_system);
|
||||||
|
|
||||||
|
return path_bar;
|
||||||
|
}
|
||||||
|
|
||||||
/* Creates the widgets for the files/folders pane */
|
/* Creates the widgets for the files/folders pane */
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
file_pane_create (GtkFileChooserDefault *impl,
|
file_pane_create (GtkFileChooserDefault *impl,
|
||||||
@ -2008,7 +2019,7 @@ file_pane_create (GtkFileChooserDefault *impl,
|
|||||||
/* The path bar and 'Create Folder' button */
|
/* The path bar and 'Create Folder' button */
|
||||||
hbox = gtk_hbox_new (FALSE, 12);
|
hbox = gtk_hbox_new (FALSE, 12);
|
||||||
gtk_widget_show (hbox);
|
gtk_widget_show (hbox);
|
||||||
impl->browse_path_bar = g_object_new (GTK_TYPE_PATH_BAR, NULL);
|
impl->browse_path_bar = create_path_bar (impl);
|
||||||
g_signal_connect (impl->browse_path_bar, "path-clicked", G_CALLBACK (path_bar_clicked), impl);
|
g_signal_connect (impl->browse_path_bar, "path-clicked", G_CALLBACK (path_bar_clicked), impl);
|
||||||
gtk_widget_show_all (impl->browse_path_bar);
|
gtk_widget_show_all (impl->browse_path_bar);
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), impl->browse_path_bar, TRUE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), impl->browse_path_bar, TRUE, TRUE, 0);
|
||||||
@ -2858,7 +2869,7 @@ gtk_file_chooser_default_set_current_folder (GtkFileChooser *chooser,
|
|||||||
GError *err;
|
GError *err;
|
||||||
|
|
||||||
err = NULL;
|
err = NULL;
|
||||||
if (!_gtk_path_bar_set_path (GTK_PATH_BAR (impl->browse_path_bar), path, impl->file_system, &err))
|
if (!_gtk_path_bar_set_path (GTK_PATH_BAR (impl->browse_path_bar), path, &err))
|
||||||
{
|
{
|
||||||
g_propagate_error (error, err);
|
g_propagate_error (error, err);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
233
gtk/gtkpathbar.c
233
gtk/gtkpathbar.c
@ -22,7 +22,10 @@
|
|||||||
#include "gtkpathbar.h"
|
#include "gtkpathbar.h"
|
||||||
#include "gtktogglebutton.h"
|
#include "gtktogglebutton.h"
|
||||||
#include "gtkarrow.h"
|
#include "gtkarrow.h"
|
||||||
|
#include "gtkimage.h"
|
||||||
|
#include "gtkintl.h"
|
||||||
#include "gtklabel.h"
|
#include "gtklabel.h"
|
||||||
|
#include "gtkhbox.h"
|
||||||
#include "gtkmain.h"
|
#include "gtkmain.h"
|
||||||
#include "gtkmarshalers.h"
|
#include "gtkmarshalers.h"
|
||||||
|
|
||||||
@ -31,14 +34,22 @@ enum {
|
|||||||
LAST_SIGNAL
|
LAST_SIGNAL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
NORMAL_BUTTON,
|
||||||
|
ROOT_BUTTON,
|
||||||
|
HOME_BUTTON,
|
||||||
|
} ButtonType;
|
||||||
|
|
||||||
static guint path_bar_signals [LAST_SIGNAL] = { 0 };
|
static guint path_bar_signals [LAST_SIGNAL] = { 0 };
|
||||||
|
|
||||||
|
/* FIXME: this should correspond to gtk_icon_size_lookup_for_settings */
|
||||||
|
#define ICON_SIZE 20
|
||||||
|
|
||||||
|
|
||||||
G_DEFINE_TYPE (GtkPathBar,
|
G_DEFINE_TYPE (GtkPathBar,
|
||||||
gtk_path_bar,
|
gtk_path_bar,
|
||||||
GTK_TYPE_CONTAINER);
|
GTK_TYPE_CONTAINER);
|
||||||
|
|
||||||
|
|
||||||
static void gtk_path_bar_finalize (GObject *object);
|
static void gtk_path_bar_finalize (GObject *object);
|
||||||
static void gtk_path_bar_size_request (GtkWidget *widget,
|
static void gtk_path_bar_size_request (GtkWidget *widget,
|
||||||
GtkRequisition *requisition);
|
GtkRequisition *requisition);
|
||||||
@ -132,12 +143,16 @@ gtk_path_bar_finalize (GObject *object)
|
|||||||
|
|
||||||
path_bar = GTK_PATH_BAR (object);
|
path_bar = GTK_PATH_BAR (object);
|
||||||
g_list_free (path_bar->button_list);
|
g_list_free (path_bar->button_list);
|
||||||
if (path_bar->home_directory)
|
if (path_bar->home_path)
|
||||||
gtk_file_path_free (path_bar->home_directory);
|
gtk_file_path_free (path_bar->home_path);
|
||||||
|
if (path_bar->root_path)
|
||||||
|
gtk_file_path_free (path_bar->root_path);
|
||||||
if (path_bar->home_icon)
|
if (path_bar->home_icon)
|
||||||
g_object_unref (path_bar->home_icon);
|
g_object_unref (path_bar->home_icon);
|
||||||
if (path_bar->root_icon)
|
if (path_bar->root_icon)
|
||||||
g_object_unref (path_bar->home_icon);
|
g_object_unref (path_bar->home_icon);
|
||||||
|
if (path_bar->file_system)
|
||||||
|
g_object_unref (path_bar->file_system);
|
||||||
|
|
||||||
G_OBJECT_CLASS (gtk_path_bar_parent_class)->finalize (object);
|
G_OBJECT_CLASS (gtk_path_bar_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
@ -556,8 +571,6 @@ static void
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Public functions. */
|
/* Public functions. */
|
||||||
static void
|
static void
|
||||||
gtk_path_bar_clear_buttons (GtkPathBar *path_bar)
|
gtk_path_bar_clear_buttons (GtkPathBar *path_bar)
|
||||||
@ -585,28 +598,85 @@ button_clicked_cb (GtkWidget *button,
|
|||||||
g_signal_emit (path_bar, path_bar_signals [PATH_CLICKED], 0, file_path);
|
g_signal_emit (path_bar, path_bar_signals [PATH_CLICKED], 0, file_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static GdkPixbuf *
|
||||||
update_button_appearance (GtkWidget *button,
|
get_button_image (GtkPathBar *path_bar,
|
||||||
gboolean current_dir)
|
ButtonType button_type)
|
||||||
{
|
{
|
||||||
|
if (button_type == ROOT_BUTTON)
|
||||||
|
{
|
||||||
|
GtkFileSystemVolume *volume;
|
||||||
|
|
||||||
|
if (path_bar->root_icon != NULL)
|
||||||
|
return path_bar->root_icon;
|
||||||
|
|
||||||
|
volume = gtk_file_system_get_volume_for_path (path_bar->file_system, path_bar->root_path);
|
||||||
|
if (volume == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
path_bar->root_icon = gtk_file_system_volume_render_icon (path_bar->file_system,
|
||||||
|
volume,
|
||||||
|
GTK_WIDGET (path_bar),
|
||||||
|
ICON_SIZE,
|
||||||
|
NULL);
|
||||||
|
gtk_file_system_volume_free (path_bar->file_system, volume);
|
||||||
|
|
||||||
|
return path_bar->root_icon;
|
||||||
|
}
|
||||||
|
else if (button_type == HOME_BUTTON)
|
||||||
|
{
|
||||||
|
if (path_bar->home_icon != NULL)
|
||||||
|
return path_bar->home_icon;
|
||||||
|
|
||||||
|
path_bar->home_icon = gtk_file_system_render_icon (path_bar->file_system,
|
||||||
|
path_bar->home_path,
|
||||||
|
GTK_WIDGET (path_bar),
|
||||||
|
ICON_SIZE, NULL);
|
||||||
|
return path_bar->home_icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
update_button_appearance (GtkPathBar *path_bar,
|
||||||
|
GtkWidget *button,
|
||||||
|
gboolean current_dir)
|
||||||
|
{
|
||||||
|
GtkWidget *image;
|
||||||
GtkWidget *label;
|
GtkWidget *label;
|
||||||
const gchar *dir_name;
|
const gchar *dir_name;
|
||||||
|
ButtonType button_type;
|
||||||
|
|
||||||
dir_name = (const gchar *) g_object_get_data (G_OBJECT (button),
|
button_type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "gtk-path-bar-button-type"));
|
||||||
"gtk-path-bar-button-dir-name");
|
if (button_type == HOME_BUTTON)
|
||||||
label = gtk_bin_get_child (GTK_BIN (button));
|
dir_name = _("Home");
|
||||||
|
|
||||||
if (current_dir)
|
|
||||||
{
|
|
||||||
char *markup;
|
|
||||||
|
|
||||||
markup = g_markup_printf_escaped ("<b>%s</b>", dir_name);
|
|
||||||
gtk_label_set_markup (GTK_LABEL (label), markup);
|
|
||||||
g_free (markup);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
|
dir_name = (const gchar *) g_object_get_data (G_OBJECT (button), "gtk-path-bar-button-dir-name");
|
||||||
|
|
||||||
|
label = g_object_get_data (G_OBJECT (button), "gtk-path-bar-button-label");
|
||||||
|
image = g_object_get_data (G_OBJECT (button), "gtk-path-bar-button-image");
|
||||||
|
|
||||||
|
if (label != NULL)
|
||||||
{
|
{
|
||||||
gtk_label_set_text (GTK_LABEL (label), dir_name);
|
if (current_dir)
|
||||||
|
{
|
||||||
|
char *markup;
|
||||||
|
|
||||||
|
markup = g_markup_printf_escaped ("<b>%s</b>", dir_name);
|
||||||
|
gtk_label_set_markup (GTK_LABEL (label), markup);
|
||||||
|
g_free (markup);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gtk_label_set_text (GTK_LABEL (label), dir_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (image != NULL)
|
||||||
|
{
|
||||||
|
GdkPixbuf *pixbuf;
|
||||||
|
pixbuf = get_button_image (path_bar, button_type);
|
||||||
|
gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) != current_dir)
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) != current_dir)
|
||||||
@ -627,30 +697,70 @@ file_path_destroy (GtkFilePath *path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
make_directory_button (const char *dir_name,
|
make_directory_button (GtkPathBar *path_bar,
|
||||||
|
const char *dir_name,
|
||||||
GtkFilePath *path,
|
GtkFilePath *path,
|
||||||
gboolean current_dir)
|
gboolean current_dir)
|
||||||
{
|
{
|
||||||
GtkWidget *button, *label;
|
GtkWidget *button;
|
||||||
|
GtkWidget *child = NULL;
|
||||||
|
GtkWidget *label = NULL;
|
||||||
|
GtkWidget *image = NULL;
|
||||||
|
ButtonType button_type;
|
||||||
|
|
||||||
|
/* Is it a special button? */
|
||||||
|
button_type = NORMAL_BUTTON;
|
||||||
|
if (! gtk_file_path_compare (path, path_bar->root_path))
|
||||||
|
button_type = ROOT_BUTTON;
|
||||||
|
if (! gtk_file_path_compare (path, path_bar->home_path))
|
||||||
|
button_type = HOME_BUTTON;
|
||||||
|
|
||||||
button = gtk_toggle_button_new ();
|
button = gtk_toggle_button_new ();
|
||||||
label = gtk_label_new (NULL);
|
|
||||||
|
switch (button_type)
|
||||||
|
{
|
||||||
|
case ROOT_BUTTON:
|
||||||
|
image = gtk_image_new ();
|
||||||
|
child = image;
|
||||||
|
label = NULL;
|
||||||
|
break;
|
||||||
|
case HOME_BUTTON:
|
||||||
|
image = gtk_image_new ();
|
||||||
|
label = gtk_label_new (NULL);
|
||||||
|
child = gtk_hbox_new (FALSE, 2);
|
||||||
|
gtk_box_pack_start (GTK_BOX (child), image, FALSE, FALSE, 0);
|
||||||
|
gtk_box_pack_start (GTK_BOX (child), label, FALSE, FALSE, 0);
|
||||||
|
break;
|
||||||
|
case NORMAL_BUTTON:
|
||||||
|
label = gtk_label_new (NULL);
|
||||||
|
child = label;
|
||||||
|
image = NULL;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
g_assert_not_reached ();
|
||||||
|
}
|
||||||
|
|
||||||
g_signal_connect (button, "clicked",
|
g_signal_connect (button, "clicked",
|
||||||
G_CALLBACK (button_clicked_cb),
|
G_CALLBACK (button_clicked_cb),
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
/* FIXME: setting all this data is ugly. I really need a ButtonInfo
|
||||||
|
* struct. */
|
||||||
g_object_set_data_full (G_OBJECT (button), "gtk-path-bar-button-dir-name",
|
g_object_set_data_full (G_OBJECT (button), "gtk-path-bar-button-dir-name",
|
||||||
g_strdup (dir_name),
|
g_strdup (dir_name),
|
||||||
(GDestroyNotify) g_free);
|
(GDestroyNotify) g_free);
|
||||||
g_object_set_data_full (G_OBJECT (button), "gtk-path-bar-button-path",
|
g_object_set_data_full (G_OBJECT (button), "gtk-path-bar-button-path",
|
||||||
gtk_file_path_new_dup (gtk_file_path_get_string (path)),
|
gtk_file_path_new_dup (gtk_file_path_get_string (path)),
|
||||||
(GDestroyNotify) file_path_destroy);
|
(GDestroyNotify) file_path_destroy);
|
||||||
|
g_object_set_data (G_OBJECT (button), "gtk-path-bar-button-type",
|
||||||
|
GINT_TO_POINTER (button_type));
|
||||||
|
g_object_set_data (G_OBJECT (button), "gtk-path-bar-button-image", image);
|
||||||
|
g_object_set_data (G_OBJECT (button), "gtk-path-bar-button-label", label);
|
||||||
|
|
||||||
gtk_container_add (GTK_CONTAINER (button), label);
|
gtk_container_add (GTK_CONTAINER (button), child);
|
||||||
gtk_widget_show_all (button);
|
gtk_widget_show_all (button);
|
||||||
|
|
||||||
update_button_appearance (button, current_dir);
|
update_button_appearance (path_bar, button, current_dir);
|
||||||
|
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
@ -681,7 +791,8 @@ gtk_path_bar_check_parent_path (GtkPathBar *path_bar,
|
|||||||
{
|
{
|
||||||
for (list = path_bar->button_list; list; list = list->next)
|
for (list = path_bar->button_list; list; list = list->next)
|
||||||
{
|
{
|
||||||
update_button_appearance (GTK_WIDGET (list->data),
|
update_button_appearance (path_bar,
|
||||||
|
GTK_WIDGET (list->data),
|
||||||
(list == current_path) ? TRUE : FALSE);
|
(list == current_path) ? TRUE : FALSE);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -692,7 +803,6 @@ gtk_path_bar_check_parent_path (GtkPathBar *path_bar,
|
|||||||
gboolean
|
gboolean
|
||||||
_gtk_path_bar_set_path (GtkPathBar *path_bar,
|
_gtk_path_bar_set_path (GtkPathBar *path_bar,
|
||||||
const GtkFilePath *file_path,
|
const GtkFilePath *file_path,
|
||||||
GtkFileSystem *file_system,
|
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GtkFilePath *path;
|
GtkFilePath *path;
|
||||||
@ -701,11 +811,10 @@ _gtk_path_bar_set_path (GtkPathBar *path_bar,
|
|||||||
|
|
||||||
g_return_val_if_fail (GTK_IS_PATH_BAR (path_bar), FALSE);
|
g_return_val_if_fail (GTK_IS_PATH_BAR (path_bar), FALSE);
|
||||||
g_return_val_if_fail (file_path != NULL, FALSE);
|
g_return_val_if_fail (file_path != NULL, FALSE);
|
||||||
g_return_val_if_fail (file_system != NULL, FALSE);
|
|
||||||
|
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
|
|
||||||
if (gtk_path_bar_check_parent_path (path_bar, file_path, file_system))
|
if (gtk_path_bar_check_parent_path (path_bar, file_path, path_bar->file_system))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
gtk_path_bar_clear_buttons (path_bar);
|
gtk_path_bar_clear_buttons (path_bar);
|
||||||
@ -722,8 +831,9 @@ _gtk_path_bar_set_path (GtkPathBar *path_bar,
|
|||||||
GtkFileFolder *file_folder;
|
GtkFileFolder *file_folder;
|
||||||
GtkFileInfo *file_info;
|
GtkFileInfo *file_info;
|
||||||
gboolean valid;
|
gboolean valid;
|
||||||
|
ButtonType button_type;
|
||||||
|
|
||||||
valid = gtk_file_system_get_parent (file_system,
|
valid = gtk_file_system_get_parent (path_bar->file_system,
|
||||||
path,
|
path,
|
||||||
&parent_path,
|
&parent_path,
|
||||||
&err);
|
&err);
|
||||||
@ -736,10 +846,10 @@ _gtk_path_bar_set_path (GtkPathBar *path_bar,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (parent_path)
|
if (parent_path)
|
||||||
file_folder = gtk_file_system_get_folder (file_system, parent_path,
|
file_folder = gtk_file_system_get_folder (path_bar->file_system, parent_path,
|
||||||
GTK_FILE_INFO_DISPLAY_NAME, NULL);
|
GTK_FILE_INFO_DISPLAY_NAME, NULL);
|
||||||
else
|
else
|
||||||
file_folder = gtk_file_system_get_folder (file_system, path,
|
file_folder = gtk_file_system_get_folder (path_bar->file_system, path,
|
||||||
GTK_FILE_INFO_DISPLAY_NAME, NULL);
|
GTK_FILE_INFO_DISPLAY_NAME, NULL);
|
||||||
|
|
||||||
file_info = gtk_file_folder_get_info (file_folder, path, &err);
|
file_info = gtk_file_folder_get_info (file_folder, path, &err);
|
||||||
@ -754,10 +864,8 @@ _gtk_path_bar_set_path (GtkPathBar *path_bar,
|
|||||||
}
|
}
|
||||||
|
|
||||||
display_name = gtk_file_info_get_display_name (file_info);
|
display_name = gtk_file_info_get_display_name (file_info);
|
||||||
/* FIXME: Do this better */
|
|
||||||
if (! strcmp ("/", display_name))
|
button = make_directory_button (path_bar, display_name, path, first_directory);
|
||||||
display_name = " / ";
|
|
||||||
button = make_directory_button (display_name, path, first_directory);
|
|
||||||
gtk_file_info_free (file_info);
|
gtk_file_info_free (file_info);
|
||||||
gtk_file_path_free (path);
|
gtk_file_path_free (path);
|
||||||
g_object_unref (file_folder);
|
g_object_unref (file_folder);
|
||||||
@ -765,6 +873,14 @@ _gtk_path_bar_set_path (GtkPathBar *path_bar,
|
|||||||
gtk_container_add (GTK_CONTAINER (path_bar), button);
|
gtk_container_add (GTK_CONTAINER (path_bar), button);
|
||||||
path_bar->button_list = g_list_prepend (path_bar->button_list, button);
|
path_bar->button_list = g_list_prepend (path_bar->button_list, button);
|
||||||
|
|
||||||
|
button_type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button), "gtk-path-bar-button-type"));
|
||||||
|
if (button_type != NORMAL_BUTTON)
|
||||||
|
{
|
||||||
|
if (parent_path)
|
||||||
|
gtk_file_path_free (parent_path);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
path = parent_path;
|
path = parent_path;
|
||||||
first_directory = FALSE;
|
first_directory = FALSE;
|
||||||
}
|
}
|
||||||
@ -776,40 +892,21 @@ _gtk_path_bar_set_path (GtkPathBar *path_bar,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* FIXME: This should be a construct-only property */
|
||||||
void
|
void
|
||||||
gtk_path_bar_set_root_icon (GtkPathBar *path_bar,
|
_gtk_path_bar_set_file_system (GtkPathBar *path_bar,
|
||||||
GdkPixbuf *root_icon)
|
GtkFileSystem *file_system)
|
||||||
{
|
{
|
||||||
|
const char *home;
|
||||||
g_return_if_fail (GTK_IS_PATH_BAR (path_bar));
|
g_return_if_fail (GTK_IS_PATH_BAR (path_bar));
|
||||||
|
|
||||||
if (root_icon)
|
g_assert (path_bar->file_system == NULL);
|
||||||
path_bar->home_icon = g_object_ref (root_icon);
|
|
||||||
|
|
||||||
if (path_bar->root_icon)
|
path_bar->file_system = g_object_ref (file_system);
|
||||||
g_object_unref (root_icon);
|
|
||||||
|
home = g_get_home_dir ();
|
||||||
|
path_bar->home_path = gtk_file_system_filename_to_path (path_bar->file_system, home);
|
||||||
|
path_bar->root_path = gtk_file_system_filename_to_path (path_bar->file_system, "/");
|
||||||
|
|
||||||
path_bar->root_icon = root_icon;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
gtk_path_bar_set_home_icon (GtkPathBar *path_bar,
|
|
||||||
const GtkFilePath *home_directory,
|
|
||||||
GdkPixbuf *home_icon)
|
|
||||||
{
|
|
||||||
g_return_if_fail (GTK_IS_PATH_BAR (path_bar));
|
|
||||||
|
|
||||||
if (home_icon)
|
|
||||||
g_object_ref (home_icon);
|
|
||||||
|
|
||||||
if (path_bar->home_directory != NULL)
|
|
||||||
gtk_file_path_free (path_bar->home_directory);
|
|
||||||
if (path_bar->home_icon)
|
|
||||||
g_object_unref (home_icon);
|
|
||||||
|
|
||||||
if (home_directory)
|
|
||||||
path_bar->home_directory = gtk_file_path_new_dup (gtk_file_path_get_string (home_directory));
|
|
||||||
else
|
|
||||||
path_bar->home_directory = NULL;
|
|
||||||
path_bar->home_icon = home_icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -40,7 +40,9 @@ struct _GtkPathBar
|
|||||||
{
|
{
|
||||||
GtkContainer parent;
|
GtkContainer parent;
|
||||||
|
|
||||||
GtkFilePath *home_directory;
|
GtkFileSystem *file_system;
|
||||||
|
GtkFilePath *root_path;
|
||||||
|
GtkFilePath *home_path;
|
||||||
GdkPixbuf *home_icon;
|
GdkPixbuf *home_icon;
|
||||||
GdkPixbuf *root_icon;
|
GdkPixbuf *root_icon;
|
||||||
|
|
||||||
@ -63,15 +65,11 @@ struct _GtkPathBarClass
|
|||||||
};
|
};
|
||||||
|
|
||||||
GType gtk_path_bar_get_type (void) G_GNUC_CONST;
|
GType gtk_path_bar_get_type (void) G_GNUC_CONST;
|
||||||
gboolean _gtk_path_bar_set_path (GtkPathBar *path_bar,
|
void _gtk_path_bar_set_file_system (GtkPathBar *path_bar,
|
||||||
const GtkFilePath *file_path,
|
GtkFileSystem *file_system);
|
||||||
GtkFileSystem *file_system,
|
gboolean _gtk_path_bar_set_path (GtkPathBar *path_bar,
|
||||||
GError **error);
|
const GtkFilePath *file_path,
|
||||||
void _gtk_path_bar_set_root_icon (GtkPathBar *path_bar,
|
GError **error);
|
||||||
GdkPixbuf *home_icon);
|
|
||||||
void _gtk_path_bar_set_home_icon (GtkPathBar *path_bar,
|
|
||||||
const GtkFilePath *home_dir,
|
|
||||||
GdkPixbuf *home_icon);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
@ -216,6 +216,7 @@ my_new_from_file_at_size (const char *filename,
|
|||||||
|
|
||||||
fclose (f);
|
fclose (f);
|
||||||
|
|
||||||
|
g_assert (*error == NULL);
|
||||||
if (!gdk_pixbuf_loader_close (loader, error)) {
|
if (!gdk_pixbuf_loader_close (loader, error)) {
|
||||||
g_object_unref (G_OBJECT (loader));
|
g_object_unref (G_OBJECT (loader));
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -225,6 +226,11 @@ my_new_from_file_at_size (const char *filename,
|
|||||||
|
|
||||||
if (!pixbuf) {
|
if (!pixbuf) {
|
||||||
g_object_unref (G_OBJECT (loader));
|
g_object_unref (G_OBJECT (loader));
|
||||||
|
|
||||||
|
/* did the loader set an error? */
|
||||||
|
if (*error != NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
GDK_PIXBUF_ERROR,
|
GDK_PIXBUF_ERROR,
|
||||||
GDK_PIXBUF_ERROR_FAILED,
|
GDK_PIXBUF_ERROR_FAILED,
|
||||||
|
Loading…
Reference in New Issue
Block a user