Beispiel #1
0
static GtkStyleContext *
get_style (GtkStyleContext *parent,
           const char      *selector)
{
  GtkWidgetPath *path;

  if (parent)
    path = gtk_widget_path_copy (gtk_style_context_get_path (parent));
  else
    path = gtk_widget_path_new ();

  append_element (path, selector);

  return create_context_for_path (path, parent);
}
static GtkStyleContext *
gd_tagged_entry_tag_get_context (GdTaggedEntryTag *tag,
                                 GdTaggedEntry    *entry)
{
    GtkWidget *widget = GTK_WIDGET (entry);
    GtkWidgetPath *path;
    gint pos;
    GtkStyleContext *retval;

    retval = gtk_style_context_new ();
    path = gtk_widget_path_copy (gtk_widget_get_path (widget));

    pos = gtk_widget_path_append_type (path, GD_TYPE_TAGGED_ENTRY);
    gtk_widget_path_iter_add_class (path, pos, tag->style);

    gtk_style_context_set_path (retval, path);

    gtk_widget_path_unref (path);

    return retval;
}
Beispiel #3
0
static GtkStyleContext*
CreateCSSNode(const char* aName, GtkStyleContext *aParentStyle)
{
  static auto sGtkWidgetPathIterSetObjectName =
    reinterpret_cast<void (*)(GtkWidgetPath *, gint, const char *)>
    (dlsym(RTLD_DEFAULT, "gtk_widget_path_iter_set_object_name"));

  GtkWidgetPath* path =
    gtk_widget_path_copy(gtk_style_context_get_path(aParentStyle));

  gtk_widget_path_append_type(path, G_TYPE_NONE);

  (*sGtkWidgetPathIterSetObjectName)(path, -1, aName);

  GtkStyleContext *context = gtk_style_context_new();
  gtk_style_context_set_path(context, path);
  gtk_style_context_set_parent(context, aParentStyle);
  gtk_widget_path_unref(path);

  return context;
}
Beispiel #4
0
static GtkStyleContext *
get_style (GtkStyleContext *parent,
           const char      *selector)
{
  GtkWidgetPath *path;
  GtkStyleContext *context;

  if (parent)
    path = gtk_widget_path_copy (gtk_style_context_get_path (parent));
  else
    path = gtk_widget_path_new ();

  append_element (path, selector);

  context = gtk_style_context_new ();
  gtk_style_context_set_path (context, path);
  gtk_style_context_set_parent (context, parent);
  gtk_widget_path_unref (path);

  return context;
}
Beispiel #5
0
static GtkWidgetPath *
gtk_css_path_node_real_create_widget_path (GtkCssNode *node)
{
  GtkCssPathNode *path_node = GTK_CSS_PATH_NODE (node);
  GtkWidgetPath *path;
  guint length;

  if (path_node->path == NULL)
    path = gtk_widget_path_new ();
  else
    path = gtk_widget_path_copy (path_node->path);

  length = gtk_widget_path_length (path);
  if (length > 0)
    {
      gtk_css_node_declaration_add_to_widget_path (gtk_css_node_get_declaration (node),
                                                   path,
                                                   length - 1);
    }

  return path;
}
Beispiel #6
0
static GtkStyleContext *
get_style_with_siblings (GtkStyleContext *parent,
                         const char      *selector,
                         const char     **siblings,
                         gint             position)
{
  GtkWidgetPath *path, *siblings_path;
  guint i;

  if (parent)
    path = gtk_widget_path_copy (gtk_style_context_get_path (parent));
  else
    path = gtk_widget_path_new ();

  siblings_path = gtk_widget_path_new ();
  for (i = 0; siblings[i]; i++)
    append_element (siblings_path, siblings[i]);

  gtk_widget_path_append_with_siblings (path, siblings_path, position);
  gtk_widget_path_unref (siblings_path);

  return create_context_for_path (path, parent);
}
Beispiel #7
0
static void
gtk_numerable_icon_update_properties_from_style (GtkNumerableIcon *self)
{
  GtkStyleContext *style = self->priv->style;
  GtkWidgetPath *path, *saved;
  cairo_pattern_t *pattern = NULL;
  GdkRGBA background, foreground;
  PangoFontDescription *font = NULL;

  /* save an unmodified copy of the original widget path, in order
   * to restore it later */
  path = gtk_widget_path_copy (gtk_style_context_get_path (style));
  saved = gtk_widget_path_copy (path);

  if (!gtk_widget_path_is_type (path, GTK_TYPE_NUMERABLE_ICON))
    {
      /* append our GType to the style context to fetch appropriate colors */
      gtk_widget_path_append_type (path, GTK_TYPE_NUMERABLE_ICON);
      gtk_style_context_set_path (style, path);
    }

  gtk_style_context_get_background_color (style, gtk_style_context_get_state (style),
                                          &background);
  gtk_style_context_get_color (style, gtk_style_context_get_state (style),
                               &foreground);

  if (self->priv->background != NULL)
    gdk_rgba_free (self->priv->background);

  self->priv->background = gdk_rgba_copy (&background);

  if (self->priv->foreground != NULL)
    gdk_rgba_free (self->priv->foreground);

  self->priv->foreground = gdk_rgba_copy (&foreground);

  gtk_style_context_get (style, gtk_style_context_get_state (style),
                         GTK_STYLE_PROPERTY_BACKGROUND_IMAGE, &pattern,
                         NULL);

  if (pattern != NULL)
    {
      if (self->priv->background_image != NULL)
        cairo_pattern_destroy (self->priv->background_image);

      self->priv->background_image = pattern;
    }

  gtk_style_context_get (style, gtk_style_context_get_state (style),
                         GTK_STYLE_PROPERTY_FONT, &font,
                         NULL);

  if (font != NULL)
    {
      if (self->priv->font != NULL)
        pango_font_description_free (self->priv->font);

      self->priv->font = font;
    }

  gtk_numerable_icon_ensure_emblem (self);

  /* restore original widget path */
  gtk_style_context_set_path (style, saved);

  gtk_widget_path_free (path);
  gtk_widget_path_free (saved);
}