| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_GTK_BOOKMARK_MANAGER_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_BOOKMARK_MANAGER_GTK_H_ |
| 6 #define CHROME_BROWSER_GTK_BOOKMARK_MANAGER_GTK_H_ | 6 #define CHROME_BROWSER_GTK_BOOKMARK_MANAGER_GTK_H_ |
| 7 | 7 |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "app/gtk_signal.h" |
| 11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 12 #include "base/ref_counted.h" | 13 #include "base/ref_counted.h" |
| 13 #include "base/task.h" | 14 #include "base/task.h" |
| 14 #include "chrome/browser/bookmarks/bookmark_context_menu_controller.h" | 15 #include "chrome/browser/bookmarks/bookmark_context_menu_controller.h" |
| 15 #include "chrome/browser/bookmarks/bookmark_model_observer.h" | 16 #include "chrome/browser/bookmarks/bookmark_model_observer.h" |
| 16 #include "chrome/browser/gtk/gtk_tree.h" | 17 #include "chrome/browser/gtk/gtk_tree.h" |
| 17 #include "chrome/browser/sync/profile_sync_service.h" | 18 #include "chrome/browser/sync/profile_sync_service.h" |
| 18 #include "chrome/browser/shell_dialogs.h" | 19 #include "chrome/browser/shell_dialogs.h" |
| 19 #include "gfx/rect.h" | 20 #include "gfx/rect.h" |
| 20 #include "testing/gtest/include/gtest/gtest_prod.h" | 21 #include "testing/gtest/include/gtest/gtest_prod.h" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 void AllowUpdatesToRightStore(); | 160 void AllowUpdatesToRightStore(); |
| 160 | 161 |
| 161 // Tries to find the node with id |target_id|. If found, returns true and set | 162 // Tries to find the node with id |target_id|. If found, returns true and set |
| 162 // |iter| to point to the entry. If you pass a |iter| with stamp of 0, then it | 163 // |iter| to point to the entry. If you pass a |iter| with stamp of 0, then it |
| 163 // will be treated as the first row of |model|. | 164 // will be treated as the first row of |model|. |
| 164 bool RecursiveFind(GtkTreeModel* model, GtkTreeIter* iter, int64 target_id); | 165 bool RecursiveFind(GtkTreeModel* model, GtkTreeIter* iter, int64 target_id); |
| 165 | 166 |
| 166 // Search helpers. | 167 // Search helpers. |
| 167 void PerformSearch(); | 168 void PerformSearch(); |
| 168 | 169 |
| 169 void OnSearchTextChanged(); | 170 CHROMEGTK_CALLBACK_0(BookmarkManagerGtk, void, OnSearchTextChanged); |
| 170 | |
| 171 static void OnSearchTextChangedThunk(GtkWidget* search_entry, | |
| 172 BookmarkManagerGtk* bookmark_manager) { | |
| 173 bookmark_manager->OnSearchTextChanged(); | |
| 174 } | |
| 175 | 171 |
| 176 // TreeView signal handlers. | 172 // TreeView signal handlers. |
| 177 static void OnLeftSelectionChanged(GtkTreeSelection* selection, | 173 static void OnLeftSelectionChanged(GtkTreeSelection* selection, |
| 178 BookmarkManagerGtk* bm); | 174 BookmarkManagerGtk* bm); |
| 179 | 175 |
| 180 static void OnRightSelectionChanged(GtkTreeSelection* selection, | 176 static void OnRightSelectionChanged(GtkTreeSelection* selection, |
| 181 BookmarkManagerGtk* bm); | 177 BookmarkManagerGtk* bm); |
| 182 | 178 |
| 183 static void OnLeftTreeViewDragReceived(GtkWidget* tree_view, | 179 CHROMEGTK_CALLBACK_6(BookmarkManagerGtk, void, OnLeftTreeViewDragReceived, |
| 184 GdkDragContext* context, | 180 GdkDragContext*, gint, gint, GtkSelectionData*, |
| 185 gint x, | 181 guint, guint); |
| 186 gint y, | 182 CHROMEGTK_CALLBACK_4(BookmarkManagerGtk, gboolean, OnLeftTreeViewDragMotion, |
| 187 GtkSelectionData* selection_data, | 183 GdkDragContext*, gint, gint, guint); |
| 188 guint target_type, | |
| 189 guint time, | |
| 190 BookmarkManagerGtk* bm); | |
| 191 | 184 |
| 192 static gboolean OnLeftTreeViewDragMotion(GtkWidget* tree_view, | 185 CHROMEGTK_CALLBACK_2(BookmarkManagerGtk, void, OnLeftTreeViewRowCollapsed, |
| 193 GdkDragContext* context, | 186 GtkTreeIter*, GtkTreePath*); |
| 194 gint x, | 187 CHROMEGTK_CALLBACK_4(BookmarkManagerGtk, void, OnRightTreeViewDragGet, |
| 195 gint y, | 188 GdkDragContext*, GtkSelectionData*, guint, guint); |
| 196 guint time, | |
| 197 BookmarkManagerGtk* bm); | |
| 198 | 189 |
| 199 static void OnLeftTreeViewRowCollapsed(GtkTreeView* tree_view, | 190 CHROMEGTK_CALLBACK_6(BookmarkManagerGtk, void, OnRightTreeViewDragReceived, |
| 200 GtkTreeIter* iter, | 191 GdkDragContext*, gint, gint, GtkSelectionData*, |
| 201 GtkTreePath* path, | 192 guint, guint); |
| 202 BookmarkManagerGtk* bm); | 193 CHROMEGTK_CALLBACK_1(BookmarkManagerGtk, void, OnRightTreeViewDragBegin, |
| 194 GdkDragContext*); |
| 195 CHROMEGTK_CALLBACK_4(BookmarkManagerGtk, gboolean, OnRightTreeViewDragMotion, |
| 196 GdkDragContext*, gint, gint, guint); |
| 203 | 197 |
| 204 static void OnRightTreeViewDragGet(GtkWidget* tree_view, | 198 CHROMEGTK_CALLBACK_2(BookmarkManagerGtk, void, OnRightTreeViewRowActivated, |
| 205 GdkDragContext* context, | 199 GtkTreePath*, GtkTreeViewColumn*); |
| 206 GtkSelectionData* selection_data, | 200 CHROMEGTK_CALLBACK_1(BookmarkManagerGtk, void, OnRightTreeViewFocusIn, |
| 207 guint target_type, | 201 GdkEventFocus*); |
| 208 guint time, | 202 CHROMEGTK_CALLBACK_1(BookmarkManagerGtk, void, OnLeftTreeViewFocusIn, |
| 209 BookmarkManagerGtk* bm); | 203 GdkEventFocus*); |
| 204 CHROMEGTK_CALLBACK_1(BookmarkManagerGtk, gboolean, OnRightTreeViewButtonPress, |
| 205 GdkEventButton*); |
| 210 | 206 |
| 211 static void OnRightTreeViewDragReceived(GtkWidget* tree_view, | 207 CHROMEGTK_CALLBACK_1(BookmarkManagerGtk, gboolean, OnRightTreeViewMotion, |
| 212 GdkDragContext* context, | 208 GdkEventMotion*); |
| 213 gint x, | 209 CHROMEGTK_CALLBACK_1(BookmarkManagerGtk, gboolean, OnTreeViewButtonPress, |
| 214 gint y, | 210 GdkEventButton*); |
| 215 GtkSelectionData* selection_data, | 211 CHROMEGTK_CALLBACK_1(BookmarkManagerGtk, gboolean, OnTreeViewButtonRelease, |
| 216 guint target_type, | 212 GdkEventButton*); |
| 217 guint time, | 213 CHROMEGTK_CALLBACK_1(BookmarkManagerGtk, gboolean, OnTreeViewKeyPress, |
| 218 BookmarkManagerGtk* bm); | 214 GdkEventKey*); |
| 219 | |
| 220 static void OnRightTreeViewDragBegin(GtkWidget* tree_view, | |
| 221 GdkDragContext* drag_context, | |
| 222 BookmarkManagerGtk* bm); | |
| 223 | |
| 224 static gboolean OnRightTreeViewDragMotion(GtkWidget* tree_view, | |
| 225 GdkDragContext* context, | |
| 226 gint x, | |
| 227 gint y, | |
| 228 guint time, | |
| 229 BookmarkManagerGtk* bm); | |
| 230 | |
| 231 static void OnRightTreeViewRowActivated(GtkTreeView* tree_view, | |
| 232 GtkTreePath* path, | |
| 233 GtkTreeViewColumn* column, | |
| 234 BookmarkManagerGtk* bm); | |
| 235 | |
| 236 static void OnRightTreeViewFocusIn(GtkTreeView* tree_view, | |
| 237 GdkEventFocus* event, | |
| 238 BookmarkManagerGtk* bm); | |
| 239 | |
| 240 static void OnLeftTreeViewFocusIn(GtkTreeView* tree_view, | |
| 241 GdkEventFocus* event, | |
| 242 BookmarkManagerGtk* bm); | |
| 243 | |
| 244 static gboolean OnRightTreeViewButtonPress(GtkWidget* tree_view, | |
| 245 GdkEventButton* event, | |
| 246 BookmarkManagerGtk* bm); | |
| 247 | |
| 248 static gboolean OnRightTreeViewMotion(GtkWidget* tree_view, | |
| 249 GdkEventMotion* event, | |
| 250 BookmarkManagerGtk* bm); | |
| 251 | |
| 252 static gboolean OnTreeViewButtonPress(GtkWidget* tree_view, | |
| 253 GdkEventButton* button, | |
| 254 BookmarkManagerGtk* bm); | |
| 255 | |
| 256 static gboolean OnTreeViewButtonRelease(GtkWidget* tree_view, | |
| 257 GdkEventButton* button, | |
| 258 BookmarkManagerGtk* bm); | |
| 259 | |
| 260 static gboolean OnTreeViewKeyPress(GtkWidget* tree_view, | |
| 261 GdkEventKey* key, | |
| 262 BookmarkManagerGtk* bm); | |
| 263 | 215 |
| 264 // Callback from inline edits to folder names. This changes the name in the | 216 // Callback from inline edits to folder names. This changes the name in the |
| 265 // model. | 217 // model. |
| 266 static void OnFolderNameEdited(GtkCellRendererText* render, | 218 static void OnFolderNameEdited(GtkCellRendererText* render, |
| 267 gchar* path, | 219 gchar* path, |
| 268 gchar* new_folder_name, | 220 gchar* new_folder_name, |
| 269 BookmarkManagerGtk* bm); | 221 BookmarkManagerGtk* bm); |
| 270 | 222 |
| 271 // Tools menu item callbacks. | 223 // Tools menu item callbacks. |
| 272 static void OnImportItemActivated(GtkMenuItem* menuitem, | 224 CHROMEGTK_CALLBACK_0(BookmarkManagerGtk, void, OnImportItemActivated); |
| 273 BookmarkManagerGtk* bm); | 225 CHROMEGTK_CALLBACK_0(BookmarkManagerGtk, void, OnExportItemActivated); |
| 274 static void OnExportItemActivated(GtkMenuItem* menuitem, | |
| 275 BookmarkManagerGtk* bm); | |
| 276 | 226 |
| 277 // Sync status menu item callback. | 227 // Sync status menu item callback. |
| 278 static void OnSyncStatusMenuActivated(GtkMenuItem* menu_item, | 228 CHROMEGTK_CALLBACK_0(BookmarkManagerGtk, void, OnSyncStatusMenuActivated); |
| 279 BookmarkManagerGtk* bm); | |
| 280 | 229 |
| 281 // Window callbacks. | 230 // Window callbacks. |
| 282 static gboolean OnWindowDestroyedThunk(GtkWidget* window, gpointer self) { | 231 CHROMEGTK_CALLBACK_0(BookmarkManagerGtk, gboolean, OnWindowDestroyed); |
| 283 return reinterpret_cast<BookmarkManagerGtk*>(self)-> | 232 CHROMEGTK_CALLBACK_1(BookmarkManagerGtk, gboolean, OnWindowStateChanged, |
| 284 OnWindowDestroyed(window); | 233 GdkEventWindowState*); |
| 285 } | 234 CHROMEGTK_CALLBACK_1(BookmarkManagerGtk, gboolean, OnWindowConfigured, |
| 286 gboolean OnWindowDestroyed(GtkWidget* window); | 235 GdkEventConfigure*); |
| 287 | |
| 288 static gboolean OnWindowStateChangedThunk(GtkWidget* window, | |
| 289 GdkEventWindowState* event, | |
| 290 gpointer self) { | |
| 291 return reinterpret_cast<BookmarkManagerGtk*>(self)-> | |
| 292 OnWindowStateChanged(window, event); | |
| 293 } | |
| 294 gboolean OnWindowStateChanged(GtkWidget* window, GdkEventWindowState* event); | |
| 295 | |
| 296 static gboolean OnWindowConfiguredThunk(GtkWidget* window, | |
| 297 GdkEventConfigure* event, | |
| 298 gpointer self) { | |
| 299 return reinterpret_cast<BookmarkManagerGtk*>(self)-> | |
| 300 OnWindowConfigured(window, event); | |
| 301 } | |
| 302 gboolean OnWindowConfigured(GtkWidget* window, GdkEventConfigure* event); | |
| 303 | 236 |
| 304 // Handles an accelerator being pressed. | 237 // Handles an accelerator being pressed. |
| 305 static gboolean OnGtkAccelerator(GtkAccelGroup* accel_group, | 238 static gboolean OnGtkAccelerator(GtkAccelGroup* accel_group, |
| 306 GObject* acceleratable, | 239 GObject* acceleratable, |
| 307 guint keyval, | 240 guint keyval, |
| 308 GdkModifierType modifier, | 241 GdkModifierType modifier, |
| 309 BookmarkManagerGtk* bookmark_manager); | 242 BookmarkManagerGtk* bookmark_manager); |
| 310 | 243 |
| 311 void UpdateSyncStatus(); | 244 void UpdateSyncStatus(); |
| 312 | 245 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 bool sending_delayed_mousedown_; | 312 bool sending_delayed_mousedown_; |
| 380 | 313 |
| 381 // This is used to avoid recursively calling our right click handler. It is | 314 // This is used to avoid recursively calling our right click handler. It is |
| 382 // only true when a right click is already being handled. | 315 // only true when a right click is already being handled. |
| 383 bool ignore_rightclicks_; | 316 bool ignore_rightclicks_; |
| 384 | 317 |
| 385 GtkAccelGroup* accel_group_; | 318 GtkAccelGroup* accel_group_; |
| 386 }; | 319 }; |
| 387 | 320 |
| 388 #endif // CHROME_BROWSER_GTK_BOOKMARK_MANAGER_GTK_H_ | 321 #endif // CHROME_BROWSER_GTK_BOOKMARK_MANAGER_GTK_H_ |
| OLD | NEW |