Chromium Code Reviews| 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/libgtk2ui/gtk2_ui.h" | 5 #include "chrome/browser/ui/libgtk2ui/gtk2_ui.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/leak_annotations.h" | 10 #include "base/debug/leak_annotations.h" |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 552 } | 552 } |
| 553 return gfx::Image(); | 553 return gfx::Image(); |
| 554 } | 554 } |
| 555 | 555 |
| 556 scoped_ptr<views::Border> Gtk2UI::CreateNativeBorder( | 556 scoped_ptr<views::Border> Gtk2UI::CreateNativeBorder( |
| 557 views::LabelButton* owning_button, | 557 views::LabelButton* owning_button, |
| 558 scoped_ptr<views::Border> border) { | 558 scoped_ptr<views::Border> border) { |
| 559 if (owning_button->GetNativeTheme() != NativeThemeGtk2::instance()) | 559 if (owning_button->GetNativeTheme() != NativeThemeGtk2::instance()) |
| 560 return border.Pass(); | 560 return border.Pass(); |
| 561 | 561 |
| 562 return scoped_ptr<views::Border>(new Gtk2Border(this, owning_button)); | 562 return scoped_ptr<views::Border>( |
| 563 new Gtk2Border(this, owning_button, border.Pass())); | |
| 563 } | 564 } |
| 564 | 565 |
| 565 void Gtk2UI::AddWindowButtonOrderObserver( | 566 void Gtk2UI::AddWindowButtonOrderObserver( |
| 566 views::WindowButtonOrderObserver* observer) { | 567 views::WindowButtonOrderObserver* observer) { |
| 567 if (!leading_buttons_.empty() || !trailing_buttons_.empty()) { | 568 if (!leading_buttons_.empty() || !trailing_buttons_.empty()) { |
| 568 observer->OnWindowButtonOrderingChange(leading_buttons_, | 569 observer->OnWindowButtonOrderingChange(leading_buttons_, |
| 569 trailing_buttons_); | 570 trailing_buttons_); |
| 570 } | 571 } |
| 571 | 572 |
| 572 observer_list_.AddObserver(observer); | 573 observer_list_.AddObserver(observer); |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 933 // Some GTK themes only define the text selection colors on the GtkEntry | 934 // Some GTK themes only define the text selection colors on the GtkEntry |
| 934 // class, so we need to use that for getting selection colors. | 935 // class, so we need to use that for getting selection colors. |
| 935 active_selection_bg_color_ = | 936 active_selection_bg_color_ = |
| 936 GdkColorToSkColor(entry_style->base[GTK_STATE_SELECTED]); | 937 GdkColorToSkColor(entry_style->base[GTK_STATE_SELECTED]); |
| 937 active_selection_fg_color_ = | 938 active_selection_fg_color_ = |
| 938 GdkColorToSkColor(entry_style->text[GTK_STATE_SELECTED]); | 939 GdkColorToSkColor(entry_style->text[GTK_STATE_SELECTED]); |
| 939 inactive_selection_bg_color_ = | 940 inactive_selection_bg_color_ = |
| 940 GdkColorToSkColor(entry_style->base[GTK_STATE_ACTIVE]); | 941 GdkColorToSkColor(entry_style->base[GTK_STATE_ACTIVE]); |
| 941 inactive_selection_fg_color_ = | 942 inactive_selection_fg_color_ = |
| 942 GdkColorToSkColor(entry_style->text[GTK_STATE_ACTIVE]); | 943 GdkColorToSkColor(entry_style->text[GTK_STATE_ACTIVE]); |
| 943 | |
| 944 // Update the insets that we hand to Gtk2Border. | |
| 945 UpdateButtonInsets(); | |
| 946 } | 944 } |
| 947 | 945 |
| 948 GdkColor Gtk2UI::BuildFrameColors(GtkStyle* frame_style) { | 946 GdkColor Gtk2UI::BuildFrameColors(GtkStyle* frame_style) { |
| 949 GdkColor* theme_frame = NULL; | 947 GdkColor* theme_frame = NULL; |
| 950 GdkColor* theme_inactive_frame = NULL; | 948 GdkColor* theme_inactive_frame = NULL; |
| 951 GdkColor* theme_incognito_frame = NULL; | 949 GdkColor* theme_incognito_frame = NULL; |
| 952 GdkColor* theme_incognito_inactive_frame = NULL; | 950 GdkColor* theme_incognito_inactive_frame = NULL; |
| 953 gtk_widget_style_get(GTK_WIDGET(fake_frame_), | 951 gtk_widget_style_get(GTK_WIDGET(fake_frame_), |
| 954 "frame-color", &theme_frame, | 952 "frame-color", &theme_frame, |
| 955 "inactive-frame-color", &theme_inactive_frame, | 953 "inactive-frame-color", &theme_inactive_frame, |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1352 | 1350 |
| 1353 // Finally, we convert our pixbuf into a type we can use. | 1351 // Finally, we convert our pixbuf into a type we can use. |
| 1354 SkBitmap border = GdkPixbufToImageSkia(pixbuf); | 1352 SkBitmap border = GdkPixbufToImageSkia(pixbuf); |
| 1355 g_object_unref(pixbuf); | 1353 g_object_unref(pixbuf); |
| 1356 g_object_unref(pixmap); | 1354 g_object_unref(pixmap); |
| 1357 gtk_widget_destroy(window); | 1355 gtk_widget_destroy(window); |
| 1358 | 1356 |
| 1359 return border; | 1357 return border; |
| 1360 } | 1358 } |
| 1361 | 1359 |
| 1362 gfx::Insets Gtk2UI::GetButtonInsets() const { | |
| 1363 return button_insets_; | |
| 1364 } | |
| 1365 | |
| 1366 void Gtk2UI::UpdateButtonInsets() { | |
| 1367 GtkWidget* window = gtk_offscreen_window_new(); | |
| 1368 GtkWidget* button = gtk_button_new(); | |
| 1369 gtk_container_add(GTK_CONTAINER(window), button); | |
| 1370 | |
| 1371 GtkBorder* border = NULL; | |
| 1372 gtk_widget_style_get(GTK_WIDGET(button), | |
|
msw
2014/05/21 22:57:14
Why isn't code like this needed at all anymore? It
Elliot Glaysher
2014/05/21 23:16:57
This code is flat out wrong. This code grabs the "
| |
| 1373 "default-border", | |
| 1374 &border, | |
| 1375 NULL); | |
| 1376 | |
| 1377 gfx::Insets insets; | |
| 1378 if (border) { | |
| 1379 button_insets_ = gfx::Insets(border->top, border->left, | |
| 1380 border->bottom, border->right); | |
| 1381 gtk_border_free(border); | |
| 1382 } else { | |
| 1383 // Defined in gtkbutton.c: | |
| 1384 button_insets_ = gfx::Insets(1, 1, 1, 1); | |
| 1385 } | |
| 1386 | |
| 1387 gtk_widget_destroy(window); | |
| 1388 } | |
| 1389 | |
| 1390 void Gtk2UI::ClearAllThemeData() { | 1360 void Gtk2UI::ClearAllThemeData() { |
| 1391 gtk_images_.clear(); | 1361 gtk_images_.clear(); |
| 1392 } | 1362 } |
| 1393 | 1363 |
| 1394 void Gtk2UI::OnStyleSet(GtkWidget* widget, GtkStyle* previous_style) { | 1364 void Gtk2UI::OnStyleSet(GtkWidget* widget, GtkStyle* previous_style) { |
| 1395 ClearAllThemeData(); | 1365 ClearAllThemeData(); |
| 1396 LoadGtkValues(); | 1366 LoadGtkValues(); |
| 1397 NativeThemeGtk2::instance()->NotifyObservers(); | 1367 NativeThemeGtk2::instance()->NotifyObservers(); |
| 1398 } | 1368 } |
| 1399 | 1369 |
| 1400 } // namespace libgtk2ui | 1370 } // namespace libgtk2ui |
| 1401 | 1371 |
| 1402 views::LinuxUI* BuildGtk2UI() { | 1372 views::LinuxUI* BuildGtk2UI() { |
| 1403 return new libgtk2ui::Gtk2UI; | 1373 return new libgtk2ui::Gtk2UI; |
| 1404 } | 1374 } |
| OLD | NEW |