summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2007-03-23 05:06:00 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2007-03-23 05:06:00 +0000
commitdabf04423b09e1c017c607e965a5d22707badb8b (patch)
treec0b2a429a290fc2d6702c956c1e70d23c46ed985 /gtk
parent229999d8a9603ef0b8d524e27cc8c228de189744 (diff)
downloadgtk+-dabf04423b09e1c017c607e965a5d22707badb8b.tar.gz
Add a keybinding to toggle the visibility of the location entry. (#383354,
2007-03-23 Matthias Clasen <mclasen@redhat.com> * gtk/gtkfilechooserdefault.c: Add a keybinding to toggle the visibility of the location entry. (#383354, John Pye, patch by Carlos Garnacho) svn path=/trunk/; revision=17555
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkfilechooserdefault.c49
1 files changed, 36 insertions, 13 deletions
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index 95d42b679a..4adb524c88 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -161,6 +161,7 @@ enum {
HOME_FOLDER,
DESKTOP_FOLDER,
QUICK_BOOKMARK,
+ LOCATION_TOGGLE_POPUP,
LAST_SIGNAL
};
@@ -316,6 +317,7 @@ static void gtk_file_chooser_default_initial_focus (GtkFileCh
static void location_popup_handler (GtkFileChooserDefault *impl,
const gchar *path);
static void location_popup_on_paste_handler (GtkFileChooserDefault *impl);
+static void location_toggle_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);
@@ -497,6 +499,14 @@ _gtk_file_chooser_default_class_init (GtkFileChooserDefaultClass *class)
NULL, NULL,
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+ signals[LOCATION_TOGGLE_POPUP] =
+ _gtk_binding_signal_new (I_("location-toggle-popup"),
+ G_OBJECT_CLASS_TYPE (class),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
+ G_CALLBACK (location_toggle_popup_handler),
+ NULL, NULL,
+ _gtk_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
signals[UP_FOLDER] =
_gtk_binding_signal_new (I_("up-folder"),
G_OBJECT_CLASS_TYPE (class),
@@ -542,8 +552,8 @@ _gtk_file_chooser_default_class_init (GtkFileChooserDefaultClass *class)
gtk_binding_entry_add_signal (binding_set,
GDK_l, GDK_CONTROL_MASK,
- "location-popup",
- 1, G_TYPE_STRING, "");
+ "location-toggle-popup",
+ 0);
gtk_binding_entry_add_signal (binding_set,
GDK_slash, 0,
@@ -4550,28 +4560,40 @@ location_mode_set (GtkFileChooserDefault *impl,
impl->location_mode = new_mode;
}
+static void
+toggle_location_mode (GtkFileChooserDefault *impl,
+ gboolean set_button)
+{
+ LocationMode new_mode;
+
+ /* toggle value */
+ new_mode = (impl->location_mode == LOCATION_MODE_PATH_BAR) ?
+ LOCATION_MODE_FILENAME_ENTRY : LOCATION_MODE_PATH_BAR;
+
+ location_mode_set (impl, new_mode, set_button);
+}
+
+static void
+location_toggle_popup_handler (GtkFileChooserDefault *impl)
+{
+ toggle_location_mode (impl, TRUE);
+}
+
/* Callback used when one of the location mode buttons is toggled */
static void
location_button_toggled_cb (GtkToggleButton *toggle,
GtkFileChooserDefault *impl)
{
gboolean is_active;
- LocationMode new_mode;
is_active = gtk_toggle_button_get_active (toggle);
if (is_active)
- {
- g_assert (impl->location_mode == LOCATION_MODE_PATH_BAR);
- new_mode = LOCATION_MODE_FILENAME_ENTRY;
- }
+ g_assert (impl->location_mode == LOCATION_MODE_PATH_BAR);
else
- {
- g_assert (impl->location_mode == LOCATION_MODE_FILENAME_ENTRY);
- new_mode = LOCATION_MODE_PATH_BAR;
- }
+ g_assert (impl->location_mode == LOCATION_MODE_FILENAME_ENTRY);
- location_mode_set (impl, new_mode, FALSE);
+ toggle_location_mode (impl, FALSE);
}
/* Creates a toggle button for the location entry. */
@@ -8296,7 +8318,8 @@ list_selection_changed (GtkTreeSelection *selection,
out:
- update_chooser_entry (impl);
+ if (impl->location_entry)
+ update_chooser_entry (impl);
check_preview_change (impl);
bookmarks_check_add_sensitivity (impl);