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

gEDA-cvs: CVS update: o_picture.c



  User: werner  
  Date: 07/01/02 10:08:34

  Modified:    .        o_picture.c
  Log:
  	* src/o_picture.c: picture_selection_dialog() replaced the
  
            GtkFileSelection dialog with a GtkFileChooserDialog
  
  
  
  
  Revision  Changes    Path
  1.9       +55 -115   eda/geda/gaf/gschem/src/o_picture.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: o_picture.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/o_picture.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -b -r1.8 -r1.9
  --- o_picture.c	18 Dec 2006 17:11:14 -0000	1.8
  +++ o_picture.c	2 Jan 2007 15:08:34 -0000	1.9
  @@ -157,82 +157,35 @@
   
   }
   
  -/*! \todo Finish function documentation!!!
  - *  \brief
  +/*! \brief Creates the add image dialog
    *  \par Function Description
  - *
  + *  This function creates the add image dialog and loads the selected picture.
    */
   void picture_selection_dialog (TOPLEVEL *w_current)
   {
  -  GtkWidget *file_selector;
  +  gchar *filename;
  +  GdkPixbuf *pixbuf;
  +  GError *error = NULL;
     
  -  /* Create the selector */
  -  if (!w_current->pfswindow) {
  -#if DEBUG
  -    printf("Creating new picture file selection dialog\n");
  -#endif
  -    w_current->pfswindow = gtk_file_selection_new (_("Please select a picture file."));
  -    file_selector = w_current->pfswindow;
  +  w_current->pfswindow = gtk_file_chooser_dialog_new ("Select a picture file...",
  +						      GTK_WINDOW(w_current->main_window),
  +						      GTK_FILE_CHOOSER_ACTION_OPEN,
  +						      GTK_STOCK_CANCEL, 
  +						      GTK_RESPONSE_CANCEL,
  +						      GTK_STOCK_OPEN, 
  +						      GTK_RESPONSE_ACCEPT,
  +						      NULL);
       if (w_current->pixbuf_filename)
  -      gtk_file_selection_set_filename(GTK_FILE_SELECTION(file_selector), w_current->pixbuf_filename);
  -    gtk_window_position(GTK_WINDOW (w_current->pfswindow),
  -			GTK_WIN_POS_NONE);
  -    
  -    gtk_window_set_transient_for(GTK_WINDOW(file_selector),
  -				 GTK_WINDOW(w_current->main_window));
  -
  -    g_signal_connect (G_OBJECT (file_selector), "destroy",
  -		      G_CALLBACK (picture_selection_cancel), w_current);
  -    
  -    
  -    g_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->ok_button),
  -		      "clicked",
  -		      G_CALLBACK (picture_selection_ok),
  -		      w_current);
  -    
  -    /* 
  -     * Ensure that the dialog box is destroyed when the user clicks the
  -     * cancel button.
  -     */
  -    g_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)->cancel_button),
  -		      "clicked",
  -		      G_CALLBACK (picture_selection_cancel),
  -		      w_current); 
  -    
  -  }
  -
  -  /* Display that dialog */
  -  if (!GTK_WIDGET_VISIBLE (w_current->pfswindow)) {
  -    gtk_widget_show (w_current->pfswindow);
  -#if 0
  -    gtk_grab_add (w_current->pfswindow);
  -#endif
  -  } else {
  -    gdk_window_raise(w_current->pfswindow->window);
  -  }
  -}
  -
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  - */
  -void picture_selection_ok (GtkWidget *widget, TOPLEVEL *w_current)
  -{
  -  GtkWidget *file_selector = (GtkWidget *)w_current->pfswindow;
  -  const gchar *selected_filename;
  -  GdkPixbuf *pixbuf;
  -  GError *error;
  +    gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(w_current->pfswindow), 
  +				  w_current->pixbuf_filename);
     
  +  if (gtk_dialog_run (GTK_DIALOG (w_current->pfswindow)) == GTK_RESPONSE_ACCEPT) {
   
  -  selected_filename = (char *) g_strdup(gtk_file_selection_get_filename (GTK_FILE_SELECTION (file_selector)));
  -#if DEBUG
  -  g_print ("Selected picture: %s\n", selected_filename);
  -#endif   
  -  picture_selection_cancel(widget, w_current);
  +    filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (w_current->pfswindow));
  +    gtk_widget_destroy(w_current->pfswindow);
  +    w_current->pfswindow=NULL;
     
  -  error = NULL;
  -  pixbuf = gdk_pixbuf_new_from_file (selected_filename, &error);
  +    pixbuf = gdk_pixbuf_new_from_file (filename, &error);
   
     if (!pixbuf) {
       GtkWidget *dialog;
  @@ -243,48 +196,35 @@
                                        GTK_BUTTONS_CLOSE,
                                        _("Failed to load picture: %s"),
                                        error->message);
  -    g_error_free (error);
  +      /* Wait for any user response */
  +      gtk_dialog_run (GTK_DIALOG (dialog));
        
  -    g_signal_connect (dialog, "response",
  -                      G_CALLBACK (gtk_widget_destroy), NULL);
  -
  -    gtk_widget_show (dialog);
  -    return;
  +      g_error_free (error);
  +      gtk_widget_destroy(dialog);
     }
  -
  +    else {
   #if DEBUG
     printf("Picture loaded succesfully.\n");
   #endif
   
  -  exit_if_null(w_current);
  -
     o_erase_rubber(w_current);
  -
     i_update_middle_button(w_current, i_callback_add_picture, _("Picture"));
     w_current->inside_action = 0;
   
  -  o_picture_set_pixbuf(w_current, pixbuf, (char *) selected_filename);
  -  /* o_picture_set_pixbuf allocates memory for filename, so free the pointer */
  -  g_free((char *)selected_filename);
  +      o_picture_set_pixbuf(w_current, pixbuf, filename);
   
     w_current->page_current->CHANGED=1;
  -
     i_allow_expose();
     i_set_state(w_current, DRAWPICTURE);
  +    }
  +    g_free (filename);
  +  }
      
  -}
  -
  -/*! \todo Finish function documentation!!!
  - *  \brief
  - *  \par Function Description
  - *
  - */
  -void picture_selection_cancel (GtkWidget *widget, TOPLEVEL *w_current)
  -{
  -  i_set_state(w_current, SELECT);
     i_update_toolbar(w_current);
  +  if (w_current->pfswindow) {
     gtk_widget_destroy(w_current->pfswindow);
     w_current->pfswindow=NULL;
  +  }
   }
   
   /*! \todo Finish function documentation!!!
  
  
  


_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs