[libgda] Use GtkWidget::expand and related properties



commit 6e70a2d36730e662375a8bfdb71caa308936a2b3
Author: Vivien Malerba <malerba gnome-db org>
Date:   Mon Aug 20 21:53:13 2012 +0200

    Use GtkWidget::expand and related properties
    
    instead of custom properties

 libgda-ui/gdaui-basic-form.c       |   33 ++++++---------------------------
 libgda-ui/gdaui-server-operation.c |   19 +++++--------------
 2 files changed, 11 insertions(+), 41 deletions(-)
---
diff --git a/libgda-ui/gdaui-basic-form.c b/libgda-ui/gdaui-basic-form.c
index 8cb7f88..64cf9f2 100644
--- a/libgda-ui/gdaui-basic-form.c
+++ b/libgda-ui/gdaui-basic-form.c
@@ -71,14 +71,12 @@ typedef struct {
 	gboolean        prog_hidden; /* status as requested by the programmer */
 	gboolean        hidden; /* real status of the data entry */
 	gboolean        not_null; /* TRUE if @entry's contents can't be NULL */
-	gboolean        can_expand; /* tells if @entry can expand */
 	gboolean        forward_param_updates; /* forward them to the GdauiDataEntry widgets ? */
 
 	gulong          entry_shown_id; /* signal ID */
 	gulong          label_shown_id; /* signal ID */
 
 	gulong          entry_contents_modified_id; /* signal ID */
-	gulong          entry_expand_changed_id; /* signal ID */
 	gulong          entry_contents_activated_id; /* signal ID */
 
 	GdaHolder      *single_param;
@@ -118,7 +116,6 @@ static void paramlist_holder_type_set_cb (GdaSet *paramlist, GdaHolder *param,
 					  GdauiBasicForm *form);
 
 static void entry_contents_modified (GdauiDataEntry *entry, SingleEntry *sentry);
-static void entry_expand_changed_cb (GdauiDataEntry *entry, SingleEntry *sentry);
 static void entry_contents_activated (GdauiDataEntry *entry, GdauiBasicForm *form);
 static void parameter_changed_cb (GdaHolder *param, SingleEntry *sentry);
 
@@ -417,6 +414,7 @@ gdaui_basic_form_init (GdauiBasicForm *wid)
 	gtk_widget_show (evbox);
 	gtk_box_pack_start (GTK_BOX (wid), evbox, TRUE, TRUE, 0);
 	wid->priv->mainbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+	
 	gtk_widget_show (wid->priv->mainbox);
 	gtk_container_add (GTK_CONTAINER (evbox), wid->priv->mainbox);
 	g_object_set (evbox, "visible-window", FALSE, NULL);
@@ -722,13 +720,8 @@ gdaui_basic_form_get_property (GObject *object,
 			break;
 		case PROP_CAN_VEXPAND: {
 			gboolean can_expand = FALSE;
-			GSList *list;
-			for (list = form->priv->s_entries; list; list = list->next) {
-				if (((SingleEntry*) list->data)->can_expand) {
-					can_expand = TRUE;
-					break;
-				}
-			}
+			can_expand = gtk_widget_compute_expand (GTK_WIDGET (form),
+								GTK_ORIENTATION_VERTICAL);
 			g_value_set_boolean (value, can_expand);
 			break;
 		}
@@ -742,12 +735,10 @@ gdaui_basic_form_get_property (GObject *object,
 static void
 disconnect_single_entry_signals (SingleEntry *sentry)
 {
-	if (sentry->entry) {
+	if (sentry->entry)
 		g_signal_handler_disconnect (sentry->entry, sentry->entry_contents_modified_id);
-		g_signal_handler_disconnect (sentry->entry, sentry->entry_expand_changed_id);
-	}
+
 	sentry->entry_contents_modified_id = 0;
-	sentry->entry_expand_changed_id = 0;
 	if (sentry->entry)
 		g_signal_handler_disconnect (sentry->entry, sentry->entry_contents_activated_id);
 	sentry->entry_contents_activated_id = 0;
@@ -1088,8 +1079,6 @@ create_entry_widget (SingleEntry *sentry)
 	sentry->entry_contents_modified_id = g_signal_connect (G_OBJECT (entry), "contents-modified",
 							       G_CALLBACK (entry_contents_modified),
 							       sentry);
-	sentry->entry_expand_changed_id = g_signal_connect (sentry->entry, "expand-changed",
-							    G_CALLBACK (entry_expand_changed_cb), sentry);
 
 	sentry->entry_contents_activated_id = g_signal_connect (G_OBJECT (entry), "contents-activated",
 								G_CALLBACK (entry_contents_activated),
@@ -1133,10 +1122,6 @@ create_entries (GdauiBasicForm *form)
 static void
 pack_entry_widget (SingleEntry *sentry)
 {
-	gboolean expand;
-	expand = gtk_widget_get_vexpand (GTK_WIDGET (sentry->entry));
-	sentry->can_expand = expand;
-
 	switch (sentry->packing_type) {
 	case PACKING_TABLE: {
 		/* label for the entry */
@@ -1569,12 +1554,6 @@ entry_contents_modified (GdauiDataEntry *entry, SingleEntry *sentry)
 	}
 }
 
-static void
-entry_expand_changed_cb (G_GNUC_UNUSED GdauiDataEntry *entry, SingleEntry *sentry)
-{
-	pack_entry_widget (sentry);
-}
-
 
 /*
  * Called when a parameter changes
@@ -2187,7 +2166,7 @@ gdaui_basic_form_new_in_dialog (GdaSet *data_set, GtkWindow *parent,
 	}
 
 	gboolean can_expand;
-	g_object_get ((GObject*) form, "can-expand-v", &can_expand, NULL);
+	can_expand = gtk_widget_compute_expand (GTK_WIDGET (form), GTK_ORIENTATION_VERTICAL);
 	gtk_container_set_border_width (GTK_CONTAINER (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg)))), 4);
 	gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))), form,
 			    can_expand, can_expand, 10);
diff --git a/libgda-ui/gdaui-server-operation.c b/libgda-ui/gdaui-server-operation.c
index 70fd3eb..090be51 100644
--- a/libgda-ui/gdaui-server-operation.c
+++ b/libgda-ui/gdaui-server-operation.c
@@ -369,14 +369,12 @@ sequence_grid_attach_widget (GdauiServerOperation *form, GtkWidget *grid, GtkWid
 			     const gchar *path, gint index)
 {
 	GtkWidget *image;
-	gboolean expand;
 	guint min, size;
 
 	min = gda_server_operation_get_sequence_min_size (form->priv->op, path);
 	size = gda_server_operation_get_sequence_size (form->priv->op, path);
 
 	/* new widget */
-	expand = g_object_get_data (G_OBJECT (wid), "expand") ?  TRUE : FALSE;
 	gtk_grid_attach (GTK_GRID (grid), wid, 0, index, 1, 1);
 	gtk_widget_show (wid);
 
@@ -512,7 +510,7 @@ fill_create_widget (GdauiServerOperation *form, const gchar *path, gchar **secti
 			*label_widgets = g_slist_prepend (*label_widgets, label_entry);
 		}
 
-		g_object_set_data (G_OBJECT (plwid), "expand", GINT_TO_POINTER (TRUE));
+		gtk_widget_set_vexpand (plwid, TRUE);
 		break;
 	}
 	case GDA_SERVER_OPERATION_NODE_PARAM: {
@@ -608,7 +606,7 @@ fill_create_widget (GdauiServerOperation *form, const gchar *path, gchar **secti
 			g_object_set_data_full (G_OBJECT (wid), "_seq_path", g_strdup (path), g_free);
 		}
 
-		g_object_set_data (G_OBJECT (plwid), "expand", GINT_TO_POINTER (TRUE));
+		gtk_widget_set_vexpand (plwid, TRUE);
 		break;
 	}
 	case GDA_SERVER_OPERATION_NODE_SEQUENCE_ITEM: {
@@ -616,7 +614,6 @@ fill_create_widget (GdauiServerOperation *form, const gchar *path, gchar **secti
 		gint size;
 		gchar *parent_path;
 		WidgetData *wdp, *wdi;
-		gboolean seq_expand = FALSE;
 
 		node_names = gda_server_operation_get_sequence_item_names (form->priv->op, path);
 		size = g_strv_length (node_names);
@@ -629,11 +626,9 @@ fill_create_widget (GdauiServerOperation *form, const gchar *path, gchar **secti
 				GtkWidget *wid;
 				GSList *lab_list, *list;
 				gint nb_labels = 0;
-				gboolean expand;
 
 				wid = fill_create_widget (form, node_names[i], NULL, &lab_list);
-				list = lab_list;
-				while (list) {
+				for (list = lab_list; list; list = list->next) {
 					GtkWidget *label_entry = (GtkWidget *) list->data;
 					GtkWidget *parent;
 
@@ -650,12 +645,9 @@ fill_create_widget (GdauiServerOperation *form, const gchar *path, gchar **secti
 					}
 					nb_labels++;
 					tab_index++;
-					list = list->next;
 				}
 				g_slist_free (lab_list);
 
-				expand = g_object_get_data (G_OBJECT (wid), "expand") ? TRUE : FALSE;
-				seq_expand = seq_expand || expand;
 				if (nb_labels > 0)
 					gtk_grid_attach (GTK_GRID (grid), wid, 1,
 							 tab_index - nb_labels, 1, nb_labels);
@@ -670,7 +662,6 @@ fill_create_widget (GdauiServerOperation *form, const gchar *path, gchar **secti
 		else
 			plwid = fill_create_widget (form, node_names[0], NULL, NULL);
 
-		g_object_set_data (G_OBJECT (plwid), "expand", GINT_TO_POINTER (seq_expand));
 		parent_path = gda_server_operation_get_node_parent (form->priv->op, path);
 		wdp = widget_data_find (form, parent_path);
 		g_assert (wdp);
@@ -797,8 +788,8 @@ gdaui_server_operation_fill (GdauiServerOperation *form)
 			}
 			case GDA_SERVER_OPERATION_STATUS_REQUIRED: {
 				gboolean expand;
+				expand = gtk_widget_get_vexpand (plwid);
 
-				expand = g_object_get_data (G_OBJECT (plwid), "expand") ? TRUE : FALSE;
 				if (label)
 					gtk_box_pack_start (GTK_BOX (container), label, FALSE, TRUE, 5);
 				if (hbox)
@@ -1214,7 +1205,7 @@ create_table_fields_array_create_widget (GdauiServerOperation *form, const gchar
 	g_signal_connect (form_iter, "row-changed",
 			  G_CALLBACK (create_table_grid_fields_iter_row_changed_cb), grid_iter);
 
-	g_object_set_data (G_OBJECT (hlayout), "expand", GINT_TO_POINTER (TRUE));
+	gtk_widget_set_vexpand (hlayout, TRUE);
 
 	{
 		GtkActionGroup *group;



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