Beispiel #1
0
/**
 * gtk_cell_layout_get_cells:
 * @cell_layout: a #GtkCellLayout
 *
 * Returns the cell renderers which have been added to @cell_layout.
 *
 * Returns: (element-type GtkCellRenderer) (transfer container):
 *     a list of cell renderers. The list, but not the renderers has
 *     been newly allocated and should be freed with g_list_free()
 *     when no longer needed.
 */
GList *
gtk_cell_layout_get_cells (GtkCellLayout *cell_layout)
{
  g_return_val_if_fail (GTK_IS_CELL_LAYOUT (cell_layout), NULL);

  return GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->get_cells (cell_layout);
}
Beispiel #2
0
static gboolean
    glade_gtk_sheet_layout_move_child (GladeBaseEditor *editor, 
                                       GladeWidget *gparent,
                                       GladeWidget *gchild,
                                       gpointer data)
{   
    GObject *parent = glade_widget_get_object (gparent);
    GObject *child  = glade_widget_get_object (gchild);
    GList list   = { 0,};

#ifdef GTK_SHEET_DEBUG
    g_debug("glade_gtk_sheet_layout_move_child: called");
#endif

    if (GTK_IS_SHEET(parent) && !GTK_IS_SHEET_COLUMN (child)) return FALSE;
    if (GTK_IS_CELL_LAYOUT(parent) && !GTK_IS_CELL_RENDERER (child)) return FALSE;
    if (GTK_IS_CELL_RENDERER(parent)) return FALSE;

    if (gparent != glade_widget_get_parent (gchild))
    {
        list.data = gchild;
        glade_command_dnd(&list, gparent, NULL);
    }

    return TRUE;
}
Beispiel #3
0
/**
 * gtk_cell_layout_clear:
 * @cell_layout: a #GtkCellLayout
 *
 * Unsets all the mappings on all renderers on @cell_layout and
 * removes all renderers from @cell_layout.
 */
void
gtk_cell_layout_clear (GtkCellLayout *cell_layout)
{
  g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));

  GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->clear (cell_layout);
}
Beispiel #4
0
/**
 * gtk_cell_layout_clear_attributes:
 * @cell_layout: a #GtkCellLayout
 * @cell: a #GtkCellRenderer to clear the attribute mapping on
 *
 * Clears all existing attributes previously set with
 * gtk_cell_layout_set_attributes().
 */
void
gtk_cell_layout_clear_attributes (GtkCellLayout   *cell_layout,
                                  GtkCellRenderer *cell)
{
  g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
  g_return_if_fail (GTK_IS_CELL_RENDERER (cell));

  GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->clear_attributes (cell_layout, cell);
}
Beispiel #5
0
/**
 * gtk_cell_layout_reorder:
 * @cell_layout: a #GtkCellLayout
 * @cell: a #GtkCellRenderer to reorder
 * @position: new position to insert @cell at
 *
 * Re-inserts @cell at @position.
 *
 * Note that @cell has already to be packed into @cell_layout
 * for this to function properly.
 */
void
gtk_cell_layout_reorder (GtkCellLayout   *cell_layout,
                         GtkCellRenderer *cell,
                         gint             position)
{
  g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
  g_return_if_fail (GTK_IS_CELL_RENDERER (cell));

  GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->reorder (cell_layout, cell, position);
}
Beispiel #6
0
/**
 * gtk_cell_layout_pack_end:
 * @cell_layout: a #GtkCellLayout
 * @cell: a #GtkCellRenderer
 * @expand: %TRUE if @cell is to be given extra space allocated to @cell_layout
 *
 * Adds the @cell to the end of @cell_layout. If @expand is %FALSE, then the
 * @cell is allocated no more space than it needs. Any unused space is
 * divided evenly between cells for which @expand is %TRUE.
 *
 * Note that reusing the same cell renderer is not supported.
 */
void
gtk_cell_layout_pack_end (GtkCellLayout   *cell_layout,
                          GtkCellRenderer *cell,
                          gboolean         expand)
{
  g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
  g_return_if_fail (GTK_IS_CELL_RENDERER (cell));

  GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->pack_end (cell_layout, cell, expand);
}
Beispiel #7
0
void
_gtk_cell_layout_buildable_add_child (GtkBuildable      *buildable,
				      GtkBuilder        *builder,
				      GObject           *child,
				      const gchar       *type)
{
  g_return_if_fail (GTK_IS_CELL_LAYOUT (buildable));
  g_return_if_fail (GTK_IS_CELL_RENDERER (child));

  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (buildable), GTK_CELL_RENDERER (child), FALSE);
}
Beispiel #8
0
/**
 * gtk_cell_layout_get_area:
 * @cell_layout: a #GtkCellLayout
 *
 * Returns the underlying #GtkCellArea which might be @cell_layout
 * if called on a #GtkCellArea or might be %NULL if no #GtkCellArea
 * is used by @cell_layout.
 *
 * Returns: (transfer none) (nullable): the cell area used by @cell_layout,
 * or %NULL in case no cell area is used.
 */
GtkCellArea *
gtk_cell_layout_get_area (GtkCellLayout *cell_layout)
{
  GtkCellLayoutIface *iface;

  g_return_val_if_fail (GTK_IS_CELL_LAYOUT (cell_layout), NULL);

  iface = GTK_CELL_LAYOUT_GET_IFACE (cell_layout);  
  if (iface->get_area)
    return iface->get_area (cell_layout);

  return NULL;
}
Beispiel #9
0
/**
 * gtk_cell_layout_set_cell_data_func:
 * @cell_layout: a #GtkCellLayout
 * @cell: a #GtkCellRenderer
 * @func: (allow-none): the #GtkCellLayoutDataFunc to use, or %NULL
 * @func_data: (closure): user data for @func
 * @destroy: destroy notify for @func_data
 *
 * Sets the #GtkCellLayoutDataFunc to use for @cell_layout.
 *
 * This function is used instead of the standard attributes mapping
 * for setting the column value, and should set the value of @cell_layout’s
 * cell renderer(s) as appropriate.
 *
 * @func may be %NULL to remove a previously set function.
 */
void
gtk_cell_layout_set_cell_data_func (GtkCellLayout         *cell_layout,
                                    GtkCellRenderer       *cell,
                                    GtkCellLayoutDataFunc  func,
                                    gpointer               func_data,
                                    GDestroyNotify         destroy)
{
  g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
  g_return_if_fail (GTK_IS_CELL_RENDERER (cell));

  GTK_CELL_LAYOUT_GET_IFACE 
    (cell_layout)->set_cell_data_func (cell_layout, cell, func, func_data, destroy);
}
Beispiel #10
0
/**
 * gtk_cell_layout_add_attribute:
 * @cell_layout: a #GtkCellLayout
 * @cell: a #GtkCellRenderer
 * @attribute: an attribute on the renderer
 * @column: the column position on the model to get the attribute from
 *
 * Adds an attribute mapping to the list in @cell_layout.
 *
 * The @column is the column of the model to get a value from, and the
 * @attribute is the parameter on @cell to be set from the value. So for
 * example if column 2 of the model contains strings, you could have the
 * “text” attribute of a #GtkCellRendererText get its values from column 2.
 */
void
gtk_cell_layout_add_attribute (GtkCellLayout   *cell_layout,
                               GtkCellRenderer *cell,
                               const gchar     *attribute,
                               gint             column)
{
  g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
  g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
  g_return_if_fail (attribute != NULL);
  g_return_if_fail (column >= 0);

  GTK_CELL_LAYOUT_GET_IFACE (cell_layout)->add_attribute (cell_layout, cell, attribute, column);
}
Beispiel #11
0
/**
 * gtk_cell_layout_set_attributes:
 * @cell_layout: a #GtkCellLayout
 * @cell: a #GtkCellRenderer
 * @...: a %NULL-terminated list of attributes
 *
 * Sets the attributes in list as the attributes of @cell_layout.
 *
 * The attributes should be in attribute/column order, as in
 * gtk_cell_layout_add_attribute(). All existing attributes are
 * removed, and replaced with the new attributes.
 */
void
gtk_cell_layout_set_attributes (GtkCellLayout   *cell_layout,
                                GtkCellRenderer *cell,
                                ...)
{
  va_list args;

  g_return_if_fail (GTK_IS_CELL_LAYOUT (cell_layout));
  g_return_if_fail (GTK_IS_CELL_RENDERER (cell));

  va_start (args, cell);
  gtk_cell_layout_set_attributesv (cell_layout, cell, args);
  va_end (args);
}
Beispiel #12
0
static void
attribute_mapping_changed (GtkComboBox            *combo,
                           GtkInspectorPropEditor *editor)
{
  gint col;
  gpointer layout;
  GtkCellRenderer *cell;
  GtkCellArea *area;

  col = gtk_combo_box_get_active (combo) - 1;
  layout = g_object_get_data (editor->priv->object, "gtk-inspector-cell-layout");
  if (GTK_IS_CELL_LAYOUT (layout))
    {
      cell = GTK_CELL_RENDERER (editor->priv->object);
      area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (layout));
      gtk_cell_area_attribute_disconnect (area, cell, editor->priv->name);
      if (col != -1)
        gtk_cell_area_attribute_connect (area, cell, editor->priv->name, col);
      gtk_widget_set_sensitive (editor->priv->editor, col == -1);
      notify_property (editor->priv->object, find_property (editor));
      gtk_widget_queue_draw (gtk_cell_layout_get_widget (GTK_CELL_LAYOUT (layout)));
    }
}
Beispiel #13
0
static GtkWidget *
attribute_editor (GObject                *object,
                  GParamSpec             *spec,
                  GtkInspectorPropEditor *editor)
{
  gpointer layout;
  GtkCellArea *area;
  GtkTreeModel *model = NULL;
  gint col = -1;
  GtkWidget *label;
  GtkWidget *button;
  GtkWidget *vbox;
  GtkWidget *box;
  GtkWidget *combo;
  gchar *text;
  gint i;
  gboolean sensitive;
  GtkCellRenderer *renderer;
  GtkListStore *store;
  GtkTreeIter iter;

  layout = g_object_get_data (object, "gtk-inspector-cell-layout");
  if (GTK_IS_CELL_LAYOUT (layout))
    {
      area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (layout));
      col = gtk_cell_area_attribute_get_column (area,
                                                GTK_CELL_RENDERER (object), 
                                                editor->priv->name);
      model = gtk_cell_layout_get_model (GTK_CELL_LAYOUT (layout));
    }

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);

  label = gtk_label_new (_("Attribute mapping"));
  gtk_widget_set_margin_top (label, 10);
  gtk_container_add (GTK_CONTAINER (vbox), label);

  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
  gtk_container_add (GTK_CONTAINER (box), gtk_label_new (_("Model:")));
  text = g_strdup_printf (_("%p (%s)"), model, g_type_name (G_TYPE_FROM_INSTANCE (model)));
  gtk_container_add (GTK_CONTAINER (box), gtk_label_new (text));
  g_free (text);
  button = gtk_button_new_with_label (_("Properties"));
  g_object_set_data (G_OBJECT (button), "model", model);
  g_signal_connect (button, "clicked", G_CALLBACK (model_properties), editor);
  gtk_container_add (GTK_CONTAINER (box), button);
  gtk_container_add (GTK_CONTAINER (vbox), box);

  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
  gtk_container_add (GTK_CONTAINER (box), gtk_label_new (_("Column:")));
  store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_BOOLEAN);
  combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
  renderer = gtk_cell_renderer_text_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,
                                  "text", 0,
                                  "sensitive", 1,
                                  NULL);
  gtk_list_store_append (store, &iter);
  gtk_list_store_set (store, &iter, 0, _("None"), 1, TRUE, -1);
  for (i = 0; i < gtk_tree_model_get_n_columns (model); i++)
    {
      text = g_strdup_printf ("%d", i);
      sensitive = g_value_type_transformable (gtk_tree_model_get_column_type (model, i),
                                              spec->value_type);
      gtk_list_store_append (store, &iter);
      gtk_list_store_set (store, &iter, 0, text, 1, sensitive, -1);
      g_free (text);
    }
  gtk_combo_box_set_active (GTK_COMBO_BOX (combo), col + 1);
  attribute_mapping_changed (GTK_COMBO_BOX (combo), editor);
  g_signal_connect (combo, "changed",
                    G_CALLBACK (attribute_mapping_changed), editor);
  gtk_container_add (GTK_CONTAINER (box), combo);
  gtk_container_add (GTK_CONTAINER (vbox), box);
  gtk_widget_show_all (vbox);

  return vbox;
}