Hi all,
I have changed the export image window so it uses the gtk file selector
too.
I tried to setup a VM running gtk2.4 for testing, but I coudn't find an
easy way. I'm using debian, and there is no debian version using gtk2.4:
 - stable has version 2.6
 - old stable has version 2.0

so I decided to post the patch here. Could anyone test it in gtk2.4?

Thanks!

Carlos
Index: include/prototype.h
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/include/prototype.h,v
retrieving revision 1.143
diff -u -r1.143 prototype.h
--- include/prototype.h	30 Sep 2006 19:12:29 -0000	1.143
+++ include/prototype.h	3 Oct 2006 18:57:39 -0000
@@ -870,11 +870,12 @@
 gint image_1280(GtkWidget *w, TOPLEVEL *w_current);
 gint image_1600(GtkWidget *w, TOPLEVEL *w_current);
 gint image_3200(GtkWidget *w, TOPLEVEL *w_current);
-void x_image_lowlevel(TOPLEVEL *w_current, const char* filename);
+void x_image_lowlevel(TOPLEVEL *w_current, const char* filename,
+		      int desired_width, int desired_height, char *filetype);
 gint x_image_write(GtkWidget *w, TOPLEVEL *w_current);
 gint x_image_cancel(GtkWidget *w, TOPLEVEL *w_current);
 int x_image_keypress(GtkWidget *widget, GdkEventKey *event, TOPLEVEL *w_current);
-void x_image_setup(TOPLEVEL *w_current, char *filename);
+void x_image_setup(TOPLEVEL *w_current);
 GdkPixbuf *x_image_get_pixbuf (TOPLEVEL *w_current);
 /* x_log.c */
 void x_log_open ();
Index: src/g_funcs.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/g_funcs.c,v
retrieving revision 1.19
diff -u -r1.19 g_funcs.c
--- src/g_funcs.c	30 Aug 2006 11:06:16 -0000	1.19
+++ src/g_funcs.c	3 Oct 2006 18:57:40 -0000
@@ -90,9 +90,15 @@
               SCM_ARG1, "gschem-image");
 
   if (output_filename) {
-    x_image_lowlevel (global_window_current, output_filename);
+    x_image_lowlevel (global_window_current, output_filename,
+		      global_window_current->image_width,
+		      global_window_current->image_height,
+		      "png");
   } else  {
-    x_image_lowlevel (global_window_current, SCM_STRING_CHARS (filename));
+    x_image_lowlevel (global_window_current, SCM_STRING_CHARS (filename),
+		      global_window_current->image_width,
+		      global_window_current->image_height,
+		      "png");
   }
   
   return SCM_BOOL_T;
Index: src/i_callbacks.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/i_callbacks.c,v
retrieving revision 1.66
diff -u -r1.66 i_callbacks.c
--- src/i_callbacks.c	30 Sep 2006 16:01:36 -0000	1.66
+++ src/i_callbacks.c	3 Oct 2006 18:57:42 -0000
@@ -494,44 +494,7 @@
 
   exit_if_null(w_current);
 
-#if 0
-#ifndef HAS_LIBGD
-  /*! \todo integrate these to messages */
-  fprintf(stderr,
-          _("libgd not installed or disabled, "
-          "so this feature is disabled\n"));
-  s_log_message(
-		_("libgd not installed or disabled, "
-		"so this feature is disabled\n"));
-  return;
-#endif
-#endif
-  /* get the base file name */
-  if (strcmp(fnameext_get(w_current->page_current->page_filename),
-             ".sch") == 0) {
-    /* the filename ends with .sch */
-    base = fnameext_remove(w_current->page_current->page_filename);
-  } else {
-    /* the filename does not end with .sch */
-    base = g_strdup (w_current->page_current->page_filename);
-  }
-  if(base == NULL) {
-    /*! \todo do something */
-  }
-
-  /* add ".png" tp the base filename */
-  img_filename = fnameext_add(base, ".png");
-  g_free(base);
-
-  if (output_filename) {
-    x_image_setup(w_current, output_filename);
-  } else {
-    x_image_setup(w_current, img_filename);
-  }
-
-  if (img_filename) {
-    g_free(img_filename);
-  }
+  x_image_setup(w_current);
 }
 
 /*! \todo Finish function documentation!!!
Index: src/x_image.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/x_image.c,v
retrieving revision 1.26
diff -u -r1.26 x_image.c
--- src/x_image.c	30 Sep 2006 20:03:32 -0000	1.26
+++ src/x_image.c	3 Oct 2006 18:57:43 -0000
@@ -35,194 +35,202 @@
 #include <dmalloc.h>
 #endif
 
+#ifndef HAS_LIBGD
+#define X_IMAGE_SIZE_MENU_NAME "image_size_menu"
+#define X_IMAGE_TYPE_MENU_NAME "image_type_menu"
 
-/* static const   gchar   *list_item_data_key="list_item_data";	*/
+#define X_IMAGE_DEFAULT_SIZE "800x600"
+#define X_IMAGE_DEFAULT_TYPE "PNG"
 
-/*! \todo Finish function documentation!!!
- *  \brief
- *  \par Function Description
- *
- */
-gint image_320(GtkWidget *w, TOPLEVEL *w_current)
-{
-  w_current->image_width = 320;
-  w_current->image_height = 240;
-  return(0);
-}
+static char *x_image_sizes[] = {"320x240", "640x480", "800x600", "1200x768",
+                                "1280x960", "1600x1200", "3200x2400", NULL};
 
-/*! \todo Finish function documentation!!!
- *  \brief
- *  \par Function Description
- *
- */
-gint image_640(GtkWidget *w, TOPLEVEL *w_current)
-{
-  w_current->image_width = 640;
-  w_current->image_height = 480;
-  return(0);
-}
+#endif
 
-/*! \todo Finish function documentation!!!
- *  \brief
- *  \par Function Description
- *
- */
-gint image_800(GtkWidget *w, TOPLEVEL *w_current)
-{
-  w_current->image_width = 800;
-  w_current->image_height = 600;
-  return(0);
-}
+/* static const   gchar   *list_item_data_key="list_item_data";	*/
 
-/*! \todo Finish function documentation!!!
- *  \brief
- *  \par Function Description
- *
+/*! \brief Create the options of the image size combobox
+ *  \par This function adds the options of the image size to the given combobox.
+ *  \param combo [in] the combobox to add the options to.
+ *  \return nothing
+ *  \note
+ *  This function is only used in this file, there are other create_menus...
  */
-gint image_1024(GtkWidget *w, TOPLEVEL *w_current)
+static void create_size_menu (GtkComboBox *combo)
 {
-  w_current->image_width = 1024;
-  w_current->image_height = 768;
-  return(0);
-}
+  char *buf;
+  char *default_size;
+  int i, default_index = 0;
 
-/*! \todo Finish function documentation!!!
- *  \brief
- *  \par Function Description
- *
- */
-gint image_1280(GtkWidget *w, TOPLEVEL *w_current)
-{
-  w_current->image_width = 1280;
-  w_current->image_height = 960;
-  return(0);
-}
+  default_size = g_strdup_printf(X_IMAGE_DEFAULT_SIZE);
+  for (i=0; x_image_sizes[i] != NULL;i++) {
+    /* Create a new string and add it as an option*/
+    buf = g_strdup_printf(x_image_sizes[i]);
+    gtk_combo_box_append_text (GTK_COMBO_BOX (combo), buf);
+
+    /* Compare with the default size, to get the default index */
+    if (strcasecmp(buf, default_size ) == 0) {
+      default_index = i;
+    }
+    g_free(buf);
+  }
+  g_free(default_size);
 
-/*! \todo Finish function documentation!!!
- *  \brief
- *  \par Function Description
- *
- */
-gint image_1600(GtkWidget *w, TOPLEVEL *w_current)
-{
-  w_current->image_width = 1600;
-  w_current->image_height = 1200;
-  return(0);
-}
+  /* Set the default menu */
+  gtk_combo_box_set_active(GTK_COMBO_BOX (combo), default_index);
 
-/*! \todo Finish function documentation!!!
- *  \brief
- *  \par Function Description
- *
- */
-gint image_3200(GtkWidget *w, TOPLEVEL *w_current)
-{
-  w_current->image_width = 3200;
-  w_current->image_height = 2400;
-  return(0);
+  return;
 }
 
-/*! \todo Finish function documentation!!!
- *  \brief
- *  \par Function Description
- *
+#ifndef HAS_LIBGD
+/*! \brief Create the options of the image type combobox
+ *  \par This function adds the options of the image type to the given combobox.
+ *  \param combo [in] the combobox to add the options to.
+ *  \return nothing
  *  \note
- *  this is from gtktest.c and only used in this file,
- *  there are other create_menus...
+ *  This function is only used in this file, there are other create_menus...
  */
-static GtkWidget *create_menu_size(TOPLEVEL *w_current)
+static void create_type_menu(GtkComboBox *combo)
 {
-  GtkWidget *menu;
-  GtkWidget *menuitem;
-  GSList *group;
+  GSList *formats = gdk_pixbuf_get_formats ();
+  GSList *ptr;
   char *buf;
+  int i=0, default_index=0;
 
-  menu = gtk_menu_new ();
-  group = NULL;
+  ptr = formats;
+  while (ptr) {
+    if (gdk_pixbuf_format_is_writable (ptr->data)) {
+      /* Get the format description and add it to the menu */
+      buf = g_strdup_printf(gdk_pixbuf_format_get_description(ptr->data));
+      gtk_combo_box_append_text (GTK_COMBO_BOX (combo), buf);
+      
+      /* Compare the name with "png" and store the index */
+      buf = g_strdup_printf(gdk_pixbuf_format_get_name(ptr->data));
+      if (strcasecmp(buf, X_IMAGE_DEFAULT_TYPE) == 0) {
+	default_index = i;
+      }
+      g_free(buf);
+    }
+    i++;
+    ptr = ptr->next;
+  }
+  g_slist_free (formats);
+  
+  /* Set the default menu */
+  gtk_combo_box_set_active(GTK_COMBO_BOX(combo), default_index);
+    
+  return;
+}
+
+/*! \brief Given a gdk-pixbuf image type description, it returns the type, 
+ *  or extension of the image.
+ *  \par Return the gdk-pixbuf image type, or extension, which has the
+ *  given gdk-pixbuf description.
+ *  \param description The gdk-pixbuf image type description.
+ *  \return The gdk-pixbuf type, or extension, of the image.
+ *  \note This function is only used in this file.
+ */
+static char *x_image_get_type_from_description(char *description) {
+  gchar *descr = g_strdup_printf(description);
+  GSList *formats = gdk_pixbuf_get_formats ();
+  GSList *ptr;
+  gchar *ptr_descr;
+
+  ptr = formats;
+  while (ptr) {
+    ptr_descr = gdk_pixbuf_format_get_description (ptr->data);
+    if (strcasecmp(ptr_descr, descr) == 0) {
+      g_free(descr);
+      return(gdk_pixbuf_format_get_name(ptr->data));
+    }
+
+    ptr = ptr->next;
+  }
+  g_free (descr);
+  return NULL;  
+}
+
+/*! \brief Update the filename of a file dialog, when the image type has changed.
+ *  \par Given a combobox inside a file chooser dialog, this function updates
+ *  the filename displayed by the dialog, removing the current extension, and
+ *  adding the extension of the image type selected.
+ *  \param combo [in] A combobox inside a file chooser dialog, with gdk-pixbuf image type descriptions.
+ *  \param w_current [in] the TOPLEVEL structure.
+ *  \return nothing.
+ * 
+ */
+static void x_image_update_dialog_filename(GtkComboBox *combo, 
+					  TOPLEVEL *w_current) {
+
+  char* image_type_descr = NULL;
+  char *image_type = NULL;
+  char *old_image_filename = NULL;
+  char *file_basename = NULL;
+  char *file_name = NULL ;
+  char *new_image_filename = NULL;
+  GtkWidget *file_chooser;
+  
+  /* Get the current image type */
+  image_type_descr = gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo));
+  image_type = x_image_get_type_from_description(image_type_descr);
+
+  /* Get the parent dialog */
+  file_chooser = gtk_widget_get_ancestor(GTK_WIDGET(combo),
+					 GTK_TYPE_FILE_CHOOSER);
+
+  /* Get the previous file name. If none, revert to the page filename */
+  old_image_filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(file_chooser));
+  if (!old_image_filename) {
+    old_image_filename = w_current->page_current->page_filename;
+  }
+
+  /* Get the file name, without extension */
+  if (old_image_filename) {
+    file_basename = g_path_get_basename(old_image_filename);
+
+    if (g_strrstr(file_basename, ".") != NULL) {
+      file_name = g_strndup(file_basename, 
+			    g_strrstr(file_basename, ".") - file_basename);
+    }
+  }
 
-  buf = g_strdup_printf("320x240");
-  menuitem = gtk_radio_menu_item_new_with_label (group, buf);
-  g_free(buf);
-  group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
-  gtk_menu_append (GTK_MENU (menu), menuitem);
-  gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
-                      (GtkSignalFunc) image_320,
-                      w_current);
-
-  gtk_widget_show (menuitem);
-
-  buf = g_strdup_printf("640x480");
-  menuitem = gtk_radio_menu_item_new_with_label (group, buf);
-  g_free(buf);
-  group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
-  gtk_menu_append (GTK_MENU (menu), menuitem);
-  gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
-                      (GtkSignalFunc) image_640,
-                      w_current);
-
-  gtk_widget_show (menuitem);
-
-  buf = g_strdup_printf("800x600");
-  menuitem = gtk_radio_menu_item_new_with_label (group, buf);
-  g_free(buf);
-  group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
-  gtk_menu_append (GTK_MENU (menu), menuitem);
-  gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
-                      (GtkSignalFunc) image_800,
-                      w_current);
-  gtk_widget_show (menuitem);
-
-  buf = g_strdup_printf("1024x768");
-  menuitem = gtk_radio_menu_item_new_with_label (group, buf);
-  g_free(buf);
-  group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
-  gtk_menu_append (GTK_MENU (menu), menuitem);
-  gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
-                      (GtkSignalFunc) image_1024,
-                      w_current);
-  gtk_widget_show (menuitem);
-
-  buf = g_strdup_printf("1280x960");
-  menuitem = gtk_radio_menu_item_new_with_label (group, buf);
-  g_free(buf);
-  group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
-  gtk_menu_append (GTK_MENU (menu), menuitem);
-  gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
-                      (GtkSignalFunc) image_1280,
-                      w_current);
-  gtk_widget_show (menuitem);
-
-  buf = g_strdup_printf("1600x1200");
-  menuitem = gtk_radio_menu_item_new_with_label (group, buf);
-  g_free(buf);
-  group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
-  gtk_menu_append (GTK_MENU (menu), menuitem);
-  gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
-                      (GtkSignalFunc) image_1600,
-                      w_current);
-  gtk_widget_show (menuitem);
-
-  buf = g_strdup_printf("3200x2400");
-  menuitem = gtk_radio_menu_item_new_with_label (group, buf);
-  g_free(buf);
-  group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
-  gtk_menu_append (GTK_MENU (menu), menuitem);
-  gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
-                      (GtkSignalFunc) image_3200,
-                      w_current);
-  gtk_widget_show (menuitem);
+  /* Add the extension */
+  if (file_name) {
+    new_image_filename = g_strdup_printf("%s.%s", file_name, 
+					 image_type);
+  } else {
+    new_image_filename = g_strdup_printf("%s.%s", file_basename, 
+					 image_type);    
+  }
 
-  gtk_menu_set_active(GTK_MENU (menu),2);
+  /* Set the new filename */
+  if (file_chooser) {
+    gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(file_chooser),
+				      new_image_filename);
+  } else {
+    s_log_message("x_image_update_dialog_filename: No parent file chooser found!.\n");
+    fprintf(stderr, "x_image_update_dialog_filename: No parent file chooser found!.\n");
+  }
 
-  return menu;
+  g_free(file_name);
+  g_free(file_basename);
+  g_free(new_image_filename);
 }
+#endif
 
-/*! \todo Finish function documentation!!!
- *  \brief
- *  \par Function Description
+/*! \brief Write the image file, with the desired options.
+ *  \par This function writes the image file, with the options set in the
+ *  dialog by the user.
+ *  \param w_current [in] the TOPLEVEL structure.
+ *  \param filename [in] the image filename.
+ *  \param desired_width [in] the image width chosen by the user.
+ *  \param desired_height [in] the image height chosen by the user.
+ *  \param filetype [in] image filetype.
+ *  \return nothing
  *
  */
-void x_image_lowlevel(TOPLEVEL *w_current, const char* filename)
+void x_image_lowlevel(TOPLEVEL *w_current, const char* filename,
+		      int desired_width, int desired_height, char *filetype)
 {
   int width, height;
   int save_height, save_width;
@@ -230,12 +238,11 @@
   int page_width, page_height, page_center_left, page_center_top;
 #ifndef HAS_LIBGD
   GdkPixbuf *pixbuf;
-  char *filetype;
 #endif
   float prop;
 
-  width = w_current->image_width;
-  height = w_current->image_height;
+  w_current->image_width = width = desired_width;
+  w_current->image_height = height = desired_height;
 
   save_width = w_current->width;
   save_height = w_current->height;
@@ -280,16 +287,16 @@
   /* try to use recalc here */
   o_redraw_all(w_current);
 
-  printf("Calling f_image_write.\n");
   f_image_write(w_current, filename, width, height, 
                 w_current->image_color);
 #else
   pixbuf = x_image_get_pixbuf(w_current);
   if (pixbuf != NULL) {
-    filetype = g_strdup("png");
     if (!gdk_pixbuf_save(pixbuf, filename, filetype, NULL, NULL)) {
-      fprintf(stderr, "x_image_lowlevel: Unable to save PNG file  %s.\n", filename);
-      s_log_message(_("x_image_lowlevel: Unable to write PNG file.\n"));
+      fprintf(stderr, "x_image_lowlevel: Unable to save %s file  %s.\n", 
+	      filetype, filename);
+      s_log_message(_("x_image_lowlevel: Unable to write %s file %s.\n"),
+		    filetype, filename);
     }
     else {
       if (w_current->image_color == TRUE) {
@@ -331,212 +338,116 @@
 #endif
 }
 
-/*! \todo Finish function documentation!!!
- *  \brief
- *  \par Function Description
- *
- */
-gint x_image_write(GtkWidget *w, TOPLEVEL *w_current)
-{
-  const char *filename=NULL;
-
-  filename = gtk_entry_get_text(GTK_ENTRY(w_current->ifilename_entry));
-  if (filename[0] != '\0') {
-    x_image_lowlevel(w_current, filename);
-  }
-
-  gtk_widget_destroy(w_current->iwindow);
-  w_current->iwindow=NULL;
-  return(0);
-}
-
-/*! \todo Finish function documentation!!!
- *  \brief
- *  \par Function Description
- *
- */
-gint x_image_cancel(GtkWidget *w, TOPLEVEL *w_current)
-{
-  /* gtk_grab_remove(w_current->iwindow);*/
-  gtk_widget_destroy(w_current->iwindow);
-  w_current->iwindow=NULL;
-  return(0);
-}
-
-/*! \todo Finish function documentation!!!
- *  \brief
- *  \par Function Description
- *
- */
-int x_image_keypress(GtkWidget * widget, GdkEventKey * event, 
-		     TOPLEVEL * w_current)
-{
-  if (strcmp(gdk_keyval_name(event->keyval), "Escape") == 0) {
-    x_image_cancel(NULL, w_current);	
-    return TRUE;
-  }
-
-  return FALSE;
-}
+/*! \brief Display the image file selection dialog.
+ *  \par Display the image file selection dialog, allowing the user to
+ *  set several options, like image size and image type.
+ *  When the user hits "ok", then it writes the image file.
+ *  \param w_current [in] the TOPLEVEL structure.
+ *  \return nothing
+ */
+void x_image_setup (TOPLEVEL *w_current)
+{
+  GtkWidget *dialog;
+  GtkWidget *vbox1;
+  GtkWidget *hbox;
+  GtkWidget *label1;
+  GtkWidget *size_combo;
+#ifndef HAS_LIBGD
+  GtkWidget *vbox2;
+  GtkWidget *label2;
+  GtkWidget *type_combo;
+#endif
+  char *filename;
+  char *image_type_descr;
+  char *image_size;
+  char *image_type;
+  int width, height;
 
-/*! \todo Finish function documentation!!!
- *  \brief
- *  \par Function Description
- *
- */
-void x_image_setup (TOPLEVEL *w_current, char *filename)
-{
-  GtkWidget *label;
-  GtkWidget *separator;
-  GtkWidget *box;
-  GtkWidget *buttonwrite;
-  GtkWidget *buttoncancel;
-  GtkWidget *optionmenu;
-  GtkWidget *vbox, *action_area;
-
-  /* freeze the window_current pointer so that it doesn't change */
-
-  if (!w_current->iwindow) {
-
-    w_current->iwindow = x_create_dialog_box(&vbox, &action_area); 
-
-    gtk_window_position (GTK_WINDOW (w_current->iwindow),
-                         GTK_WIN_POS_MOUSE);
-
-    gtk_signal_connect (GTK_OBJECT (w_current->iwindow), "destroy",
-			GTK_SIGNAL_FUNC(destroy_window),
-			&w_current->iwindow);
-
-#if 0 /* this was causing the dialog box to not die */
-    gtk_signal_connect (GTK_OBJECT (w_current->iwindow), "delete_event",
-			GTK_SIGNAL_FUNC(destroy_window),
-			&w_current->iwindow);
-#endif
-
-    gtk_window_set_title (GTK_WINDOW (w_current->iwindow), _("Write Image..."));
-
-    buttonwrite = gtk_button_new_from_stock (GTK_STOCK_OK);
-    GTK_WIDGET_SET_FLAGS (buttonwrite, GTK_CAN_DEFAULT);
-    gtk_box_pack_start (GTK_BOX (action_area),
-			buttonwrite, TRUE, TRUE, 0);
-    gtk_signal_connect (GTK_OBJECT (buttonwrite), "clicked",
-			GTK_SIGNAL_FUNC(x_image_write), w_current);
-    gtk_widget_show (buttonwrite);
-    gtk_widget_grab_default (buttonwrite);
-
-    buttoncancel = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
-    GTK_WIDGET_SET_FLAGS (buttoncancel, GTK_CAN_DEFAULT);
-    gtk_box_pack_start (GTK_BOX (action_area),
-			buttoncancel, TRUE, TRUE, 0);
-    gtk_signal_connect ( GTK_OBJECT(buttoncancel),
-                         "clicked", GTK_SIGNAL_FUNC(x_image_cancel),
-                         w_current);
-    gtk_widget_show (buttoncancel);
+  hbox = gtk_hbox_new(FALSE, 0);
+  
+  /* Image size selection */
+  vbox1 = gtk_vbox_new(TRUE, 0);
+  label1 = gtk_label_new (_("Width x Height"));
+  gtk_widget_show (label1);
+  gtk_misc_set_alignment( GTK_MISC (label1), 0, 0);
+  gtk_misc_set_padding (GTK_MISC (label1), 0, 0);
+  gtk_box_pack_start (GTK_BOX (vbox1),
+		      label1, FALSE, FALSE, 0);
+  
+  size_combo =  gtk_combo_box_new_text ();
+  create_size_menu (GTK_COMBO_BOX(size_combo));
+  
+  gtk_widget_show (size_combo);
+  gtk_box_pack_start (GTK_BOX (vbox1), size_combo, TRUE, TRUE, 0);
+  gtk_widget_show(vbox1);
+  
+#ifndef HAS_LIBGD
+  /* Image type selection */
+  vbox2 = gtk_vbox_new(TRUE, 0);
+  label2 = gtk_label_new (_("Image type"));
+  gtk_widget_show (label2);
+  gtk_misc_set_alignment( GTK_MISC (label2), 0, 0);
+  gtk_misc_set_padding (GTK_MISC (label2), 0, 0);
+  gtk_box_pack_start (GTK_BOX (vbox2),
+		      label2, FALSE, FALSE, 0);
+  
+  type_combo = gtk_combo_box_new_text ();
+  gtk_box_pack_start (GTK_BOX (vbox2), type_combo, TRUE, TRUE, 0);
+  create_type_menu (GTK_COMBO_BOX(type_combo));
+  
+  /* Connect the changed signal to the callback, so the filename
+     gets updated every time the image type is changed */
+  g_signal_connect (type_combo, "changed", 
+		    G_CALLBACK(x_image_update_dialog_filename),
+		    w_current);
 
-#if 0
-    separator = gtk_hseparator_new ();
-    gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, TRUE, 0);
-    gtk_widget_show (separator);
+  gtk_widget_show (type_combo);
+  gtk_widget_show(vbox2);
 #endif
+  
+  /* Create the dialog */
+  dialog = gtk_file_chooser_dialog_new (_("Save as..."),
+					GTK_WINDOW(w_current->main_window),
+					GTK_FILE_CHOOSER_ACTION_SAVE,
+					GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+					GTK_STOCK_SAVE,   GTK_RESPONSE_ACCEPT,
+					NULL);
+  
+  /* Add the extra widgets to the dialog*/
+  gtk_box_pack_start(GTK_BOX(hbox), vbox1, FALSE, FALSE, 10);
+#ifndef HAS_LIBGD
+  gtk_box_pack_start(GTK_BOX(hbox), vbox2, FALSE, FALSE, 10);
+#endif
+  gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER(dialog), hbox);
+  
+  g_object_set (dialog,
+		/* GtkFileChooser */
+		"select-multiple", FALSE,
+#if ((GTK_MAJOR_VERSION > 2) || ((GTK_MAJOR_VERSION == 2) && (GTK_MINOR_VERSION >=8)))
+		/* only in GTK 2.8 */
+                "do-overwrite-confirmation", TRUE,
+#endif
+		  NULL);
+  
+  /* Update the filename */
+  x_image_update_dialog_filename(GTK_COMBO_BOX(type_combo), w_current);
 
-    box = gtk_vbox_new(FALSE, 0);
-    gtk_container_border_width(GTK_CONTAINER(box), 5);
-    gtk_container_add(GTK_CONTAINER(vbox), box);
-    gtk_widget_show(box);
-
-#if 0
-    label = gtk_label_new (_("Width"));
-    gtk_misc_set_alignment( GTK_MISC (label), 0, 0);
-    gtk_misc_set_padding (GTK_MISC (label), 0, 0);
-    gtk_box_pack_start (GTK_BOX (box),
-                        label, FALSE, FALSE, 0);
-    gtk_widget_show (label);
-
-    w_current->iwidth_entry = gtk_entry_new_with_max_length (5);
-    gtk_editable_select_region (GTK_EDITABLE (w_current->iwidth_entry), 0, -1);
-    gtk_box_pack_start (GTK_BOX (box),
-                        w_current->iwidth_entry, TRUE, TRUE, 10);
-    /*
-      gtk_signal_connect(GTK_OBJECT(w_current->width_entry),
-      "activate",
-      GTK_SIGNAL_FUNC(x_image_write),
-      w_current);
-    */
-    gtk_widget_show (w_current->iwidth_entry);
-
-    label = gtk_label_new (_("Height"));
-    gtk_misc_set_alignment( GTK_MISC (label), 0, 0);
-    gtk_misc_set_padding (GTK_MISC (label), 0, 0);
-    gtk_box_pack_start (GTK_BOX (box),
-                        label, FALSE, FALSE, 0);
-    gtk_widget_show (label);
-
-    w_current->iheight_entry = gtk_entry_new_with_max_length (5);
-    gtk_editable_select_region (GTK_EDITABLE (w_current->iheight_entry), 0, -1);
-    gtk_box_pack_start (GTK_BOX (box),
-                        w_current->iheight_entry, TRUE, TRUE, 10);
-    /*
-      gtk_signal_connect(GTK_OBJECT(w_current->height_entry),
-      "activate",
-      GTK_SIGNAL_FUNC(x_image_write),
-      w_current);
-    */
-    gtk_widget_show (w_current->iheight_entry);
-#endif
-    label = gtk_label_new (_("Width x Height"));
-    gtk_misc_set_alignment( GTK_MISC (label), 0, 0);
-    gtk_misc_set_padding (GTK_MISC (label), 0, 0);
-    gtk_box_pack_start (GTK_BOX (box),
-                        label, FALSE, FALSE, 0);
-    gtk_widget_show (label);
-
-    optionmenu = gtk_option_menu_new ();
-    gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), create_menu_size (w_current));
-    gtk_option_menu_set_history (GTK_OPTION_MENU (optionmenu), 2);
-    gtk_box_pack_start (GTK_BOX (box), optionmenu, TRUE, TRUE, 0);
-    gtk_widget_show (optionmenu);
-
-    label = gtk_label_new (_("Filename"));
-    gtk_misc_set_alignment( GTK_MISC (label), 0, 0);
-    gtk_misc_set_padding (GTK_MISC (label), 0, 0);
-    gtk_box_pack_start (GTK_BOX (box),
-                        label, FALSE, FALSE, 0);
-    gtk_widget_show (label);
-
-    w_current->ifilename_entry = gtk_entry_new_with_max_length (200);
-    gtk_editable_select_region (GTK_EDITABLE (w_current->ifilename_entry), 0, -1);
-    gtk_box_pack_start (GTK_BOX (box),
-                        w_current->ifilename_entry, TRUE, TRUE, 10);
-    gtk_signal_connect(GTK_OBJECT(w_current->ifilename_entry),
-                       "activate",
-                       GTK_SIGNAL_FUNC(x_image_write),
-                       w_current);
-    gtk_widget_show (w_current->ifilename_entry);
-
-    separator = gtk_hseparator_new ();
-    gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, TRUE, 0);
-    gtk_widget_show (separator);
+  gtk_widget_show (dialog);
+  
+  if (gtk_dialog_run((GTK_DIALOG(dialog))) == GTK_RESPONSE_ACCEPT) {    
+    image_size = gtk_combo_box_get_active_text(GTK_COMBO_BOX(size_combo));
+#ifndef HAS_LIBGD
+    image_type_descr = gtk_combo_box_get_active_text(GTK_COMBO_BOX(type_combo));
+    image_type = x_image_get_type_from_description(image_type_descr);
+#endif
+    sscanf(image_size, "%ix%i", &width, &height);
+    filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
 
-    gtk_signal_connect(GTK_OBJECT(w_current->iwindow), "key_press_event",
-                       (GtkSignalFunc) x_image_keypress, w_current);
-  }
- 
-  if (!GTK_WIDGET_VISIBLE (w_current->iwindow)) {
-    gtk_entry_set_text(GTK_ENTRY(w_current->ifilename_entry), filename);
-    /* gtk_entry_set_text(GTK_ENTRY(w_current->iwidth_entry), "800");
-       gtk_entry_set_text(GTK_ENTRY(w_current->iheight_entry), "600");*/
-
-    /*gtk_entry_select_region(GTK_ENTRY(w_current->ifilename_entry), 0, strlen(filename)); 	*/
-    w_current->image_width = 800;
-    w_current->image_height = 600;
-    gtk_widget_show (w_current->iwindow);
-    gdk_window_raise(w_current->iwindow->window);
-    /* gtk_grab_add (w_current->iwindow);*/
-  } else {
-    /* window should already be mapped */
-    /* otherwise this will core */
-    gdk_window_raise(w_current->iwindow->window);
+    x_image_lowlevel(w_current, filename, width, height, image_type);
   }
+  
+  gtk_widget_destroy (dialog);
+    
 }
 
 /*! \todo Finish function documentation!!!

_______________________________________________
geda-dev mailing list
[email protected]
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev

Reply via email to