Display the root a bit more cleanly.

Mon Feb 23 15:23:23 2004  Jonathan Blandford  <jrb@gnome.org>

        * gtk/gtkpathbar.c (gtk_path_bar_set_path): Display the root a bit
        more cleanly.

        * gtk/gtkpathbar.h (struct _GtkPathBarClass): fix the signal.
This commit is contained in:
Jonathan Blandford 2004-02-23 20:24:01 +00:00 committed by Jonathan Blandford
parent fa72f157ac
commit 4b041f8241
9 changed files with 74 additions and 36 deletions

View File

@ -1,3 +1,10 @@
Mon Feb 23 15:23:23 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtkpathbar.c (gtk_path_bar_set_path): Display the root a bit
more cleanly.
* gtk/gtkpathbar.h (struct _GtkPathBarClass): fix the signal.
2004-02-23 Federico Mena Quintero <federico@ximian.com> 2004-02-23 Federico Mena Quintero <federico@ximian.com>
Rework the user interface of the file chooser, as per Rework the user interface of the file chooser, as per

View File

@ -1,3 +1,10 @@
Mon Feb 23 15:23:23 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtkpathbar.c (gtk_path_bar_set_path): Display the root a bit
more cleanly.
* gtk/gtkpathbar.h (struct _GtkPathBarClass): fix the signal.
2004-02-23 Federico Mena Quintero <federico@ximian.com> 2004-02-23 Federico Mena Quintero <federico@ximian.com>
Rework the user interface of the file chooser, as per Rework the user interface of the file chooser, as per

View File

@ -1,3 +1,10 @@
Mon Feb 23 15:23:23 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtkpathbar.c (gtk_path_bar_set_path): Display the root a bit
more cleanly.
* gtk/gtkpathbar.h (struct _GtkPathBarClass): fix the signal.
2004-02-23 Federico Mena Quintero <federico@ximian.com> 2004-02-23 Federico Mena Quintero <federico@ximian.com>
Rework the user interface of the file chooser, as per Rework the user interface of the file chooser, as per

View File

@ -1,3 +1,10 @@
Mon Feb 23 15:23:23 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtkpathbar.c (gtk_path_bar_set_path): Display the root a bit
more cleanly.
* gtk/gtkpathbar.h (struct _GtkPathBarClass): fix the signal.
2004-02-23 Federico Mena Quintero <federico@ximian.com> 2004-02-23 Federico Mena Quintero <federico@ximian.com>
Rework the user interface of the file chooser, as per Rework the user interface of the file chooser, as per

View File

@ -1,3 +1,10 @@
Mon Feb 23 15:23:23 2004 Jonathan Blandford <jrb@gnome.org>
* gtk/gtkpathbar.c (gtk_path_bar_set_path): Display the root a bit
more cleanly.
* gtk/gtkpathbar.h (struct _GtkPathBarClass): fix the signal.
2004-02-23 Federico Mena Quintero <federico@ximian.com> 2004-02-23 Federico Mena Quintero <federico@ximian.com>
Rework the user interface of the file chooser, as per Rework the user interface of the file chooser, as per

View File

@ -18,8 +18,6 @@
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
#define USE_PATH_BAR
#include "gdk/gdkkeysyms.h" #include "gdk/gdkkeysyms.h"
#include "gtkalignment.h" #include "gtkalignment.h"
#include "gtkbindings.h" #include "gtkbindings.h"
@ -268,7 +266,7 @@ static void shortcuts_row_activated_cb (GtkTreeView *tree_view,
static gboolean shortcuts_select_func (GtkTreeSelection *selection, static gboolean shortcuts_select_func (GtkTreeSelection *selection,
GtkTreeModel *model, GtkTreeModel *model,
GtkTreePath *path, GtkTreePath *path,
gboolean path_currentlny_selected, gboolean path_currently_selected,
gpointer data); gpointer data);
static void list_selection_changed (GtkTreeSelection *tree_selection, static void list_selection_changed (GtkTreeSelection *tree_selection,
@ -279,7 +277,7 @@ static void list_row_activated (GtkTreeView *tree_view,
GtkFileChooserDefault *impl); GtkFileChooserDefault *impl);
static void path_bar_clicked (GtkPathBar *path_bar, static void path_bar_clicked (GtkPathBar *path_bar,
const char *file_path, GtkFilePath *file_path,
GtkFileChooserDefault *impl); GtkFileChooserDefault *impl);
static void add_bookmark_button_clicked_cb (GtkButton *button, static void add_bookmark_button_clicked_cb (GtkButton *button,
@ -3101,14 +3099,10 @@ list_row_activated (GtkTreeView *tree_view,
static void static void
path_bar_clicked (GtkPathBar *path_bar, path_bar_clicked (GtkPathBar *path_bar,
const char *file_path, GtkFilePath *file_path,
GtkFileChooserDefault *impl) GtkFileChooserDefault *impl)
{ {
GtkFilePath *new_folder = NULL; _gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), file_path);
new_folder = gtk_file_path_new_dup (file_path);
_gtk_file_chooser_set_current_folder_path (GTK_FILE_CHOOSER (impl), new_folder);
gtk_file_path_free (new_folder);
} }
static const GtkFileInfo * static const GtkFileInfo *

View File

@ -1017,7 +1017,6 @@ _gtk_file_system_module_create (GtkFileSystemModule *fs_module)
GtkFileSystem * GtkFileSystem *
_gtk_file_system_create (const char *file_system_name) _gtk_file_system_create (const char *file_system_name)
{ {
struct FileSystemInfo *file_system_info;
GSList *l; GSList *l;
char *module_path; char *module_path;
GtkFileSystemModule *fs_module; GtkFileSystemModule *fs_module;
@ -1054,3 +1053,5 @@ _gtk_file_system_create (const char *file_system_name)
return fs; return fs;
} }

View File

@ -17,6 +17,7 @@
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
#include <string.h>
#include "gtkpathbar.h" #include "gtkpathbar.h"
#include "gtktogglebutton.h" #include "gtktogglebutton.h"
#include "gtkarrow.h" #include "gtkarrow.h"
@ -113,9 +114,9 @@ gtk_path_bar_class_init (GtkPathBarClass *path_bar_class)
G_SIGNAL_RUN_FIRST, G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkPathBarClass, path_clicked), G_STRUCT_OFFSET (GtkPathBarClass, path_clicked),
NULL, NULL, NULL, NULL,
_gtk_marshal_VOID__STRING, _gtk_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_NONE, 1,
G_TYPE_STRING); G_TYPE_POINTER);
} }
@ -562,11 +563,14 @@ button_clicked_cb (GtkWidget *button,
gpointer data) gpointer data)
{ {
GtkWidget *path_bar; GtkWidget *path_bar;
GtkFilePath *file_path;
path_bar = button->parent; path_bar = button->parent;
g_assert (path_bar); g_assert (path_bar);
g_signal_emit (path_bar, path_bar_signals [PATH_CLICKED], 0, (const char *) data); file_path = gtk_file_path_new_dup ((char *)data);
g_signal_emit (path_bar, path_bar_signals [PATH_CLICKED], 0, file_path);
gtk_file_path_free (file_path);
} }
static GtkWidget * static GtkWidget *
@ -588,8 +592,12 @@ make_directory_button (const char *dir_name,
{ {
gchar *str; gchar *str;
/* FIXME: gtk_file_path_free is not be a function!! I have to
* copy it to a string in order to manage this correctly */
str = g_strdup (gtk_file_path_get_string (path)); str = g_strdup (gtk_file_path_get_string (path));
g_signal_connect (button, "clicked", G_CALLBACK (button_clicked_cb), str); g_signal_connect (button, "clicked",
G_CALLBACK (button_clicked_cb),
str);
g_object_weak_ref (G_OBJECT (button), (GWeakNotify) g_free, str); g_object_weak_ref (G_OBJECT (button), (GWeakNotify) g_free, str);
} }
@ -623,9 +631,12 @@ gtk_path_bar_set_path (GtkPathBar *path_bar,
GtkFileSystem *file_system, GtkFileSystem *file_system,
GError **error) GError **error)
{ {
gboolean valid = TRUE;
GtkFilePath *path; GtkFilePath *path;
gboolean first_directory = TRUE; gboolean first_directory = TRUE;
g_return_if_fail (GTK_IS_PATH_BAR (path_bar));
g_return_if_fail (file_path != NULL);
g_return_if_fail (file_system != NULL);
gtk_path_bar_clear_buttons (path_bar); gtk_path_bar_clear_buttons (path_bar);
path = gtk_file_path_copy (file_path); path = gtk_file_path_copy (file_path);
@ -636,6 +647,9 @@ gtk_path_bar_set_path (GtkPathBar *path_bar,
GtkWidget *button; GtkWidget *button;
const gchar *display_name; const gchar *display_name;
GError *err = NULL; GError *err = NULL;
GtkFileFolder *file_folder;
GtkFileInfo *file_info;
gboolean valid;
valid = gtk_file_system_get_parent (file_system, valid = gtk_file_system_get_parent (file_system,
path, path,
@ -650,29 +664,23 @@ 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,
GtkFileFolder *file_folder; GTK_FILE_INFO_DISPLAY_NAME, NULL);
GtkFileInfo *file_info;
file_folder = gtk_file_system_get_folder (file_system, parent_path,
GTK_FILE_INFO_DISPLAY_NAME, NULL);
file_info = gtk_file_folder_get_info (file_folder, path, NULL);
display_name = gtk_file_info_get_display_name (file_info);
button = make_directory_button (display_name, path, first_directory);
gtk_file_info_free (file_info);
/* FIXME: ask owen about mem management. gtk_file_folder_free (file_folder); */
}
else else
{ file_folder = gtk_file_system_get_folder (file_system, path,
/* We've reached the root node */ GTK_FILE_INFO_DISPLAY_NAME, NULL);
/* FIXME: gtk_file_system_get_root_display_name() or something */
button = make_directory_button (gtk_file_path_get_string (path), file_info = gtk_file_folder_get_info (file_folder, path, NULL);
path, first_directory); display_name = gtk_file_info_get_display_name (file_info);
} if (! strcmp ("/", display_name))
display_name = " / ";
button = make_directory_button (display_name, path, first_directory);
gtk_file_info_free (file_info);
gtk_file_path_free (path);
g_object_unref (file_folder);
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);
gtk_file_path_free (path);
path = parent_path; path = parent_path;
first_directory = FALSE; first_directory = FALSE;

View File

@ -55,7 +55,7 @@ struct _GtkPathBarClass
GtkContainerClass parent_class; GtkContainerClass parent_class;
void (* path_clicked) (GtkPathBar *path_bar, void (* path_clicked) (GtkPathBar *path_bar,
const gchar *file_path); GtkFilePath *file_path);
}; };
GType gtk_path_bar_get_type (void) G_GNUC_CONST; GType gtk_path_bar_get_type (void) G_GNUC_CONST;