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

Unified Diff: chrome/browser/ui/libgtkui/gtk_util.cc

Issue 2609943005: Gtk3: Add support for Gtk3.20 themes (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/libgtkui/gtk_ui.cc ('k') | chrome/browser/ui/libgtkui/native_theme_gtk3.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/libgtkui/gtk_util.cc
diff --git a/chrome/browser/ui/libgtkui/gtk_util.cc b/chrome/browser/ui/libgtkui/gtk_util.cc
index 53a370f57dff1bdf89a055d92481be8ac45bbc52..4dbd519cf369f6213d52de31902e8970b5445187 100644
--- a/chrome/browser/ui/libgtkui/gtk_util.cc
+++ b/chrome/browser/ui/libgtkui/gtk_util.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/libgtkui/gtk_util.h"
+#include <dlfcn.h>
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
@@ -52,6 +53,14 @@ void CommonInitFromCommandLine(const base::CommandLine& command_line,
}
}
+#if GTK_MAJOR_VERSION == 3
+void* GetGtk3SharedLibrary() {
+ static void* gtk3lib = dlopen("libgtk-3.so.0", RTLD_LAZY);
+ DCHECK(gtk3lib);
+ return gtk3lib;
+}
+#endif
+
} // namespace
namespace libgtkui {
@@ -199,8 +208,8 @@ ScopedStyleContext AppendNode(GtkStyleContext* context,
: gtk_widget_path_new();
enum {
- // TODO(thomasanderson): Add CSS_NAME here to handle the Gtk3.20 case.
CSS_TYPE,
+ CSS_NAME,
CSS_CLASS,
CSS_PSEUDOCLASS,
} part_type = CSS_TYPE;
@@ -224,7 +233,7 @@ ScopedStyleContext AppendNode(GtkStyleContext* context,
};
GtkStateFlags state =
context ? gtk_style_context_get_state(context) : GTK_STATE_FLAG_NORMAL;
- base::StringTokenizer t(css_node, ".:");
+ base::StringTokenizer t(css_node, ".:#");
t.set_options(base::StringTokenizer::RETURN_DELIMS);
while (t.GetNext()) {
if (t.token_is_delim()) {
@@ -233,6 +242,9 @@ ScopedStyleContext AppendNode(GtkStyleContext* context,
gtk_widget_path_append_type(path, G_TYPE_NONE);
}
switch (*t.token_begin()) {
+ case '#':
+ part_type = CSS_NAME;
+ break;
case '.':
part_type = CSS_CLASS;
break;
@@ -244,6 +256,20 @@ ScopedStyleContext AppendNode(GtkStyleContext* context,
}
} else {
switch (part_type) {
+ case CSS_NAME: {
+ static auto* _gtk_widget_path_iter_set_object_name =
+ reinterpret_cast<void (*)(GtkWidgetPath*, gint, const char*)>(
+ dlsym(GetGtk3SharedLibrary(),
+ "gtk_widget_path_iter_set_object_name"));
Elliot Glaysher 2017/01/05 18:14:45 You probably want this inside the version checked
Tom (Use chromium acct) 2017/01/05 20:27:05 Done.
+ if (gtk_get_major_version() > 3 ||
+ (gtk_get_major_version() == 3 && gtk_get_minor_version() >= 20)) {
+ DCHECK(_gtk_widget_path_iter_set_object_name);
+ _gtk_widget_path_iter_set_object_name(path, -1, t.token().c_str());
+ } else {
+ gtk_widget_path_iter_add_class(path, -1, t.token().c_str());
+ }
+ break;
+ }
case CSS_TYPE: {
GType type = g_type_from_name(t.token().c_str());
DCHECK(type);
« no previous file with comments | « chrome/browser/ui/libgtkui/gtk_ui.cc ('k') | chrome/browser/ui/libgtkui/native_theme_gtk3.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698