[evolution/gtk-builder] For .../widgets/table now. Dropped e-table-field-chooser.ui.



commit e3f965447d0c36b189ba649a73c6bc5f4cfbb036
Author: Milan Crha <mcrha redhat com>
Date:   Mon Nov 2 20:01:58 2009 +0100

    For .../widgets/table now. Dropped e-table-field-chooser.ui.

 widgets/table/Makefile.am              |    3 +-
 widgets/table/e-table-config.c         |   59 ++++++++------
 widgets/table/e-table-config.ui        |  134 +++-----------------------------
 widgets/table/e-table-field-chooser.c  |   54 ++++++++++---
 widgets/table/e-table-field-chooser.h  |    1 -
 widgets/table/e-table-field-chooser.ui |  113 ---------------------------
 6 files changed, 85 insertions(+), 279 deletions(-)
---
diff --git a/widgets/table/Makefile.am b/widgets/table/Makefile.am
index 3f2b565..8df9b4b 100644
--- a/widgets/table/Makefile.am
+++ b/widgets/table/Makefile.am
@@ -1,6 +1,5 @@
 ui_DATA = 					\
-	e-table-config.ui			\
-	e-table-field-chooser.ui
+	e-table-config.ui
 
 privsolib_LTLIBRARIES = libetable.la
 
diff --git a/widgets/table/e-table-config.c b/widgets/table/e-table-config.c
index 1887b4c..226b04c 100644
--- a/widgets/table/e-table-config.c
+++ b/widgets/table/e-table-config.c
@@ -594,14 +594,13 @@ static ETableMemoryStoreColumnInfo store_columns[] = {
 	E_TABLE_MEMORY_STORE_TERMINATOR
 };
 
-static ETableModel *global_store;  /* Glade better not be reentrant any time soon. */
-
-static void
-create_global_store (ETableConfig *config)
+static ETableModel *
+create_store (ETableConfig *config)
 {
 	gint i;
+	ETableModel *store;
 
-	global_store = e_table_memory_store_new (store_columns);
+	store = e_table_memory_store_new (store_columns);
 	for (i = 0; config->source_spec->columns[i]; i++) {
 
 		gchar *text;
@@ -610,8 +609,10 @@ create_global_store (ETableConfig *config)
 			continue;
 
 		text = g_strdup (dgettext (config->domain, config->source_spec->columns[i]->title));
-		e_table_memory_store_insert_adopt (E_TABLE_MEMORY_STORE (global_store), -1, NULL, text, i);
+		e_table_memory_store_insert_adopt (E_TABLE_MEMORY_STORE (store), -1, NULL, text, i);
 	}
+
+	return store;
 }
 
 static const gchar *spec =
@@ -623,16 +624,14 @@ static const gchar *spec =
 "</ETableState>"
 "</ETableSpecification>";
 
-GtkWidget *e_table_proxy_etable_shown_new (void);
-
-GtkWidget *
-e_table_proxy_etable_shown_new (void)
+static GtkWidget *
+e_table_proxy_etable_shown_new (ETableModel *store)
 {
 	ETableModel *model = NULL;
 	GtkWidget *widget;
 	ETableScrolled *ets;
 
-	model = e_table_subset_variable_new (global_store);
+	model = e_table_subset_variable_new (store);
 
 	widget = e_table_scrolled_new (model, NULL, spec, NULL);
 	ets = E_TABLE_SCROLLED (widget);
@@ -641,16 +640,14 @@ e_table_proxy_etable_shown_new (void)
 	return widget;
 }
 
-GtkWidget *e_table_proxy_etable_available_new (void);
-
-GtkWidget *
-e_table_proxy_etable_available_new (void)
+static GtkWidget *
+e_table_proxy_etable_available_new (ETableModel *store)
 {
 	ETableModel *model;
 	GtkWidget *widget;
 	ETableScrolled *ets;
 
-	model = e_table_without_new (global_store,
+	model = e_table_without_new (store,
 				     NULL, NULL, NULL, NULL, NULL, NULL, NULL);
 
 	e_table_without_show_all (E_TABLE_WITHOUT (model));
@@ -704,8 +701,7 @@ dialog_response (GtkWidget *dialog, gint response_id, ETableConfig *config)
 /*
  * Invoked by the GtkBuilder auto-connect code
  */
-GtkWidget *e_table_proxy_gtk_combo_text_new (void);
-GtkWidget *
+static GtkWidget *
 e_table_proxy_gtk_combo_text_new (void)
 {
 	GtkCellRenderer *renderer;
@@ -811,13 +807,15 @@ configure_sort_dialog (ETableConfig *config, GtkBuilder *builder)
 {
 	GSList *l;
 	gint i;
+	const gchar *algs[] = {"alignment4", "alignment3", "alignment2", "alignment1", NULL};
 
 	for (i = 0; i < 4; i++) {
 		gchar buffer [80];
 
 		snprintf (buffer, sizeof (buffer), "sort-combo-%d", i + 1);
-		config->sort [i].combo = e_builder_get_widget (builder, buffer);
+		config->sort [i].combo = e_table_proxy_gtk_combo_text_new ();
 		gtk_widget_show (GTK_WIDGET (config->sort [i].combo));
+		gtk_container_add (GTK_CONTAINER (e_builder_get_widget (builder, algs [i])), config->sort [i].combo);
 		configure_combo_box_add (
 			GTK_COMBO_BOX (config->sort[i].combo), "", "");
 
@@ -921,13 +919,15 @@ configure_group_dialog (ETableConfig *config, GtkBuilder *builder)
 {
 	GSList *l;
 	gint i;
+	const gchar *vboxes[] = {"vbox7", "vbox9", "vbox11", "vbox13", NULL};
 
 	for (i = 0; i < 4; i++) {
 		gchar buffer [80];
 
 		snprintf (buffer, sizeof (buffer), "group-combo-%d", i + 1);
-		config->group [i].combo = e_builder_get_widget (builder, buffer);
+		config->group [i].combo = e_table_proxy_gtk_combo_text_new ();
 		gtk_widget_show (GTK_WIDGET (config->group [i].combo));
+		gtk_box_pack_start (GTK_BOX (e_builder_get_widget (builder, vboxes [i])), config->group [i].combo, FALSE, FALSE, 0);
 
 		configure_combo_box_add (
 			GTK_COMBO_BOX (config->group[i].combo), "", "");
@@ -1153,20 +1153,29 @@ static void
 configure_fields_dialog (ETableConfig *config, GtkBuilder *builder)
 {
 	GtkWidget *scrolled;
+	ETableModel *store = create_store (config);
 
-	scrolled = e_builder_get_widget (builder, "custom-available");
+	/* "custom-available" widget */
+	scrolled = e_table_proxy_etable_available_new (store);
+	gtk_widget_show (scrolled);
+	gtk_box_pack_start (GTK_BOX (e_builder_get_widget (builder, "vbox4")), scrolled, TRUE, TRUE, 0);
 	config->available = e_table_scrolled_get_table (E_TABLE_SCROLLED (scrolled));
 	g_object_get (config->available,
 		      "model", &config->available_model,
 		      NULL);
 	gtk_widget_show_all (scrolled);
+	gtk_label_set_mnemonic_widget (GTK_LABEL (e_builder_get_widget (builder, "label-available")), scrolled);
 
-	scrolled = e_builder_get_widget (builder, "custom-shown");
+	/* "custom-shown" widget */
+	scrolled = e_table_proxy_etable_shown_new (store);
+	gtk_widget_show (scrolled);
+	gtk_box_pack_start (GTK_BOX (e_builder_get_widget (builder, "vbox5")), scrolled, TRUE, TRUE, 0);
 	config->shown = e_table_scrolled_get_table (E_TABLE_SCROLLED (scrolled));
 	g_object_get (config->shown,
 		      "model", &config->shown_model,
 		      NULL);
 	gtk_widget_show_all (scrolled);
+	gtk_label_set_mnemonic_widget (GTK_LABEL (e_builder_get_widget (builder, "label-displayed")), scrolled);
 
 	connect_button (config, builder, "button-add",    G_CALLBACK (config_button_add));
 	connect_button (config, builder, "button-remove", G_CALLBACK (config_button_remove));
@@ -1174,6 +1183,8 @@ configure_fields_dialog (ETableConfig *config, GtkBuilder *builder)
 	connect_button (config, builder, "button-down",   G_CALLBACK (config_button_down));
 
 	setup_fields (config);
+
+	g_object_unref (store);
 }
 
 static void
@@ -1182,14 +1193,10 @@ setup_gui (ETableConfig *config)
 	GtkBuilder *builder;
 	gboolean can_group;
 
-	create_global_store (config);
-
 	can_group = e_table_sort_info_get_can_group (config->state->sort_info);
 	builder = gtk_builder_new ();
 	e_load_ui_builder_definition (builder, "e-table-config.ui");
 
-	g_object_unref (global_store);
-
 	config->dialog_toplevel = e_builder_get_widget (
 		builder, "e-table-config");
 
diff --git a/widgets/table/e-table-config.ui b/widgets/table/e-table-config.ui
index ff2cdb0..5e81172 100644
--- a/widgets/table/e-table-config.ui
+++ b/widgets/table/e-table-config.ui
@@ -79,7 +79,6 @@
                     <property name="yalign">0.5</property>
                     <property name="xpad">0</property>
                     <property name="ypad">0</property>
-                    <property name="mnemonic_widget">custom-available</property>
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
@@ -102,7 +101,6 @@
                     <property name="yalign">0.5</property>
                     <property name="xpad">0</property>
                     <property name="ypad">0</property>
-                    <property name="mnemonic_widget">custom-shown</property>
                   </object>
                   <packing>
                     <property name="left_attach">3</property>
@@ -132,20 +130,7 @@
                     <property name="visible">True</property>
                     <property name="homogeneous">False</property>
                     <property name="spacing">6</property>
-                    <child>
-                      <object class="Custom" id="custom-available">
-                        <property name="visible">True</property>
-                        <property name="creation_function">e_table_proxy_etable_available_new</property>
-                        <property name="int1">0</property>
-                        <property name="int2">0</property>
-                        <property name="last_modification_time">Thu, 21 Feb 2002 16:09:53 GMT</property>
-                      </object>
-                      <packing>
-                        <property name="padding">0</property>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                      </packing>
-                    </child>
+                    <!-- child id="custom-available" here -->
                   </object>
                   <packing>
                     <property name="left_attach">0</property>
@@ -159,20 +144,7 @@
                     <property name="visible">True</property>
                     <property name="homogeneous">False</property>
                     <property name="spacing">6</property>
-                    <child>
-                      <object class="Custom" id="custom-shown">
-                        <property name="visible">True</property>
-                        <property name="creation_function">e_table_proxy_etable_shown_new</property>
-                        <property name="int1">0</property>
-                        <property name="int2">0</property>
-                        <property name="last_modification_time">Thu, 21 Feb 2002 16:09:58 GMT</property>
-                      </object>
-                      <packing>
-                        <property name="padding">0</property>
-                        <property name="expand">True</property>
-                        <property name="fill">True</property>
-                      </packing>
-                    </child>
+                    <!-- child  id="custom-shown" here -->
                     <child>
                       <object class="GtkHBox" id="hbox4">
                         <property name="visible">True</property>
@@ -611,20 +583,7 @@
                             <property name="visible">True</property>
                             <property name="homogeneous">False</property>
                             <property name="spacing">0</property>
-                            <child>
-                              <object class="Custom" id="group-combo-1">
-                                <property name="visible">True</property>
-                                <property name="creation_function">e_table_proxy_gtk_combo_text_new</property>
-                                <property name="int1">0</property>
-                                <property name="int2">0</property>
-                                <property name="last_modification_time">Fri, 19 Jan 2001 04:52:09 GMT</property>
-                              </object>
-                              <packing>
-                                <property name="padding">0</property>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                              </packing>
-                            </child>
+                            <!-- child id="group-combo-1" here -->
                             <child>
                               <object class="GtkCheckButton" id="checkbutton-group-1">
                                 <property name="visible">True</property>
@@ -831,20 +790,7 @@
                             <property name="visible">True</property>
                             <property name="homogeneous">False</property>
                             <property name="spacing">0</property>
-                            <child>
-                              <object class="Custom" id="group-combo-2">
-                                <property name="visible">True</property>
-                                <property name="creation_function">e_table_proxy_gtk_combo_text_new</property>
-                                <property name="int1">0</property>
-                                <property name="int2">0</property>
-                                <property name="last_modification_time">Fri, 19 Jan 2001 04:52:14 GMT</property>
-                              </object>
-                              <packing>
-                                <property name="padding">0</property>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                              </packing>
-                            </child>
+                            <!-- child id="group-combo-2" here -->
                             <child>
                               <object class="GtkCheckButton" id="checkbutton-group-2">
                                 <property name="visible">True</property>
@@ -1051,20 +997,7 @@
                             <property name="visible">True</property>
                             <property name="homogeneous">False</property>
                             <property name="spacing">0</property>
-                            <child>
-                              <object class="Custom" id="group-combo-3">
-                                <property name="visible">True</property>
-                                <property name="creation_function">e_table_proxy_gtk_combo_text_new</property>
-                                <property name="int1">0</property>
-                                <property name="int2">0</property>
-                                <property name="last_modification_time">Fri, 19 Jan 2001 04:52:18 GMT</property>
-                              </object>
-                              <packing>
-                                <property name="padding">0</property>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                              </packing>
-                            </child>
+                            <!-- child id="group-combo-3" here -->
                             <child>
                               <object class="GtkCheckButton" id="checkbutton-group-3">
                                 <property name="visible">True</property>
@@ -1271,20 +1204,7 @@
                             <property name="visible">True</property>
                             <property name="homogeneous">False</property>
                             <property name="spacing">0</property>
-                            <child>
-                              <object class="Custom" id="group-combo-4">
-                                <property name="visible">True</property>
-                                <property name="creation_function">e_table_proxy_gtk_combo_text_new</property>
-                                <property name="int1">0</property>
-                                <property name="int2">0</property>
-                                <property name="last_modification_time">Fri, 19 Jan 2001 04:52:21 GMT</property>
-                              </object>
-                              <packing>
-                                <property name="padding">0</property>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                              </packing>
-                            </child>
+                            <!-- child id="group-combo-4" here -->
                             <child>
                               <object class="GtkCheckButton" id="checkbutton-group-4">
                                 <property name="visible">True</property>
@@ -1499,15 +1419,7 @@
                         <property name="bottom_padding">0</property>
                         <property name="left_padding">0</property>
                         <property name="right_padding">0</property>
-                        <child>
-                          <object class="Custom" id="sort-combo-4">
-                            <property name="visible">True</property>
-                            <property name="creation_function">e_table_proxy_gtk_combo_text_new</property>
-                            <property name="int1">0</property>
-                            <property name="int2">0</property>
-                            <property name="last_modification_time">Tue, 16 Jan 2001 08:33:52 GMT</property>
-                          </object>
-                        </child>
+                        <!-- child id="sort-combo-4" here -->
                       </object>
                       <packing>
                         <property name="padding">0</property>
@@ -1612,15 +1524,7 @@
                         <property name="bottom_padding">0</property>
                         <property name="left_padding">0</property>
                         <property name="right_padding">0</property>
-                        <child>
-                          <object class="Custom" id="sort-combo-3">
-                            <property name="visible">True</property>
-                            <property name="creation_function">e_table_proxy_gtk_combo_text_new</property>
-                            <property name="int1">0</property>
-                            <property name="int2">0</property>
-                            <property name="last_modification_time">Tue, 16 Jan 2001 05:22:22 GMT</property>
-                          </object>
-                        </child>
+                        <!-- child id="sort-combo-3" here -->
                       </object>
                       <packing>
                         <property name="padding">0</property>
@@ -1725,15 +1629,7 @@
                         <property name="bottom_padding">0</property>
                         <property name="left_padding">0</property>
                         <property name="right_padding">0</property>
-                        <child>
-                          <object class="Custom" id="sort-combo-2">
-                            <property name="visible">True</property>
-                            <property name="creation_function">e_table_proxy_gtk_combo_text_new</property>
-                            <property name="int1">0</property>
-                            <property name="int2">0</property>
-                            <property name="last_modification_time">Tue, 16 Jan 2001 05:22:15 GMT</property>
-                          </object>
-                        </child>
+                        <!-- child id="sort-combo-2" here -->
                       </object>
                       <packing>
                         <property name="padding">0</property>
@@ -1838,17 +1734,7 @@
                         <property name="bottom_padding">0</property>
                         <property name="left_padding">0</property>
                         <property name="right_padding">0</property>
-                        <child>
-                          <object class="Custom" id="sort-combo-1">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="has_focus">True</property>
-                            <property name="creation_function">e_table_proxy_gtk_combo_text_new</property>
-                            <property name="int1">0</property>
-                            <property name="int2">0</property>
-                            <property name="last_modification_time">Tue, 16 Jan 2001 05:22:00 GMT</property>
-                          </object>
-                        </child>
+                        <!-- child id="sort-combo-1" here -->
                       </object>
                       <packing>
                         <property name="padding">0</property>
diff --git a/widgets/table/e-table-field-chooser.c b/widgets/table/e-table-field-chooser.c
index 8784a66..8d6ddb5 100644
--- a/widgets/table/e-table-field-chooser.c
+++ b/widgets/table/e-table-field-chooser.c
@@ -29,6 +29,8 @@
 #include "e-util/e-util.h"
 #include "e-util/e-util-private.h"
 
+#include "misc/e-canvas.h"
+
 #include "e-table-field-chooser.h"
 #include "e-table-field-chooser-item.h"
 
@@ -133,25 +135,55 @@ static void resize(GnomeCanvas *canvas, ETableFieldChooser *etfc)
 	ensure_nonzero_step_increments (etfc);
 }
 
+static GtkWidget *
+create_content (GnomeCanvas **canvas)
+{
+	GtkWidget *vbox_top;
+	GtkWidget *label1;
+	GtkWidget *scrolledwindow1;
+	GtkWidget *canvas_buttons;
+
+	g_return_val_if_fail (canvas != NULL, NULL);
+
+	vbox_top = gtk_vbox_new (FALSE, 4);
+	gtk_widget_show (vbox_top);
+
+	label1 = gtk_label_new (_("To add a column to your table, drag it into\nthe location in which you want it to appear."));
+	gtk_widget_show (label1);
+	gtk_box_pack_start (GTK_BOX (vbox_top), label1, FALSE, FALSE, 0);
+	gtk_label_set_justify (GTK_LABEL (label1), GTK_JUSTIFY_CENTER);
+
+	scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
+	gtk_widget_show (scrolledwindow1);
+	gtk_box_pack_start (GTK_BOX (vbox_top), scrolledwindow1, TRUE, TRUE, 0);
+	GTK_WIDGET_UNSET_FLAGS (scrolledwindow1, GTK_CAN_FOCUS);
+	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+	canvas_buttons = e_canvas_new ();
+	gtk_widget_show (canvas_buttons);
+	gtk_container_add (GTK_CONTAINER (scrolledwindow1), canvas_buttons);
+	GTK_WIDGET_UNSET_FLAGS (canvas_buttons, GTK_CAN_FOCUS);
+	GTK_WIDGET_UNSET_FLAGS (canvas_buttons, GTK_CAN_DEFAULT);
+
+	*canvas = GNOME_CANVAS (canvas_buttons);
+
+	return vbox_top;
+}
+
 static void
 e_table_field_chooser_init (ETableFieldChooser *etfc)
 {
 	GtkWidget *widget;
 
-	etfc->builder = gtk_builder_new ();
-	e_load_ui_builder_definition (
-		etfc->builder, "e-table-field-chooser.ui");
-
-	widget = e_builder_get_widget(etfc->builder, "vbox-top");
+	widget = create_content (&etfc->canvas);
 	if (!widget) {
 		return;
 	}
-	gtk_widget_reparent(widget,
-			    GTK_WIDGET(etfc));
 
-	gtk_widget_push_colormap (gdk_rgb_get_colormap ());
+	gtk_widget_set_size_request (widget, -1, 250);
+	gtk_box_pack_start (GTK_BOX (etfc), widget, TRUE, TRUE, 0);
 
-	etfc->canvas = GNOME_CANVAS(e_builder_get_widget(etfc->builder, "canvas-buttons"));
+	gtk_widget_push_colormap (gdk_rgb_get_colormap ());
 
 	etfc->rect = gnome_canvas_item_new(gnome_canvas_root( GNOME_CANVAS( etfc->canvas ) ),
 					   gnome_canvas_rect_get_type(),
@@ -203,10 +235,6 @@ e_table_field_chooser_dispose (GObject *object)
 		g_object_unref (etfc->header);
 	etfc->header = NULL;
 
-	if (etfc->builder)
-		g_object_unref (etfc->builder);
-	etfc->builder = NULL;
-
 	if (G_OBJECT_CLASS (e_table_field_chooser_parent_class)->dispose)
 		(* G_OBJECT_CLASS (e_table_field_chooser_parent_class)->dispose) (object);
 }
diff --git a/widgets/table/e-table-field-chooser.h b/widgets/table/e-table-field-chooser.h
index ddbec47..9d890de 100644
--- a/widgets/table/e-table-field-chooser.h
+++ b/widgets/table/e-table-field-chooser.h
@@ -51,7 +51,6 @@ struct _ETableFieldChooser
 	GtkVBox parent;
 
 	/* item specific fields */
-	GtkBuilder *builder;
 	GnomeCanvas *canvas;
 	GnomeCanvasItem *item;
 



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