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

Re: question on using GtkCellRendererProgress



On Mon, Feb 18, 2008 at 10:27:03PM +0800, Gregory Hosler wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Mike Massonnet wrote:
> | On Mon, Feb 18, 2008 at 09:29:26PM +0800, Gregory Hosler wrote:
> |> -----BEGIN PGP SIGNED MESSAGE-----
> |> Hash: SHA1
> |>
> |> Hi all,
> |>
> |> I've got a gtk_list_store, and one of the columns I want to make a progress meter.
> |>
> |> I'm gathering that I use teh cell rendered GtkCellRendererProgress for this column. But I
> |> have 2 points of confusion.
> |>
> |> 1) When I create the table (gtk_list_store_new()), what is the G_TYPE I use for this
> |> particular column defn ?
> |>
> |> 2) How do I refer to this column in a gtk_list_store_set() (i.e. yes, I know I refer to
> |> the column number, but what do I pass in for a value ?)
> |
> | Progress bars have two properties: value and text.  value should be of
> | G_TYPE_INT, while text is STRING and can print text onto the progress
> | bar.
> |
> | You can then set the values with:
> | gtk_list_store_set (..., COLUMN_PERCENT, new_value, COLUMN_TEXT, new_text);
>
> confusion again... :( COLUMN_PERCENT, and COLUMN_TEXT -- would these be the same column or
> different columns. The progress bar is only 1 column, as I understand.

There can be several columns just for a single cell renderer.
Those are the column numbers, I use the next enum for a gtk list store:

> With your above example, what would my gtk_list_store_new() look like ? 2 columns for the
> progress bar ?
>
> any code snippets for the column(s) creation ?
>
> (or code / projects that you know use this ? (I can look it up if I know the project... :)
>
> I looked at Pidghin, but they created their own custom cell render class. I really prefer
> not to do that. :(

enum
{
  COLUMN_VALUE,
  COLUMN_TEXT,
  N_COLUMNS,
};

store = gtk_list_store_new (N_COLUMNS,
                            G_TYPE_INT,
                            G_TYPE_STRING);

cell = gtk_cell_renderer_progress_new ();
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (treeview),
                                             -1, "progress", cell,
                                             "value", COLUMN_VALUE,
                                             "text", COLUMN_TEXT,
                                             NULL);

GtkTreeIter iter;
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
                    COLUMN_VALUE, 40,
                    COLUMN_TEXT, "blah", /* see http://library.gnome.org/devel/gtk/unstable/GtkCellRendererProgress.html#GtkCellRendererProgress--text */
                    -1);

Voilà, something that uses these function.

> thx, and best rgds,
>
> - -Greg

mike


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