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