Attachment 'gtk-simple-list-03-add-new-with-titles-constructor.diff'

Download

   1 From a55d4dcb20e2faf534f2a67822cfd313d3d6f699 Mon Sep 17 00:00:00 2001
   2 From: Kristian Rietveld <kris@gtk.org>
   3 Date: Thu, 16 Oct 2008 16:47:50 +0200
   4 Subject: Add a gtk_simple_list_new_with_titles() constructor as suggested by ebassi.
   5 
   6 ---
   7  gtk/gtksimplelist.c |   36 ++++++++++++++++++++++++++++++++++++
   8  gtk/gtksimplelist.h |    2 ++
   9  2 files changed, 38 insertions(+), 0 deletions(-)
  10 
  11 diff --git a/gtk/gtksimplelist.c b/gtk/gtksimplelist.c
  12 index 42596df..dac462e 100644
  13 --- a/gtk/gtksimplelist.c
  14 +++ b/gtk/gtksimplelist.c
  15 @@ -295,6 +295,42 @@ gtk_simple_list_new (int n_columns,
  16  }
  17  
  18  GtkWidget *
  19 +gtk_simple_list_new_with_titles (int n_columns,
  20 +                                 ...)
  21 +{
  22 +  int i;
  23 +  GtkSimpleListColumn *columns;
  24 +  char **titles;
  25 +  va_list args;
  26 +  GtkWidget *retval;
  27 +
  28 +  g_return_val_if_fail (n_columns > 0, NULL);
  29 +
  30 +  va_start (args, n_columns);
  31 +
  32 +  columns = g_new (GtkSimpleListColumn, n_columns);
  33 +  titles = g_new (char *, n_columns);
  34 +
  35 +  for (i = 0; i < n_columns; i++)
  36 +    {
  37 +      columns[i] = va_arg (args, GtkSimpleListColumn);
  38 +      titles[i] = va_arg (args, char *);
  39 +    }
  40 +
  41 +  va_end (args);
  42 +
  43 +  retval = gtk_simple_list_newv (n_columns, columns);
  44 +
  45 +  for (i = 0; i < n_columns; i++)
  46 +    gtk_simple_list_column_set_title (GTK_SIMPLE_LIST (retval), i, titles[i]);
  47 +
  48 +  g_free (columns);
  49 +  g_free (titles);
  50 +
  51 +  return retval;
  52 +}
  53 +
  54 +GtkWidget *
  55  gtk_simple_list_newv (int                  n_columns,
  56                        GtkSimpleListColumn *column_types)
  57  {
  58 diff --git a/gtk/gtksimplelist.h b/gtk/gtksimplelist.h
  59 index e52d8b9..6a08241 100644
  60 --- a/gtk/gtksimplelist.h
  61 +++ b/gtk/gtksimplelist.h
  62 @@ -72,6 +72,8 @@ struct _GtkSimpleListClass
  63  GType      gtk_simple_list_get_type                 (void) G_GNUC_CONST;
  64  GtkWidget *gtk_simple_list_new                      (int                  n_columns,
  65                                                       ...);
  66 +GtkWidget *gtk_simple_list_new_with_titles          (int                  n_columns,
  67 +                                                     ...);
  68  GtkWidget *gtk_simple_list_newv                     (int                  n_columns,
  69                                                       GtkSimpleListColumn *column_types);
  70  
  71 -- 
  72 1.6.4

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2021-02-25 09:59:00, 9.1 KB) [[attachment:gtk-simple-list-01-handle-toggle-renderers.diff]]
  • [get | view] (2021-02-25 09:59:00, 1.7 KB) [[attachment:gtk-simple-list-02-remove-set-cell-renderer-stub.diff]]
  • [get | view] (2021-02-25 09:59:00, 2.2 KB) [[attachment:gtk-simple-list-03-add-new-with-titles-constructor.diff]]
  • [get | view] (2021-02-25 09:59:00, 34.7 KB) [[attachment:gtk-simple-list-20sep2008.diff]]
  • [get | view] (2021-02-25 09:59:00, 50.1 KB) [[attachment:gtk-tree-extra-space-API-jul2008.tar.gz]]
  • [get | view] (2021-02-25 09:59:00, 111.2 KB) [[attachment:gtk-tree-new-dnd-28oct2008.diff]]
  • [get | view] (2021-02-25 09:59:00, 26.2 KB) [[attachment:gtk-tree-no-validation-jul2008.diff]]
  • [get | view] (2021-02-25 09:59:00, 17.3 KB) [[attachment:gtk-tree-refactor-dec2009.tar.gz]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.