FileChooser overwrite_confirmation



My application forces the extension of saved files, in this case, to
be .pdf. Up to now, I have used my own dialog box to check if a file
should be overwritten. Just, spotting that the FileChooser has
set_do_overwrite_confirmation (TRUE) - and wanting to use it for
consistency with other Gtk+ apps, I am having trouble with the
possibility that the user types in a new filename that, without an
extension, does not already exist, but with one, does.

I can't seem to get FileChooser to recheck the filename. Should I be
emitting a specific signal?

Below is a code fragment showing where I am.

Thanks for any ideas

Jeff

  my $file_chooser = Gtk2::FileChooserDialog -> new('PDF filename',
                                                    $window, 'save',
                                                    'gtk-cancel' => 'cancel',
                                                    'gtk-save' => 'ok');
  $file_chooser -> set_default_response('ok');
 $file_chooser->set_do_overwrite_confirmation (TRUE);
 $file_chooser -> signal_connect (response => sub {
  my ($dialog, $response) = @_;
  if ($response eq 'ok') {
   my $filename = $file_chooser -> get_filename;
   if ($filename !~ /\.pdf$/i) {
    $filename = $filename.'.pdf';
    $file_chooser -> set_filename($filename);
    $file_chooser->response ('ok');
#    $file_chooser -> signal_emit('file-activated');
   }
   else {
    $file_chooser -> destroy;
[do something with file]
   }
  }
 });
 $file_chooser -> show;



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