From: John Darrington Date: Sun, 4 Jan 2009 12:34:16 +0000 (+0900) Subject: Write message to status bar on saving syntax files X-Git-Tag: v0.7.3~296^2~8^2 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ef60a827a20593dcebdb98f509614d7d94e3fe5c;p=pspp-builds.git Write message to status bar on saving syntax files --- diff --git a/src/ui/gui/psppire-syntax-window.c b/src/ui/gui/psppire-syntax-window.c index 4241949e..31f4966e 100644 --- a/src/ui/gui/psppire-syntax-window.c +++ b/src/ui/gui/psppire-syntax-window.c @@ -247,8 +247,11 @@ save_editor_to_file (PsppireSyntaxWindow *se, 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; @@ -260,7 +263,6 @@ save_editor_to_file (PsppireSyntaxWindow *se, static void save_if_modified (PsppireSyntaxWindow *se) { - if ( TRUE == gtk_text_buffer_get_modified (se->buffer)) { gint response; @@ -281,14 +283,15 @@ save_if_modified (PsppireSyntaxWindow *se) 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); @@ -471,6 +474,11 @@ open_syntax_window (GtkMenuItem *menuitem, gpointer parent) } +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 ; @@ -482,12 +490,17 @@ psppire_syntax_window_init (PsppireSyntaxWindow *window) 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); @@ -496,12 +509,12 @@ psppire_syntax_window_init (PsppireSyntaxWindow *window) g_object_ref (sw); - g_object_ref (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); diff --git a/src/ui/gui/psppire-syntax-window.h b/src/ui/gui/psppire-syntax-window.h index c434e07f..2144b86f 100644 --- a/src/ui/gui/psppire-syntax-window.h +++ b/src/ui/gui/psppire-syntax-window.h @@ -49,6 +49,8 @@ struct _PsppireSyntaxWindow GtkTextBuffer *buffer; /* The buffer which contains the text */ struct lexer *lexer; /* Lexer to parse syntax */ + GtkWidget *sb; + guint text_context; }; struct _PsppireSyntaxWindowClass