2004-04-29  Federico Mena Quintero  <federico@ximian.com>

	Fixes #140412.

	* gtk/gtkfilechooserdefault.c (remove_selected_bookmarks): New
	function; moved the code over from
	remove_bookmark_button_clicked_cb().
	(remove_selected_bookmarks): Now, getting a non-removable bookmark
	is not an error, as we may be called as a result of hitting the
	Delete key.
	(shortcuts_key_press_event_cb): New handler; delete the bookmark
	if the user presses Backspace, Delete, or KP_Delete.
This commit is contained in:
Federico Mena Quintero
2004-04-29 23:13:50 +00:00
committed by Federico Mena Quintero
parent 40532b0d45
commit 6631943388
6 changed files with 120 additions and 21 deletions

View File

@ -1,3 +1,16 @@
2004-04-29 Federico Mena Quintero <federico@ximian.com>
Fixes #140412.
* gtk/gtkfilechooserdefault.c (remove_selected_bookmarks): New
function; moved the code over from
remove_bookmark_button_clicked_cb().
(remove_selected_bookmarks): Now, getting a non-removable bookmark
is not an error, as we may be called as a result of hitting the
Delete key.
(shortcuts_key_press_event_cb): New handler; delete the bookmark
if the user presses Backspace, Delete, or KP_Delete.
2004-04-29 Matthias Clasen <mclasen@redhat.com> 2004-04-29 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkaction.c (closure_accel_activate): Use * gtk/gtkaction.c (closure_accel_activate): Use

View File

@ -1,3 +1,16 @@
2004-04-29 Federico Mena Quintero <federico@ximian.com>
Fixes #140412.
* gtk/gtkfilechooserdefault.c (remove_selected_bookmarks): New
function; moved the code over from
remove_bookmark_button_clicked_cb().
(remove_selected_bookmarks): Now, getting a non-removable bookmark
is not an error, as we may be called as a result of hitting the
Delete key.
(shortcuts_key_press_event_cb): New handler; delete the bookmark
if the user presses Backspace, Delete, or KP_Delete.
2004-04-29 Matthias Clasen <mclasen@redhat.com> 2004-04-29 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkaction.c (closure_accel_activate): Use * gtk/gtkaction.c (closure_accel_activate): Use

View File

@ -1,3 +1,16 @@
2004-04-29 Federico Mena Quintero <federico@ximian.com>
Fixes #140412.
* gtk/gtkfilechooserdefault.c (remove_selected_bookmarks): New
function; moved the code over from
remove_bookmark_button_clicked_cb().
(remove_selected_bookmarks): Now, getting a non-removable bookmark
is not an error, as we may be called as a result of hitting the
Delete key.
(shortcuts_key_press_event_cb): New handler; delete the bookmark
if the user presses Backspace, Delete, or KP_Delete.
2004-04-29 Matthias Clasen <mclasen@redhat.com> 2004-04-29 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkaction.c (closure_accel_activate): Use * gtk/gtkaction.c (closure_accel_activate): Use

View File

@ -1,3 +1,16 @@
2004-04-29 Federico Mena Quintero <federico@ximian.com>
Fixes #140412.
* gtk/gtkfilechooserdefault.c (remove_selected_bookmarks): New
function; moved the code over from
remove_bookmark_button_clicked_cb().
(remove_selected_bookmarks): Now, getting a non-removable bookmark
is not an error, as we may be called as a result of hitting the
Delete key.
(shortcuts_key_press_event_cb): New handler; delete the bookmark
if the user presses Backspace, Delete, or KP_Delete.
2004-04-29 Matthias Clasen <mclasen@redhat.com> 2004-04-29 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkaction.c (closure_accel_activate): Use * gtk/gtkaction.c (closure_accel_activate): Use

View File

@ -1,3 +1,16 @@
2004-04-29 Federico Mena Quintero <federico@ximian.com>
Fixes #140412.
* gtk/gtkfilechooserdefault.c (remove_selected_bookmarks): New
function; moved the code over from
remove_bookmark_button_clicked_cb().
(remove_selected_bookmarks): Now, getting a non-removable bookmark
is not an error, as we may be called as a result of hitting the
Delete key.
(shortcuts_key_press_event_cb): New handler; delete the bookmark
if the user presses Backspace, Delete, or KP_Delete.
2004-04-29 Matthias Clasen <mclasen@redhat.com> 2004-04-29 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkaction.c (closure_accel_activate): Use * gtk/gtkaction.c (closure_accel_activate): Use

View File

@ -329,6 +329,11 @@ static void shortcuts_row_activated_cb (GtkTreeView *tree_view,
GtkTreePath *path, GtkTreePath *path,
GtkTreeViewColumn *column, GtkTreeViewColumn *column,
GtkFileChooserDefault *impl); GtkFileChooserDefault *impl);
static gboolean shortcuts_key_press_event_cb (GtkWidget *widget,
GdkEventKey *event,
GtkFileChooserDefault *impl);
static gboolean shortcuts_select_func (GtkTreeSelection *selection, static gboolean shortcuts_select_func (GtkTreeSelection *selection,
GtkTreeModel *model, GtkTreeModel *model,
GtkTreePath *path, GtkTreePath *path,
@ -1701,10 +1706,9 @@ add_bookmark_button_clicked_cb (GtkButton *button,
impl); impl);
} }
/* Callback used when the "Remove bookmark" button is clicked */ /* Removes the selected bookmarks */
static void static void
remove_bookmark_button_clicked_cb (GtkButton *button, remove_selected_bookmarks (GtkFileChooserDefault *impl)
GtkFileChooserDefault *impl)
{ {
GtkTreeSelection *selection; GtkTreeSelection *selection;
GtkTreeIter iter; GtkTreeIter iter;
@ -1714,28 +1718,33 @@ remove_bookmark_button_clicked_cb (GtkButton *button,
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view)); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view));
if (gtk_tree_selection_get_selected (selection, NULL, &iter)) if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
{ return;
gtk_tree_model_get (impl->shortcuts_filter_model, &iter,
SHORTCUTS_COL_PATH, &path,
SHORTCUTS_COL_REMOVABLE, &removable, -1);
if (!removable)
{
g_assert_not_reached ();
return;
}
error = NULL; gtk_tree_model_get (impl->shortcuts_filter_model, &iter,
if (!gtk_file_system_remove_bookmark (impl->file_system, path, &error)) SHORTCUTS_COL_PATH, &path,
{ SHORTCUTS_COL_REMOVABLE, &removable, -1);
error_dialog (impl, if (!removable)
_("Could not remove bookmark for %s:\n%s"), return;
path,
error); error = NULL;
} if (!gtk_file_system_remove_bookmark (impl->file_system, path, &error))
{
error_dialog (impl,
_("Could not remove bookmark for %s:\n%s"),
path,
error);
} }
} }
/* Callback used when the "Remove bookmark" button is clicked */
static void
remove_bookmark_button_clicked_cb (GtkButton *button,
GtkFileChooserDefault *impl)
{
remove_selected_bookmarks (impl);
}
struct selection_check_closure { struct selection_check_closure {
GtkFileChooserDefault *impl; GtkFileChooserDefault *impl;
gboolean empty; gboolean empty;
@ -2482,6 +2491,9 @@ shortcuts_list_create (GtkFileChooserDefault *impl)
g_signal_connect (impl->browse_shortcuts_tree_view, "row-activated", g_signal_connect (impl->browse_shortcuts_tree_view, "row-activated",
G_CALLBACK (shortcuts_row_activated_cb), impl); G_CALLBACK (shortcuts_row_activated_cb), impl);
g_signal_connect (impl->browse_shortcuts_tree_view, "key-press-event",
G_CALLBACK (shortcuts_key_press_event_cb), impl);
g_signal_connect (impl->browse_shortcuts_tree_view, "drag-begin", g_signal_connect (impl->browse_shortcuts_tree_view, "drag-begin",
G_CALLBACK (shortcuts_drag_begin_cb), impl); G_CALLBACK (shortcuts_drag_begin_cb), impl);
g_signal_connect (impl->browse_shortcuts_tree_view, "drag-end", g_signal_connect (impl->browse_shortcuts_tree_view, "drag-end",
@ -4819,6 +4831,28 @@ shortcuts_row_activated_cb (GtkTreeView *tree_view,
shortcuts_activate_item (impl, selected); shortcuts_activate_item (impl, selected);
} }
/* Handler for GtkWidget::key-press-event on the shortcuts list */
static gboolean
shortcuts_key_press_event_cb (GtkWidget *widget,
GdkEventKey *event,
GtkFileChooserDefault *impl)
{
guint modifiers;
modifiers = gtk_accelerator_get_default_mod_mask ();
if ((event->keyval == GDK_BackSpace
|| event->keyval == GDK_Delete
|| event->keyval == GDK_KP_Delete)
&& (event->state & modifiers) == 0)
{
remove_selected_bookmarks (impl);
return TRUE;
}
return FALSE;
}
static gboolean static gboolean
shortcuts_select_func (GtkTreeSelection *selection, shortcuts_select_func (GtkTreeSelection *selection,
GtkTreeModel *model, GtkTreeModel *model,