OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/location_bar_view_gtk.h" | 5 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 #include "chrome/browser/ui/gtk/content_setting_bubble_gtk.h" | 53 #include "chrome/browser/ui/gtk/content_setting_bubble_gtk.h" |
54 #include "chrome/browser/ui/gtk/extensions/extension_popup_gtk.h" | 54 #include "chrome/browser/ui/gtk/extensions/extension_popup_gtk.h" |
55 #include "chrome/browser/ui/gtk/first_run_bubble.h" | 55 #include "chrome/browser/ui/gtk/first_run_bubble.h" |
56 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 56 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
57 #include "chrome/browser/ui/gtk/gtk_util.h" | 57 #include "chrome/browser/ui/gtk/gtk_util.h" |
58 #include "chrome/browser/ui/gtk/nine_box.h" | 58 #include "chrome/browser/ui/gtk/nine_box.h" |
59 #include "chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h" | 59 #include "chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h" |
60 #include "chrome/browser/ui/gtk/rounded_window.h" | 60 #include "chrome/browser/ui/gtk/rounded_window.h" |
61 #include "chrome/browser/ui/gtk/view_id_util.h" | 61 #include "chrome/browser/ui/gtk/view_id_util.h" |
62 #include "chrome/browser/ui/gtk/zoom_bubble_gtk.h" | 62 #include "chrome/browser/ui/gtk/zoom_bubble_gtk.h" |
63 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" | |
63 #include "chrome/browser/ui/omnibox/location_bar_util.h" | 64 #include "chrome/browser/ui/omnibox/location_bar_util.h" |
64 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" | 65 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
65 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 66 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
66 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 67 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
67 #include "chrome/browser/ui/webui/extensions/extension_info_ui.h" | 68 #include "chrome/browser/ui/webui/extensions/extension_info_ui.h" |
68 #include "chrome/browser/ui/zoom/zoom_controller.h" | 69 #include "chrome/browser/ui/zoom/zoom_controller.h" |
69 #include "chrome/common/chrome_notification_types.h" | 70 #include "chrome/common/chrome_notification_types.h" |
70 #include "chrome/common/extensions/extension.h" | 71 #include "chrome/common/extensions/extension.h" |
71 #include "chrome/common/extensions/extension_action.h" | 72 #include "chrome/common/extensions/extension_action.h" |
72 #include "chrome/common/extensions/extension_manifest_constants.h" | 73 #include "chrome/common/extensions/extension_manifest_constants.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 const GdkColor kHintTextColor = GDK_COLOR_RGB(0x75, 0x75, 0x75); | 135 const GdkColor kHintTextColor = GDK_COLOR_RGB(0x75, 0x75, 0x75); |
135 | 136 |
136 // Size of the rounding of the "Search site for:" box. | 137 // Size of the rounding of the "Search site for:" box. |
137 const int kCornerSize = 3; | 138 const int kCornerSize = 3; |
138 | 139 |
139 // The time, in ms, that the content setting label is fully displayed, for the | 140 // The time, in ms, that the content setting label is fully displayed, for the |
140 // cases where we animate it into and out of view. | 141 // cases where we animate it into and out of view. |
141 const int kContentSettingImageDisplayTime = 3200; | 142 const int kContentSettingImageDisplayTime = 3200; |
142 // The time, in ms, of the animation (open and close). | 143 // The time, in ms, of the animation (open and close). |
143 const int kContentSettingImageAnimationTime = 150; | 144 const int kContentSettingImageAnimationTime = 150; |
145 const int kPageToolAnimationTime = 1000; | |
144 | 146 |
145 // Color of border of content setting area (icon/label). | 147 // Color of border of content setting area (icon/label). |
146 const GdkColor kContentSettingBorderColor = GDK_COLOR_RGB(0xe9, 0xb9, 0x66); | 148 const GdkColor kContentSettingBorderColor = GDK_COLOR_RGB(0xe9, 0xb9, 0x66); |
147 // Colors for the background gradient. | 149 // Colors for the background gradient. |
148 const double kContentSettingTopColor[] = { 0xff / 255.0, | 150 const double kContentSettingTopColor[] = { 0xff / 255.0, |
149 0xf8 / 255.0, | 151 0xf8 / 255.0, |
150 0xd4 / 255.0 }; | 152 0xd4 / 255.0 }; |
151 const double kContentSettingBottomColor[] = { 0xff / 255.0, | 153 const double kContentSettingBottomColor[] = { 0xff / 255.0, |
152 0xe6 / 255.0, | 154 0xe6 / 255.0, |
153 0xaf / 255.0 }; | 155 0xaf / 255.0 }; |
154 | 156 |
157 const GdkColor kContentSettingGrayColor = GDK_COLOR_RGB(0xa0, 0xa0, 0xa0); | |
158 const double kContentSettingTopColorGray[] = { 0xe5 / 255.0, | |
159 0xe5 / 255.0, | |
160 0xe5 / 255.0 }; | |
161 const double kContentSettingBottomColorGray[] = { 0xd0 / 255.0, | |
162 0xd0 / 255.0, | |
163 0xd0 / 255.0 }; | |
164 | |
155 // If widget is visible, increment the int pointed to by count. | 165 // If widget is visible, increment the int pointed to by count. |
156 // Suitible for use with gtk_container_foreach. | 166 // Suitible for use with gtk_container_foreach. |
157 void CountVisibleWidgets(GtkWidget* widget, gpointer count) { | 167 void CountVisibleWidgets(GtkWidget* widget, gpointer count) { |
158 if (gtk_widget_get_visible(widget)) | 168 if (gtk_widget_get_visible(widget)) |
159 *static_cast<int*>(count) += 1; | 169 *static_cast<int*>(count) += 1; |
160 } | 170 } |
161 | 171 |
162 } // namespace | 172 } // namespace |
163 | 173 |
164 //////////////////////////////////////////////////////////////////////////////// | 174 //////////////////////////////////////////////////////////////////////////////// |
165 // LocationBarViewGtk | 175 // LocationBarViewGtk |
166 | 176 |
167 // static | 177 // static |
168 const GdkColor LocationBarViewGtk::kBackgroundColor = | 178 const GdkColor LocationBarViewGtk::kBackgroundColor = |
169 GDK_COLOR_RGB(255, 255, 255); | 179 GDK_COLOR_RGB(255, 255, 255); |
170 | 180 |
171 LocationBarViewGtk::LocationBarViewGtk(Browser* browser) | 181 LocationBarViewGtk::LocationBarViewGtk(Browser* browser) |
172 : zoom_image_(NULL), | 182 : zoom_image_(NULL), |
173 star_image_(NULL), | 183 star_image_(NULL), |
174 starred_(false), | 184 starred_(false), |
175 chrome_to_mobile_image_(NULL), | 185 chrome_to_mobile_image_(NULL), |
176 site_type_alignment_(NULL), | 186 site_type_alignment_(NULL), |
177 site_type_event_box_(NULL), | 187 site_type_event_box_(NULL), |
178 location_icon_image_(NULL), | 188 location_icon_image_(NULL), |
179 drag_icon_(NULL), | 189 drag_icon_(NULL), |
180 enable_location_drag_(false), | 190 enable_location_drag_(false), |
181 security_info_label_(NULL), | 191 security_info_label_(NULL), |
192 web_intents_tool_view_(this), | |
182 tab_to_search_alignment_(NULL), | 193 tab_to_search_alignment_(NULL), |
183 tab_to_search_box_(NULL), | 194 tab_to_search_box_(NULL), |
184 tab_to_search_full_label_(NULL), | 195 tab_to_search_full_label_(NULL), |
185 tab_to_search_partial_label_(NULL), | 196 tab_to_search_partial_label_(NULL), |
186 tab_to_search_hint_(NULL), | 197 tab_to_search_hint_(NULL), |
187 tab_to_search_hint_leading_label_(NULL), | 198 tab_to_search_hint_leading_label_(NULL), |
188 tab_to_search_hint_icon_(NULL), | 199 tab_to_search_hint_icon_(NULL), |
189 tab_to_search_hint_trailing_label_(NULL), | 200 tab_to_search_hint_trailing_label_(NULL), |
190 command_updater_(browser->command_controller()->command_updater()), | 201 command_updater_(browser->command_controller()->command_updater()), |
191 toolbar_model_(browser->toolbar_model()), | 202 toolbar_model_(browser->toolbar_model()), |
(...skipping 12 matching lines...) Expand all Loading... | |
204 } | 215 } |
205 | 216 |
206 LocationBarViewGtk::~LocationBarViewGtk() { | 217 LocationBarViewGtk::~LocationBarViewGtk() { |
207 // All of our widgets should be children of / owned by the alignment. | 218 // All of our widgets should be children of / owned by the alignment. |
208 zoom_.Destroy(); | 219 zoom_.Destroy(); |
209 star_.Destroy(); | 220 star_.Destroy(); |
210 chrome_to_mobile_view_.Destroy(); | 221 chrome_to_mobile_view_.Destroy(); |
211 hbox_.Destroy(); | 222 hbox_.Destroy(); |
212 content_setting_hbox_.Destroy(); | 223 content_setting_hbox_.Destroy(); |
213 page_action_hbox_.Destroy(); | 224 page_action_hbox_.Destroy(); |
225 web_intents_hbox_.Destroy(); | |
214 } | 226 } |
215 | 227 |
216 void LocationBarViewGtk::Init(bool popup_window_mode) { | 228 void LocationBarViewGtk::Init(bool popup_window_mode) { |
217 popup_window_mode_ = popup_window_mode; | 229 popup_window_mode_ = popup_window_mode; |
218 | 230 |
219 Profile* profile = browser_->profile(); | 231 Profile* profile = browser_->profile(); |
220 theme_service_ = GtkThemeService::GetFrom(profile); | 232 theme_service_ = GtkThemeService::GetFrom(profile); |
221 | 233 |
222 // Create the widget first, so we can pass it to the OmniboxViewGtk. | 234 // Create the widget first, so we can pass it to the OmniboxViewGtk. |
223 hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); | 235 hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
359 gtk_box_pack_end(GTK_BOX(content_setting_hbox_.get()), | 371 gtk_box_pack_end(GTK_BOX(content_setting_hbox_.get()), |
360 content_setting_view->widget(), FALSE, FALSE, 0); | 372 content_setting_view->widget(), FALSE, FALSE, 0); |
361 } | 373 } |
362 | 374 |
363 page_action_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); | 375 page_action_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); |
364 gtk_widget_set_name(page_action_hbox_.get(), | 376 gtk_widget_set_name(page_action_hbox_.get(), |
365 "chrome-page-action-hbox"); | 377 "chrome-page-action-hbox"); |
366 gtk_box_pack_end(GTK_BOX(hbox_.get()), page_action_hbox_.get(), | 378 gtk_box_pack_end(GTK_BOX(hbox_.get()), page_action_hbox_.get(), |
367 FALSE, FALSE, 0); | 379 FALSE, FALSE, 0); |
368 | 380 |
381 web_intents_hbox_.Own(gtk_hbox_new(FALSE, kInnerPadding)); | |
382 gtk_widget_set_name(web_intents_hbox_.get(), | |
383 "chrome-web-intents-hbox"); | |
384 gtk_box_pack_end(GTK_BOX(hbox_.get()), web_intents_hbox_.get(), | |
385 FALSE, FALSE, 0); | |
386 gtk_box_pack_end(GTK_BOX(web_intents_hbox_.get()), | |
387 web_intents_tool_view_.widget(), FALSE, FALSE, 0); | |
388 | |
369 // Now that we've created the widget hierarchy, connect to the main |hbox_|'s | 389 // Now that we've created the widget hierarchy, connect to the main |hbox_|'s |
370 // size-allocate so we can do proper resizing and eliding on | 390 // size-allocate so we can do proper resizing and eliding on |
371 // |security_info_label_|. | 391 // |security_info_label_|. |
372 g_signal_connect(hbox_.get(), "size-allocate", | 392 g_signal_connect(hbox_.get(), "size-allocate", |
373 G_CALLBACK(&OnHboxSizeAllocateThunk), this); | 393 G_CALLBACK(&OnHboxSizeAllocateThunk), this); |
374 | 394 |
375 registrar_.Add(this, | 395 registrar_.Add(this, |
376 chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 396 chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
377 content::Source<ThemeService>(theme_service_)); | 397 content::Source<ThemeService>(theme_service_)); |
378 registrar_.Add(this, | 398 registrar_.Add(this, |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
490 return NULL; | 510 return NULL; |
491 } | 511 } |
492 | 512 |
493 void LocationBarViewGtk::Update(const WebContents* contents) { | 513 void LocationBarViewGtk::Update(const WebContents* contents) { |
494 UpdateZoomIcon(); | 514 UpdateZoomIcon(); |
495 UpdateStarIcon(); | 515 UpdateStarIcon(); |
496 UpdateChromeToMobileIcon(); | 516 UpdateChromeToMobileIcon(); |
497 UpdateSiteTypeArea(); | 517 UpdateSiteTypeArea(); |
498 UpdateContentSettingsIcons(); | 518 UpdateContentSettingsIcons(); |
499 UpdatePageActions(); | 519 UpdatePageActions(); |
520 UpdateWebIntentsTool(); | |
500 location_entry_->Update(contents); | 521 location_entry_->Update(contents); |
501 // The security level (background color) could have changed, etc. | 522 // The security level (background color) could have changed, etc. |
502 if (theme_service_->UsingNativeTheme()) { | 523 if (theme_service_->UsingNativeTheme()) { |
503 // In GTK mode, we need our parent to redraw, as it draws the text entry | 524 // In GTK mode, we need our parent to redraw, as it draws the text entry |
504 // border. | 525 // border. |
505 gtk_widget_queue_draw(gtk_widget_get_parent(widget())); | 526 gtk_widget_queue_draw(gtk_widget_get_parent(widget())); |
506 } else { | 527 } else { |
507 gtk_widget_queue_draw(widget()); | 528 gtk_widget_queue_draw(widget()); |
508 } | 529 } |
509 } | 530 } |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
773 size_t count_before = page_action_views_.size(); | 794 size_t count_before = page_action_views_.size(); |
774 page_action_views_.clear(); | 795 page_action_views_.clear(); |
775 if (page_action_views_.size() != count_before) { | 796 if (page_action_views_.size() != count_before) { |
776 content::NotificationService::current()->Notify( | 797 content::NotificationService::current()->Notify( |
777 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 798 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, |
778 content::Source<LocationBar>(this), | 799 content::Source<LocationBar>(this), |
779 content::NotificationService::NoDetails()); | 800 content::NotificationService::NoDetails()); |
780 } | 801 } |
781 } | 802 } |
782 | 803 |
804 void LocationBarViewGtk::UpdateWebIntentsTool() { | |
805 web_intents_tool_view_.Update(GetTabContents()); | |
806 gtk_widget_set_visible(web_intents_hbox_.get(), | |
807 web_intents_tool_view_.IsVisible()); | |
808 } | |
809 | |
783 void LocationBarViewGtk::SaveStateToContents(WebContents* contents) { | 810 void LocationBarViewGtk::SaveStateToContents(WebContents* contents) { |
784 location_entry_->SaveStateToTab(contents); | 811 location_entry_->SaveStateToTab(contents); |
785 } | 812 } |
786 | 813 |
787 void LocationBarViewGtk::Revert() { | 814 void LocationBarViewGtk::Revert() { |
788 location_entry_->RevertAll(); | 815 location_entry_->RevertAll(); |
789 } | 816 } |
790 | 817 |
791 const OmniboxView* LocationBarViewGtk::GetLocationEntry() const { | 818 const OmniboxView* LocationBarViewGtk::GetLocationEntry() const { |
792 return location_entry_.get(); | 819 return location_entry_.get(); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
915 1, 1, 0, 0); | 942 1, 1, 0, 0); |
916 gtk_alignment_set_padding(GTK_ALIGNMENT(site_type_alignment_), | 943 gtk_alignment_set_padding(GTK_ALIGNMENT(site_type_alignment_), |
917 1, 1, 0, 0); | 944 1, 1, 0, 0); |
918 } | 945 } |
919 | 946 |
920 UpdateZoomIcon(); | 947 UpdateZoomIcon(); |
921 UpdateStarIcon(); | 948 UpdateStarIcon(); |
922 UpdateChromeToMobileIcon(); | 949 UpdateChromeToMobileIcon(); |
923 UpdateSiteTypeArea(); | 950 UpdateSiteTypeArea(); |
924 UpdateContentSettingsIcons(); | 951 UpdateContentSettingsIcons(); |
952 UpdateWebIntentsTool(); | |
925 break; | 953 break; |
926 } | 954 } |
927 | 955 |
928 default: | 956 default: |
929 NOTREACHED(); | 957 NOTREACHED(); |
930 } | 958 } |
931 } | 959 } |
932 | 960 |
933 gboolean LocationBarViewGtk::HandleExpose(GtkWidget* widget, | 961 gboolean LocationBarViewGtk::HandleExpose(GtkWidget* widget, |
934 GdkEventExpose* event) { | 962 GdkEventExpose* event) { |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1407 gtk_widget_show(tab_to_search_hint_); | 1435 gtk_widget_show(tab_to_search_hint_); |
1408 } else if (full_width < available_width) { | 1436 } else if (full_width < available_width) { |
1409 gtk_widget_show(tab_to_search_hint_leading_label_); | 1437 gtk_widget_show(tab_to_search_hint_leading_label_); |
1410 gtk_widget_show(tab_to_search_hint_trailing_label_); | 1438 gtk_widget_show(tab_to_search_hint_trailing_label_); |
1411 gtk_widget_show(tab_to_search_hint_); | 1439 gtk_widget_show(tab_to_search_hint_); |
1412 } | 1440 } |
1413 } | 1441 } |
1414 } | 1442 } |
1415 | 1443 |
1416 //////////////////////////////////////////////////////////////////////////////// | 1444 //////////////////////////////////////////////////////////////////////////////// |
1445 // LocationBarViewGtk::PageToolViewGtk | |
1446 | |
1447 LocationBarViewGtk::PageToolViewGtk::PageToolViewGtk( | |
1448 const LocationBarViewGtk* parent) | |
1449 : alignment_(gtk_alignment_new(0, 0, 1, 1)), | |
1450 event_box_(gtk_event_box_new()), | |
1451 hbox_(gtk_hbox_new(FALSE, kInnerPadding)), | |
1452 image_(gtk_image_new()), | |
1453 label_(gtk_label_new(NULL)), | |
1454 parent_(parent), | |
1455 animation_(this), | |
1456 weak_factory_(this) { | |
1457 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_.get()), 1, 1, 0, 0); | |
1458 gtk_container_add(GTK_CONTAINER(alignment_.get()), event_box_.get()); | |
1459 | |
1460 // Make the event box not visible so it does not paint a background. | |
1461 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE); | |
1462 g_signal_connect(event_box_.get(), "button-press-event", | |
1463 G_CALLBACK(&OnButtonPressedThunk), this); | |
1464 g_signal_connect(event_box_.get(), "expose-event", | |
1465 G_CALLBACK(&OnExposeThunk), this); | |
1466 | |
1467 gtk_widget_set_no_show_all(label_.get(), TRUE); | |
1468 gtk_label_set_line_wrap(GTK_LABEL(label_.get()), FALSE); | |
1469 | |
1470 gtk_box_pack_start(GTK_BOX(hbox_), image_.get(), FALSE, FALSE, 0); | |
1471 gtk_box_pack_start(GTK_BOX(hbox_), label_.get(), FALSE, FALSE, 0); | |
1472 | |
1473 gtk_container_set_border_width(GTK_CONTAINER(hbox_), kHboxBorder); | |
1474 | |
1475 gtk_container_add(GTK_CONTAINER(event_box_.get()), hbox_); | |
1476 gtk_widget_hide(widget()); | |
1477 | |
1478 animation_.SetSlideDuration(kPageToolAnimationTime); | |
1479 } | |
1480 | |
1481 LocationBarViewGtk::PageToolViewGtk::~PageToolViewGtk() { | |
1482 image_.Destroy(); | |
1483 label_.Destroy(); | |
1484 event_box_.Destroy(); | |
1485 alignment_.Destroy(); | |
1486 } | |
1487 | |
1488 GtkWidget* LocationBarViewGtk::PageToolViewGtk::widget() { | |
1489 return alignment_.get(); | |
1490 } | |
1491 | |
1492 bool LocationBarViewGtk::PageToolViewGtk::IsVisible() { | |
1493 return gtk_widget_get_visible(widget()); | |
1494 } | |
1495 | |
1496 void LocationBarViewGtk::PageToolViewGtk::Update( | |
1497 TabContents* tab_contents) { | |
1498 if (!tab_contents || | |
1499 !tab_contents->web_intent_picker_controller() || | |
1500 !tab_contents->web_intent_picker_controller()-> | |
1501 ShowLocationBarPickerTool()) { | |
1502 gtk_widget_hide(widget()); | |
1503 return; | |
1504 } | |
1505 | |
1506 gtk_widget_set_tooltip_text(widget(), | |
1507 l10n_util::GetStringUTF8(IDS_INTENT_PICKER_USE_ANOTHER_SERVICE).c_str()); | |
1508 gtk_widget_show_all(widget()); | |
1509 | |
1510 gtk_label_set_text(GTK_LABEL(label_.get()), | |
1511 l10n_util::GetStringUTF8(IDS_INTENT_PICKER_USE_ANOTHER_SERVICE).c_str()); | |
1512 | |
1513 StartAnimating(); | |
1514 } | |
1515 | |
1516 void LocationBarViewGtk::PageToolViewGtk::StartAnimating() { | |
1517 if (animation_.IsShowing() || animation_.IsClosing()) | |
1518 return; | |
1519 | |
1520 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), TRUE); | |
1521 GdkColor border_color = kContentSettingGrayColor; | |
1522 gtk_util::ActAsRoundedWindow(event_box_.get(), border_color, | |
1523 kCornerSize, | |
1524 gtk_util::ROUNDED_ALL, gtk_util::BORDER_ALL); | |
1525 | |
1526 gtk_widget_set_size_request(label_.get(), -1, -1); | |
1527 gtk_widget_size_request(label_.get(), &label_req_); | |
1528 gtk_widget_set_size_request(label_.get(), 0, -1); | |
1529 gtk_widget_show(label_.get()); | |
1530 | |
1531 animation_.Show(); | |
1532 } | |
1533 | |
1534 void LocationBarViewGtk::PageToolViewGtk::AnimationProgressed( | |
1535 const ui::Animation* animation) { | |
1536 gtk_widget_set_size_request( | |
1537 label_.get(), | |
1538 animation->GetCurrentValue() * label_req_.width, | |
1539 -1); | |
1540 } | |
1541 | |
1542 void LocationBarViewGtk::PageToolViewGtk::AnimationCanceled( | |
1543 const ui::Animation* animation) { | |
1544 } | |
1545 | |
1546 void LocationBarViewGtk::PageToolViewGtk::AnimationEnded( | |
1547 const ui::Animation* animation) { | |
1548 if (!animation_.IsShowing()) { | |
1549 gtk_widget_hide(label_.get()); | |
1550 gtk_util::StopActingAsRoundedWindow(event_box_.get()); | |
1551 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), FALSE); | |
1552 } | |
1553 } | |
1554 | |
1555 gboolean LocationBarViewGtk::PageToolViewGtk::OnButtonPressed( | |
1556 GtkWidget* sender, GdkEvent* event) { | |
1557 LOG(INFO) << "CLICK!!!"; | |
Bernhard Bauer
2012/07/24 20:37:03
? :)
| |
1558 return TRUE; | |
1559 } | |
1560 | |
1561 gboolean LocationBarViewGtk::PageToolViewGtk::OnExpose( | |
1562 GtkWidget* sender, GdkEventExpose* event) { | |
1563 TRACE_EVENT0("ui::gtk", "LocationBarViewGtk::PageToolViewGtk::OnExpose"); | |
1564 | |
1565 if (!(animation_.IsShowing() || animation_.IsClosing())) | |
1566 return FALSE; | |
1567 | |
1568 GtkAllocation allocation; | |
1569 gtk_widget_get_allocation(sender, &allocation); | |
1570 const int height = allocation.height; | |
1571 | |
1572 cairo_t* cr = gdk_cairo_create(gtk_widget_get_window(sender)); | |
1573 gdk_cairo_rectangle(cr, &event->area); | |
1574 cairo_clip(cr); | |
1575 | |
1576 cairo_pattern_t* pattern = cairo_pattern_create_linear(0, 0, 0, height); | |
1577 | |
1578 const double* top_color = kContentSettingTopColorGray; | |
1579 const double* bottom_color = kContentSettingBottomColorGray; | |
1580 cairo_pattern_add_color_stop_rgb( | |
1581 pattern, 0.0, top_color[0], top_color[1], top_color[2]); | |
1582 cairo_pattern_add_color_stop_rgb( | |
1583 pattern, 1.0, bottom_color[0], bottom_color[1], bottom_color[2]); | |
1584 | |
1585 cairo_set_source(cr, pattern); | |
1586 cairo_paint(cr); | |
1587 cairo_pattern_destroy(pattern); | |
1588 cairo_destroy(cr); | |
1589 | |
1590 return FALSE; | |
1591 } | |
1592 | |
1593 //////////////////////////////////////////////////////////////////////////////// | |
1417 // LocationBarViewGtk::ContentSettingImageViewGtk | 1594 // LocationBarViewGtk::ContentSettingImageViewGtk |
1418 LocationBarViewGtk::ContentSettingImageViewGtk::ContentSettingImageViewGtk( | 1595 LocationBarViewGtk::ContentSettingImageViewGtk::ContentSettingImageViewGtk( |
1419 ContentSettingsType content_type, | 1596 ContentSettingsType content_type, |
1420 const LocationBarViewGtk* parent) | 1597 const LocationBarViewGtk* parent) |
1421 : content_setting_image_model_( | 1598 : content_setting_image_model_( |
1422 ContentSettingImageModel::CreateContentSettingImageModel( | 1599 ContentSettingImageModel::CreateContentSettingImageModel( |
1423 content_type)), | 1600 content_type)), |
1424 alignment_(gtk_alignment_new(0, 0, 1, 1)), | 1601 alignment_(gtk_alignment_new(0, 0, 1, 1)), |
1425 event_box_(gtk_event_box_new()), | 1602 event_box_(gtk_event_box_new()), |
1426 hbox_(gtk_hbox_new(FALSE, kInnerPadding)), | 1603 hbox_(gtk_hbox_new(FALSE, kInnerPadding)), |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1507 gtk_label_set_text(GTK_LABEL(label_.get()), | 1684 gtk_label_set_text(GTK_LABEL(label_.get()), |
1508 l10n_util::GetStringUTF8(label_string_id).c_str()); | 1685 l10n_util::GetStringUTF8(label_string_id).c_str()); |
1509 StartAnimating(); | 1686 StartAnimating(); |
1510 } | 1687 } |
1511 | 1688 |
1512 void LocationBarViewGtk::ContentSettingImageViewGtk::StartAnimating() { | 1689 void LocationBarViewGtk::ContentSettingImageViewGtk::StartAnimating() { |
1513 if (animation_.IsShowing() || animation_.IsClosing()) | 1690 if (animation_.IsShowing() || animation_.IsClosing()) |
1514 return; | 1691 return; |
1515 | 1692 |
1516 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), TRUE); | 1693 gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box_.get()), TRUE); |
1517 gtk_util::ActAsRoundedWindow(event_box_.get(), kContentSettingBorderColor, | 1694 GdkColor border_color = kContentSettingBorderColor; |
1695 gtk_util::ActAsRoundedWindow(event_box_.get(), border_color, | |
1518 kCornerSize, | 1696 kCornerSize, |
1519 gtk_util::ROUNDED_ALL, gtk_util::BORDER_ALL); | 1697 gtk_util::ROUNDED_ALL, gtk_util::BORDER_ALL); |
1520 | 1698 |
1521 gtk_widget_set_size_request(label_.get(), -1, -1); | 1699 gtk_widget_set_size_request(label_.get(), -1, -1); |
1522 gtk_widget_size_request(label_.get(), &label_req_); | 1700 gtk_widget_size_request(label_.get(), &label_req_); |
1523 gtk_widget_set_size_request(label_.get(), 0, -1); | 1701 gtk_widget_set_size_request(label_.get(), 0, -1); |
1524 gtk_widget_show(label_.get()); | 1702 gtk_widget_show(label_.get()); |
1525 | 1703 |
1526 animation_.Show(); | 1704 animation_.Show(); |
1527 } | 1705 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1585 GtkAllocation allocation; | 1763 GtkAllocation allocation; |
1586 gtk_widget_get_allocation(sender, &allocation); | 1764 gtk_widget_get_allocation(sender, &allocation); |
1587 const int height = allocation.height; | 1765 const int height = allocation.height; |
1588 | 1766 |
1589 cairo_t* cr = gdk_cairo_create(gtk_widget_get_window(sender)); | 1767 cairo_t* cr = gdk_cairo_create(gtk_widget_get_window(sender)); |
1590 gdk_cairo_rectangle(cr, &event->area); | 1768 gdk_cairo_rectangle(cr, &event->area); |
1591 cairo_clip(cr); | 1769 cairo_clip(cr); |
1592 | 1770 |
1593 cairo_pattern_t* pattern = cairo_pattern_create_linear(0, 0, 0, height); | 1771 cairo_pattern_t* pattern = cairo_pattern_create_linear(0, 0, 0, height); |
1594 | 1772 |
1595 cairo_pattern_add_color_stop_rgb(pattern, 0.0, | 1773 const double* top_color = kContentSettingTopColor; |
1596 kContentSettingTopColor[0], | 1774 const double* bottom_color = kContentSettingBottomColor; |
1597 kContentSettingTopColor[1], | 1775 cairo_pattern_add_color_stop_rgb( |
1598 kContentSettingTopColor[2]); | 1776 pattern, 0.0, top_color[0], top_color[1], top_color[2]); |
1599 cairo_pattern_add_color_stop_rgb(pattern, 1.0, | 1777 cairo_pattern_add_color_stop_rgb( |
1600 kContentSettingBottomColor[0], | 1778 pattern, 1.0, bottom_color[0], bottom_color[1], bottom_color[2]); |
1601 kContentSettingBottomColor[1], | 1779 |
1602 kContentSettingBottomColor[2]); | |
1603 cairo_set_source(cr, pattern); | 1780 cairo_set_source(cr, pattern); |
1604 cairo_paint(cr); | 1781 cairo_paint(cr); |
1605 cairo_pattern_destroy(pattern); | 1782 cairo_pattern_destroy(pattern); |
1606 cairo_destroy(cr); | 1783 cairo_destroy(cr); |
1607 | 1784 |
1608 return FALSE; | 1785 return FALSE; |
1609 } | 1786 } |
1610 | 1787 |
1611 void LocationBarViewGtk::ContentSettingImageViewGtk::BubbleClosing( | 1788 void LocationBarViewGtk::ContentSettingImageViewGtk::BubbleClosing( |
1612 BubbleGtk* bubble, | 1789 BubbleGtk* bubble, |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1973 } | 2150 } |
1974 | 2151 |
1975 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( | 2152 void LocationBarViewGtk::PageActionViewGtk::InspectPopup( |
1976 ExtensionAction* action) { | 2153 ExtensionAction* action) { |
1977 ExtensionPopupGtk::Show( | 2154 ExtensionPopupGtk::Show( |
1978 action->GetPopupUrl(current_tab_id_), | 2155 action->GetPopupUrl(current_tab_id_), |
1979 owner_->browser_, | 2156 owner_->browser_, |
1980 event_box_.get(), | 2157 event_box_.get(), |
1981 ExtensionPopupGtk::SHOW_AND_INSPECT); | 2158 ExtensionPopupGtk::SHOW_AND_INSPECT); |
1982 } | 2159 } |
OLD | NEW |