/* Callback for data_save_as action. Prompt for a filename and save */
static void
-data_save_as_dialog (GtkAction *action, PsppireDataWindow *de)
+data_save_as_dialog (PsppireDataWindow *de)
{
GtkWidget *button_sys;
GtkWidget *dialog =
If there's an existing file name, then just save,
otherwise prompt for a file name, then save */
static void
-data_save (GtkAction *action, PsppireDataWindow *de)
+data_save (PsppireDataWindow *de)
{
if (de->file_name)
save_file (de);
else
- data_save_as_dialog (action, de);
+ data_save_as_dialog (de);
}
psppire_window_set_unsaved (PSPPIRE_WINDOW (w), TRUE);
}
+/* Callback for the "delete" action (clicking the x on the top right
+ hand corner of the window) */
+static gboolean
+on_delete (GtkWidget *w, GdkEvent *event, gpointer user_data)
+{
+ PsppireDataWindow *dw = PSPPIRE_DATA_WINDOW (user_data);
+
+ return FALSE;
+}
+
+
static void
psppire_data_window_init (PsppireDataWindow *de)
{
"stock-id", "gtk-save",
NULL);
- g_signal_connect (action_data_save, "activate",
- G_CALLBACK (data_save), de);
+ g_signal_connect_swapped (action_data_save, "activate",
+ G_CALLBACK (data_save), de);
}
"stock-id", "gtk-save-as",
NULL);
- g_signal_connect (action_data_save_as, "activate",
+ g_signal_connect_swapped (action_data_save_as, "activate",
G_CALLBACK (data_save_as_dialog), de);
}
"varsheet-row-menu", de->var_sheet_variable_popup_menu,
NULL);
+ g_signal_connect (de, "delete-event", G_CALLBACK (on_delete), de);
+
+
gtk_widget_show (GTK_WIDGET (de->data_editor));
gtk_widget_show (box);
}
Otherwise just close the window.
*/
static void
-save_if_modified (PsppireSyntaxWindow *se)
+save_if_modified (PsppireWindow *se)
{
- if ( TRUE == gtk_text_buffer_get_modified (se->buffer))
+ if ( TRUE == psppire_window_get_unsaved (se))
{
gint response;
GtkWidget *dialog;
- const gchar *filename = psppire_window_get_filename (PSPPIRE_WINDOW (se));
+ const gchar *description;
+ const gchar *filename = psppire_window_get_filename (se);
+
+ g_object_get (se, "description", &description, NULL);
g_return_if_fail (filename != NULL);
GTK_DIALOG_MODAL,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_NONE,
- _("Save contents of syntax editor to %s?"),
+ _("Save contents of %s to \"%s\"?"),
+ description,
filename);
gtk_dialog_add_button (GTK_DIALOG (dialog),
msg (ME, err->message);
g_error_free (err);
}
- psppire_window_set_filename (PSPPIRE_WINDOW (se), filename);
+ psppire_window_set_filename (se, filename);
}
if ( response == GTK_RESPONSE_CANCEL )
PsppireSyntaxWindow *se = PSPPIRE_SYNTAX_WINDOW (user_data);
save_if_modified (se);
- return TRUE;
+ return FALSE;
}
{
return g_object_new (psppire_window_register_get_type (), NULL);
}
+
+
+gint
+psppire_window_register_n_items (PsppireWindowRegister *wr)
+{
+ return g_hash_table_size (wr->name_table);
+}
void psppire_window_register_minimise_all (PsppireWindowRegister *wr);
+gint psppire_window_register_n_items (PsppireWindowRegister *wr);
+
G_END_DECLS
psppire_window_register_foreach (psppire_window_register_new (), insert_item, window);
}
+
+static gboolean
+on_delete (GtkWidget *w, GdkEvent *event, gpointer user_data)
+{
+ PsppireWindow *dw = PSPPIRE_WINDOW (user_data);
+
+ PsppireWindowRegister *reg = psppire_window_register_new ();
+
+
+ if ( 1 == psppire_window_register_n_items (reg))
+ gtk_main_quit ();
+
+ return FALSE;
+}
+
+
static void
psppire_window_init (PsppireWindow *window)
{
window);
window->unsaved = FALSE;
+
+ g_signal_connect (window, "delete-event", G_CALLBACK (on_delete), window);
}
psppire_window_set_title (w);
}
+gboolean
+psppire_window_get_unsaved (PsppireWindow *w)
+{
+ return w->unsaved;
+}
+
+
\f
void psppire_window_set_unsaved (PsppireWindow *, gboolean );
+gboolean psppire_window_get_unsaved (PsppireWindow *);
+
G_END_DECLS
#endif /* __PSPPIRE_WINDOW_H__ */