diff --git a/src/nautilus-bookmark-list.c b/src/nautilus-bookmark-list.c index 6f2971aade316509ea962e40eeeb1325cd45f83c..8733252e715cad31002d43d4ad4d1990e81ca535 100644 --- a/src/nautilus-bookmark-list.c +++ b/src/nautilus-bookmark-list.c @@ -330,15 +330,9 @@ nautilus_bookmark_list_move_item (NautilusBookmarkList *bookmarks, bookmarks->list = g_list_remove_link (bookmarks->list, bookmark_item); - if (index < destination) { - bookmarks->list = g_list_insert (bookmarks->list, - bookmark_item->data, - destination - 1); - } else { - bookmarks->list = g_list_insert (bookmarks->list, - bookmark_item->data, - destination); - } + bookmarks->list = g_list_insert (bookmarks->list, + bookmark_item->data, + destination); nautilus_bookmark_list_save_file (bookmarks); } diff --git a/src/nautilus-bookmarks-window.c b/src/nautilus-bookmarks-window.c index e86d10b7aa0cc397ccba00bfbc1c75c086fbf326..a308e1aa33f78d43b564174dbdec9979b3ed2fd1 100644 --- a/src/nautilus-bookmarks-window.c +++ b/src/nautilus-bookmarks-window.c @@ -53,7 +53,8 @@ static int selection_changed_id = 0; static GtkWidget *name_field = NULL; static int name_field_changed_signal_id; static GtkWidget *remove_button = NULL; -static GtkWidget *jump_button = NULL; +static GtkWidget *up_button = NULL; +static GtkWidget *down_button = NULL; static gboolean text_changed = FALSE; static gboolean name_text_changed = FALSE; static GtkWidget *uri_field = NULL; @@ -121,39 +122,6 @@ get_selected_bookmark (void) return nautilus_bookmark_list_item_at(bookmarks, get_selected_row ()); } -static void -nautilus_bookmarks_window_response_cb (GtkDialog *dialog, - int response_id, - gpointer callback_data) -{ - if (response_id == GTK_RESPONSE_HELP) { - GError *error = NULL; - - gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (dialog)), - "help:gnome-help/nautilus-bookmarks-edit", - gtk_get_current_event_time (), &error); - - if (error) { - GtkWidget *err_dialog; - err_dialog = gtk_message_dialog_new (GTK_WINDOW (dialog), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("There was an error displaying help: \n%s"), - error->message); - - g_signal_connect (G_OBJECT (err_dialog), - "response", G_CALLBACK (gtk_widget_destroy), - NULL); - gtk_window_set_resizable (GTK_WINDOW (err_dialog), FALSE); - gtk_widget_show (err_dialog); - g_error_free (error); - } - } else if (response_id == GTK_RESPONSE_CLOSE) { - gtk_widget_destroy (GTK_WIDGET (dialog)); - } -} - static int nautilus_bookmarks_window_key_press_event_cb (GtkWindow *window, GdkEventKey *event, @@ -191,6 +159,27 @@ setup_empty_list (void) -1); } +static void +update_button_sensitivity (void) +{ + NautilusBookmark *selected; + int n_active; + int index = -1; + + selected = get_selected_bookmark (); + n_active = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (bookmark_list_store), NULL); + if (selected != NULL) { + index = get_selected_row (); + } + + /* Set the sensitivity of widgets that require a selection */ + gtk_widget_set_sensitive (remove_button, index >= 0 && n_active > 1); + gtk_widget_set_sensitive (up_button, index > 0); + gtk_widget_set_sensitive (down_button, index >= 0 && index < n_active - 1); + gtk_widget_set_sensitive (name_field, selected != NULL); + gtk_widget_set_sensitive (uri_field, selected != NULL); +} + static void on_selection_changed (GtkTreeSelection *treeselection, gpointer user_data) @@ -212,12 +201,8 @@ on_selection_changed (GtkTreeSelection *treeselection, g_object_unref (location); } - - /* Set the sensitivity of widgets that require a selection */ - gtk_widget_set_sensitive (remove_button, selected != NULL); - gtk_widget_set_sensitive (jump_button, selected != NULL); - gtk_widget_set_sensitive (name_field, selected != NULL); - gtk_widget_set_sensitive (uri_field, selected != NULL); + + update_button_sensitivity (); g_signal_handler_block (name_field, name_field_changed_signal_id); nautilus_entry_set_text (NAUTILUS_ENTRY (name_field), @@ -416,13 +401,6 @@ open_selected_bookmark (NautilusWindow *window) g_object_unref (location); } -static void -on_jump_button_clicked (GtkButton *button, - gpointer user_data) -{ - open_selected_bookmark (user_data); -} - static void bookmarks_delete_bookmark (void) { @@ -466,6 +444,33 @@ on_remove_button_clicked (GtkButton *button, bookmarks_delete_bookmark (); } +static void +on_up_button_clicked (GtkButton *button, + gpointer user_data) +{ + guint row; + GtkTreeIter iter; + + row = get_selected_row (); + nautilus_bookmark_list_move_item (bookmarks, row, row - 1); + gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (bookmark_list_store), + &iter, NULL, row - 1); + gtk_tree_selection_select_iter (bookmark_selection, &iter); +} + +static void +on_down_button_clicked (GtkButton *button, + gpointer user_data) +{ + guint row; + GtkTreeIter iter; + + row = get_selected_row (); + nautilus_bookmark_list_move_item (bookmarks, row, row + 1); + gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (bookmark_list_store), + &iter, NULL, row + 1); + gtk_tree_selection_select_iter (bookmark_selection, &iter); +} /* This is a bit of a kludge to get DnD to work. We check if the row in the GtkListStore matches the one in the bookmark list. If it doesn't, we assume @@ -709,12 +714,11 @@ nautilus_bookmarks_window_new (NautilusWindow *parent_window, g_signal_connect (window, "key-press-event", G_CALLBACK (nautilus_bookmarks_window_key_press_event_cb), NULL); - g_signal_connect (window, "response", - G_CALLBACK (nautilus_bookmarks_window_response_cb), NULL); bookmark_list_widget = GTK_TREE_VIEW (gtk_builder_get_object (builder, "bookmark_tree_view")); - remove_button = GTK_WIDGET (gtk_builder_get_object (builder, "bookmark_delete_button")); - jump_button = GTK_WIDGET (gtk_builder_get_object (builder, "bookmark_jump_button")); + remove_button = GTK_WIDGET (gtk_builder_get_object (builder, "bookmark_remove_button")); + up_button = GTK_WIDGET (gtk_builder_get_object (builder, "bookmark_up_button")); + down_button = GTK_WIDGET (gtk_builder_get_object (builder, "bookmark_down_button")); rend = gtk_cell_renderer_pixbuf_new (); g_object_set (rend, @@ -814,8 +818,10 @@ nautilus_bookmarks_window_new (NautilusWindow *parent_window, G_CALLBACK (name_or_uri_field_activate), NULL); g_signal_connect (remove_button, "clicked", G_CALLBACK (on_remove_button_clicked), NULL); - g_signal_connect (jump_button, "clicked", - G_CALLBACK (on_jump_button_clicked), parent_window); + g_signal_connect (up_button, "clicked", + G_CALLBACK (on_up_button_clicked), NULL); + g_signal_connect (down_button, "clicked", + G_CALLBACK (on_down_button_clicked), NULL); gtk_tree_selection_set_mode (bookmark_selection, GTK_SELECTION_BROWSE); diff --git a/src/nautilus-bookmarks-window.ui b/src/nautilus-bookmarks-window.ui index 4d0ed8e2c3aa1a3e93f0528fa9997f14d245a584..49f674f0faaea207cddc6445f60a75363a6362a3 100644 --- a/src/nautilus-bookmarks-window.ui +++ b/src/nautilus-bookmarks-window.ui @@ -1,48 +1,133 @@ - - + + False - 5 - Edit Bookmarks - center - normal - - + 6 + Bookmarks + + True False - vertical - 2 - - + 5 + 18 + + + 200 True False - end + vertical - - gtk-help + True True - True - False - False - True + never + in + + + True + True + False + True + + + + + - False + True True 0 - - gtk-jump-to + True - True - True - False - False - True + False + icons + 1 + + + + True + False + True + Remove + Remove + list-remove-symbolic + + + False + + + + + True + False + False + + + True + + + + + True + False + + + True + False + + + True + True + True + + + True + False + go-up-symbolic + 1 + + + + + False + True + 0 + + + + + True + True + True + + + True + False + go-down-symbolic + 1 + + + + + False + True + 1 + + + + + + + False + + False @@ -50,74 +135,53 @@ 1 - - - gtk-remove - True - True - True - False - False - True - - - False - True - 2 - - - - - gtk-close - True - True - True - False - False - True - - - False - True - 3 - - False True - end 0 - + True False - 5 + start + True + vertical 18 - True - + True False + vertical + 6 + + + True + False + 0 + _Name + True + + + + + + False + False + 0 + + - + True False - vertical - 6 - + True False - 0 - _Bookmarks - True - bookmark_tree_view - - - + False @@ -126,44 +190,11 @@ - + True False - - True - False - - - - False - False - 0 - - - - - True - True - never - in - - - True - True - False - True - - - - - - - - True - True - 1 - + @@ -173,166 +204,84 @@ + + True + True + 1 + - True + False True 0 - + True False + vertical + 6 - + + True + False + 0 + 2 + 2 + _Location + True + + + + + + False + False + 0 + + + + True False - start - vertical - 18 - + True False - vertical - 6 - - - True - False - 0 - _Name - True - - - - - - False - False - 0 - - - - - True - False - - - True - False - - - - False - False - 0 - - - - - True - False - - - - - - True - True - 1 - - - - - True - True - 1 - - + False - True + False 0 - + True False - vertical - 6 - - True - False - 0 - 2 - 2 - _Location - True - - - - - - False - False - 0 - - - - - True - False - - - True - False - - - - False - False - 0 - - - - - True - False - - - - - - True - True - 1 - - - - - True - True - 1 - + - False + True True 1 + + True + True + 1 + - True + False True 1 @@ -346,11 +295,5 @@ - - helpbutton1 - bookmark_jump_button - bookmark_delete_button - button2 -