[goffice] Use GSettings as default and redesigned the image selector.



commit 1e1f9683b589c35324edc40de47979bf60386efb
Author: Jean Brefort <jean brefort normalesup org>
Date:   Fri Oct 21 14:26:45 2011 +0200

    Use GSettings as default and redesigned the image selector.

 ChangeLog                    |   11 ++
 NEWS                         |    1 +
 configure.in                 |   35 +-----
 goffice/graph/gog-renderer.c |    4 -
 goffice/gtk/go-image-sel.c   |  142 +++++++++++----------
 goffice/gtk/go-image-sel.ui  |  282 ++++++++++++++++--------------------------
 goffice/gtk/goffice-gtk.c    |    8 ++
 goffice/gtk/goffice-gtk.h    |    1 +
 8 files changed, 204 insertions(+), 280 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2ade617..28fdc2e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2011-10-21  Jean Brefort  <jean brefort normalesup org>
+
+	* configure.in: make GSettings the default configuration backend.
+	* goffice/graph/gog-renderer.c (gog_renderer_export_image): use GdkPixbuf
+	even in the no gtk build.
+	* goffice/gtk/go-image-sel.c: redesigned.
+	* goffice/gtk/go-image-sel.ui: ditto.
+	* goffice/gtk/goffice-gtk.c (go_gtk_select_image),
+	(go_gtk_select_image_with_extra_widget): new function.
+	* goffice/gtk/goffice-gtk.h: ditto.
+
 2011-10-18  Morten Welinder  <terra gnome org>
 
 	* goffice/gtk/goffice-gtk.c (go_gtk_builder_new): Handle
diff --git a/NEWS b/NEWS
index ed9f13a..602c18f 100644
--- a/NEWS
+++ b/NEWS
@@ -30,6 +30,7 @@ Jean:
 	* Make sheet widgets scalable. [#605434]
 	* Update series labels when needed. [658527]
 	* Fix background images issues in graphs. [#660917]
+	* Make GSettings trhe default configuration backend.
 
 Morten:
 	* Recognize scientific formats with longer exponents.
diff --git a/configure.in b/configure.in
index 3bde2d5..444a8bb 100644
--- a/configure.in
+++ b/configure.in
@@ -103,6 +103,7 @@ goffice_reqs="
 	pangocairo		>= 1.24.0
 	cairo			>= 1.10.0
 	librsvg-2.0		>= 2.22.0
+	gdk-pixbuf-2.0	>= 2.22.0
 "
 
 goffice_gtk_reqs="
@@ -135,18 +136,6 @@ if test "x$goffice_with_lasem" = "xtrue" ; then
 	EXTRA_DEPS="$EXTRA_DEPS lasem-0.4"
 fi
 
-goffice_with_rsvg=false
-AC_ARG_WITH(librsvg, [  --with-librsvg          Build with librsvg use])
-if test "x$with_librsvg" = xyes; then
-	PKG_CHECK_MODULES(rsvg, librsvg-2.0 >= 2.22.0)
-	goffice_with_rsvg=true
-fi
-if test "x$goffice_with_rsvg" = "xtrue" ; then
-	AC_DEFINE(GOFFICE_WITH_RSVG, 1, [Define if librsvg is used])
-	goffice_reqs="$goffice_reqs librsvg-2.0 >= 2.22.0 "
-	EXTRA_DEPS="$EXTRA_DEPS librsvg-2.0"
-fi
-
 AM_CONDITIONAL(GOFFICE_WITH_LASEM, $goffice_with_lasem)
 
 
@@ -243,9 +232,7 @@ case $with_config_backend in
 		AC_CHECK_LIB(gio-2.0,[g_settings_new],
 		[
 			AC_DEFINE(GOFFICE_WITH_GSETTINGS, 1, [Goffice uses gsettings])
-			conf_msg="GSettings
-
-WARNING: the GSettings backend is experimental, use it with care"
+			conf_msg="GSettings"
 		],[
 			AC_MSG_ERROR([ GSettings not available ])
 		])
@@ -258,22 +245,8 @@ WARNING: the GSettings backend is experimental, use it with care"
 			AC_DEFINE(GOFFICE_WITH_WINREG, 1, [Goffice uses Windows registry])
 			conf_msg="Windows registry"
 		else
-			PKG_CHECK_MODULES(GCONF, gconf-2.0,
-			[
-				EXTRA_DEPS="$EXTRA_DEPS gconf-2.0"
-				AC_DEFINE(GOFFICE_WITH_GCONF, 1, [Goffice uses gconf])
-				conf_msg="GConf"
-				goffice_reqs="$goffice_reqs gconf-2.0"
-			],[
-dnl Never use GSettings if not explicitly requested
-dnl				AC_CHECK_LIB(glib-2.0,[g_settings_new],
-dnl					[
-dnl						AC_DEFINE(GOFFICE_WITH_GSETTINGS, 1, [Goffice uses gsettings])
-dnl						conf_msg="GSettings"
-dnl					],[
-						conf_msg="keyfile"
-dnl					])
-			])
+			AC_DEFINE(GOFFICE_WITH_GSETTINGS, 1, [Goffice uses gsettings])
+			conf_msg="GSettings"
 		fi
 		;;
 esac
diff --git a/goffice/graph/gog-renderer.c b/goffice/graph/gog-renderer.c
index 96e6bee..bc2ee2f 100644
--- a/goffice/graph/gog-renderer.c
+++ b/goffice/graph/gog-renderer.c
@@ -1524,10 +1524,8 @@ gog_renderer_export_image (GogRenderer *rend, GOImageFormat format,
 	cairo_surface_t *surface = NULL;
 	gboolean status;
 	GdkPixbuf *pixbuf;
-#ifdef GOFFICE_WITH_GTK
 	GdkPixbuf *output_pixbuf;
 	gboolean result;
-#endif
 	double width_in_pts, height_in_pts;
 
 	g_return_val_if_fail (GOG_IS_RENDERER (rend), FALSE);
@@ -1594,7 +1592,6 @@ do_export_vectorial:
 			if (pixbuf == NULL)
 				return FALSE;
 			format_info = go_image_get_format_info (format);
-#ifdef GOFFICE_WITH_GTK
 			if (!format_info->alpha_support)
 				output_pixbuf = gdk_pixbuf_composite_color_simple
 					(pixbuf,
@@ -1612,7 +1609,6 @@ do_export_vectorial:
 			if (!format_info->alpha_support)
 				g_object_unref (output_pixbuf);
 			return result;
-#endif
 	}
 
 	return FALSE;
diff --git a/goffice/gtk/go-image-sel.c b/goffice/gtk/go-image-sel.c
index 55c967a..7dd6fbc 100644
--- a/goffice/gtk/go-image-sel.c
+++ b/goffice/gtk/go-image-sel.c
@@ -38,73 +38,81 @@ struct _GOImageSelState {
 
 	/* GUI accessors */
 	GtkBuilder    *gui;
-	GtkEntry    *name_entry;
 	GtkIconView *icon_view;
 	GtkListStore *model;
-	GtkWidget *add_button;
+	GtkWidget *ok_button;
 	char *uri;
+	char *name;
 };
 
 static void
-cb_file_image_select (GtkWidget *cc, GOImageSelState *state)
+cb_entry_destroyed (GtkEntry *entry, G_GNUC_UNUSED GdkEvent *event, GOImageSelState *state)
 {
-	g_free (state->uri);
-
-	state->uri = go_gtk_select_image (GTK_WINDOW (gtk_widget_get_toplevel (cc)),
-				   NULL);
-	gtk_widget_set_sensitive (state->add_button,
-	                          state->uri != NULL && strlen (gtk_entry_get_text (state->name_entry)) > 0);
+	char const *new_name = gtk_entry_get_text (entry);
+	if (new_name && *new_name && !go_doc_get_image (state->doc, new_name)) {
+		g_free (state->name);
+		state->name = g_strdup (new_name);
+	}
 }
 
 static void
-cb_image_add (GtkWidget *cc, GOImageSelState *state)
+cb_file_image_select (GtkWidget *cc, GOImageSelState *state)
 {
-	char const *name;
-	char *image_name, *filename;
+	GtkWidget *box, *w;
+	char *new_name, *filename;
+	unsigned n = 1; 
 	GError *error = NULL;
 	GOImage *image, *real_image;
-	if (!state->uri)
-		return;
-	name = gtk_entry_get_text (state->name_entry);
-	filename = go_filename_from_uri (state->uri);
-	g_free (state->uri);
-	state->uri = NULL;
-	if (!(name && strlen (name))) {
-		char *basename = g_path_get_basename (filename);
-		char *dot = strrchr (basename, '.');
-		image_name = (dot)? g_strndup (basename, dot - basename): g_strdup (basename);
-		g_free (basename);
-	} else
-		image_name = g_strdup (name);
-	image = go_image_new_from_file (filename, &error);
-	g_free (filename);
-	if (error) {
-		g_warning ("%s", error->message);
-		g_error_free (error);
-		error = NULL;
+
+	/* FIXME: use a GtkGrid there */
+	box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+	w = gtk_label_new (_("New image name"));
+	gtk_container_add (GTK_CONTAINER (box), w);
+	w = gtk_entry_new ();
+	while (1) {
+		new_name = g_strdup_printf (_("image%u"), n++);
+		if (!go_doc_get_image (state->doc, new_name))
+			break;
+		g_free (new_name);
 	}
-	if (image) {
-		real_image = go_doc_add_image (state->doc, image_name, image);
-		if (real_image == image) {
-			/* add the new image to the list */
-			GtkTreeIter iter;
-			GtkTreePath *path;
-			gtk_list_store_append (state->model, &iter);
-			gtk_list_store_set (state->model, &iter,
-					    0, go_image_get_thumbnail (real_image),
-					    1, go_image_get_name (real_image),
-					    -1);
-			path = gtk_tree_model_get_path (GTK_TREE_MODEL (state->model), &iter);
-			gtk_icon_view_select_path (state->icon_view, path);
-			gtk_tree_path_free (path);
+	gtk_entry_set_text (GTK_ENTRY (w), new_name);
+	g_signal_connect (G_OBJECT (w), "focus-out-event", G_CALLBACK (cb_entry_destroyed), state);
+	state->name = new_name;
+	gtk_container_add (GTK_CONTAINER (box), w);
+	gtk_widget_show_all (box);
+	
+	g_free (state->uri);
+
+	state->uri = go_gtk_select_image_with_extra_widget (GTK_WINDOW (gtk_widget_get_toplevel (cc)),
+				   NULL, box);
+	if (state->uri) {
+		filename = go_filename_from_uri (state->uri);
+		image = go_image_new_from_file (filename, &error);
+		g_free (filename);
+		if (error) {
+			g_warning ("%s", error->message);
+			g_error_free (error);
+			error = NULL;
+		}
+		if (image) {
+			real_image = go_doc_add_image (state->doc, state->name, image);
+			if (real_image == image) {
+				/* add the new image to the list */
+				GtkTreeIter iter;
+				GtkTreePath *path;
+				gtk_list_store_append (state->model, &iter);
+				gtk_list_store_set (state->model, &iter,
+						    0, go_image_get_thumbnail (real_image),
+						    1, go_image_get_name (real_image),
+						    -1);
+				path = gtk_tree_model_get_path (GTK_TREE_MODEL (state->model), &iter);
+				gtk_icon_view_select_path (state->icon_view, path);
+				gtk_tree_path_free (path);
+			}
+			g_object_unref (image);
 		}
-		g_object_unref (image);
 	}
-	g_free (image_name);
-	gtk_entry_set_text (state->name_entry, "");
-	gtk_widget_set_sensitive (state->add_button, FALSE);
 }
-
 static gint
 sort_func (GtkTreeModel *model,
 	   GtkTreeIter  *a,
@@ -127,6 +135,7 @@ sort_func (GtkTreeModel *model,
 static gboolean
 delete_event_cb (GtkWidget *cc, GdkEvent *event, GOImageSelState *state)
 {
+	g_free (state->name);
 	g_free (state->uri);
 	g_free (state);
 	return FALSE;
@@ -154,6 +163,7 @@ ok_button_clicked_cb (GtkWidget *cc, GOImageSelState *state)
 	} else
 		*(state->result) = NULL;
 	gtk_widget_destroy (state->dialog);
+	g_free (state->name);
 	g_free (state->uri);
 	g_free (state);
 }
@@ -183,10 +193,12 @@ add_image_cb (char const *key, GOImage *image, GOImageSelState *state)
 }
 
 static void
-name_entry_activate_cb (GOImageSelState *state)
+cb_selection_changed (GtkIconView *view, GOImageSelState *state)
 {
-	gtk_widget_set_sensitive (state->add_button,
-	                          state->uri != NULL && strlen (gtk_entry_get_text (state->name_entry)) > 0);
+	GList *l = gtk_icon_view_get_selected_items (view);
+	gtk_widget_set_sensitive (state->ok_button, l != NULL);
+	g_list_foreach (l, (GFunc) gtk_tree_path_free, NULL);
+	g_list_free (l);
 }
 
 /**
@@ -223,14 +235,6 @@ go_image_sel_new (GODoc *doc, GOCmdContext *cc, GOImage **image)
 		"clicked",
 		G_CALLBACK (cb_file_image_select), state);
 
-	state->add_button = go_gtk_builder_get_widget (state->gui, "add");
-	g_signal_connect (G_OBJECT (state->add_button),
-		"clicked",
-		G_CALLBACK (cb_image_add), state);
-	gtk_widget_set_sensitive (state->add_button, FALSE);
-
-	state->name_entry = GTK_ENTRY (gtk_builder_get_object (state->gui, "name-entry"));
-	g_signal_connect_swapped (G_OBJECT (state->name_entry), "activate", G_CALLBACK (name_entry_activate_cb), state);
 	state->icon_view = GTK_ICON_VIEW (gtk_builder_get_object (state->gui, "image-iconview"));
 	state->model = gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_STRING);
 	gtk_icon_view_set_model (state->icon_view , GTK_TREE_MODEL (state->model));
@@ -238,6 +242,11 @@ go_image_sel_new (GODoc *doc, GOCmdContext *cc, GOImage **image)
 	gtk_icon_view_set_pixbuf_column (state->icon_view, 0);
 	g_object_unref (state->model);
 
+	/* populate the list */
+	hash = go_doc_get_images (doc);
+	if (hash)
+		g_hash_table_foreach (hash, (GHFunc) add_image_cb, state);
+
 	/* Set sort column and function */
 	gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (state->model),
 					       sort_func,
@@ -245,15 +254,12 @@ go_image_sel_new (GODoc *doc, GOCmdContext *cc, GOImage **image)
 	gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (state->model),
 					    GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
 					    GTK_SORT_ASCENDING);
-
-	/* populate the list */
-	hash = go_doc_get_images (doc);
-	if (hash)
-		g_hash_table_foreach (hash, (GHFunc) add_image_cb, state);
+	g_signal_connect (state->icon_view, "selection-changed", G_CALLBACK (cb_selection_changed), state);
 
 	/* buttons */
-	w = go_gtk_builder_get_widget (state->gui, "ok-button");
-	g_signal_connect (w, "clicked", G_CALLBACK (ok_button_clicked_cb), state);
+	state->ok_button = go_gtk_builder_get_widget (state->gui, "ok-button");
+	g_signal_connect (state->ok_button, "clicked", G_CALLBACK (ok_button_clicked_cb), state);
+	gtk_widget_set_sensitive (state->ok_button, FALSE);
 	w = go_gtk_builder_get_widget (state->gui, "cancel-button");
 	g_signal_connect (w, "clicked", G_CALLBACK (cancel_button_clicked_cb), state);
 
diff --git a/goffice/gtk/go-image-sel.ui b/goffice/gtk/go-image-sel.ui
index e6ccb53..1ca64e9 100644
--- a/goffice/gtk/go-image-sel.ui
+++ b/goffice/gtk/go-image-sel.ui
@@ -4,6 +4,7 @@
   <object class="GtkDialog" id="go-image-sel">
     <property name="can_focus">False</property>
     <property name="border_width">5</property>
+    <property name="title" translatable="yes">Select an image</property>
     <property name="modal">True</property>
     <property name="window_position">center-on-parent</property>
     <property name="type_hint">dialog</property>
@@ -13,230 +14,155 @@
         <property name="can_focus">False</property>
         <property name="orientation">vertical</property>
         <property name="spacing">2</property>
-        <child internal-child="action_area">
-          <object class="GtkButtonBox" id="dialog-action_area1">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="layout_style">end</property>
-            <child>
-              <placeholder/>
-            </child>
-            <child>
-              <object class="GtkButton" id="cancel-button">
-                <property name="label">gtk-cancel</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="ok-button">
-                <property name="label">gtk-ok</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">2</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="pack_type">end</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
         <child>
-          <object class="GtkBox" id="image-vbox">
+          <object class="GtkGrid" id="grid1">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="orientation">vertical</property>
-            <property name="spacing">6</property>
+            <property name="hexpand">True</property>
+            <property name="vexpand">True</property>
+            <property name="row_spacing">6</property>
+            <property name="column_spacing">12</property>
             <child>
               <object class="GtkScrolledWindow" id="scrolledwindow1">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
+                <property name="hexpand">True</property>
+                <property name="vexpand">True</property>
                 <child>
                   <object class="GtkIconView" id="image-iconview">
                     <property name="width_request">200</property>
                     <property name="height_request">150</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
+                    <property name="hexpand">True</property>
+                    <property name="vexpand">True</property>
                     <property name="reorderable">True</property>
                   </object>
                 </child>
               </object>
               <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkSeparator" id="hseparator1">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
+                <property name="left_attach">0</property>
+                <property name="top_attach">0</property>
+                <property name="width">3</property>
+                <property name="height">1</property>
               </packing>
             </child>
             <child>
-              <object class="GtkBox" id="vbox1">
+              <object class="GtkButton" id="file-image-select">
+                <property name="use_action_appearance">False</property>
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="orientation">vertical</property>
-                <property name="spacing">5</property>
-                <child>
-                  <object class="GtkLabel" id="label1">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="xalign">0</property>
-                    <property name="label" translatable="yes">&lt;b&gt;Add an image&lt;/b&gt;</property>
-                    <property name="use_markup">True</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">True</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
                 <child>
-                  <object class="GtkAlignment" id="alignment1">
+                  <object class="GtkAlignment" id="alignment2">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="left_padding">15</property>
+                    <property name="xscale">0</property>
+                    <property name="yscale">0</property>
                     <child>
-                      <object class="GtkTable" id="new-image-table">
+                      <object class="GtkBox" id="hbox4">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="n_rows">2</property>
-                        <property name="n_columns">3</property>
-                        <property name="column_spacing">15</property>
-                        <property name="row_spacing">5</property>
+                        <property name="spacing">2</property>
                         <child>
-                          <object class="GtkButton" id="add">
-                            <property name="label">gtk-add</property>
+                          <object class="GtkImage" id="image1">
                             <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">True</property>
-                            <property name="use_action_appearance">False</property>
-                            <property name="use_stock">True</property>
-                          </object>
-                          <packing>
-                            <property name="left_attach">2</property>
-                            <property name="right_attach">3</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkButton" id="file-image-select">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="receives_default">False</property>
-                            <property name="use_action_appearance">False</property>
-                            <child>
-                              <object class="GtkAlignment" id="alignment2">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="xscale">0</property>
-                                <property name="yscale">0</property>
-                                <child>
-                                  <object class="GtkBox" id="hbox4">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">False</property>
-                                    <property name="spacing">2</property>
-                                    <child>
-                                      <object class="GtkImage" id="image1">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                        <property name="stock">gtk-open</property>
-                                      </object>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                        <property name="fill">False</property>
-                                        <property name="position">0</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <object class="GtkLabel" id="label32">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                        <property name="label" translatable="yes">_Select...</property>
-                                        <property name="use_underline">True</property>
-                                      </object>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                        <property name="fill">False</property>
-                                        <property name="position">1</property>
-                                      </packing>
-                                    </child>
-                                  </object>
-                                </child>
-                              </object>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="right_attach">2</property>
-                            <property name="x_options">GTK_SHRINK | GTK_FILL</property>
-                            <property name="y_options">GTK_SHRINK</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkEntry" id="name-entry">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="stock">gtk-open</property>
                           </object>
                           <packing>
-                            <property name="left_attach">1</property>
-                            <property name="right_attach">2</property>
-                            <property name="top_attach">1</property>
-                            <property name="bottom_attach">2</property>
-                            <property name="y_options">GTK_FILL</property>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">0</property>
                           </packing>
                         </child>
                         <child>
-                          <object class="GtkLabel" id="label2">
+                          <object class="GtkLabel" id="label32">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
-                            <property name="xalign">0</property>
-                            <property name="label" translatable="yes">Name:</property>
+                            <property name="label" translatable="yes">_Select a new image</property>
+                            <property name="use_underline">True</property>
                           </object>
                           <packing>
-                            <property name="top_attach">1</property>
-                            <property name="bottom_attach">2</property>
-                            <property name="x_options">GTK_FILL</property>
-                            <property name="y_options">GTK_FILL</property>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">1</property>
                           </packing>
                         </child>
-                        <child>
-                          <placeholder/>
-                        </child>
                       </object>
                     </child>
                   </object>
-                  <packing>
-                    <property name="expand">True</property>
-                    <property name="fill">True</property>
-                    <property name="position">1</property>
-                  </packing>
                 </child>
               </object>
               <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">1</property>
+                <property name="width">3</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="dialog-action_area1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="valign">end</property>
+            <property name="layout_style">end</property>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <object class="GtkButton" id="cancel-button">
+                <property name="label">gtk-cancel</property>
+                <property name="use_action_appearance">False</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="ok-button">
+                <property name="label">gtk-ok</property>
+                <property name="use_action_appearance">False</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_action_appearance">False</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
                 <property name="expand">False</property>
                 <property name="fill">False</property>
                 <property name="position">2</property>
@@ -246,6 +172,7 @@
           <packing>
             <property name="expand">False</property>
             <property name="fill">True</property>
+            <property name="pack_type">end</property>
             <property name="position">1</property>
           </packing>
         </child>
@@ -253,6 +180,7 @@
           <object class="GtkSeparator" id="hseparator2">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
+            <property name="valign">center</property>
           </object>
           <packing>
             <property name="expand">False</property>
diff --git a/goffice/gtk/goffice-gtk.c b/goffice/gtk/goffice-gtk.c
index 128d7dc..d457a72 100644
--- a/goffice/gtk/goffice-gtk.c
+++ b/goffice/gtk/goffice-gtk.c
@@ -724,6 +724,12 @@ gui_image_chooser_new (gboolean is_save)
 char *
 go_gtk_select_image (GtkWindow *toplevel, char const *initial)
 {
+	return go_gtk_select_image_with_extra_widget (toplevel, initial, NULL);
+}
+
+char *
+go_gtk_select_image_with_extra_widget (GtkWindow *toplevel, char const *initial, GtkWidget *extra)
+{
 	char const *key = "go_gtk_select_image";
 	char *uri = NULL;
 	GtkFileChooser *fsel;
@@ -731,6 +737,8 @@ go_gtk_select_image (GtkWindow *toplevel, char const *initial)
 	g_return_val_if_fail (GTK_IS_WINDOW (toplevel), NULL);
 
 	fsel = gui_image_chooser_new (FALSE);
+	if (GTK_IS_WIDGET (extra))
+		gtk_file_chooser_set_extra_widget (fsel, extra);
 
 	if (!initial)
 		initial = g_object_get_data (G_OBJECT (toplevel), key);
diff --git a/goffice/gtk/goffice-gtk.h b/goffice/gtk/goffice-gtk.h
index ff18df9..5d6312b 100644
--- a/goffice/gtk/goffice-gtk.h
+++ b/goffice/gtk/goffice-gtk.h
@@ -106,6 +106,7 @@ void	   go_gtk_help_button_init	(GtkWidget *w, char const *data_dir,
 void       go_gtk_nonmodal_dialog	(GtkWindow *toplevel, GtkWindow *dialog);
 gboolean   go_gtk_file_sel_dialog	(GtkWindow *toplevel, GtkWidget *w);
 char	  *go_gtk_select_image		(GtkWindow *toplevel, const char *initial);
+char	  *go_gtk_select_image_with_extra_widget (GtkWindow *toplevel, char const *initial, GtkWidget *extra);
 char      *go_gui_get_image_save_info 	(GtkWindow *toplevel,
 					 GSList *supported_formats,
 					 GOImageFormat *ret_format,



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