2 PSPPIRE --- A Graphical User Interface for PSPP
3 Copyright (C) 2006, 2007 Free Software Foundation
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 #include "syntax-editor.h"
25 #include "data-editor.h"
28 #define _(msgid) gettext (msgid)
29 #define N_(msgid) msgid
32 #include "window-manager.h"
36 /* A list of struct editor_windows */
37 static GSList *window_list = NULL;
41 deregister_window (GtkWindow *w, gpointer data)
43 struct editor_window *e = data;
45 window_list = g_slist_remove (window_list, e);
47 if ( g_slist_length (window_list) == 0 )
53 register_window (struct editor_window *e)
55 window_list = g_slist_prepend (window_list, e);
62 return g_slist_length (window_list);
66 minimise_all_windows (void)
68 const GSList *i = NULL;
70 for (i = window_list; i != NULL ; i = i->next)
72 struct editor_window *e = i->data;
73 gtk_window_iconify (e->window);
77 static void set_window_name (struct editor_window *e, const gchar *name );
80 struct editor_window *
81 window_create (enum window_type type, const gchar *name)
83 struct editor_window *e;
87 e = (struct editor_window *) new_syntax_editor ();
90 e = (struct editor_window *) new_data_editor ();
93 g_assert_not_reached ();
99 set_window_name (e, name);
102 gtk_window_set_icon_from_file (GTK_WINDOW (e->window),
103 PKGDATADIR "/psppicon.png", 0);
105 g_signal_connect (e->window, "destroy",
106 G_CALLBACK (deregister_window), e);
110 gtk_widget_show (GTK_WIDGET (e->window));
116 default_window_name (struct editor_window *w)
118 set_window_name (w, NULL);
122 set_window_name (struct editor_window *e,
132 e->name = g_strdup (name);
139 e->name = g_strdup_printf (_("Syntax%d"), next_window_id () );
140 title = g_strdup_printf (_("%s --- PSPP Syntax Editor"), e->name);
143 e->name = g_strdup_printf (_("Untitled%d"), next_window_id () );
144 title = g_strdup_printf (_("%s --- PSPP Data Editor"), e->name);
147 g_assert_not_reached ();
150 gtk_window_set_title (GTK_WINDOW (e->window), title);
156 /* Set the name of this window based on FILENAME.
157 FILENAME is in "filename encoding" */
159 window_set_name_from_filename (struct editor_window *e,
160 const gchar *filename)
163 gchar *basename = g_path_get_basename (filename);
165 set_window_name (e, filename);
170 title = g_strdup_printf (_("%s --- PSPP Syntax Editor"), basename);
173 title = g_strdup_printf (_("%s --- PSPP Data Editor"), basename);
176 g_assert_not_reached ();
180 gtk_window_set_title (GTK_WINDOW (e->window), title);
186 window_name (const struct editor_window *e)