示例#1
0
int main (void)
{
  GStylesheet *stylesheet;
  GStyleClass *style_class;
  gchar *property = NULL;

  g_print ("Started...\n");
  g_type_init ();

  style_class = init_style_class_hierarchy ();

  g_print ("> Name: %s\n", g_style_class_get_name (style_class));
  
  g_print ("Load file...\n");

  stylesheet = g_stylesheet_new_from_file ("./hierarchy.css", NULL);

  g_print ("Get property <button> ");
  g_stylesheet_get_property (stylesheet,
                             G_STYLEABLE (button),
                             "color",
                             &property);
  g_print ("%s\n", property);

  g_print ("Get property <notebook> ");
  g_stylesheet_get_property (stylesheet,
                             G_STYLEABLE (notebook),
                             "color",
                             &property);
  g_print ("%s\n", property);

  g_print ("Get property <notebook > tab> ");
  g_stylesheet_get_property (stylesheet,
                             G_STYLEABLE (notebooktab),
                             "color",
                             &property);
  g_print ("%s\n", property);

  g_print ("Get property <notebook > tab:first-child> ");
  g_stylesheet_get_property (stylesheet,
                             G_STYLEABLE (notebooktab_first),
                             "color",
                             &property);
  g_print ("%s\n", property);

  g_print ("Get property <treeview > row> ");
  g_stylesheet_get_property (stylesheet,
                             G_STYLEABLE (treeviewrow),
                             "color",
                             &property);
  g_print ("%s\n", property);

  g_print ("Finished...\n");

  return 0;
}
示例#2
0
void
g_style_class_set_first_child (GStyleClass *node,
                               GStyleClass *first_child)
{
  GStyleClassPrivate *priv;

  g_return_if_fail (node && first_child);

  priv = G_STYLE_CLASS_GET_PRIVATE (node);

  if (g_list_index (priv->children, first_child) >= 0)
    {
      GList *child;

      child = g_list_remove (priv->children, first_child);
      g_free (child);
    }
  else
    {
      GStyleClassPrivate *child_priv;

      child_priv = G_STYLE_CLASS_GET_PRIVATE (first_child);

      child_priv->parent = G_STYLEABLE (node);
    }

  priv->children = g_list_prepend (priv->children, first_child);
}
示例#3
0
static GStyleable*
g_style_class_get_previous_sibling (const GStyleable *node)
{
  GStyleClassPrivate *priv;
  GStyleClassPrivate *parent_priv;
  GStyleable *sibling = NULL;

  priv = G_STYLE_CLASS_GET_PRIVATE (node);

  if (priv->parent)
    {
      GList *children;

      parent_priv = G_STYLE_CLASS_GET_PRIVATE (priv->parent);

      children = parent_priv->children;

      while (children && children->data != node)
        children = children->next;

      sibling = G_STYLEABLE (children->prev->data);
    }

  return sibling;
}
示例#4
0
void
g_style_class_add_child (GStyleClass *node,
                         GStyleClass *child)
{
  GStyleClassPrivate *priv;
  GStyleClassPrivate *child_priv;

  g_return_if_fail (node && child);

  priv = G_STYLE_CLASS_GET_PRIVATE (node);

  if (g_list_index (priv->children, child) >= 0)
    {
      g_warning ("Attempting to add a child to a styleable, "
                 "but the widget is already a child of the styleable. "
                 "Nothing will be added!");
      return;
    }

  priv->children = g_list_append (priv->children, child);

  child_priv = G_STYLE_CLASS_GET_PRIVATE (child);

  /*
  g_print ("> ADD INDEX NODE: %s %s %d\n", priv->name, 
           child_priv->name, g_list_index (priv->children, child));
  */

  child_priv->parent = G_STYLEABLE (node);
}
示例#5
0
static GStyleable*
g_style_class_get_first_child (const GStyleable *node)
{
  GStyleClassPrivate *priv;

  priv = G_STYLE_CLASS_GET_PRIVATE (node);

  if (!priv->children)
    return NULL;

  return G_STYLEABLE (priv->children->data);
}