From 016a506eeeebf3a8b00058e7979b49c1f3200782 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Thu, 14 Jun 2018 10:41:27 -0700 Subject: [PATCH] add GtkWidgetPath wrapper class --- src/gtk/settings.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/gtk/settings.cpp b/src/gtk/settings.cpp index d5859dc069..2c8132cbbe 100644 --- a/src/gtk/settings.cpp +++ b/src/gtk/settings.cpp @@ -193,6 +193,18 @@ static void notify_gtk_font_name(GObject*, GParamSpec*, void*) // the same hierarchy in it. So the best way to get style information seems // to be creating the widget paths and context hierarchy directly. +//----------------------------------------------------------------------------- + +class wxGtkWidgetPath +{ +public: + wxGtkWidgetPath() : m_path(gtk_widget_path_new()) { } + ~wxGtkWidgetPath() { gtk_widget_path_free(m_path); } + operator GtkWidgetPath*() { return m_path; } +private: + GtkWidgetPath* const m_path; +}; + //----------------------------------------------------------------------------- // wxGtkStyleContext //----------------------------------------------------------------------------- @@ -241,7 +253,7 @@ wxGtkStyleContext& wxGtkStyleContext::Add(const char* objectName) wxGtkStyleContext::~wxGtkStyleContext() { - gtk_widget_path_unref(m_path); + gtk_widget_path_free(m_path); if (m_context == NULL) return; if (gtk_check_version(3,16,0) == NULL || gtk_check_version(3,4,0)) @@ -320,7 +332,7 @@ wxGtkStyleContext& wxGtkStyleContext::AddTreeviewHeaderButton(int pos) AddTreeview().Add("header"); GtkStyleContext* sc = gtk_style_context_new(); - GtkWidgetPath* siblings = gtk_widget_path_new(); + wxGtkWidgetPath siblings; gtk_widget_path_append_type(siblings, GTK_TYPE_BUTTON); gtk_widget_path_iter_set_object_name(siblings, -1, "button"); gtk_widget_path_append_type(siblings, GTK_TYPE_BUTTON); @@ -329,7 +341,6 @@ wxGtkStyleContext& wxGtkStyleContext::AddTreeviewHeaderButton(int pos) gtk_widget_path_iter_set_object_name(siblings, -1, "button"); gtk_widget_path_append_with_siblings(m_path, siblings, pos); - gtk_widget_path_unref(siblings); gtk_style_context_set_path(sc, m_path); gtk_style_context_set_parent(sc, m_context);