]> Pileus Git - ~andy/gtk/commitdiff
Added `visible'.
authorMartin Baulig <martin@home-of-linux.org>
Sun, 4 Oct 1998 10:52:52 +0000 (10:52 +0000)
committerMartin Baulig <martin@src.gnome.org>
Sun, 4 Oct 1998 10:52:52 +0000 (10:52 +0000)
1998-10-01  Martin Baulig  <martin@home-of-linux.org>

* gtk/gtkclist.h (GtkCListColumn): Added `visible'.

* gtk/gtkclist.c (gtk_clist_set_column_visibility): New function.
Makes it possible to individually show and hide columns.
(size_allocate_columns): Adapted to keep track of hidden columns.
(size_allocate_title_buttons): Likewise.

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkclist.c
gtk/gtkclist.h

index 824948b58e5515029be8d4f655cfba285c64ccd2..9fc0b94f711665b487af5da046a54ad21b8d6730 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+1998-10-01  Martin Baulig  <martin@home-of-linux.org>
+
+       * gtk/gtkclist.h (GtkCListColumn): Added `visible'.
+       
+       * gtk/gtkclist.c (gtk_clist_set_column_visibility): New function.
+       Makes it possible to individually show and hide columns.
+       (size_allocate_columns): Adapted to keep track of hidden columns.
+       (size_allocate_title_buttons): Likewise.
+
 Sat Oct  3 17:54:48 1998  Tim Janik  <timj@gtk.org>
 
        * gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign
index 824948b58e5515029be8d4f655cfba285c64ccd2..9fc0b94f711665b487af5da046a54ad21b8d6730 100644 (file)
@@ -1,3 +1,12 @@
+1998-10-01  Martin Baulig  <martin@home-of-linux.org>
+
+       * gtk/gtkclist.h (GtkCListColumn): Added `visible'.
+       
+       * gtk/gtkclist.c (gtk_clist_set_column_visibility): New function.
+       Makes it possible to individually show and hide columns.
+       (size_allocate_columns): Adapted to keep track of hidden columns.
+       (size_allocate_title_buttons): Likewise.
+
 Sat Oct  3 17:54:48 1998  Tim Janik  <timj@gtk.org>
 
        * gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign
index 824948b58e5515029be8d4f655cfba285c64ccd2..9fc0b94f711665b487af5da046a54ad21b8d6730 100644 (file)
@@ -1,3 +1,12 @@
+1998-10-01  Martin Baulig  <martin@home-of-linux.org>
+
+       * gtk/gtkclist.h (GtkCListColumn): Added `visible'.
+       
+       * gtk/gtkclist.c (gtk_clist_set_column_visibility): New function.
+       Makes it possible to individually show and hide columns.
+       (size_allocate_columns): Adapted to keep track of hidden columns.
+       (size_allocate_title_buttons): Likewise.
+
 Sat Oct  3 17:54:48 1998  Tim Janik  <timj@gtk.org>
 
        * gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign
index 824948b58e5515029be8d4f655cfba285c64ccd2..9fc0b94f711665b487af5da046a54ad21b8d6730 100644 (file)
@@ -1,3 +1,12 @@
+1998-10-01  Martin Baulig  <martin@home-of-linux.org>
+
+       * gtk/gtkclist.h (GtkCListColumn): Added `visible'.
+       
+       * gtk/gtkclist.c (gtk_clist_set_column_visibility): New function.
+       Makes it possible to individually show and hide columns.
+       (size_allocate_columns): Adapted to keep track of hidden columns.
+       (size_allocate_title_buttons): Likewise.
+
 Sat Oct  3 17:54:48 1998  Tim Janik  <timj@gtk.org>
 
        * gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign
index 824948b58e5515029be8d4f655cfba285c64ccd2..9fc0b94f711665b487af5da046a54ad21b8d6730 100644 (file)
@@ -1,3 +1,12 @@
+1998-10-01  Martin Baulig  <martin@home-of-linux.org>
+
+       * gtk/gtkclist.h (GtkCListColumn): Added `visible'.
+       
+       * gtk/gtkclist.c (gtk_clist_set_column_visibility): New function.
+       Makes it possible to individually show and hide columns.
+       (size_allocate_columns): Adapted to keep track of hidden columns.
+       (size_allocate_title_buttons): Likewise.
+
 Sat Oct  3 17:54:48 1998  Tim Janik  <timj@gtk.org>
 
        * gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign
index 824948b58e5515029be8d4f655cfba285c64ccd2..9fc0b94f711665b487af5da046a54ad21b8d6730 100644 (file)
@@ -1,3 +1,12 @@
+1998-10-01  Martin Baulig  <martin@home-of-linux.org>
+
+       * gtk/gtkclist.h (GtkCListColumn): Added `visible'.
+       
+       * gtk/gtkclist.c (gtk_clist_set_column_visibility): New function.
+       Makes it possible to individually show and hide columns.
+       (size_allocate_columns): Adapted to keep track of hidden columns.
+       (size_allocate_title_buttons): Likewise.
+
 Sat Oct  3 17:54:48 1998  Tim Janik  <timj@gtk.org>
 
        * gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign
index 824948b58e5515029be8d4f655cfba285c64ccd2..9fc0b94f711665b487af5da046a54ad21b8d6730 100644 (file)
@@ -1,3 +1,12 @@
+1998-10-01  Martin Baulig  <martin@home-of-linux.org>
+
+       * gtk/gtkclist.h (GtkCListColumn): Added `visible'.
+       
+       * gtk/gtkclist.c (gtk_clist_set_column_visibility): New function.
+       Makes it possible to individually show and hide columns.
+       (size_allocate_columns): Adapted to keep track of hidden columns.
+       (size_allocate_title_buttons): Likewise.
+
 Sat Oct  3 17:54:48 1998  Tim Janik  <timj@gtk.org>
 
        * gtk/gtkargcollector.c (GTK_ARG_COLLECT_VALUE): for unknown foreign
index f5a51a30d87ba6a287f5a1e3d830918b5a698dc3..182afedd4ba0da2e1113ce954e1fc31fdf513689 100644 (file)
@@ -1009,6 +1009,23 @@ gtk_clist_column_titles_hide (GtkCList * clist)
     }
 }
 
+void
+gtk_clist_set_column_visibility (GtkCList * clist, gint column, gint visible)
+{
+  g_return_if_fail (clist != NULL);
+  g_return_if_fail (GTK_IS_CLIST (clist));
+
+  if (column < 0 || column >= clist->columns)
+    return;
+
+  if (clist->column[column].visible && !visible)
+    gtk_widget_hide (clist->column[column].button);
+  else if (!clist->column[column].visible && visible)
+    gtk_widget_show (clist->column[column].button);
+
+  clist->column[column].visible = visible ? TRUE : FALSE;
+}
+
 void
 gtk_clist_column_title_active (GtkCList * clist,
                               gint column)
@@ -2653,6 +2670,8 @@ gtk_clist_draw (GtkWidget * widget,
 
       for (i = 0; i < clist->columns; i++)
        {
+         if (!clist->column[i].visible)
+           continue;
          if (gtk_widget_intersect (clist->column[i].button, area, &child_area))
            gtk_widget_draw (clist->column[i].button, &child_area);
        }
@@ -3913,6 +3932,7 @@ size_allocate_title_buttons (GtkCList * clist)
 {
   gint i, last_button = 0;
   GtkAllocation button_allocation;
+  gint visible_columns = clist->columns;
 
   if (!GTK_WIDGET_REALIZED (clist))
     return;
@@ -3922,16 +3942,22 @@ size_allocate_title_buttons (GtkCList * clist)
   button_allocation.width = 0;
   button_allocation.height = clist->column_title_area.height;
 
-  for (i = 0; i < clist->columns; i++)
+  for (i = clist->columns-1; i > 0; i--)
+    if (!clist->column[i].visible)
+      visible_columns = i;
+    else
+      break;
+
+  for (i = 0; i < visible_columns; i++)
     {
       button_allocation.width += clist->column[i].area.width;
 
-      if (i == clist->columns - 1)
+      if (i == visible_columns - 1)
        button_allocation.width += 2 * (CELL_SPACING + COLUMN_INSET);
-      else
+      else if (clist->column[i].visible)
        button_allocation.width += CELL_SPACING + (2 * COLUMN_INSET);
 
-      if (i == (clist->columns - 1) || clist->column[i + 1].button)
+      if (i == (visible_columns - 1) || clist->column[i + 1].button)
        {
          gtk_widget_size_allocate (clist->column[last_button].button, &button_allocation);
          button_allocation.x += button_allocation.width;
@@ -3955,12 +3981,19 @@ static void
 size_allocate_columns (GtkCList * clist)
 {
   gint i, xoffset = 0;
+  gint visible_columns = clist->columns;
 
-  for (i = 0; i < clist->columns; i++)
+  for (i = visible_columns-1; i > 0; i--)
+    if (!clist->column[i].visible)
+      visible_columns = i;
+    else
+      break;
+
+  for (i = 0; i < visible_columns; i++)
     {
       clist->column[i].area.x = xoffset + CELL_SPACING + COLUMN_INSET;
 
-      if (i == clist->columns - 1)
+      if (i == visible_columns - 1)
        {
          gint width;
 
@@ -3987,8 +4020,13 @@ size_allocate_columns (GtkCList * clist)
          clist->column[i].area.width = clist->column[i].width;
        }
 
-      xoffset += clist->column[i].area.width + CELL_SPACING + (2 * COLUMN_INSET);
+      if (clist->column[i].visible)
+       xoffset += clist->column[i].area.width +
+         CELL_SPACING + (2 * COLUMN_INSET);
     }
+
+  for (i = visible_columns; i < clist->columns; i++)
+    clist->column[i].area.width = 0;
 }
 
 /*
@@ -4749,6 +4787,7 @@ columns_new (GtkCList * clist)
       column[i].button = NULL;
       column[i].window = NULL;
       column[i].width = 0;
+      column[i].visible = 1;
       column[i].width_set = FALSE;
       column[i].justification = GTK_JUSTIFY_LEFT;
     }
index a8d2608f44043ea443510d7fac6bca139582e71b..bfa4bbabeb05be8269db936f1cd181f44737b421 100644 (file)
@@ -261,6 +261,7 @@ struct _GtkCListColumn
   gint width;
   GtkJustification justification;
   
+  gint visible : 1;  
   gint width_set : 1;
 };
 
@@ -401,6 +402,11 @@ void gtk_clist_column_title_passive  (GtkCList *clist,
 void gtk_clist_column_titles_active  (GtkCList *clist);
 void gtk_clist_column_titles_passive (GtkCList *clist);
 
+/* set visibility of a column */
+void gtk_clist_set_column_visibility (GtkCList *clist,
+                                     gint      column,
+                                     gint      visible);
+
 /* set the title in the column title button */
 void gtk_clist_set_column_title (GtkCList    *clist,
                                 gint         column,