summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/bookmark_editor_gtk.cc
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-06 22:00:44 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-06 22:00:44 +0000
commitabaadab3c6a099e19ddc1758ef10663c69e31c1f (patch)
treee080e0e41aa73f78a33657c51a4346fd4ff42089 /chrome/browser/gtk/bookmark_editor_gtk.cc
parent8e92efdf4d3b2a50b8efc1bd4aca9a3895b7d2b7 (diff)
downloadchromium_src-abaadab3c6a099e19ddc1758ef10663c69e31c1f.zip
chromium_src-abaadab3c6a099e19ddc1758ef10663c69e31c1f.tar.gz
chromium_src-abaadab3c6a099e19ddc1758ef10663c69e31c1f.tar.bz2
GTK: Don't choke when there's no selection in the bookmark editor tree view.
1) disable "new folder" when no folder is selected 2) if a user clicks apply when no folder is selected, apply the title/url edits but leave it in its original location Review URL: http://codereview.chromium.org/164016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22676 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/bookmark_editor_gtk.cc')
-rw-r--r--chrome/browser/gtk/bookmark_editor_gtk.cc27
1 files changed, 20 insertions, 7 deletions
diff --git a/chrome/browser/gtk/bookmark_editor_gtk.cc b/chrome/browser/gtk/bookmark_editor_gtk.cc
index c5824ec..a6d46c3 100644
--- a/chrome/browser/gtk/bookmark_editor_gtk.cc
+++ b/chrome/browser/gtk/bookmark_editor_gtk.cc
@@ -90,13 +90,13 @@ void BookmarkEditorGtk::Init(GtkWindow* parent_window) {
if (show_tree_) {
GtkWidget* action_area = GTK_DIALOG(dialog_)->action_area;
- GtkWidget* new_folder_button = gtk_button_new_with_label(
+ new_folder_button_ = gtk_button_new_with_label(
l10n_util::GetStringUTF8(IDS_BOOMARK_EDITOR_NEW_FOLDER_BUTTON).c_str());
- g_signal_connect(new_folder_button, "clicked",
+ g_signal_connect(new_folder_button_, "clicked",
G_CALLBACK(OnNewFolderClicked), this);
- gtk_container_add(GTK_CONTAINER(action_area), new_folder_button);
+ gtk_container_add(GTK_CONTAINER(action_area), new_folder_button_);
gtk_button_box_set_child_secondary(GTK_BUTTON_BOX(action_area),
- new_folder_button, TRUE);
+ new_folder_button_, TRUE);
}
gtk_dialog_set_default_response(GTK_DIALOG(dialog_), GTK_RESPONSE_ACCEPT);
@@ -184,6 +184,9 @@ void BookmarkEditorGtk::Init(GtkWindow* parent_window) {
gtk_container_add(GTK_CONTAINER(scroll_window), tree_view_);
gtk_box_pack_start(GTK_BOX(vbox), scroll_window, TRUE, TRUE, 0);
+
+ g_signal_connect(gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view_)),
+ "changed", G_CALLBACK(OnSelectionChanged), this);
}
gtk_box_pack_start(GTK_BOX(content_area), vbox, TRUE, TRUE, 0);
@@ -267,7 +270,7 @@ void BookmarkEditorGtk::ApplyEdits() {
if (show_tree_) {
if (!gtk_tree_selection_get_selected(tree_selection_, NULL,
&currently_selected_iter)) {
- NOTREACHED() << "Something should always be selected";
+ ApplyEdits(NULL);
return;
}
}
@@ -284,7 +287,7 @@ void BookmarkEditorGtk::ApplyEdits(GtkTreeIter* selected_parent) {
GURL new_url(GetInputURL());
std::wstring new_title(GetInputTitle());
- if (!show_tree_) {
+ if (!show_tree_ || !selected_parent) {
bookmark_utils::ApplyEditsWithNoGroupChange(
bb_model_, parent_, node_, new_title, new_url, handler_.get());
return;
@@ -318,6 +321,15 @@ void BookmarkEditorGtk::AddNewGroup(GtkTreeIter* parent, GtkTreeIter* child) {
}
// static
+void BookmarkEditorGtk::OnSelectionChanged(GtkTreeSelection* selection,
+ BookmarkEditorGtk* dialog) {
+ if (!gtk_tree_selection_get_selected(dialog->tree_selection_, NULL, NULL))
+ gtk_widget_set_sensitive(dialog->new_folder_button_, FALSE);
+ else
+ gtk_widget_set_sensitive(dialog->new_folder_button_, TRUE);
+}
+
+// static
void BookmarkEditorGtk::OnResponse(GtkDialog* dialog, int response_id,
BookmarkEditorGtk* window) {
if (response_id == GTK_RESPONSE_ACCEPT) {
@@ -370,7 +382,8 @@ void BookmarkEditorGtk::OnNewFolderClicked(GtkWidget* button,
if (!gtk_tree_selection_get_selected(dialog->tree_selection_,
NULL,
&iter)) {
- NOTREACHED() << "Something should always be selected";
+ NOTREACHED() << "Something should always be selected if New Folder " <<
+ "is clicked";
return;
}