#include <libpspp/message.h>
#include <stdlib.h>
-
#include "psppire-syntax-window.h"
-#include "data-editor.h"
+#include "psppire-data-window.h"
+#include "psppire-window-register.h"
#include "about.h"
#include "psppire-syntax-window.h"
#include "syntax-editor-source.h"
#define _(msgid) gettext (msgid)
#define N_(msgid) msgid
-
-
static void psppire_syntax_window_base_finalize (PsppireSyntaxWindowClass *, gpointer);
static void psppire_syntax_window_base_init (PsppireSyntaxWindowClass *class);
static void psppire_syntax_window_class_init (PsppireSyntaxWindowClass *class);
static void psppire_syntax_window_init (PsppireSyntaxWindow *syntax_editor);
-
GType
psppire_syntax_window_get_type (void)
{
return psppire_syntax_window_type;
}
+static GObjectClass *parent_class ;
static void
psppire_syntax_window_finalize (GObject *object)
{
- g_debug ("%s %p", __FUNCTION__, object);
-
- GObjectClass *class = G_OBJECT_GET_CLASS (object);
-
- GObjectClass *parent_class = g_type_class_peek_parent (class);
-
-
if (G_OBJECT_CLASS (parent_class)->finalize)
(*G_OBJECT_CLASS (parent_class)->finalize) (object);
-
}
static void
psppire_syntax_window_class_init (PsppireSyntaxWindowClass *class)
{
+ parent_class = g_type_class_peek_parent (class);
}
static void
-editor_execute_syntax (const PsppireSyntaxWindow *se, GtkTextIter start,
- GtkTextIter stop)
+editor_execute_syntax (const PsppireSyntaxWindow *sw, GtkTextIter start,
+ GtkTextIter stop)
{
- execute_syntax (create_syntax_editor_source (se->buffer, start, stop));
+ PsppireWindow *win = PSPPIRE_WINDOW (sw);
+ const gchar *name = psppire_window_get_filename (win);
+ execute_syntax (create_syntax_editor_source (sw->buffer, start, stop, name));
}
if ( result )
{
+ gchar *msg = g_strdup_printf (_("Saved file \"%s\""), filename);
+ gtk_statusbar_push (GTK_STATUSBAR (se->sb), se->text_context, msg);
psppire_window_set_filename (PSPPIRE_WINDOW (se), filename);
gtk_text_buffer_set_modified (buffer, FALSE);
+ g_free (msg);
}
return result;
static void
save_if_modified (PsppireSyntaxWindow *se)
{
-
if ( TRUE == gtk_text_buffer_get_modified (se->buffer))
{
gint response;
gtk_dialog_add_button (GTK_DIALOG (dialog),
GTK_STOCK_YES,
GTK_RESPONSE_ACCEPT);
+
gtk_dialog_add_button (GTK_DIALOG (dialog),
GTK_STOCK_NO,
GTK_RESPONSE_REJECT);
+
gtk_dialog_add_button (GTK_DIALOG (dialog),
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL);
-
response = gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
}
+static void
+on_text_changed (GtkTextBuffer *buffer, PsppireSyntaxWindow *window)
+{
+ gtk_statusbar_pop (GTK_STATUSBAR (window->sb), window->text_context);
+}
+
extern struct source_stream *the_source_stream ;
static void
GtkWidget *menubar = get_widget_assert (xml, "menubar2");
GtkWidget *sw = get_widget_assert (xml, "scrolledwindow8");
- GtkWidget *sb = get_widget_assert (xml, "statusbar2");
+
GtkWidget *text_view = get_widget_assert (xml, "syntax_text_view");
window->buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
window->lexer = lex_create (the_source_stream);
+ window->sb = get_widget_assert (xml, "statusbar2");
+ window->text_context = gtk_statusbar_get_context_id (GTK_STATUSBAR (window->sb), "Text Context");
+
+ g_signal_connect (window->buffer, "changed", G_CALLBACK (on_text_changed), window);
+
connect_help (xml);
gtk_container_add (GTK_CONTAINER (window), box);
g_object_ref (menubar);
- gtk_widget_unparent (menubar);
g_object_ref (sw);
- gtk_widget_unparent (sw);
- g_object_ref (sb);
- gtk_widget_unparent (sb);
+ g_object_ref (window->sb);
gtk_box_pack_start (GTK_BOX (box), menubar, FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (box), sw, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (box), sb, FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (box), window->sb, FALSE, TRUE, 0);
gtk_widget_show_all (box);
G_CALLBACK (open_syntax_window),
window);
-
+#if 0
g_signal_connect (get_widget_assert (xml,"file_new_data"),
"activate",
- G_CALLBACK (new_data_window),
+ G_CALLBACK (create_data_window),
window);
+#endif
g_signal_connect (get_widget_assert (xml,"help_about"),
"activate",
G_CALLBACK (on_run_to_end),
window);
-#if 0
g_signal_connect (get_widget_assert (xml,"windows_minimise_all"),
"activate",
- G_CALLBACK (minimise_all_windows),
- NULL);
-#endif
+ G_CALLBACK (psppire_window_minimise_all), NULL);
+
+ PSPPIRE_WINDOW (window)->menu = GTK_MENU_SHELL (get_widget_assert (xml,"windows_menu"));
g_object_unref (xml);
GtkWidget*
psppire_syntax_window_new (void)
{
- return GTK_WIDGET (g_object_new (psppire_syntax_window_get_type (), NULL));
+ return GTK_WIDGET (g_object_new (psppire_syntax_window_get_type (),
+ "usage", PSPPIRE_WINDOW_USAGE_SYNTAX,
+ NULL));
}