Add _gtk_path_bar_up()/ _gtk_path_bar_down().

Sun Mar 14 21:03:15 2004  Owen Taylor  <otaylor@redhat.com>

        * gtk/gtkpathbar.[ch]: Add _gtk_path_bar_up()/
        _gtk_path_bar_down().

        * gtk/gtkfilechooserdefault.c: Use _gtk_path_bar_up()/
        _gtk_path_bar_down() as bindings for Alt-Up
        and new Alt-Down. (Partly based on a patch by
        Mark McLoughlin, #136987)
This commit is contained in:
Owen Taylor 2004-03-15 02:12:08 +00:00 committed by Owen Taylor
parent dfa36bb4e4
commit f8b3e6fe42
7 changed files with 131 additions and 17 deletions

View File

@ -1,3 +1,13 @@
Sun Mar 14 21:03:15 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtkpathbar.[ch]: Add _gtk_path_bar_up()/
_gtk_path_bar_down().
* gtk/gtkfilechooserdefault.c: Use _gtk_path_bar_up()/
_gtk_path_bar_down() as bindings for Alt-Up
and new Alt-Down. (Partly based on a patch by
Mark McLoughlin, #136987)
2004-03-14 Federico Mena Quintero <federico@ximian.com>
Fixes #136185, patch by Morten Welinder, with some changes.

View File

@ -1,3 +1,13 @@
Sun Mar 14 21:03:15 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtkpathbar.[ch]: Add _gtk_path_bar_up()/
_gtk_path_bar_down().
* gtk/gtkfilechooserdefault.c: Use _gtk_path_bar_up()/
_gtk_path_bar_down() as bindings for Alt-Up
and new Alt-Down. (Partly based on a patch by
Mark McLoughlin, #136987)
2004-03-14 Federico Mena Quintero <federico@ximian.com>
Fixes #136185, patch by Morten Welinder, with some changes.

View File

@ -1,3 +1,13 @@
Sun Mar 14 21:03:15 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtkpathbar.[ch]: Add _gtk_path_bar_up()/
_gtk_path_bar_down().
* gtk/gtkfilechooserdefault.c: Use _gtk_path_bar_up()/
_gtk_path_bar_down() as bindings for Alt-Up
and new Alt-Down. (Partly based on a patch by
Mark McLoughlin, #136987)
2004-03-14 Federico Mena Quintero <federico@ximian.com>
Fixes #136185, patch by Morten Welinder, with some changes.

View File

@ -1,3 +1,13 @@
Sun Mar 14 21:03:15 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtkpathbar.[ch]: Add _gtk_path_bar_up()/
_gtk_path_bar_down().
* gtk/gtkfilechooserdefault.c: Use _gtk_path_bar_up()/
_gtk_path_bar_down() as bindings for Alt-Up
and new Alt-Down. (Partly based on a patch by
Mark McLoughlin, #136987)
2004-03-14 Federico Mena Quintero <federico@ximian.com>
Fixes #136185, patch by Morten Welinder, with some changes.

View File

@ -1,3 +1,13 @@
Sun Mar 14 21:03:15 2004 Owen Taylor <otaylor@redhat.com>
* gtk/gtkpathbar.[ch]: Add _gtk_path_bar_up()/
_gtk_path_bar_down().
* gtk/gtkfilechooserdefault.c: Use _gtk_path_bar_up()/
_gtk_path_bar_down() as bindings for Alt-Up
and new Alt-Down. (Partly based on a patch by
Mark McLoughlin, #136987)
2004-03-14 Federico Mena Quintero <federico@ximian.com>
Fixes #136185, patch by Morten Welinder, with some changes.

View File

@ -138,6 +138,7 @@ struct _GtkFileChooserDefault
GtkFilePath *current_volume_path;
GtkFilePath *current_folder;
GtkFilePath *lowest_folder;
GtkFilePath *preview_path;
char *preview_display_name;
@ -168,6 +169,7 @@ struct _GtkFileChooserDefault
enum {
LOCATION_POPUP,
UP_FOLDER,
DOWN_FOLDER,
HOME_FOLDER,
LAST_SIGNAL
};
@ -306,6 +308,7 @@ static void gtk_file_chooser_default_initial_focus (GtkFileCh
static void location_popup_handler (GtkFileChooserDefault *impl);
static void up_folder_handler (GtkFileChooserDefault *impl);
static void down_folder_handler (GtkFileChooserDefault *impl);
static void home_folder_handler (GtkFileChooserDefault *impl);
static void update_appearance (GtkFileChooserDefault *impl);
@ -486,6 +489,14 @@ gtk_file_chooser_default_class_init (GtkFileChooserDefaultClass *class)
NULL, NULL,
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
signals[DOWN_FOLDER] =
_gtk_binding_signal_new ("down-folder",
G_OBJECT_CLASS_TYPE (class),
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
G_CALLBACK (down_folder_handler),
NULL, NULL,
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
signals[HOME_FOLDER] =
_gtk_binding_signal_new ("home-folder",
G_OBJECT_CLASS_TYPE (class),
@ -511,6 +522,15 @@ gtk_file_chooser_default_class_init (GtkFileChooserDefaultClass *class)
"up-folder",
0);
gtk_binding_entry_add_signal (binding_set,
GDK_Down, GDK_MOD1_MASK,
"down-folder",
0);
gtk_binding_entry_add_signal (binding_set,
GDK_KP_Down, GDK_MOD1_MASK,
"down-folder",
0);
gtk_binding_entry_add_signal (binding_set,
GDK_Home, GDK_MOD1_MASK,
"home-folder",
@ -4941,24 +4961,14 @@ location_popup_handler (GtkFileChooserDefault *impl)
static void
up_folder_handler (GtkFileChooserDefault *impl)
{
GtkFilePath *parent_path;
GError *error;
_gtk_path_bar_up (GTK_PATH_BAR (impl->browse_path_bar));
}
error = NULL;
if (gtk_file_system_get_parent (impl->file_system, impl->current_folder, &parent_path, &error))
{
if (parent_path) /* If we were on a root, parent_path will be NULL */
{
change_folder_and_display_error (impl, parent_path);
gtk_file_path_free (parent_path);
}
}
else
{
error_dialog (impl,
_("Could not go to the parent folder of %s:\n%s"),
impl->current_folder, error);
}
/* Handler for the "down-folder" keybinding signal */
static void
down_folder_handler (GtkFileChooserDefault *impl)
{
_gtk_path_bar_down (GTK_PATH_BAR (impl->browse_path_bar));
}
/* Handler for the "home-folder" keybinding signal */

View File

@ -1073,3 +1073,57 @@ _gtk_path_bar_set_file_system (GtkPathBar *path_bar,
path_bar->root_path = gtk_file_system_filename_to_path (path_bar->file_system, "/");
g_free (desktop);
}
/**
* _gtk_path_bar_up:
* @path_bar: a #GtkPathBar
*
* If the selected button in the pathbar is not the furthest button "up" (in the
* root direction), act as if the user clicked on the next button up.
**/
void
_gtk_path_bar_up (GtkPathBar *path_bar)
{
GList *l;
for (l = path_bar->button_list; l; l = l->next)
{
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
*
* If the selected button in the pathbar is not the furthest button "down" (in the
* leaf direction), act as if the user clicked on the next button down.
**/
void
_gtk_path_bar_down (GtkPathBar *path_bar)
{
GList *l;
for (l = path_bar->button_list; l; l = l->next)
{
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;
}
}
}