OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/gtk/bookmark_manager_gtk.h" | 5 #include "chrome/browser/gtk/bookmark_manager_gtk.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 manager->SelectInTree(node, false); | 125 manager->SelectInTree(node, false); |
126 } | 126 } |
127 | 127 |
128 void BookmarkManager::Show(Profile* profile) { | 128 void BookmarkManager::Show(Profile* profile) { |
129 BookmarkManagerGtk::Show(profile); | 129 BookmarkManagerGtk::Show(profile); |
130 } | 130 } |
131 | 131 |
132 // BookmarkManagerGtk, public -------------------------------------------------- | 132 // BookmarkManagerGtk, public -------------------------------------------------- |
133 | 133 |
134 void BookmarkManagerGtk::SelectInTree(const BookmarkNode* node, bool expand) { | 134 void BookmarkManagerGtk::SelectInTree(const BookmarkNode* node, bool expand) { |
| 135 if (expand) |
| 136 DCHECK(node->is_folder()); |
| 137 |
| 138 // Expand the left tree view to |node| if |node| is a folder, or to the parent |
| 139 // folder of |node| if it is a URL. |
135 GtkTreeIter iter = { 0, }; | 140 GtkTreeIter iter = { 0, }; |
136 if (RecursiveFind(GTK_TREE_MODEL(left_store_), &iter, node->id())) { | 141 int id = node->is_folder() ? node->id() : node->GetParent()->id(); |
| 142 if (RecursiveFind(GTK_TREE_MODEL(left_store_), &iter, id)) { |
137 GtkTreePath* path = gtk_tree_model_get_path(GTK_TREE_MODEL(left_store_), | 143 GtkTreePath* path = gtk_tree_model_get_path(GTK_TREE_MODEL(left_store_), |
138 &iter); | 144 &iter); |
139 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(left_tree_view_), path); | 145 gtk_tree_view_expand_to_path(GTK_TREE_VIEW(left_tree_view_), path); |
140 gtk_tree_selection_select_path(left_selection(), path); | 146 gtk_tree_selection_select_path(left_selection(), path); |
141 if (expand) | 147 if (expand) |
142 gtk_tree_view_expand_row(GTK_TREE_VIEW(left_tree_view_), path, true); | 148 gtk_tree_view_expand_row(GTK_TREE_VIEW(left_tree_view_), path, true); |
143 | 149 |
144 gtk_tree_path_free(path); | 150 gtk_tree_path_free(path); |
145 } | 151 } |
146 // TODO(estade): select in the right side table view? | 152 |
| 153 if (node->is_url()) { |
| 154 GtkTreeIter iter; |
| 155 bool found = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(right_store_), |
| 156 &iter); |
| 157 while (found) { |
| 158 if (node->id() == GetRowIDAt(GTK_TREE_MODEL(right_store_), &iter)) { |
| 159 gtk_tree_selection_select_iter(right_selection(), &iter); |
| 160 break; |
| 161 } |
| 162 |
| 163 found = gtk_tree_model_iter_next(GTK_TREE_MODEL(right_store_), &iter); |
| 164 } |
| 165 |
| 166 DCHECK(found); |
| 167 } |
147 } | 168 } |
148 | 169 |
149 // static | 170 // static |
150 void BookmarkManagerGtk::Show(Profile* profile) { | 171 void BookmarkManagerGtk::Show(Profile* profile) { |
151 if (!profile->GetBookmarkModel()) | 172 if (!profile->GetBookmarkModel()) |
152 return; | 173 return; |
153 if (!manager) | 174 if (!manager) |
154 manager = new BookmarkManagerGtk(profile); | 175 manager = new BookmarkManagerGtk(profile); |
155 else | 176 else |
156 gtk_window_present(GTK_WINDOW(manager->window_)); | 177 gtk_window_present(GTK_WINDOW(manager->window_)); |
157 } | 178 } |
158 | 179 |
159 void BookmarkManagerGtk::BookmarkManagerGtk::Loaded(BookmarkModel* model) { | 180 void BookmarkManagerGtk::BookmarkManagerGtk::Loaded(BookmarkModel* model) { |
160 BuildLeftStore(); | 181 BuildLeftStore(); |
161 BuildRightStore(); | 182 BuildRightStore(); |
162 g_signal_connect(left_selection(), "changed", | 183 g_signal_connect(left_selection(), "changed", |
163 G_CALLBACK(OnLeftSelectionChanged), this); | 184 G_CALLBACK(OnLeftSelectionChanged), this); |
| 185 ResetOrganizeMenu(false); |
164 } | 186 } |
165 | 187 |
166 void BookmarkManagerGtk::BookmarkModelBeingDeleted(BookmarkModel* model) { | 188 void BookmarkManagerGtk::BookmarkModelBeingDeleted(BookmarkModel* model) { |
167 gtk_widget_destroy(window_); | 189 gtk_widget_destroy(window_); |
168 } | 190 } |
169 | 191 |
170 void BookmarkManagerGtk::BookmarkNodeMoved(BookmarkModel* model, | 192 void BookmarkManagerGtk::BookmarkNodeMoved(BookmarkModel* model, |
171 const BookmarkNode* old_parent, | 193 const BookmarkNode* old_parent, |
172 int old_index, | 194 int old_index, |
173 const BookmarkNode* new_parent, | 195 const BookmarkNode* new_parent, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 gtk_tree_selection_select_iter(left_selection(), &parent); | 231 gtk_tree_selection_select_iter(left_selection(), &parent); |
210 } | 232 } |
211 | 233 |
212 gtk_tree_store_remove(left_store_, &iter); | 234 gtk_tree_store_remove(left_store_, &iter); |
213 } | 235 } |
214 } | 236 } |
215 } | 237 } |
216 | 238 |
217 void BookmarkManagerGtk::BookmarkNodeChanged(BookmarkModel* model, | 239 void BookmarkManagerGtk::BookmarkNodeChanged(BookmarkModel* model, |
218 const BookmarkNode* node) { | 240 const BookmarkNode* node) { |
219 // TODO(estade): rename in the left tree view. | 241 if (node->is_folder()) { |
| 242 GtkTreeIter iter = { 0, }; |
| 243 if (RecursiveFind(GTK_TREE_MODEL(left_store_), &iter, node->id())) { |
| 244 gtk_tree_store_set(left_store_, &iter, |
| 245 bookmark_utils::FOLDER_NAME, |
| 246 WideToUTF8(node->GetTitle()).c_str(), |
| 247 bookmark_utils::ITEM_ID, node->id(), |
| 248 -1); |
| 249 } |
| 250 } |
220 } | 251 } |
221 | 252 |
222 void BookmarkManagerGtk::BookmarkNodeChildrenReordered( | 253 void BookmarkManagerGtk::BookmarkNodeChildrenReordered( |
223 BookmarkModel* model, const BookmarkNode* node) { | 254 BookmarkModel* model, const BookmarkNode* node) { |
224 // TODO(estade): reorder in the left tree view. | 255 // TODO(estade): reorder in the left tree view. |
225 } | 256 } |
226 | 257 |
227 void BookmarkManagerGtk::BookmarkNodeFavIconLoaded(BookmarkModel* model, | 258 void BookmarkManagerGtk::BookmarkNodeFavIconLoaded(BookmarkModel* model, |
228 const BookmarkNode* node) { | 259 const BookmarkNode* node) { |
229 // I don't think we have anything to do, as we should never get this for a | 260 // I don't think we have anything to do, as we should never get this for a |
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1173 } else if (id == IDS_BOOKMARK_MANAGER_EXPORT_MENU) { | 1204 } else if (id == IDS_BOOKMARK_MANAGER_EXPORT_MENU) { |
1174 if (g_browser_process->io_thread()) { | 1205 if (g_browser_process->io_thread()) { |
1175 bookmark_html_writer::WriteBookmarks( | 1206 bookmark_html_writer::WriteBookmarks( |
1176 g_browser_process->io_thread()->message_loop(), model_, | 1207 g_browser_process->io_thread()->message_loop(), model_, |
1177 path.ToWStringHack()); | 1208 path.ToWStringHack()); |
1178 } | 1209 } |
1179 } else { | 1210 } else { |
1180 NOTREACHED(); | 1211 NOTREACHED(); |
1181 } | 1212 } |
1182 } | 1213 } |
OLD | NEW |