1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_GTK_BOOKMARK_EDITOR_GTK_H_
#define CHROME_BROWSER_GTK_BOOKMARK_EDITOR_GTK_H_
#include <gtk/gtk.h>
#include "chrome/browser/bookmarks/bookmark_editor.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
// GTK version of the bookmark editor dialog.
class BookmarkEditorGtk : public BookmarkEditor,
public BookmarkModelObserver {
FRIEND_TEST(BookmarkEditorGtkTest, ChangeParent);
FRIEND_TEST(BookmarkEditorGtkTest, ChangeParentAndURL);
FRIEND_TEST(BookmarkEditorGtkTest, ChangeURLToExistingURL);
FRIEND_TEST(BookmarkEditorGtkTest, EditTitleKeepsPosition);
FRIEND_TEST(BookmarkEditorGtkTest, EditURLKeepsPosition);
FRIEND_TEST(BookmarkEditorGtkTest, ModelsMatch);
FRIEND_TEST(BookmarkEditorGtkTest, MoveToNewParent);
FRIEND_TEST(BookmarkEditorGtkTest, NewURL);
FRIEND_TEST(BookmarkEditorGtkTest, ChangeURLNoTree);
FRIEND_TEST(BookmarkEditorGtkTest, ChangeTitleNoTree);
public:
BookmarkEditorGtk(GtkWindow* window,
Profile* profile,
BookmarkNode* parent,
BookmarkNode* node,
BookmarkEditor::Configuration configuration,
BookmarkEditor::Handler* handler);
virtual ~BookmarkEditorGtk();
void Show();
void Close();
private:
void Init(GtkWindow* parent_window);
// BookmarkModel observer methods. Any structural change results in
// resetting the tree model.
virtual void Loaded(BookmarkModel* model) { }
virtual void BookmarkNodeMoved(BookmarkModel* model,
BookmarkNode* old_parent,
int old_index,
BookmarkNode* new_parent,
int new_index);
virtual void BookmarkNodeAdded(BookmarkModel* model,
BookmarkNode* parent,
int index);
virtual void BookmarkNodeRemoved(BookmarkModel* model,
BookmarkNode* parent,
int index,
BookmarkNode* node);
virtual void BookmarkNodeChanged(BookmarkModel* model,
BookmarkNode* node) {}
virtual void BookmarkNodeChildrenReordered(BookmarkModel* model,
BookmarkNode* node);
virtual void BookmarkNodeFavIconLoaded(BookmarkModel* model,
BookmarkNode* node) {}
// Resets the model of the tree and updates the various buttons appropriately.
void Reset();
// Returns the current url the user has input.
GURL GetInputURL() const;
// Returns the title the user has input.
std::wstring GetInputTitle() const;
// Invokes ApplyEdits with the selected node.
//
// TODO(erg): This was copied from the windows version. Both should be
// cleaned up so that we don't overload ApplyEdits.
void ApplyEdits();
// Applies the edits done by the user. |selected_parent| gives the parent of
// the URL being edited.
void ApplyEdits(GtkTreeIter* selected_parent);
// Adds a new group parented on |parent| and sets |child| to point to this
// new group.
void AddNewGroup(GtkTreeIter* parent, GtkTreeIter* child);
static void OnResponse(GtkDialog* dialog, int response_id,
BookmarkEditorGtk* window);
static gboolean OnWindowDeleteEvent(GtkWidget* widget,
GdkEvent* event,
BookmarkEditorGtk* dialog);
static void OnWindowDestroy(GtkWidget* widget, BookmarkEditorGtk* dialog);
static void OnEntryChanged(GtkEditable* entry, BookmarkEditorGtk* dialog);
static void OnNewFolderClicked(GtkWidget* button, BookmarkEditorGtk* dialog);
// Profile the entry is from.
Profile* profile_;
// The dialog to display on screen.
GtkWidget* dialog_;
GtkWidget* name_entry_;
GtkWidget* url_entry_;
GtkWidget* tree_view_;
// Helper object that manages the currently selected item in |tree_view_|.
GtkTreeSelection* tree_selection_;
// Our local copy of the bookmark data that we make from the BookmarkModel
// that we can modify as much as we want and still discard when the user
// clicks Cancel.
GtkTreeStore* tree_store_;
// TODO(erg): BookmarkEditorView has an EditorTreeModel object here; convert
// that into a GObject that implements the interface GtkTreeModel.
// Initial parent to select. Is only used if node_ is NULL.
BookmarkNode* parent_;
// Node being edited. Is NULL if creating a new node.
BookmarkNode* node_;
// Mode used to create nodes from.
BookmarkModel* bb_model_;
// If true, we're running the menu for the bookmark bar or other bookmarks
// nodes.
bool running_menu_for_root_;
// Is the tree shown?
bool show_tree_;
scoped_ptr<BookmarkEditor::Handler> handler_;
DISALLOW_COPY_AND_ASSIGN(BookmarkEditorGtk);
};
#endif // CHROME_BROWSER_GTK_BOOKMARK_EDITOR_GTK_H_
|