Re: GtkTreeView alignment



Hi!

> See
> http://mail.gnome.org/archives/gtk-list/2003-October/thread.html

I am following this list closely and I was aware of your discussion about
aligning *text* cells. However, I was wondering if there is generic way to
align whatever contents of the cell, e.g. toggle-buttons and pixbufs.

Please see the example below!

Best wishes,

Andrej

--
Example: out of the three, only the 1st one gets aligned when the row is
appended with e.g.:

gtk_list_store_set (store, &iter, 0, "Undefined", 1, FALSE, 2, FALSE, 3,
syncolor, 4, expcolor, 5, 0.0, 6, TRUE, 7, 0.5, -1);


enum
  {
  PLOT_LC_FILTER,
  PLOT_LC_SYNTHETIC,
  PLOT_LC_EXPERIMENTAL,
  PLOT_LC_SYNCOLOR,
  PLOT_LC_EXPCOLOR,
  PLOT_LC_OFFSET,
  PLOT_LC_EDITABLE,
  PLOT_LC_ALIGNMENT,
  PLOT_LC_COLNO
  };

/* 1st example: */
renderer = gtk_cell_renderer_text_new ();
g_object_set_data (G_OBJECT (renderer), "column", (gint *)
                                                   PLOT_LC_FILTER);
column = gtk_tree_view_column_new ();
gtk_tree_view_column_set_alignment (column, 0.5);
gtk_tree_view_column_set_title (column, "Filter");
gtk_tree_view_column_pack_start (column, renderer, TRUE);
gtk_tree_view_column_add_attribute (column, renderer, "text", 0);
gtk_tree_view_column_add_attribute (column, renderer, "xalign", 7);
gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_column_set_min_width (column, 90);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);

/* 2nd example: */
renderer = gtk_cell_renderer_toggle_new ();
g_object_set_data (G_OBJECT (renderer), "column", (gint *)                
                                                PLOT_LC_SYNTHETIC);
g_signal_connect (G_OBJECT (renderer), "toggled", G_CALLBACK
                         (editable_cell_with_checkbox_edited), model);
column = gtk_tree_view_column_new ();
gtk_tree_view_column_set_alignment (column, 0.5);
gtk_tree_view_column_set_title (column, "Synthetic data?");
gtk_tree_view_column_pack_start (column, renderer, FALSE);
gtk_tree_view_column_add_attribute (column, renderer, "active", 1);
gtk_tree_view_column_add_attribute (column, renderer, "xalign", 7);
gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
g_object_set (G_OBJECT (column), "alignment", 0.5, NULL);

/* 3rd example: */
renderer = gtk_cell_renderer_pixbuf_new ();
g_object_set_data (G_OBJECT (renderer), "column", (gint *)
                                                 PLOT_LC_SYNCOLOR);
g_object_set (G_OBJECT (renderer), "mode",
                         GTK_CELL_RENDERER_MODE_ACTIVATABLE, NULL);
column = gtk_tree_view_column_new ();
gtk_tree_view_column_set_alignment (column, 0.5);
gtk_tree_view_column_set_title (column, "Synthetic color");
gtk_tree_view_column_pack_start (column, renderer, FALSE);
gtk_tree_view_column_add_attribute (column, renderer, "pixbuf", 3);
gtk_tree_view_column_add_attribute (column, renderer, "xalign", 7);
gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]