OLD | NEW |
1 // Copyright (c) 2011 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 #include "chrome/browser/ui/gtk/bookmarks/bookmark_bubble_gtk.h" | 5 #include "chrome/browser/ui/gtk/bookmarks/bookmark_bubble_gtk.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/string16.h" | 13 #include "base/string16.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "chrome/browser/bookmarks/bookmark_editor.h" | 15 #include "chrome/browser/bookmarks/bookmark_editor.h" |
16 #include "chrome/browser/bookmarks/bookmark_model.h" | 16 #include "chrome/browser/bookmarks/bookmark_model.h" |
17 #include "chrome/browser/bookmarks/bookmark_utils.h" | 17 #include "chrome/browser/bookmarks/bookmark_utils.h" |
18 #include "chrome/browser/bookmarks/recently_used_folders_combo_model.h" | 18 #include "chrome/browser/bookmarks/recently_used_folders_combo_model.h" |
19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 20 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
21 #include "chrome/browser/ui/gtk/gtk_util.h" | 21 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 22 #include "chrome/common/chrome_notification_types.h" |
22 #include "content/browser/user_metrics.h" | 23 #include "content/browser/user_metrics.h" |
23 #include "content/common/notification_service.h" | 24 #include "content/common/notification_service.h" |
24 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
25 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
26 | 27 |
27 namespace { | 28 namespace { |
28 | 29 |
29 // We basically have a singleton, since a bubble is sort of app-modal. This | 30 // We basically have a singleton, since a bubble is sort of app-modal. This |
30 // keeps track of the currently open bubble, or NULL if none is open. | 31 // keeps track of the currently open bubble, or NULL if none is open. |
31 BookmarkBubbleGtk* g_bubble = NULL; | 32 BookmarkBubbleGtk* g_bubble = NULL; |
(...skipping 13 matching lines...) Expand all Loading... |
45 } | 46 } |
46 | 47 |
47 void BookmarkBubbleGtk::BubbleClosing(BubbleGtk* bubble, | 48 void BookmarkBubbleGtk::BubbleClosing(BubbleGtk* bubble, |
48 bool closed_by_escape) { | 49 bool closed_by_escape) { |
49 if (closed_by_escape) { | 50 if (closed_by_escape) { |
50 remove_bookmark_ = newly_bookmarked_; | 51 remove_bookmark_ = newly_bookmarked_; |
51 apply_edits_ = false; | 52 apply_edits_ = false; |
52 } | 53 } |
53 | 54 |
54 NotificationService::current()->Notify( | 55 NotificationService::current()->Notify( |
55 NotificationType::BOOKMARK_BUBBLE_HIDDEN, | 56 chrome::BOOKMARK_BUBBLE_HIDDEN, |
56 Source<Profile>(profile_->GetOriginalProfile()), | 57 Source<Profile>(profile_->GetOriginalProfile()), |
57 NotificationService::NoDetails()); | 58 NotificationService::NoDetails()); |
58 } | 59 } |
59 | 60 |
60 void BookmarkBubbleGtk::Observe(NotificationType type, | 61 void BookmarkBubbleGtk::Observe(int type, |
61 const NotificationSource& source, | 62 const NotificationSource& source, |
62 const NotificationDetails& details) { | 63 const NotificationDetails& details) { |
63 DCHECK(type == NotificationType::BROWSER_THEME_CHANGED); | 64 DCHECK(type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED); |
64 | 65 |
65 if (theme_service_->UsingNativeTheme()) { | 66 if (theme_service_->UsingNativeTheme()) { |
66 for (std::vector<GtkWidget*>::iterator it = labels_.begin(); | 67 for (std::vector<GtkWidget*>::iterator it = labels_.begin(); |
67 it != labels_.end(); ++it) { | 68 it != labels_.end(); ++it) { |
68 gtk_widget_modify_fg(*it, GTK_STATE_NORMAL, NULL); | 69 gtk_widget_modify_fg(*it, GTK_STATE_NORMAL, NULL); |
69 } | 70 } |
70 } else { | 71 } else { |
71 for (std::vector<GtkWidget*>::iterator it = labels_.begin(); | 72 for (std::vector<GtkWidget*>::iterator it = labels_.begin(); |
72 it != labels_.end(); ++it) { | 73 it != labels_.end(); ++it) { |
73 gtk_widget_modify_fg(*it, GTK_STATE_NORMAL, >k_util::kGdkBlack); | 74 gtk_widget_modify_fg(*it, GTK_STATE_NORMAL, >k_util::kGdkBlack); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 G_CALLBACK(&OnFolderChangedThunk), this); | 175 G_CALLBACK(&OnFolderChangedThunk), this); |
175 g_signal_connect(folder_combo_, "notify::popup-shown", | 176 g_signal_connect(folder_combo_, "notify::popup-shown", |
176 G_CALLBACK(&OnFolderPopupShownThunk), this); | 177 G_CALLBACK(&OnFolderPopupShownThunk), this); |
177 g_signal_connect(edit_button, "clicked", | 178 g_signal_connect(edit_button, "clicked", |
178 G_CALLBACK(&OnEditClickedThunk), this); | 179 G_CALLBACK(&OnEditClickedThunk), this); |
179 g_signal_connect(close_button, "clicked", | 180 g_signal_connect(close_button, "clicked", |
180 G_CALLBACK(&OnCloseClickedThunk), this); | 181 G_CALLBACK(&OnCloseClickedThunk), this); |
181 g_signal_connect(remove_button_, "clicked", | 182 g_signal_connect(remove_button_, "clicked", |
182 G_CALLBACK(&OnRemoveClickedThunk), this); | 183 G_CALLBACK(&OnRemoveClickedThunk), this); |
183 | 184 |
184 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, | 185 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
185 Source<ThemeService>(theme_service_)); | 186 Source<ThemeService>(theme_service_)); |
186 theme_service_->InitThemesFor(this); | 187 theme_service_->InitThemesFor(this); |
187 } | 188 } |
188 | 189 |
189 BookmarkBubbleGtk::~BookmarkBubbleGtk() { | 190 BookmarkBubbleGtk::~BookmarkBubbleGtk() { |
190 DCHECK(!content_); // |content_| should have already been destroyed. | 191 DCHECK(!content_); // |content_| should have already been destroyed. |
191 | 192 |
192 DCHECK(g_bubble); | 193 DCHECK(g_bubble); |
193 g_bubble = NULL; | 194 g_bubble = NULL; |
194 | 195 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 // We always have nodes + 1 entries in the combo. The last entry will be | 331 // We always have nodes + 1 entries in the combo. The last entry will be |
331 // the 'Select another folder...' entry that opens the bookmark editor. | 332 // the 'Select another folder...' entry that opens the bookmark editor. |
332 for (int i = 0; i < folder_combo_model_->GetItemCount(); ++i) { | 333 for (int i = 0; i < folder_combo_model_->GetItemCount(); ++i) { |
333 gtk_combo_box_append_text(GTK_COMBO_BOX(folder_combo_), | 334 gtk_combo_box_append_text(GTK_COMBO_BOX(folder_combo_), |
334 UTF16ToUTF8(folder_combo_model_->GetItemAt(i)).c_str()); | 335 UTF16ToUTF8(folder_combo_model_->GetItemAt(i)).c_str()); |
335 } | 336 } |
336 | 337 |
337 gtk_combo_box_set_active(GTK_COMBO_BOX(folder_combo_), | 338 gtk_combo_box_set_active(GTK_COMBO_BOX(folder_combo_), |
338 folder_combo_model_->node_parent_index()); | 339 folder_combo_model_->node_parent_index()); |
339 } | 340 } |
OLD | NEW |