/[beaver]/beaver/src/filesops.c
ViewVC logotype

Diff of /beaver/src/filesops.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by mikix, Mon Mar 24 20:06:10 2003 UTC revision 1.6 by mikix, Fri Mar 28 07:22:53 2003 UTC
# Line 416  void autosave (gint Delay) Line 416  void autosave (gint Delay)
416        }        }
417  }  }
418    
419    gboolean save_a_copy_window_new (void)
420    {
421      GtkWidget *FileSelector;
422      gchar *Title, *Directory;
423      gint response;
424      const gchar *file;
425      gboolean rv = TRUE;
426    
427      Title = g_strdup_printf(_("Save a Copy of \"%s\" As..."),
428            FPROPS(gtk_notebook_get_current_page(GTK_NOTEBOOK(MainNotebook)), BaseName));
429      FileSelector = gtk_file_selection_new (Title);
430      Directory = DIRECTORY;
431      gtk_file_selection_set_filename (GTK_FILE_SELECTION(FileSelector),
432                                       Directory);
433      gtk_window_set_modal (GTK_WINDOW(FileSelector), TRUE);
434      response = gtk_dialog_run (GTK_DIALOG (FileSelector));
435      
436      file = gtk_file_selection_get_filename (GTK_FILE_SELECTION (FileSelector));
437      
438      gtk_widget_destroy (FileSelector);
439      switch (response)
440      {
441      case GTK_RESPONSE_OK:
442            save_a_copy_func (file);
443            break;
444      default:
445            rv = FALSE;
446            break;
447      }
448      
449      g_free (Title);
450      
451      return rv;
452    }
453    
454    void save_a_copy_func (const gchar *FileName)
455    {
456      FILE *File;
457      struct stat Stats;
458      gint CurrentPage;
459    
460      CurrentPage = gtk_notebook_get_current_page (GTK_NOTEBOOK(MainNotebook));
461      if (stat (FileName, &Stats) != -1)
462        if ((Stats.st_mode & S_IFMT) == S_IFDIR) return;
463      if ((File = fopen (FileName, "w")))
464        {
465          gchar *Buffer;  
466          GtkWidget *CurrentText;
467          gint length;
468    
469          CurrentText = FPROPS(CurrentPage, Text);
470          Buffer = get_text (gtk_text_view_get_buffer(
471                             GTK_TEXT_VIEW(CurrentText)));
472          length = gtk_text_buffer_get_char_count(
473                       gtk_text_view_get_buffer(GTK_TEXT_VIEW(CurrentText)));
474          fwrite (Buffer, length, 1, File);
475          g_free (Buffer);
476          fclose (File);
477          print_msg (g_strdup_printf (_("File \"%s\" saved."), FPROPS(CurrentPage, BaseName)));
478        }
479      else
480        {
481          print_msg (g_strdup_printf (_("Unable to save - \"%s\" is write-protected."), FPROPS(CurrentPage, BaseName)));
482        }
483     }
484    
485  gboolean save_file_as_window_new (void)  gboolean save_file_as_window_new (void)
486  {  {
# Line 659  void save_all (void) Line 724  void save_all (void)
724    gtk_notebook_set_current_page (GTK_NOTEBOOK(MainNotebook), CurrentPage);    gtk_notebook_set_current_page (GTK_NOTEBOOK(MainNotebook), CurrentPage);
725  }  }
726    
727    void save_a_copy (void)
728    {
729      if (!OpenedFilesCnt) return;
730      save_a_copy_window_new ();
731    }
732    
733    
734  /* Display a Dialog box which ask you wether you wanna save or not the  /* Display a Dialog box which ask you wether you wanna save or not the
735     modified files when you quit or when you close these files */     modified files when you quit or when you close these files */

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26