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"
27 #define _(msgid) gettext (msgid)
28 #define N_(msgid) msgid
31 #include "window-manager.h"
35 /* A list of struct editor_windows */
36 static GSList *window_list = NULL;
40 deregister_window (GtkWindow *w, gpointer data)
42 struct editor_window *e = data;
44 window_list = g_slist_remove (window_list, e);
46 if ( g_slist_length (window_list) == 0 )
52 register_window (struct editor_window *e)
54 window_list = g_slist_prepend (window_list, e);
61 return g_slist_length (window_list);
65 minimise_all_windows (void)
67 const GSList *i = NULL;
69 for (i = window_list; i != NULL ; i = i->next)
71 struct editor_window *e = i->data;
72 gtk_window_iconify (e->window);
76 static void set_window_name (struct editor_window *e, const gchar *name );
79 struct editor_window *
80 window_create (enum window_type type, const gchar *name)
82 struct editor_window *e;
86 e = (struct editor_window *) new_syntax_editor ();
89 e = (struct editor_window *) new_data_editor ();
92 g_assert_not_reached ();
98 set_window_name (e, name);
101 gtk_window_set_icon_from_file (GTK_WINDOW (e->window),
102 relocate (PKGDATADIR "/psppicon.png"), 0);
104 g_signal_connect (e->window, "destroy",
105 G_CALLBACK (deregister_window), e);
109 gtk_widget_show (GTK_WIDGET (e->window));
115 default_window_name (struct editor_window *w)
117 set_window_name (w, NULL);
121 set_window_name (struct editor_window *e,
131 e->name = g_strdup (name);
138 e->name = g_strdup_printf (_("Syntax%d"), next_window_id () );
139 title = g_strdup_printf (_("%s --- PSPP Syntax Editor"), e->name);
142 e->name = g_strdup_printf (_("Untitled%d"), next_window_id () );
143 title = g_strdup_printf (_("%s --- PSPP Data Editor"), e->name);
146 g_assert_not_reached ();
149 gtk_window_set_title (GTK_WINDOW (e->window), title);
155 /* Set the name of this window based on FILENAME.
156 FILENAME is in "filename encoding" */
158 window_set_name_from_filename (struct editor_window *e,
162 gchar *filename = g_filename_to_utf8 (fn, -1, NULL, NULL, NULL);
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);
187 window_name (const struct editor_window *e)