Example #1
0
void
hybrid_chat_window_set_icon(HybridChatWindow *window, GdkPixbuf *pixbuf)
{
    GtkTreeModel *model;
    GtkListStore *store;

    g_return_if_fail(window != NULL);

    if (!IS_USER_DEFINED_CHAT(window)) {
        return;
    }

    g_object_ref(pixbuf);
    window->icon = pixbuf;

    model = gtk_cell_view_get_model(GTK_CELL_VIEW(window->tablabel));
    store = GTK_LIST_STORE(model);

    gtk_list_store_set(store, &window->tabiter,
            TAB_STATUS_ICON_COLUMN, pixbuf,
            -1);

    model = gtk_cell_view_get_model(GTK_CELL_VIEW(window->tiplabel));
    store = GTK_LIST_STORE(model);

    gtk_list_store_set(store, &window->tipiter,
            BUDDY_ICON_COLUMN, pixbuf, -1);
}
Example #2
0
static void
gtk_cell_view_cell_layout_reorder (GtkCellLayout   *layout,
                                   GtkCellRenderer *cell,
                                   gint             position)
{
  GList *link;
  GtkCellViewCellInfo *info;
  GtkCellView *cellview = GTK_CELL_VIEW (layout);

  g_return_if_fail (GTK_IS_CELL_VIEW (cellview));
  g_return_if_fail (GTK_IS_CELL_RENDERER (cell));

  info = gtk_cell_view_get_cell_info (cellview, cell);

  g_return_if_fail (info != NULL);
  g_return_if_fail (position >= 0);

  link = g_list_find (cellview->priv->cell_list, info);

  g_return_if_fail (link != NULL);

  cellview->priv->cell_list = g_list_remove_link (cellview->priv->cell_list,
                                                  link);
  cellview->priv->cell_list = g_list_insert (cellview->priv->cell_list,
                                             info, position);

  gtk_widget_queue_draw (GTK_WIDGET (cellview));
}
Example #3
0
static void
gtk_cell_view_cell_layout_clear_attributes (GtkCellLayout   *layout,
                                            GtkCellRenderer *renderer)
{
  GtkCellViewCellInfo *info;
  GtkCellView *cellview = GTK_CELL_VIEW (layout);
  GSList *list;

  g_return_if_fail (GTK_IS_CELL_VIEW (cellview));
  g_return_if_fail (GTK_IS_CELL_RENDERER (renderer));

  info = gtk_cell_view_get_cell_info (cellview, renderer);
  if (info != NULL)
    {
      list = info->attributes;
      while (list && list->next)
	{
	  g_free (list->data);
	  list = list->next->next;
	}
      
      g_slist_free (info->attributes);
      info->attributes = NULL;
    }
}
Example #4
0
static void
gtk_cell_view_cell_layout_set_cell_data_func (GtkCellLayout         *layout,
                                              GtkCellRenderer       *cell,
                                              GtkCellLayoutDataFunc  func,
                                              gpointer               func_data,
                                              GDestroyNotify         destroy)
{
  GtkCellView *cellview = GTK_CELL_VIEW (layout);
  GtkCellViewCellInfo *info;

  g_return_if_fail (GTK_IS_CELL_VIEW (cellview));

  info = gtk_cell_view_get_cell_info (cellview, cell);
  g_return_if_fail (info != NULL);

  if (info->destroy)
    {
      GDestroyNotify d = info->destroy;

      info->destroy = NULL;
      d (info->func_data);
    }

  info->func = func;
  info->func_data = func_data;
  info->destroy = destroy;
}
Example #5
0
static GObject *
gtk_cell_view_constructor (GType                  type,
			   guint                  n_construct_properties,
			   GObjectConstructParam *construct_properties)
{
  GObject            *object;
  GtkCellView        *view;
  GtkCellViewPrivate *priv;

  object = G_OBJECT_CLASS (gtk_cell_view_parent_class)->constructor
    (type, n_construct_properties, construct_properties);

  view = GTK_CELL_VIEW (object);
  priv = view->priv;

  if (!priv->area)
    {
      priv->area = gtk_cell_area_box_new ();
      g_object_ref_sink (priv->area);
    }

  if (!priv->context)
    priv->context = gtk_cell_area_create_context (priv->area);

  priv->size_changed_id =
    g_signal_connect (priv->context, "notify",
		      G_CALLBACK (context_size_changed_cb), view);

  return object;
}
Example #6
0
static void
gtk_cell_view_size_allocate (GtkWidget     *widget,
                             GtkAllocation *allocation)
{
  GtkCellView        *cellview = GTK_CELL_VIEW (widget);
  GtkCellViewPrivate *priv = cellview->priv;
  gint                alloc_width, alloc_height;

  gtk_widget_set_allocation (widget, allocation);

  gtk_cell_area_context_get_allocation (priv->context, &alloc_width, &alloc_height);

  /* The first cell view in context is responsible for allocating the context at allocate time 
   * (or the cellview has its own context and is not grouped with any other cell views) 
   *
   * If the cellview is in "fit model" mode, we assume its not in context and needs to
   * allocate every time.
   */
  if (priv->fit_model)
    gtk_cell_area_context_allocate (priv->context, allocation->width, allocation->height);
  else if (alloc_width != allocation->width && priv->orientation == GTK_ORIENTATION_HORIZONTAL)
    gtk_cell_area_context_allocate (priv->context, allocation->width, -1);
  else if (alloc_height != allocation->height && priv->orientation == GTK_ORIENTATION_VERTICAL)
    gtk_cell_area_context_allocate (priv->context, -1, allocation->height);
}
Example #7
0
static void       
gtk_cell_view_get_preferred_height (GtkWidget *widget,
                                    gint      *minimum_size,
                                    gint      *natural_size)
{
  GtkCellView        *cellview = GTK_CELL_VIEW (widget);
  GtkCellViewPrivate *priv = cellview->priv;

  g_signal_handler_block (priv->context, priv->size_changed_id);

  if (priv->fit_model)
    {
      gint min = 0, nat = 0;
      gtk_cell_view_request_model (cellview, NULL, GTK_ORIENTATION_VERTICAL, -1, &min, &nat);
    }
  else
    {
      if (cellview->priv->displayed_row)
	gtk_cell_view_set_cell_data (cellview);
      
      gtk_cell_area_get_preferred_height (priv->area, priv->context, widget, NULL, NULL);
    }

  gtk_cell_area_context_get_preferred_height (priv->context, minimum_size, natural_size);

  g_signal_handler_unblock (priv->context, priv->size_changed_id);
}
Example #8
0
static void       
gtk_cell_view_get_preferred_height_for_width (GtkWidget *widget,
                                              gint       for_size,
                                              gint      *minimum_size,
                                              gint      *natural_size)
{
  GtkCellView        *cellview = GTK_CELL_VIEW (widget);
  GtkCellViewPrivate *priv = cellview->priv;

  if (priv->fit_model)
    {
      gint min = 0, nat = 0;
      gtk_cell_view_request_model (cellview, NULL, GTK_ORIENTATION_VERTICAL, for_size, &min, &nat);

      *minimum_size = min;
      *natural_size = nat;
    }
  else
    {
      if (cellview->priv->displayed_row)
	gtk_cell_view_set_cell_data (cellview);

      gtk_cell_area_get_preferred_height_for_width (priv->area, priv->context, widget, 
						    for_size, minimum_size, natural_size);
    }
}
Example #9
0
static void
gtk_cell_view_set_property (GObject      *object,
                            guint         param_id,
                            const GValue *value,
                            GParamSpec   *pspec)
{
  GtkCellView *view = GTK_CELL_VIEW (object);

  switch (param_id)
    {
      case PROP_BACKGROUND:
        {
          GdkColor color;

          if (!g_value_get_string (value))
            gtk_cell_view_set_background_color (view, NULL);
          else if (gdk_color_parse (g_value_get_string (value), &color))
            gtk_cell_view_set_background_color (view, &color);
          else
            g_warning ("Don't know color `%s'", g_value_get_string (value));

          g_object_notify (object, "background_gdk");
        }
        break;
      case PROP_BACKGROUND_GDK:
        gtk_cell_view_set_background_color (view, g_value_get_boxed (value));
        break;
      case PROP_BACKGROUND_SET:
        view->priv->background_set = g_value_get_boolean (value);
        break;
      default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
        break;
    }
}
Example #10
0
static void
gtk_cell_view_get_property (GObject    *object,
                            guint       param_id,
                            GValue     *value,
                            GParamSpec *pspec)
{
  GtkCellView *view = GTK_CELL_VIEW (object);

  switch (param_id)
    {
      case PROP_BACKGROUND_GDK:
        {
          GdkColor color;

          color = view->priv->background;

          g_value_set_boxed (value, &color);
        }
        break;
      case PROP_BACKGROUND_SET:
        g_value_set_boolean (value, view->priv->background_set);
        break;
      default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
        break;
    }
}
static void
attachment_button_update_cell_view (EAttachmentButton *button)
{
	GtkCellView *cell_view;
	EAttachment *attachment;
	GtkTreeRowReference *reference;
	GtkTreeModel *model = NULL;
	GtkTreePath *path = NULL;

	cell_view = GTK_CELL_VIEW (button->priv->cell_view);

	attachment = e_attachment_button_get_attachment (button);
	if (attachment == NULL)
		goto exit;

	reference = e_attachment_get_reference (attachment);
	if (reference == NULL)
		goto exit;

	model = gtk_tree_row_reference_get_model (reference);
	path = gtk_tree_row_reference_get_path (reference);

exit:

	gtk_cell_view_set_model (cell_view, model);
	if (model)
		gtk_cell_view_set_displayed_row (cell_view, path);

	if (path != NULL)
		gtk_tree_path_free (path);
}
Example #12
0
/**
 * Initialize the head cellview, create list store and set the cell renderers.
 */
static void
cell_view_init(HybridHead *head)
{
	GtkListStore *store;
	GtkCellRenderer *renderer;
	GtkTreePath *path;

	g_return_if_fail(head != NULL);

	store = gtk_list_store_new(HYBRID_HEAD_COLUMNS,
								GDK_TYPE_PIXBUF,
								G_TYPE_STRING,
								GDK_TYPE_PIXBUF);

	gtk_cell_view_set_model(GTK_CELL_VIEW(head->cellview), GTK_TREE_MODEL(store));

	g_object_unref(store);

	/* buddy icon renderer */
	renderer = gtk_cell_renderer_pixbuf_new();
	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(head->cellview), renderer, FALSE);
	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(head->cellview), renderer,
			"pixbuf", HYBRID_HEAD_PIXBUF_COLUMN, NULL);
	g_object_set(renderer, "yalign", 0.5, "xpad", 3, "ypad", 0, NULL);

	/* buddy name renderer */
	renderer = gtk_cell_renderer_text_new();
	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(head->cellview), renderer, TRUE);
	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(head->cellview), renderer,
			"markup", HYBRID_HEAD_NAME_COLUMN, NULL);

	g_object_set(renderer, "xalign", 0.0, "yalign", 0.0, "xpad", 6, "ypad", 0, NULL);
	g_object_set(renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);

	/* status icon renderer */
	renderer = gtk_cell_renderer_pixbuf_new();
	gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(head->cellview), renderer, FALSE);
	gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(head->cellview), renderer,
			"pixbuf", HYBRID_HEAD_STATUS_ICON_COLUMN, NULL);
	g_object_set(renderer, "yalign", 0.5, "xpad", 10, "ypad", 0, NULL);

	gtk_list_store_append(store, &head->iter);
	path = gtk_tree_path_new_from_string("0");
	gtk_cell_view_set_displayed_row(GTK_CELL_VIEW(head->cellview), path);
	gtk_tree_path_free(path);
}
Example #13
0
static GtkSizeRequestMode 
gtk_cell_view_get_request_mode (GtkWidget *widget)
{
  GtkCellView        *cellview = GTK_CELL_VIEW (widget);
  GtkCellViewPrivate *priv = cellview->priv;

  return gtk_cell_area_get_request_mode (priv->area);
}
Example #14
0
/* public API */
GtkWidget *
gtk_cell_view_new (void)
{
  GtkCellView *cellview;

  cellview = GTK_CELL_VIEW (g_object_new (gtk_cell_view_get_type (), NULL));

  return GTK_WIDGET (cellview);
}
 //________________________________________________________________________________
 void ComboBoxData::updateCellViewColor( void ) const
 {
     // change background color
     if( _cell._widget )
     {
         const GdkRGBA color = { 0, 0, 0, 0 };
         gtk_cell_view_set_background_rgba( GTK_CELL_VIEW( _cell._widget ), &color );
     }
 }
Example #16
0
static void
gtk_cell_view_finalize (GObject *object)
{
  GtkCellView *cellview = GTK_CELL_VIEW (object);

  if (cellview->priv->displayed_row)
     gtk_tree_row_reference_free (cellview->priv->displayed_row);

  G_OBJECT_CLASS (gtk_cell_view_parent_class)->finalize (object);
}
Example #17
0
void
hybrid_head_bind_to_account(HybridAccount *account)
{
	GtkTreeModel *model;
	GtkTreePath *path;
	GdkPixbuf *pixbuf;
	GdkPixbuf *status_icon;
	gchar *text;

	model = gtk_cell_view_get_model(GTK_CELL_VIEW(hybrid_head->cellview));

	if (!account) {
		pixbuf = hybrid_create_default_icon(32);
		text = g_strdup(_("No account was enabled."));
		status_icon = NULL;

	} else {
		pixbuf = hybrid_create_round_pixbuf(account->icon_data,
							account->icon_data_len, 32);
		text = g_strdup_printf(_("<b>%s</b> [%s]\n<small>%s</small>"), 
							account->nickname,
							hybrid_get_presence_name(account->state),
							account->status_text ? account->status_text : "");
		status_icon = hybrid_create_presence_pixbuf(account->state, 16);
	}


	gtk_list_store_set(GTK_LIST_STORE(model), &hybrid_head->iter,
					HYBRID_HEAD_PIXBUF_COLUMN, pixbuf,
					HYBRID_HEAD_NAME_COLUMN, text,
					HYBRID_HEAD_STATUS_ICON_COLUMN, status_icon,
					-1);

	path = gtk_tree_path_new_from_string("0");
	gtk_cell_view_set_displayed_row(GTK_CELL_VIEW(hybrid_head->cellview), path);
	gtk_tree_path_free(path);
	
	g_object_unref(pixbuf);
	if (status_icon) {
		g_object_unref(status_icon);
	}
	g_free(text);
}
Example #18
0
static gchar *
get_text_from_label_widget (GtkWidget *label)
{
  if (GTK_IS_LABEL (label))
    return g_strdup (gtk_label_get_text (GTK_LABEL (label)));
  else if (GTK_IS_CELL_VIEW (label))
    {
      GList *cells, *l;
      GtkTreeModel *model;
      GtkTreeIter iter;
      GtkTreePath *path;
      GtkCellArea *area;
      gchar *text;

      model = gtk_cell_view_get_model (GTK_CELL_VIEW (label));
      path = gtk_cell_view_get_displayed_row (GTK_CELL_VIEW (label));
      gtk_tree_model_get_iter (model, &iter, path);
      gtk_tree_path_free (path);

      area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (label));
      gtk_cell_area_apply_attributes (area, model, &iter, FALSE, FALSE);
      cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (label));

      text = NULL;
      for (l = cells; l; l = l->next)
        {
          GtkCellRenderer *cell = l->data;

          if (GTK_IS_CELL_RENDERER_TEXT (cell))
            {
              g_object_get (cell, "text", &text, NULL);
              break;
            }
        }

      g_list_free (cells);

      return text;
    }

  return NULL;
}
Example #19
0
void
hybrid_chat_window_update_tips(HybridChatWindow *window)
{
    GtkTreeModel       *model;
    GtkTreePath        *path;
    HybridConversation *conv;
    HybridBuddy        *buddy;
    gchar              *markup;

    g_return_if_fail(window != NULL);

    if (!IS_SYSTEM_CHAT(window)) {
        return;
    }

    conv = window->parent;
    buddy = window->data;

    model = gtk_cell_view_get_model(GTK_CELL_VIEW(window->tablabel));

    if (window->unread) {
        markup = g_strdup_printf("<span color=\"blue\"><b>%s (%d)</b></span>",
                                buddy->name, window->unread);

    } else {
        markup = g_strdup(buddy->name);
    }

    gtk_list_store_set(GTK_LIST_STORE(model), &window->tabiter,
                       TAB_NAME_COLUMN, markup,
                       -1);

    g_free(markup);

    path = gtk_tree_path_new_from_string("0");
    gtk_cell_view_set_displayed_row(GTK_CELL_VIEW(window->tablabel), path);
    gtk_tree_path_free(path);

}
Example #20
0
static void
gtk_cell_view_get_property (GObject    *object,
                            guint       param_id,
                            GValue     *value,
                            GParamSpec *pspec)
{
  GtkCellView *view = GTK_CELL_VIEW (object);

  switch (param_id)
    {
    case PROP_ORIENTATION:
      g_value_set_enum (value, view->priv->orientation);
      break;
    case PROP_BACKGROUND_GDK:
      {
	GdkColor color;
	
	color.red = (guint) (view->priv->background.red * 65535);
	color.green = (guint) (view->priv->background.green * 65535);
	color.blue = (guint) (view->priv->background.blue * 65535);
	color.pixel = 0;
	
	g_value_set_boxed (value, &color);
      }
      break;
    case PROP_BACKGROUND_RGBA:
      g_value_set_boxed (value, &view->priv->background);
      break;
    case PROP_BACKGROUND_SET:
      g_value_set_boolean (value, view->priv->background_set);
      break;
    case PROP_MODEL:
      g_value_set_object (value, view->priv->model);
      break;
    case PROP_CELL_AREA:
      g_value_set_object (value, view->priv->area);
      break;
    case PROP_CELL_AREA_CONTEXT:
      g_value_set_object (value, view->priv->context);
      break;
    case PROP_DRAW_SENSITIVE:
      g_value_set_boolean (value, view->priv->draw_sensitive);
      break;
    case PROP_FIT_MODEL:
      g_value_set_boolean (value, view->priv->fit_model);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
      break;
    }
}
Example #21
0
/* GtkCellLayout implementation */
static GtkCellArea *
gtk_cell_view_cell_layout_get_area (GtkCellLayout   *layout)
{
  GtkCellView *cellview = GTK_CELL_VIEW (layout);
  GtkCellViewPrivate *priv = cellview->priv;

  if (G_UNLIKELY (!priv->area))
    {
      priv->area = gtk_cell_area_box_new ();
      g_object_ref_sink (priv->area);
    }

  return priv->area;
}
Example #22
0
void
hybrid_chat_window_set_title(HybridChatWindow *window, const gchar *title)
{
    GtkTreeModel *model;
    GtkListStore *store;

    g_return_if_fail(window != NULL);

    if (!IS_USER_DEFINED_CHAT(window)) {
        return;
    }

    window->title = g_strdup(title);

    model = gtk_cell_view_get_model(GTK_CELL_VIEW(window->tablabel));
    store = GTK_LIST_STORE(model);

    gtk_list_store_set(store, &window->tabiter, TAB_NAME_COLUMN, title, -1);

    model = gtk_cell_view_get_model(GTK_CELL_VIEW(window->tiplabel));
    store = GTK_LIST_STORE(model);

    gtk_list_store_set(store, &window->tipiter, BUDDY_NAME_COLUMN, title, -1);
}
Example #23
0
static void
gtk_cell_view_cell_layout_clear (GtkCellLayout *layout)
{
  GtkCellView *cellview = GTK_CELL_VIEW (layout);

  g_return_if_fail (GTK_IS_CELL_VIEW (cellview));

  while (cellview->priv->cell_list)
    {
      GtkCellViewCellInfo *info = (GtkCellViewCellInfo *)cellview->priv->cell_list->data;

      gtk_cell_view_cell_layout_clear_attributes (layout, info->cell);
      g_object_unref (G_OBJECT (info->cell));
      g_free (info);
      cellview->priv->cell_list = g_list_delete_link (cellview->priv->cell_list, 
						      cellview->priv->cell_list);
    }
}
Example #24
0
static void
gtk_cell_view_finalize (GObject *object)
{
  GtkCellView *cellview = GTK_CELL_VIEW (object);

  gtk_cell_view_cell_layout_clear (GTK_CELL_LAYOUT (cellview));

  if (cellview->priv->model)
     g_object_unref (cellview->priv->model);

  if (cellview->priv->displayed_row)
     gtk_tree_row_reference_free (cellview->priv->displayed_row);

  if (G_OBJECT_CLASS (parent_class)->finalize)
    (* G_OBJECT_CLASS (parent_class)->finalize) (object);

  g_free (cellview->priv);
}
Example #25
0
static void
gtk_cell_view_cell_layout_add_attribute (GtkCellLayout   *layout,
                                         GtkCellRenderer *renderer,
                                         const gchar     *attribute,
                                         gint             column)
{
  GtkCellViewCellInfo *info;
  GtkCellView *cellview = GTK_CELL_VIEW (layout);

  g_return_if_fail (GTK_IS_CELL_VIEW (cellview));
  info = gtk_cell_view_get_cell_info (cellview, renderer);
  g_return_if_fail (info != NULL);

  info->attributes = g_slist_prepend (info->attributes,
                                      GINT_TO_POINTER (column));
  info->attributes = g_slist_prepend (info->attributes,
                                      g_strdup (attribute));
}
Example #26
0
static gboolean
gtk_cell_view_draw (GtkWidget *widget,
                    cairo_t   *cr)
{
  GtkCellView *cellview;
  GdkRectangle area;
  GtkCellRendererState state;

  cellview = GTK_CELL_VIEW (widget);

  /* render cells */
  area.x = 0;
  area.y = 0;
  area.width  = gtk_widget_get_allocated_width (widget);
  area.height = gtk_widget_get_allocated_height (widget);

  /* "blank" background */
  if (cellview->priv->background_set)
    {
      gdk_cairo_rectangle (cr, &area);
      gdk_cairo_set_source_rgba (cr, &cellview->priv->background);
      cairo_fill (cr);
    }

  /* set cell data (if available) */
  if (cellview->priv->displayed_row)
    gtk_cell_view_set_cell_data (cellview);
  else if (cellview->priv->model)
    return FALSE;

  if (gtk_widget_get_state_flags (widget) & GTK_STATE_FLAG_PRELIGHT)
    state = GTK_CELL_RENDERER_PRELIT;
  else if (gtk_widget_get_state_flags (widget) & GTK_STATE_FLAG_INSENSITIVE)
    state = GTK_CELL_RENDERER_INSENSITIVE;
  else
    state = 0;
      
  /* Render the cells */
  gtk_cell_area_render (cellview->priv->area, cellview->priv->context, 
			widget, cr, &area, &area, state, FALSE);

  return FALSE;
}
Example #27
0
static void
qtcComboBoxClearBgndColor(GtkWidget *widget)
{
    GList *children = gtk_container_get_children(GTK_CONTAINER(widget));
    GList *child = children;

    for (;child;child=child->next) {
        GtkWidget *boxChild = (GtkWidget*)child->data;

        if (GTK_IS_CELL_VIEW(boxChild) &&
            qtcComboBoxCellViewHasBgnd(boxChild)) {
            gtk_cell_view_set_background_color(GTK_CELL_VIEW(boxChild), 0L);
        }
    }

    if (children) {
        g_list_free(children);
    }
}
Example #28
0
/**
 * gtk_cell_view_new_with_text:
 * @text: the text to display in the cell view
 *
 * Creates a new #GtkCellView widget, adds a #GtkCellRendererText 
 * to it, and makes its show @text.
 *
 * Return value: A newly created #GtkCellView widget.
 *
 * Since: 2.6
 */
GtkWidget *
gtk_cell_view_new_with_text (const gchar *text)
{
  GtkCellView *cellview;
  GtkCellRenderer *renderer;
  GValue value = {0, };

  cellview = GTK_CELL_VIEW (gtk_cell_view_new ());

  renderer = gtk_cell_renderer_text_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (cellview),
			      renderer, TRUE);

  g_value_init (&value, G_TYPE_STRING);
  g_value_set_string (&value, text);
  gtk_cell_view_set_value (cellview, renderer, "text", &value);
  g_value_unset (&value);

  return GTK_WIDGET (cellview);
}
Example #29
0
/**
 * gtk_cell_view_new_with_pixbuf:
 * @pixbuf: the image to display in the cell view
 *
 * Creates a new #GtkCellView widget, adds a #GtkCellRendererPixbuf 
 * to it, and makes its show @pixbuf. 
 *
 * Return value: A newly created #GtkCellView widget.
 *
 * Since: 2.6
 */
GtkWidget *
gtk_cell_view_new_with_pixbuf (GdkPixbuf *pixbuf)
{
  GtkCellView *cellview;
  GtkCellRenderer *renderer;
  GValue value = {0, };

  cellview = GTK_CELL_VIEW (gtk_cell_view_new ());

  renderer = gtk_cell_renderer_pixbuf_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (cellview),
			      renderer, TRUE);

  g_value_init (&value, GDK_TYPE_PIXBUF);
  g_value_set_object (&value, pixbuf);
  gtk_cell_view_set_value (cellview, renderer, "pixbuf", &value);
  g_value_unset (&value);

  return GTK_WIDGET (cellview);
}
Example #30
0
static void
gtk_cell_view_cell_layout_pack_end (GtkCellLayout   *layout,
                                    GtkCellRenderer *renderer,
                                    gboolean         expand)
{
  GtkCellViewCellInfo *info;
  GtkCellView *cellview = GTK_CELL_VIEW (layout);

  g_return_if_fail (GTK_IS_CELL_VIEW (cellview));
  g_return_if_fail (GTK_IS_CELL_RENDERER (renderer));
  g_return_if_fail (!gtk_cell_view_get_cell_info (cellview, renderer));

  g_object_ref (G_OBJECT (renderer));
  gtk_object_sink (GTK_OBJECT (renderer));

  info = g_new0 (GtkCellViewCellInfo, 1);
  info->cell = renderer;
  info->expand = expand ? TRUE : FALSE;
  info->pack = GTK_PACK_END;

  cellview->priv->cell_list = g_list_append (cellview->priv->cell_list, info);
}