static VALUE rg_iter_set_name(VALUE self, VALUE pos, VALUE name) { gtk_widget_path_iter_set_name(_SELF(self), NUM2INT(pos), RVAL2CSTR(name)); return self; }
void gtk_css_node_declaration_add_to_widget_path (const GtkCssNodeDeclaration *decl, GtkWidgetPath *path, guint pos) { GQuark *classes; GtkRegion *regions; guint i; /* Set name and id */ gtk_widget_path_iter_set_object_name (path, pos, decl->name); if (decl->id) gtk_widget_path_iter_set_name (path, pos, decl->id); /* Set widget regions */ regions = get_regions (decl); for (i = 0; i < decl->n_regions; i++) { G_GNUC_BEGIN_IGNORE_DEPRECATIONS gtk_widget_path_iter_add_region (path, pos, g_quark_to_string (regions[i].class_quark), regions[i].flags); G_GNUC_END_IGNORE_DEPRECATIONS } /* Set widget classes */ classes = get_classes (decl); for (i = 0; i < decl->n_classes; i++) { gtk_widget_path_iter_add_qclass (path, pos, classes[i]); } /* Set widget state */ gtk_widget_path_iter_set_state (path, pos, decl->state); }
static GtkStyleContext* TooltipContext(GtkWidgetPath* path) { gtk_widget_path_append_type(path, GTK_TYPE_WINDOW); #if GTK_CHECK_VERSION(3,20,0) if (gtk_check_version(3,20,0) == NULL) gtk_widget_path_iter_set_object_name(path, -1, "tooltip"); #endif gtk_widget_path_iter_add_class(path, -1, "background"); gtk_widget_path_iter_add_class(path, -1, "tooltip"); gtk_widget_path_iter_set_name(path, -1, "gtk-tooltip"); GtkStyleContext* sc = gtk_style_context_new(); gtk_style_context_set_path(sc, path); return sc; }
PanelStyle::PanelStyle() : d(new PanelStylePrivate) { d->q = this; d->m_styleContext.reset(gtk_style_context_new()); GtkWidgetPath* widgetPath = gtk_widget_path_new (); gtk_widget_path_append_type(widgetPath, GTK_TYPE_WINDOW); gtk_widget_path_iter_set_name(widgetPath, -1 , "UnityPanelWidget"); gtk_style_context_set_path(d->m_styleContext.data(), widgetPath); gtk_style_context_add_class(d->m_styleContext.data(), "gnome-panel-menu-bar"); gtk_style_context_add_class(d->m_styleContext.data(), "unity-panel"); gtk_widget_path_free (widgetPath); d->m_gConnector.connect(gtk_settings_get_default(), "notify::gtk-theme-name", G_CALLBACK(PanelStylePrivate::onThemeChanged), d); d->updateTheme(); }
static void matekbd_indicator_config_load_colors (MatekbdIndicatorConfig * ind_config) { ind_config->foreground_color = g_settings_get_string (ind_config->settings, MATEKBD_INDICATOR_CONFIG_KEY_FOREGROUND_COLOR); if (ind_config->foreground_color == NULL || ind_config->foreground_color[0] == '\0') { GtkWidgetPath *widget_path = gtk_widget_path_new (); GtkStyleContext *context = gtk_style_context_new (); GdkRGBA fg_color; gtk_widget_path_append_type (widget_path, GTK_TYPE_WINDOW); gtk_widget_path_iter_set_name (widget_path, -1 , "PanelWidget"); gtk_style_context_set_path (context, widget_path); gtk_style_context_set_screen (context, gdk_screen_get_default ()); gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL); gtk_style_context_add_class (context, GTK_STYLE_CLASS_DEFAULT); gtk_style_context_add_class (context, "gnome-panel-menu-bar"); gtk_style_context_add_class (context, "mate-panel-menu-bar"); gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &fg_color); ind_config->foreground_color = g_strdup_printf ("%g %g %g", fg_color.red, fg_color.green, fg_color.blue); g_object_unref (G_OBJECT (context)); gtk_widget_path_unref (widget_path); } ind_config->background_color = g_settings_get_string (ind_config->settings, MATEKBD_INDICATOR_CONFIG_KEY_BACKGROUND_COLOR); }
/* * static applet config functions */ static void matekbd_indicator_config_load_font (MatekbdIndicatorConfig * ind_config) { ind_config->font_family = g_settings_get_string (ind_config->settings, MATEKBD_INDICATOR_CONFIG_KEY_FONT_FAMILY); if (ind_config->font_family == NULL || ind_config->font_family[0] == '\0') { PangoFontDescription *fd = NULL; GtkWidgetPath *widget_path = gtk_widget_path_new (); GtkStyleContext *context = gtk_style_context_new (); gtk_widget_path_append_type (widget_path, GTK_TYPE_WINDOW); gtk_widget_path_iter_set_name (widget_path, -1 , "PanelWidget"); gtk_style_context_set_path (context, widget_path); gtk_style_context_set_screen (context, gdk_screen_get_default ()); gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL); gtk_style_context_add_class (context, GTK_STYLE_CLASS_DEFAULT); gtk_style_context_add_class (context, "gnome-panel-menu-bar"); gtk_style_context_add_class (context, "mate-panel-menu-bar"); gtk_style_context_get (context, GTK_STATE_FLAG_NORMAL, GTK_STYLE_PROPERTY_FONT, &fd, NULL); if (fd != NULL) { ind_config->font_family = g_strdup (pango_font_description_to_string(fd)); } g_object_unref (G_OBJECT (context)); gtk_widget_path_unref (widget_path); } xkl_debug (150, "font: [%s]\n", ind_config->font_family); }
static void append_element (GtkWidgetPath *path, const char *selector) { static const struct { const char *name; GtkStateFlags state_flag; } pseudo_classes[] = { { "active", GTK_STATE_FLAG_ACTIVE }, { "hover", GTK_STATE_FLAG_PRELIGHT }, { "selected", GTK_STATE_FLAG_SELECTED }, { "disabled", GTK_STATE_FLAG_INSENSITIVE }, { "indeterminate", GTK_STATE_FLAG_INCONSISTENT }, { "focus", GTK_STATE_FLAG_FOCUSED }, { "backdrop", GTK_STATE_FLAG_BACKDROP }, { "dir(ltr)", GTK_STATE_FLAG_DIR_LTR }, { "dir(rtl)", GTK_STATE_FLAG_DIR_RTL }, { "link", GTK_STATE_FLAG_LINK }, { "visited", GTK_STATE_FLAG_VISITED }, { "checked", GTK_STATE_FLAG_CHECKED }, { "drop(active)", GTK_STATE_FLAG_DROP_ACTIVE } }; const char *next; char *name; char type; guint i; next = strpbrk (selector, "#.:"); if (next == NULL) next = selector + strlen (selector); name = g_strndup (selector, next - selector); if (g_ascii_isupper (selector[0])) { GType gtype; gtype = g_type_from_name (name); if (gtype == G_TYPE_INVALID) { g_critical ("Unknown type name `%s'", name); g_free (name); return; } gtk_widget_path_append_type (path, gtype); } else { /* Omit type, we're using name */ gtk_widget_path_append_type (path, G_TYPE_NONE); gtk_widget_path_iter_set_object_name (path, -1, name); } g_free (name); while (*next != '\0') { type = *next; selector = next + 1; next = strpbrk (selector, "#.:"); if (next == NULL) next = selector + strlen (selector); name = g_strndup (selector, next - selector); switch (type) { case '#': gtk_widget_path_iter_set_name (path, -1, name); break; case '.': gtk_widget_path_iter_add_class (path, -1, name); break; case ':': for (i = 0; i < G_N_ELEMENTS (pseudo_classes); i++) { if (g_str_equal (pseudo_classes[i].name, name)) { gtk_widget_path_iter_set_state (path, -1, gtk_widget_path_iter_get_state (path, -1) | pseudo_classes[i].state_flag); break; } } if (i == G_N_ELEMENTS (pseudo_classes)) g_critical ("Unknown pseudo-class :%s", name); break; default: g_assert_not_reached (); break; } g_free (name); } }