Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(791)

Side by Side Diff: chrome/common/gtk_util.cc

Issue 479006: re-apply r34183... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/gtk_util.h ('k') | chrome/common/platform_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/common/gtk_util.h" 5 #include "chrome/common/gtk_util.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 #include <gdk/gdkx.h> 8 #include <gdk/gdkx.h>
9 9
10 #include <cstdarg> 10 #include <cstdarg>
11 11
12 #include "app/l10n_util.h" 12 #include "app/l10n_util.h"
13 #include "app/resource_bundle.h" 13 #include "app/resource_bundle.h"
14 #include "base/linux_util.h" 14 #include "base/linux_util.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "chrome/browser/gtk/gtk_theme_provider.h"
16 #include "chrome/common/renderer_preferences.h" 17 #include "chrome/common/renderer_preferences.h"
17 #include "grit/theme_resources.h" 18 #include "grit/theme_resources.h"
18 #include "third_party/skia/include/core/SkBitmap.h" 19 #include "third_party/skia/include/core/SkBitmap.h"
19 #include "third_party/skia/include/core/SkColor.h" 20 #include "third_party/skia/include/core/SkColor.h"
20 21
21 namespace { 22 namespace {
22 23
23 // Callback used in RemoveAllChildren. 24 // Callback used in RemoveAllChildren.
24 void RemoveWidget(GtkWidget* widget, gpointer container) { 25 void RemoveWidget(GtkWidget* widget, gpointer container) {
25 gtk_container_remove(GTK_CONTAINER(container), widget); 26 gtk_container_remove(GTK_CONTAINER(container), widget);
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 } 412 }
412 413
413 GtkWidget* IndentWidget(GtkWidget* content) { 414 GtkWidget* IndentWidget(GtkWidget* content) {
414 GtkWidget* content_alignment = gtk_alignment_new(0.0, 0.5, 1.0, 1.0); 415 GtkWidget* content_alignment = gtk_alignment_new(0.0, 0.5, 1.0, 1.0);
415 gtk_alignment_set_padding(GTK_ALIGNMENT(content_alignment), 0, 0, 416 gtk_alignment_set_padding(GTK_ALIGNMENT(content_alignment), 0, 0,
416 gtk_util::kGroupIndent, 0); 417 gtk_util::kGroupIndent, 0);
417 gtk_container_add(GTK_CONTAINER(content_alignment), content); 418 gtk_container_add(GTK_CONTAINER(content_alignment), content);
418 return content_alignment; 419 return content_alignment;
419 } 420 }
420 421
421 void InitRendererPrefsFromGtkSettings(RendererPreferences* prefs) { 422 void InitRendererPrefsFromGtkSettings(RendererPreferences* prefs,
423 bool use_gtk_theme) {
422 DCHECK(prefs); 424 DCHECK(prefs);
423 425
424 gint antialias = 0; 426 gint antialias = 0;
425 gint hinting = 0; 427 gint hinting = 0;
426 gchar* hint_style = NULL; 428 gchar* hint_style = NULL;
427 gchar* rgba_style = NULL; 429 gchar* rgba_style = NULL;
428 g_object_get(gtk_settings_get_default(), 430 g_object_get(gtk_settings_get_default(),
429 "gtk-xft-antialias", &antialias, 431 "gtk-xft-antialias", &antialias,
430 "gtk-xft-hinting", &hinting, 432 "gtk-xft-hinting", &hinting,
431 "gtk-xft-hintstyle", &hint_style, 433 "gtk-xft-hintstyle", &hint_style,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 } 470 }
469 471
470 static GtkWidget* fixed = gtk_fixed_new(); 472 static GtkWidget* fixed = gtk_fixed_new();
471 GtkStyle* style = gtk_rc_get_style(fixed); 473 GtkStyle* style = gtk_rc_get_style(fixed);
472 // base[SELECTED] seems more appropriate but in practice it is often too light 474 // base[SELECTED] seems more appropriate but in practice it is often too light
473 // to be easily visible. 475 // to be easily visible.
474 GdkColor color = style->bg[GTK_STATE_SELECTED]; 476 GdkColor color = style->bg[GTK_STATE_SELECTED];
475 prefs->focus_ring_color = 477 prefs->focus_ring_color =
476 SkColorSetRGB(color.red / 257, color.green / 257, color.blue / 257); 478 SkColorSetRGB(color.red / 257, color.green / 257, color.blue / 257);
477 479
480 GdkColor thumb_active_color, thumb_inactive_color, track_color;
481 GtkThemeProvider::GetScrollbarColors(&thumb_active_color,
482 &thumb_inactive_color,
483 &track_color,
484 use_gtk_theme);
485 prefs->thumb_active_color =
486 SkColorSetRGB(thumb_active_color.red / 257,
487 thumb_active_color.green / 257,
488 thumb_active_color.blue / 257);
489 prefs->thumb_inactive_color =
490 SkColorSetRGB(thumb_inactive_color.red / 257,
491 thumb_inactive_color.green / 257,
492 thumb_inactive_color.blue / 257);
493 prefs->track_color =
494 SkColorSetRGB(track_color.red / 257,
495 track_color.green / 257,
496 track_color.blue / 257);
497
478 if (hint_style) 498 if (hint_style)
479 g_free(hint_style); 499 g_free(hint_style);
480 if (rgba_style) 500 if (rgba_style)
481 g_free(rgba_style); 501 g_free(rgba_style);
482 } 502 }
483 503
484 gfx::Point ScreenPoint(GtkWidget* widget) { 504 gfx::Point ScreenPoint(GtkWidget* widget) {
485 int x, y; 505 int x, y;
486 gdk_display_get_pointer(gtk_widget_get_display(widget), NULL, &x, &y, 506 gdk_display_get_pointer(gtk_widget_get_display(widget), NULL, &x, &y,
487 NULL); 507 NULL);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 if (gtk_window_get_modal(GTK_WINDOW(dialog))) { 633 if (gtk_window_get_modal(GTK_WINDOW(dialog))) {
614 // Work around a KDE 3 window manager bug. 634 // Work around a KDE 3 window manager bug.
615 scoped_ptr<base::EnvironmentVariableGetter> env( 635 scoped_ptr<base::EnvironmentVariableGetter> env(
616 base::EnvironmentVariableGetter::Create()); 636 base::EnvironmentVariableGetter::Create());
617 if (base::DESKTOP_ENVIRONMENT_KDE3 == GetDesktopEnvironment(env.get())) 637 if (base::DESKTOP_ENVIRONMENT_KDE3 == GetDesktopEnvironment(env.get()))
618 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), FALSE); 638 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), FALSE);
619 } 639 }
620 } 640 }
621 641
622 } // namespace gtk_util 642 } // namespace gtk_util
OLDNEW
« no previous file with comments | « chrome/common/gtk_util.h ('k') | chrome/common/platform_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698