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
22 #include "syntax-editor.h"
23 #include "data-editor.h"
26 #define _(msgid) gettext (msgid)
27 #define N_(msgid) msgid
30 #include "window-manager.h"
34 /* A list of struct editor_windows */
35 static GSList *window_list = NULL;
39 deregister_window (GtkWindow *w, gpointer data)
41 struct editor_window *e = data;
43 window_list = g_slist_remove (window_list, e);
45 if ( g_slist_length (window_list) == 0 )
51 register_window (struct editor_window *e)
53 window_list = g_slist_prepend (window_list, e);
60 return g_slist_length (window_list);
64 minimise_all_windows (void)
66 const GSList *i = NULL;
68 for (i = window_list; i != NULL ; i = i->next)
70 struct editor_window *e = i->data;
71 gtk_window_iconify (e->window);
75 static void set_window_name (struct editor_window *e, const gchar *name );
78 struct editor_window *
79 window_create (enum window_type type, const gchar *name)
81 struct editor_window *e;
85 e = (struct editor_window *) new_syntax_editor ();
88 e = (struct editor_window *) new_data_editor ();
91 g_assert_not_reached ();
97 set_window_name (e, name);
100 gtk_window_set_icon_from_file (GTK_WINDOW (e->window),
101 PKGDATADIR "/psppicon.png", 0);
103 g_signal_connect (e->window, "destroy",
104 G_CALLBACK (deregister_window), e);
108 gtk_widget_show (e->window);
115 set_window_name (struct editor_window *e,
124 e->name = g_strdup (name);
131 e->name = g_strdup_printf (_("Syntax%d"), next_window_id () );
132 title = g_strdup_printf (_("%s --- PSPP Syntax Editor"), e->name);
135 e->name = g_strdup_printf (_("Untitled%d"), next_window_id () );
136 title = g_strdup_printf (_("%s --- PSPP Data Editor"), e->name);
139 g_assert_not_reached ();
142 gtk_window_set_title (GTK_WINDOW (e->window), title);
149 window_set_name_from_filename (struct editor_window *e,
150 const gchar *filename)
153 gchar *basename = g_path_get_basename (filename);
155 set_window_name (e, filename);
160 title = g_strdup_printf (_("%s --- PSPP Syntax Editor"), basename);
163 title = g_strdup_printf (_("%s --- PSPP Data Editor"), basename);
166 g_assert_not_reached ();
170 gtk_window_set_title (GTK_WINDOW (e->window), title);
176 window_name (const struct editor_window *e)