1 /* PSPPIRE - a graphical user interface for PSPP.
2 Copyright (C) 2006, 2007 Free Software Foundation
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #include "relocatable.h"
23 #include "syntax-editor.h"
24 #include "data-editor.h"
25 #include "output-viewer.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 e = (struct editor_window *) new_output_viewer ();
96 g_assert_not_reached ();
102 set_window_name (e, name);
105 gtk_window_set_icon_from_file (GTK_WINDOW (e->window),
106 relocate (PKGDATADIR "/psppicon.png"), 0);
108 g_signal_connect (e->window, "destroy",
109 G_CALLBACK (deregister_window), e);
113 gtk_widget_show (GTK_WIDGET (e->window));
119 default_window_name (struct editor_window *w)
121 set_window_name (w, NULL);
125 set_window_name (struct editor_window *e,
135 e->name = g_strdup (name);
142 e->name = g_strdup_printf (_("Syntax%d"), next_window_id () );
143 title = g_strdup_printf (_("%s --- PSPP Syntax Editor"), e->name);
146 e->name = g_strdup_printf (_("Untitled%d"), next_window_id () );
147 title = g_strdup_printf (_("%s --- PSPP Data Editor"), e->name);
150 e->name = g_strdup_printf (_("Output%d"), next_window_id () );
151 title = g_strdup_printf (_("%s --- PSPP Output"), e->name);
154 g_assert_not_reached ();
157 gtk_window_set_title (GTK_WINDOW (e->window), title);
163 /* Set the name of this window based on FILENAME.
164 FILENAME is in "filename encoding" */
166 window_set_name_from_filename (struct editor_window *e,
170 gchar *filename = g_filename_to_utf8 (fn, -1, NULL, NULL, NULL);
171 gchar *basename = g_path_get_basename (filename);
173 set_window_name (e, filename);
178 title = g_strdup_printf (_("%s --- PSPP Syntax Editor"), basename);
181 title = g_strdup_printf (_("%s --- PSPP Data Editor"), basename);
184 g_assert_not_reached ();
188 gtk_window_set_title (GTK_WINDOW (e->window), title);
195 window_name (const struct editor_window *e)