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,
128 gchar mdash[6] = { 0, 0, 0, 0, 0, 0};
137 e->name = g_strdup (name);
141 g_unichar_to_utf8 (2014, mdash);
146 e->name = g_strdup_printf (_("Syntax%d"), next_window_id () );
147 title = g_strdup_printf (_("%s %s PSPP Syntax Editor"), e->name, mdash);
150 e->name = g_strdup_printf (_("Untitled%d"), next_window_id () );
151 title = g_strdup_printf (_("%s %s PSPP Data Editor"), e->name, mdash);
154 e->name = g_strdup_printf (_("Output%d"), next_window_id () );
155 title = g_strdup_printf (_("%s %s PSPP Output"), e->name, mdash);
158 g_assert_not_reached ();
161 gchar* x = g_locale_from_utf8 (title, -1, NULL, NULL, NULL);
164 gtk_window_set_title (GTK_WINDOW (e->window), x);
171 /* Set the name of this window based on FILENAME.
172 FILENAME is in "filename encoding" */
174 window_set_name_from_filename (struct editor_window *e,
178 gchar *filename = g_filename_to_utf8 (fn, -1, NULL, NULL, NULL);
179 gchar *basename = g_path_get_basename (filename);
181 set_window_name (e, filename);
186 title = g_strdup_printf (_("%s --- PSPP Syntax Editor"), basename);
189 title = g_strdup_printf (_("%s --- PSPP Data Editor"), basename);
192 g_assert_not_reached ();
196 gchar* x = g_locale_from_utf8 (title, -1, NULL, NULL, NULL);
199 gtk_window_set_title (GTK_WINDOW (e->window), x);
207 window_name (const struct editor_window *e)