Patch for GtkCList justification enhancement



	The following patch introduces a new API called
gtk_clist_set_column_justification_full that allows you to modify the
justification of a column title of a GtkCList independently of the
body of the widget.  The behaviour of the existing API
gtk_clist_set_column_justification is unchanged.

	I'm submitting this because I think centered titles look much better
than left-justified ones, even if the body of the CList is left-justified.



-------------------------- cut here ---------------------------------
diff -ruN gtk+-1.1.15/gtk/gtkclist.c /export/home/phoenix/tmp/gtk+-1.1.15/gtk/gtkclist.c
--- gtk+-1.1.15/gtk/gtkclist.c	Sat Feb 13 12:13:53 1999
+++ /export/home/phoenix/tmp/gtk+-1.1.15/gtk/gtkclist.c	Sat Feb 13 12:21:32 1999
@@ -1318,6 +1318,7 @@
  *   gtk_clist_get_column_title
  *   gtk_clist_set_column_widget
  *   gtk_clist_set_column_justification
+ *   gtk_clist_set_column_justification_full
  *   gtk_clist_set_column_visibility
  *   gtk_clist_set_column_resizeable
  *   gtk_clist_set_column_auto_resize
@@ -1462,7 +1463,7 @@
     gtk_container_remove (GTK_CONTAINER (clist->column[column].button), old_widget);
 
   /* create new alignment based no column justification */
-  switch (clist->column[column].justification)
+  switch (clist->column[column].titlejustification)
     {
     case GTK_JUSTIFY_LEFT:
       alignment = gtk_alignment_new (0.0, 0.5, 0.0, 0.0);
@@ -1568,9 +1569,10 @@
 }
 
 void
-gtk_clist_set_column_justification (GtkCList         *clist,
-				    gint              column,
-				    GtkJustification  justification)
+gtk_clist_set_column_justification_full (GtkCList         *clist,
+				         gint              column,
+				         GtkJustification  justification,
+                                         GtkJustification  titlejustification)
 {
   GtkWidget *alignment;
 
@@ -1581,14 +1583,15 @@
     return;
 
   clist->column[column].justification = justification;
+  clist->column[column].titlejustification = titlejustification;
 
-  /* change the alinment of the button title if it's not a
+  /* change the alignment of the button title if it's not a
    * custom widget */
   if (clist->column[column].title)
     {
       alignment = GTK_BIN (clist->column[column].button)->child;
 
-      switch (clist->column[column].justification)
+      switch (clist->column[column].titlejustification)
 	{
 	case GTK_JUSTIFY_LEFT:
 	  gtk_alignment_set (GTK_ALIGNMENT (alignment), 0.0, 0.5, 0.0, 0.0);
@@ -1616,6 +1619,15 @@
 }
 
 void
+gtk_clist_set_column_justification (GtkCList         *clist,
+                                    gint              column,
+                                    GtkJustification  justification)
+{
+  gtk_clist_set_column_justification_full (clist, column, justification,
+                                           justification);
+}
+
+void
 gtk_clist_set_column_visibility (GtkCList *clist,
 				 gint      column,
 				 gboolean  visible)
@@ -6413,6 +6425,7 @@
       column[i].resizeable = TRUE;
       column[i].auto_resize = FALSE;
       column[i].justification = GTK_JUSTIFY_LEFT;
+      column[i].titlejustification = GTK_JUSTIFY_LEFT;
     }
 
   return column;
diff -ruN gtk+-1.1.15/gtk/gtkclist.h /export/home/phoenix/tmp/gtk+-1.1.15/gtk/gtkclist.h
--- gtk+-1.1.15/gtk/gtkclist.h	Sat Feb 13 12:13:53 1999
+++ /export/home/phoenix/tmp/gtk+-1.1.15/gtk/gtkclist.h	Sat Feb 13 12:22:59 1999
@@ -321,6 +321,7 @@
   gint min_width;
   gint max_width;
   GtkJustification justification;
+  GtkJustification titlejustification;
   
   guint visible     : 1;  
   guint width_set   : 1;
@@ -510,6 +511,12 @@
 void gtk_clist_set_column_justification (GtkCList         *clist,
 					 gint              column,
 					 GtkJustification  justification);
+
+/* set the justification on a column and its title independently */
+void gtk_clist_set_column_justification_full (GtkCList        *clist,
+                                              gint             column,
+                                              GtkJustification justification,
+                                              GtkJustification titlejustification);
 
 /* set visibility of a column */
 void gtk_clist_set_column_visibility (GtkCList *clist,
-------------------------- cut here ---------------------------------


-- 
James Macnicol
jamesm@ee.adfa.oz.au



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