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

Side by Side Diff: chrome/browser/ui/libgtkui/gtk_util.cc

Issue 2627153003: Gtk3: Fix separator color on Gtk3.20 (Closed)
Patch Set: Add GtkVersionCheck Created 3 years, 11 months 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
« no previous file with comments | « chrome/browser/ui/libgtkui/gtk_util.h ('k') | chrome/browser/ui/libgtkui/native_theme_gtk3.cc » ('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) 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/libgtkui/gtk_util.h" 5 #include "chrome/browser/ui/libgtkui/gtk_util.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 #include <gdk/gdk.h> 8 #include <gdk/gdk.h>
9 #include <gdk/gdkx.h> 9 #include <gdk/gdkx.h>
10 #include <gtk/gtk.h> 10 #include <gtk/gtk.h>
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 aura::Window* GetAuraTransientParent(GtkWidget* dialog) { 194 aura::Window* GetAuraTransientParent(GtkWidget* dialog) {
195 return reinterpret_cast<aura::Window*>( 195 return reinterpret_cast<aura::Window*>(
196 g_object_get_data(G_OBJECT(dialog), kAuraTransientParent)); 196 g_object_get_data(G_OBJECT(dialog), kAuraTransientParent));
197 } 197 }
198 198
199 void ClearAuraTransientParent(GtkWidget* dialog) { 199 void ClearAuraTransientParent(GtkWidget* dialog) {
200 g_object_set_data(G_OBJECT(dialog), kAuraTransientParent, NULL); 200 g_object_set_data(G_OBJECT(dialog), kAuraTransientParent, NULL);
201 } 201 }
202 202
203 #if GTK_MAJOR_VERSION > 2 203 #if GTK_MAJOR_VERSION > 2
204 bool GtkVersionCheck(int major, int minor, int micro) {
205 static int actual_major = gtk_get_major_version();
206 if (actual_major > major)
207 return true;
208 else if (actual_major < major)
209 return false;
210
211 static int actual_minor = gtk_get_minor_version();
212 if (actual_minor > minor)
213 return true;
214 else if (actual_minor < minor)
215 return false;
216
217 static int actual_micro = gtk_get_micro_version();
218 if (actual_micro >= micro)
219 return true;
220 else
221 return false;
222 }
223
204 ScopedStyleContext AppendNode(GtkStyleContext* context, 224 ScopedStyleContext AppendNode(GtkStyleContext* context,
205 const std::string& css_node) { 225 const std::string& css_node) {
206 GtkWidgetPath* path = 226 GtkWidgetPath* path =
207 context ? gtk_widget_path_copy(gtk_style_context_get_path(context)) 227 context ? gtk_widget_path_copy(gtk_style_context_get_path(context))
208 : gtk_widget_path_new(); 228 : gtk_widget_path_new();
209 229
210 enum { 230 enum {
211 CSS_TYPE, 231 CSS_TYPE,
212 CSS_NAME, 232 CSS_NAME,
213 CSS_CLASS, 233 CSS_CLASS,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 break; 270 break;
251 case ':': 271 case ':':
252 part_type = CSS_PSEUDOCLASS; 272 part_type = CSS_PSEUDOCLASS;
253 break; 273 break;
254 default: 274 default:
255 NOTREACHED(); 275 NOTREACHED();
256 } 276 }
257 } else { 277 } else {
258 switch (part_type) { 278 switch (part_type) {
259 case CSS_NAME: { 279 case CSS_NAME: {
260 if (gtk_get_major_version() > 3 || 280 if (GtkVersionCheck(3, 20)) {
261 (gtk_get_major_version() == 3 && gtk_get_minor_version() >= 20)) {
262 static auto* _gtk_widget_path_iter_set_object_name = 281 static auto* _gtk_widget_path_iter_set_object_name =
263 reinterpret_cast<void (*)(GtkWidgetPath*, gint, const char*)>( 282 reinterpret_cast<void (*)(GtkWidgetPath*, gint, const char*)>(
264 dlsym(GetGtk3SharedLibrary(), 283 dlsym(GetGtk3SharedLibrary(),
265 "gtk_widget_path_iter_set_object_name")); 284 "gtk_widget_path_iter_set_object_name"));
266 DCHECK(_gtk_widget_path_iter_set_object_name); 285 DCHECK(_gtk_widget_path_iter_set_object_name);
267 _gtk_widget_path_iter_set_object_name(path, -1, t.token().c_str()); 286 _gtk_widget_path_iter_set_object_name(path, -1, t.token().c_str());
268 } else { 287 } else {
269 gtk_widget_path_iter_add_class(path, -1, t.token().c_str()); 288 gtk_widget_path_iter_add_class(path, -1, t.token().c_str());
270 } 289 }
271 break; 290 break;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 457
439 AddBorders(context); 458 AddBorders(context);
440 PixelSurface surface; 459 PixelSurface surface;
441 RenderBackground(surface.cairo(), context); 460 RenderBackground(surface.cairo(), context);
442 gtk_render_frame(context, surface.cairo(), 0, 0, 1, 1); 461 gtk_render_frame(context, surface.cairo(), 0, 0, 1, 1);
443 return surface.GetPixelValue(); 462 return surface.GetPixelValue();
444 } 463 }
445 #endif 464 #endif
446 465
447 } // namespace libgtkui 466 } // namespace libgtkui
OLDNEW
« no previous file with comments | « chrome/browser/ui/libgtkui/gtk_util.h ('k') | chrome/browser/ui/libgtkui/native_theme_gtk3.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698