455284 - Focus or toggle location entry

2007-10-02  Federico Mena Quintero  <federico@novell.com>

	Fix http://bugzilla.gnome.org/show_bug.cgi?id=455284 - In the file
	chooser, Ctrl-L should switch to the location entry.  If we are
	already on the location entry, turn it off.  Based on a patch by
	Jaap A. Haitsma <jaap@haitsma.org> and an idea by Wouter
	Bolsterlee.

	* gtk/gtkfilechooserdefault.c (location_button_toggled_cb): Call
	location_mode_set() directly instead of using toggle_location_mode().
	(toggle_location_mode): Removed.
	(location_toggle_popup_handler): If the file entry is not visible,
	show it.  If it is visible, turn it off only if it is focused.
	Otherwise, switch to the entry.

Signed-off-by: Federico Mena Quintero <federico@gnu.org>

svn path=/trunk/; revision=18874
This commit is contained in:
Federico Mena Quintero 2007-10-02 15:50:27 +00:00 committed by Federico Mena Quintero
parent 63ee4ae25d
commit 721eb57a22
2 changed files with 43 additions and 17 deletions

View File

@ -1,3 +1,18 @@
2007-10-02 Federico Mena Quintero <federico@novell.com>
Fix http://bugzilla.gnome.org/show_bug.cgi?id=455284 - In the file
chooser, Ctrl-L should switch to the location entry. If we are
already on the location entry, turn it off. Based on a patch by
Jaap A. Haitsma <jaap@haitsma.org> and an idea by Wouter
Bolsterlee.
* gtk/gtkfilechooserdefault.c (location_button_toggled_cb): Call
location_mode_set() directly instead of using toggle_location_mode().
(toggle_location_mode): Removed.
(location_toggle_popup_handler): If the file entry is not visible,
show it. If it is visible, turn it off only if it is focused.
Otherwise, switch to the entry.
2007-10-01 Kristian Rietveld <kris@imendio.com> 2007-10-01 Kristian Rietveld <kris@imendio.com>
* gtk/gtktreeviewcolumn.c (gtk_tree_view_column_update_button): * gtk/gtktreeviewcolumn.c (gtk_tree_view_column_update_button):

View File

@ -5141,23 +5141,27 @@ location_mode_set (GtkFileChooserDefault *impl,
impl->location_mode = new_mode; 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 static void
location_toggle_popup_handler (GtkFileChooserDefault *impl) location_toggle_popup_handler (GtkFileChooserDefault *impl)
{ {
toggle_location_mode (impl, TRUE); /* If the file entry is not visible, show it.
* If it is visible, turn it off only if it is focused. Otherwise, switch to the entry.
*/
if (impl->location_mode == LOCATION_MODE_PATH_BAR)
{
location_mode_set (impl, LOCATION_MODE_FILENAME_ENTRY, TRUE);
}
else if (impl->location_mode == LOCATION_MODE_FILENAME_ENTRY)
{
if (GTK_WIDGET_HAS_FOCUS (impl->location_entry))
{
location_mode_set (impl, LOCATION_MODE_PATH_BAR, TRUE);
}
else
{
gtk_widget_grab_focus (impl->location_entry);
}
}
} }
/* Callback used when one of the location mode buttons is toggled */ /* Callback used when one of the location mode buttons is toggled */
@ -5166,15 +5170,22 @@ location_button_toggled_cb (GtkToggleButton *toggle,
GtkFileChooserDefault *impl) GtkFileChooserDefault *impl)
{ {
gboolean is_active; gboolean is_active;
LocationMode new_mode;
is_active = gtk_toggle_button_get_active (toggle); is_active = gtk_toggle_button_get_active (toggle);
if (is_active) if (is_active)
g_assert (impl->location_mode == LOCATION_MODE_PATH_BAR); {
g_assert (impl->location_mode == LOCATION_MODE_PATH_BAR);
new_mode = LOCATION_MODE_FILENAME_ENTRY;
}
else else
g_assert (impl->location_mode == LOCATION_MODE_FILENAME_ENTRY); {
g_assert (impl->location_mode == LOCATION_MODE_FILENAME_ENTRY);
new_mode = LOCATION_MODE_PATH_BAR;
}
toggle_location_mode (impl, FALSE); location_mode_set (impl, new_mode, FALSE);
} }
/* Creates a toggle button for the location entry. */ /* Creates a toggle button for the location entry. */