/[pspp]/psppire/src/callbacks.c
ViewVC logotype

Diff of /psppire/src/callbacks.c

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

revision 1.3 by jmd, Wed Oct 26 08:55:09 2005 UTC revision 1.4 by jmd, Sun Oct 30 03:29:13 2005 UTC
# Line 29  Line 29 
29  #include "support.h"  #include "support.h"
30  #include "pspp-dict.h"  #include "pspp-dict.h"
31  #include <gtksheet.h>  #include <gtksheet.h>
32    #include <file-handle-def.h>
33    
34  #define _(A) A  #define _(A) A
35  #define N_(A) A  #define N_(A) A
36    
37    
38  extern PSPP_Dict *pspp_dictionary;  extern GtkWidget *window1;
39    
40    
41    static struct file_handle *psppire_handle = 0;
42    static PSPP_Dict *pspp_dictionary = 0;
43    
44    void
45    psppire_reinitialise()
46    {
47      GtkWidget *var_sheet;
48      GtkWidget *data_sheet;
49    
50      if ( pspp_dictionary )
51        g_object_unref(pspp_dictionary);
52    
53      pspp_dictionary = pspp_dict_new();
54    
55      if ( psppire_handle)
56        destroy_file_handle(psppire_handle, 0);
57      psppire_handle = 0;
58    
59      var_sheet = lookup_widget(window1,"variable_sheet");
60      var_sheet_close_all(var_sheet);
61      psppire_var_sheet_set_dictionary(var_sheet, pspp_dictionary);
62    
63      data_sheet = lookup_widget(window1,"data_sheet");
64      psppire_data_sheet_clear(data_sheet);
65      psppire_data_sheet_set_dictionary(data_sheet, pspp_dictionary);
66    
67    }
68    
69  void  void
70  on_new1_activate                       (GtkMenuItem     *menuitem,  on_new1_activate                       (GtkMenuItem     *menuitem,
71                                          gpointer         user_data)                                          gpointer         user_data)
72  {  {
73      psppire_reinitialise();
74  }  }
75    
76    
# Line 53  on_open1_activate                      ( Line 83  on_open1_activate                      (
83    
84    
85  void  void
86    recreate_file_handle(struct file_handle **handle)
87    {
88      GtkWidget *dialog;
89    
90    
91      dialog = gtk_file_chooser_dialog_new (_("Save Data As"),
92                                            GTK_WINDOW(window1),
93                                            GTK_FILE_CHOOSER_ACTION_SAVE,
94                                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
95                                            GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
96                                            NULL);
97    
98    
99      if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
100        {
101          char *filename = gtk_file_chooser_get_filename
102            (GTK_FILE_CHOOSER (dialog));
103          g_print("Filename is %s\n", filename);
104    
105          if ( *handle )
106            destroy_file_handle(*handle, 0);
107          *handle = create_file_handle_with_defaults ("__psppire_handle",
108                                                      filename);
109    
110          g_free (filename);
111    
112        }
113      
114    
115      gtk_widget_destroy (dialog);
116    
117    }
118    
119    void
120  on_save1_activate                      (GtkMenuItem     *menuitem,  on_save1_activate                      (GtkMenuItem     *menuitem,
121                                          gpointer         user_data)                                          gpointer         user_data)
122  {  {
123      if ( ! psppire_handle )
124        recreate_file_handle(&psppire_handle);
125      
126  }  }
127    
128    
# Line 64  void Line 130  void
130  on_save_as1_activate                   (GtkMenuItem     *menuitem,  on_save_as1_activate                   (GtkMenuItem     *menuitem,
131                                          gpointer         user_data)                                          gpointer         user_data)
132  {  {
133      recreate_file_handle(&psppire_handle);
134      if ( ! psppire_handle )
135        return ;
136    
137  }  }
138    
# Line 72  void Line 141  void
141  on_quit1_activate                      (GtkMenuItem     *menuitem,  on_quit1_activate                      (GtkMenuItem     *menuitem,
142                                          gpointer         user_data)                                          gpointer         user_data)
143  {  {
144      gtk_main_quit();
145  }  }
146    
147    
# Line 100  on_paste1_activate                     ( Line 169  on_paste1_activate                     (
169  }  }
170    
171    
172  extern GtkWidget *window1;  
173    
174  void  void
175  on_delete1_activate                    (GtkMenuItem     *menuitem,  on_delete1_activate                    (GtkMenuItem     *menuitem,

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

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