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_bar_gtk.h" | 5 #include "chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "chrome/common/extensions/extension_constants.h" | 35 #include "chrome/common/extensions/extension_constants.h" |
36 #include "chrome/common/pref_names.h" | 36 #include "chrome/common/pref_names.h" |
37 #include "content/browser/tab_contents/tab_contents.h" | 37 #include "content/browser/tab_contents/tab_contents.h" |
38 #include "content/browser/tab_contents/tab_contents_view.h" | 38 #include "content/browser/tab_contents/tab_contents_view.h" |
39 #include "content/browser/user_metrics.h" | 39 #include "content/browser/user_metrics.h" |
40 #include "content/common/notification_service.h" | 40 #include "content/common/notification_service.h" |
41 #include "grit/generated_resources.h" | 41 #include "grit/generated_resources.h" |
42 #include "grit/theme_resources.h" | 42 #include "grit/theme_resources.h" |
43 #include "grit/ui_resources.h" | 43 #include "grit/ui_resources.h" |
44 #include "ui/base/dragdrop/gtk_dnd_util.h" | 44 #include "ui/base/dragdrop/gtk_dnd_util.h" |
| 45 #include "ui/base/l10n/l10n_util.h" |
45 #include "ui/base/resource/resource_bundle.h" | 46 #include "ui/base/resource/resource_bundle.h" |
46 #include "ui/gfx/canvas_skia_paint.h" | 47 #include "ui/gfx/canvas_skia_paint.h" |
47 #include "ui/gfx/gtk_util.h" | 48 #include "ui/gfx/gtk_util.h" |
48 #include "ui/gfx/image/image.h" | 49 #include "ui/gfx/image/image.h" |
49 | 50 |
50 namespace { | 51 namespace { |
51 | 52 |
52 // The showing height of the bar. | 53 // The showing height of the bar. |
53 const int kBookmarkBarHeight = 29; | 54 const int kBookmarkBarHeight = 29; |
54 | 55 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 G_CALLBACK(&OnToolbarDragMotionThunk), this); | 261 G_CALLBACK(&OnToolbarDragMotionThunk), this); |
261 g_signal_connect(bookmark_toolbar_.get(), "drag-leave", | 262 g_signal_connect(bookmark_toolbar_.get(), "drag-leave", |
262 G_CALLBACK(&OnDragLeaveThunk), this); | 263 G_CALLBACK(&OnDragLeaveThunk), this); |
263 g_signal_connect(bookmark_toolbar_.get(), "drag-data-received", | 264 g_signal_connect(bookmark_toolbar_.get(), "drag-data-received", |
264 G_CALLBACK(&OnDragReceivedThunk), this); | 265 G_CALLBACK(&OnDragReceivedThunk), this); |
265 | 266 |
266 other_bookmarks_separator_ = theme_service_->CreateToolbarSeparator(); | 267 other_bookmarks_separator_ = theme_service_->CreateToolbarSeparator(); |
267 gtk_box_pack_start(GTK_BOX(bookmark_hbox_), other_bookmarks_separator_, | 268 gtk_box_pack_start(GTK_BOX(bookmark_hbox_), other_bookmarks_separator_, |
268 FALSE, FALSE, 0); | 269 FALSE, FALSE, 0); |
269 | 270 |
| 271 // Newer versions of Gtk default to not showing images on buttons if a label |
| 272 // is set. Override that here. |
| 273 GtkSettings* default_settings = gtk_settings_get_default(); |
| 274 g_object_set(default_settings, "gtk-button-images", TRUE, NULL); |
| 275 |
270 // We pack the button manually (rather than using gtk_button_set_*) so that | 276 // We pack the button manually (rather than using gtk_button_set_*) so that |
271 // we can have finer control over its label. | 277 // we can have finer control over its label. |
272 other_bookmarks_button_ = theme_service_->BuildChromeButton(); | 278 other_bookmarks_button_ = theme_service_->BuildChromeButton(); |
273 ConnectFolderButtonEvents(other_bookmarks_button_, false); | 279 ConnectFolderButtonEvents(other_bookmarks_button_, false); |
274 GtkWidget* other_padding = gtk_alignment_new(0, 0, 1, 1); | 280 GtkWidget* other_padding = gtk_alignment_new(0, 0, 1, 1); |
275 gtk_alignment_set_padding(GTK_ALIGNMENT(other_padding), | 281 gtk_alignment_set_padding(GTK_ALIGNMENT(other_padding), |
276 kOtherBookmarksPaddingVertical, | 282 kOtherBookmarksPaddingVertical, |
277 kOtherBookmarksPaddingVertical, | 283 kOtherBookmarksPaddingVertical, |
278 kOtherBookmarksPaddingHorizontal, | 284 kOtherBookmarksPaddingHorizontal, |
279 kOtherBookmarksPaddingHorizontal); | 285 kOtherBookmarksPaddingHorizontal); |
280 gtk_container_add(GTK_CONTAINER(other_padding), other_bookmarks_button_); | 286 gtk_container_add(GTK_CONTAINER(other_padding), other_bookmarks_button_); |
281 gtk_box_pack_start(GTK_BOX(bookmark_hbox_), other_padding, | 287 gtk_box_pack_start(GTK_BOX(bookmark_hbox_), other_padding, |
282 FALSE, FALSE, 0); | 288 FALSE, FALSE, 0); |
283 | 289 |
284 sync_error_button_ = theme_service_->BuildChromeButton(); | 290 sync_error_button_ = theme_service_->BuildChromeButton(); |
285 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 291 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 292 gtk_widget_set_tooltip_text( |
| 293 sync_error_button_, |
| 294 l10n_util::GetStringUTF8(IDS_SYNC_BOOKMARK_BAR_ERROR_DESC).c_str()); |
| 295 gtk_button_set_label( |
| 296 GTK_BUTTON(sync_error_button_), |
| 297 l10n_util::GetStringUTF8(IDS_SYNC_BOOKMARK_BAR_ERROR).c_str()); |
286 gtk_button_set_image( | 298 gtk_button_set_image( |
287 GTK_BUTTON(sync_error_button_), | 299 GTK_BUTTON(sync_error_button_), |
288 gtk_image_new_from_pixbuf(rb.GetNativeImageNamed(IDR_WARNING))); | 300 gtk_image_new_from_pixbuf(rb.GetNativeImageNamed(IDR_WARNING))); |
289 g_signal_connect(sync_error_button_, "button-press-event", | 301 g_signal_connect(sync_error_button_, "button-press-event", |
290 G_CALLBACK(OnSyncErrorButtonPressedThunk), this); | 302 G_CALLBACK(OnSyncErrorButtonPressedThunk), this); |
291 gtk_box_pack_start(GTK_BOX(bookmark_hbox_), sync_error_button_, | 303 gtk_box_pack_start(GTK_BOX(bookmark_hbox_), sync_error_button_, |
292 FALSE, FALSE, 0); | 304 FALSE, FALSE, 0); |
293 | 305 |
294 gtk_widget_set_size_request(event_box_.get(), -1, kBookmarkBarMinimumHeight); | 306 gtk_widget_set_size_request(event_box_.get(), -1, kBookmarkBarMinimumHeight); |
295 | 307 |
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1459 void BookmarkBarGtk::OnEditBookmarksEnabledChanged() { | 1471 void BookmarkBarGtk::OnEditBookmarksEnabledChanged() { |
1460 GtkDestDefaults dest_defaults = | 1472 GtkDestDefaults dest_defaults = |
1461 *edit_bookmarks_enabled_ ? GTK_DEST_DEFAULT_ALL : | 1473 *edit_bookmarks_enabled_ ? GTK_DEST_DEFAULT_ALL : |
1462 GTK_DEST_DEFAULT_DROP; | 1474 GTK_DEST_DEFAULT_DROP; |
1463 gtk_drag_dest_set(overflow_button_, dest_defaults, NULL, 0, kDragAction); | 1475 gtk_drag_dest_set(overflow_button_, dest_defaults, NULL, 0, kDragAction); |
1464 gtk_drag_dest_set(other_bookmarks_button_, dest_defaults, | 1476 gtk_drag_dest_set(other_bookmarks_button_, dest_defaults, |
1465 NULL, 0, kDragAction); | 1477 NULL, 0, kDragAction); |
1466 ui::SetDestTargetList(overflow_button_, kDestTargetList); | 1478 ui::SetDestTargetList(overflow_button_, kDestTargetList); |
1467 ui::SetDestTargetList(other_bookmarks_button_, kDestTargetList); | 1479 ui::SetDestTargetList(other_bookmarks_button_, kDestTargetList); |
1468 } | 1480 } |
OLD | NEW |