OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_GTK_OPTIONS_URL_PICKER_DIALOG_GTK_H_ | |
6 #define CHROME_BROWSER_UI_GTK_OPTIONS_URL_PICKER_DIALOG_GTK_H_ | |
7 #pragma once | |
8 | |
9 #include <string> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "base/callback.h" | |
13 #include "chrome/browser/history/history.h" | |
14 #include "chrome/browser/ui/gtk/gtk_tree.h" | |
15 #include "ui/base/gtk/gtk_signal.h" | |
16 | |
17 class GURL; | |
18 class Profile; | |
19 class PossibleURLModel; | |
20 | |
21 class UrlPickerDialogGtk : public gtk_tree::TableAdapter::Delegate { | |
22 public: | |
23 typedef Callback1<const GURL&>::Type UrlPickerCallback; | |
24 | |
25 UrlPickerDialogGtk(UrlPickerCallback* callback, | |
26 Profile* profile, | |
27 GtkWindow* parent); | |
28 | |
29 ~UrlPickerDialogGtk(); | |
30 | |
31 // gtk_tree::TableAdapter::Delegate implementation. | |
32 virtual void SetColumnValues(int row, GtkTreeIter* iter); | |
33 | |
34 private: | |
35 // Call the callback based on url entry. | |
36 void AddURL(); | |
37 | |
38 // Set sensitivity of buttons based on url entry state. | |
39 void EnableControls(); | |
40 | |
41 // Return the entry-formatted url for path in the sorted model. | |
42 std::string GetURLForPath(GtkTreePath* path) const; | |
43 | |
44 // GTK sorting callbacks. | |
45 static gint CompareTitle(GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, | |
46 gpointer window); | |
47 static gint CompareURL(GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, | |
48 gpointer window); | |
49 | |
50 CHROMEGTK_CALLBACK_0(UrlPickerDialogGtk, void, OnUrlEntryChanged); | |
51 CHROMEGTK_CALLBACK_2(UrlPickerDialogGtk, void, OnHistoryRowActivated, | |
52 GtkTreePath*, GtkTreeViewColumn*); | |
53 CHROMEGTK_CALLBACK_1(UrlPickerDialogGtk, void, OnResponse, int); | |
54 CHROMEGTK_CALLBACK_0(UrlPickerDialogGtk, void, OnWindowDestroy); | |
55 | |
56 // Callback for user selecting rows in recent history list. | |
57 CHROMEG_CALLBACK_0(UrlPickerDialogGtk, void, OnHistorySelectionChanged, | |
58 GtkTreeSelection*) | |
59 | |
60 // The dialog window. | |
61 GtkWidget* dialog_; | |
62 | |
63 // The text entry for manually adding an URL. | |
64 GtkWidget* url_entry_; | |
65 | |
66 // The add button (we need a reference to it so we can de-activate it when the | |
67 // |url_entry_| is empty.) | |
68 GtkWidget* add_button_; | |
69 | |
70 // The recent history list. | |
71 GtkWidget* history_tree_; | |
72 GtkListStore* history_list_store_; | |
73 GtkTreeModel* history_list_sort_; | |
74 GtkTreeSelection* history_selection_; | |
75 | |
76 // Profile. | |
77 Profile* profile_; | |
78 | |
79 // The table model. | |
80 scoped_ptr<PossibleURLModel> url_table_model_; | |
81 scoped_ptr<gtk_tree::TableAdapter> url_table_adapter_; | |
82 | |
83 // Called if the user selects an url. | |
84 UrlPickerCallback* callback_; | |
85 | |
86 DISALLOW_COPY_AND_ASSIGN(UrlPickerDialogGtk); | |
87 }; | |
88 | |
89 #endif // CHROME_BROWSER_UI_GTK_OPTIONS_URL_PICKER_DIALOG_GTK_H_ | |
OLD | NEW |