[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pspp-cvs] pspp/src data/ChangeLog data/settings.c data/se...
From: |
Ben Pfaff |
Subject: |
[Pspp-cvs] pspp/src data/ChangeLog data/settings.c data/se... |
Date: |
Tue, 25 Sep 2007 04:16:21 +0000 |
CVSROOT: /cvsroot/pspp
Module name: pspp
Changes by: Ben Pfaff <blp> 07/09/25 04:16:20
Modified files:
src/data : ChangeLog settings.c settings.h
src/ui/gui : ChangeLog message-dialog.c output-viewer.c
output-viewer.h psppire.c
src/ui/terminal: ChangeLog main.c
Log message:
John's original code for patch #6210.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/ChangeLog?cvsroot=pspp&r1=1.159&r2=1.160
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/settings.c?cvsroot=pspp&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/settings.h?cvsroot=pspp&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/ChangeLog?cvsroot=pspp&r1=1.88&r2=1.89
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/message-dialog.c?cvsroot=pspp&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/output-viewer.c?cvsroot=pspp&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/output-viewer.h?cvsroot=pspp&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/gui/psppire.c?cvsroot=pspp&r1=1.50&r2=1.51
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/terminal/ChangeLog?cvsroot=pspp&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/pspp/src/ui/terminal/main.c?cvsroot=pspp&r1=1.38&r2=1.39
Patches:
Index: data/ChangeLog
===================================================================
RCS file: /cvsroot/pspp/pspp/src/data/ChangeLog,v
retrieving revision 1.159
retrieving revision 1.160
diff -u -b -r1.159 -r1.160
--- data/ChangeLog 19 Sep 2007 04:28:59 -0000 1.159
+++ data/ChangeLog 25 Sep 2007 04:16:19 -0000 1.160
@@ -1,3 +1,9 @@
+2007-09-19 John Darrington <address@hidden>
+
+ * settings.c settings.h: Changed viewport's length and width to be
+ owned by the user interface which uses the data library. This allows
+ better abstraction, and makes dynamically adjustable dimensions easier.
+
2007-09-18 Ben Pfaff <address@hidden>
* procedure.c (proc_extract_active_file_data): New function.
Index: data/settings.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/data/settings.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- data/settings.c 10 Aug 2007 00:16:19 -0000 1.11
+++ data/settings.c 25 Sep 2007 04:16:19 -0000 1.12
@@ -29,8 +29,8 @@
#include "gettext.h"
#define _(msgid) gettext (msgid)
-static int viewlength = 24;
-static int viewwidth = 79;
+static int *viewlength = NULL;
+static int *viewwidth = NULL;
static bool long_view = false;
static bool safer_mode = false;
@@ -74,13 +74,12 @@
static int syntax = ENHANCED;
-static void init_viewport (void);
-static void get_termcap_viewport (void);
+static void init_viewport (int *, int *);
void
-settings_init (void)
+settings_init (int *width, int *length)
{
- init_viewport ();
+ init_viewport (width, length);
i18n_init ();
}
@@ -94,14 +93,14 @@
int
get_viewlength (void)
{
- return viewlength;
+ return *viewlength;
}
/* Sets the view length. */
void
set_viewlength (int viewlength_)
{
- viewlength = viewlength_;
+ *viewlength = viewlength_;
}
/* Set view width to a very long value, and prevent it from ever
@@ -110,42 +109,34 @@
force_long_view (void)
{
long_view = true;
- viewwidth = 9999;
}
/* Screen width. */
int
get_viewwidth(void)
{
- return viewwidth;
+ if (long_view)
+ return 9999;
+
+ return *viewwidth;
}
/* Sets the screen width. */
void
set_viewwidth (int viewwidth_)
{
- viewwidth = viewwidth_;
+ *viewwidth = viewwidth_;
}
static void
-init_viewport (void)
+init_viewport (int *width, int *length)
{
+ viewwidth = width;
+ viewlength = length;
+
if (long_view)
return;
- viewwidth = viewlength = -1;
-
- get_termcap_viewport ();
-
- if (viewwidth < 0 && getenv ("COLUMNS") != NULL)
- viewwidth = atoi (getenv ("COLUMNS"));
- if (viewlength < 0 && getenv ("LINES") != NULL)
- viewlength = atoi (getenv ("LINES"));
-
- if (viewwidth < 0)
- viewwidth = 79;
- if (viewlength < 0)
- viewlength = 24;
}
/* Whether PSPP can erase and overwrite files. */
@@ -498,38 +489,3 @@
{
syntax = mode;
}
-
-/* Code that interfaces to ncurses. This must be at the very end
- of this file because curses.h redefines "bool" on some systems
- (e.g. OpenBSD), causing declaration mismatches with functions
- that have parameters or return values of type "bool". */
-#if HAVE_LIBNCURSES
-#include <curses.h>
-#include <term.h>
-
-static void
-get_termcap_viewport (void)
-{
- char term_buffer[16384];
- if (getenv ("TERM") == NULL)
- return;
- else if (tgetent (term_buffer, getenv ("TERM")) <= 0)
- {
- error (0,0, _("could not access definition for terminal `%s'"),
- getenv ("TERM"));
- return;
- }
-
- if (tgetnum ("li") > 0)
- viewlength = tgetnum ("li");
-
- if (tgetnum ("co") > 1)
- viewwidth = tgetnum ("co") - 1;
-}
-#else /* !HAVE_LIBNCURSES */
-static void
-get_termcap_viewport (void)
-{
- /* Nothing to do. */
-}
-#endif /* !HAVE_LIBNCURSES */
Index: data/settings.h
===================================================================
RCS file: /cvsroot/pspp/pspp/src/data/settings.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- data/settings.h 7 Jul 2007 06:14:10 -0000 1.6
+++ data/settings.h 25 Sep 2007 04:16:19 -0000 1.7
@@ -20,7 +20,7 @@
#include <stdbool.h>
#include <stddef.h>
-void settings_init (void);
+void settings_init (int *, int *);
void settings_done (void);
void force_long_view (void);
Index: ui/gui/ChangeLog
===================================================================
RCS file: /cvsroot/pspp/pspp/src/ui/gui/ChangeLog,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -b -r1.88 -r1.89
--- ui/gui/ChangeLog 21 Sep 2007 01:53:58 -0000 1.88
+++ ui/gui/ChangeLog 25 Sep 2007 04:16:19 -0000 1.89
@@ -1,3 +1,14 @@
+2007-09-19 John Darrington <address@hidden>
+
+ * message-dialog.c: Changed the ouput message title to be
+ appropriate for the severity of the message.
+
+ * output-viewer.c output-viewer.h : Added a callback for the resize
+ signal of the output viewer, and set the viewport length and
+ width accordingly.
+
+ * psppire.c: Update to new init_settings interface.
+
2007-09-27 John Darrington <address@hidden>
Addressing bug #20821:
Index: ui/gui/message-dialog.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/ui/gui/message-dialog.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- ui/gui/message-dialog.c 7 Jul 2007 06:14:28 -0000 1.26
+++ ui/gui/message-dialog.c 25 Sep 2007 04:16:20 -0000 1.27
@@ -103,29 +103,58 @@
{
case MSG_ERROR:
message_type = GTK_MESSAGE_ERROR;
+ switch (m->category)
+ {
+ case MSG_SYNTAX:
+ msg = _("Script Error");
+ break;
+
+ case MSG_DATA:
+ msg = _("Data File Error");
+ break;
+
+ case MSG_GENERAL:
+ default:
+ msg = _("PSPP Error");
+ break;
+ };
break;
case MSG_WARNING:
message_type = GTK_MESSAGE_WARNING;
+ switch (m->category)
+ {
+ case MSG_SYNTAX:
+ msg = _("Script Warning");
break;
- case MSG_NOTE:
+
+ case MSG_DATA:
+ msg = _("Data File Warning");
+ break;
+
+ case MSG_GENERAL:
default:
- message_type = GTK_MESSAGE_INFO;
+ msg = _("PSPP Warning");
break;
};
-
+ break;
+ case MSG_NOTE:
+ default:
+ message_type = GTK_MESSAGE_INFO;
switch (m->category)
{
case MSG_SYNTAX:
- msg = _("Script Error");
+ msg = _("Script Information");
break;
case MSG_DATA:
- msg = _("Data File Error");
+ msg = _("Data File Information");
break;
case MSG_GENERAL:
default:
- msg = _("PSPP Error");
+ msg = _("PSPP Information");
+ break;
+ };
break;
};
Index: ui/gui/output-viewer.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/ui/gui/output-viewer.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- ui/gui/output-viewer.c 16 Aug 2007 06:30:24 -0000 1.1
+++ ui/gui/output-viewer.c 25 Sep 2007 04:16:20 -0000 1.2
@@ -46,6 +46,8 @@
static struct output_viewer *the_output_viewer = NULL;
+int viewer_length = -1;
+int viewer_width = -1;
/* Callback for the "delete" action (clicking the x on the top right
hand corner of the window) */
@@ -64,6 +66,46 @@
}
+/* Sets width and length according to the new size
+ of the output window */
+static void
+on_textview_resize (GtkWidget *widget,
+ GtkAllocation *allocation,
+ gpointer user_data)
+{
+ PangoContext * context ;
+ PangoLayout *layout ;
+ PangoRectangle logical;
+ GtkStyle *style;
+ gint right_margin, left_margin;
+ GtkTextView *text_view = GTK_TEXT_VIEW (widget);
+
+ context = gtk_widget_create_pango_context (widget);
+ layout = pango_layout_new (context);
+
+ style = gtk_widget_get_style (widget);
+
+ pango_layout_set_font_description (layout, style->font_desc);
+
+ /* Find the width of one character. We can use any character, because
+ the textview has a monospaced font */
+ pango_layout_set_text (layout, "M", 1);
+
+ pango_layout_get_extents (layout, NULL, &logical);
+
+ left_margin = gtk_text_view_get_left_margin (text_view);
+ right_margin = gtk_text_view_get_right_margin (text_view);
+
+ viewer_length = allocation->height / PANGO_PIXELS (logical.height);
+ viewer_width = (allocation->width - right_margin - left_margin)
+ / PANGO_PIXELS (logical.width);
+
+ g_object_unref (G_OBJECT (layout));
+ g_object_unref (G_OBJECT (context));
+}
+
+
+
/*
Create a new output viewer
*/
@@ -101,6 +143,9 @@
pango_font_description_free (font_desc);
}
+ g_signal_connect (ov->textview, "size-allocate",
+ G_CALLBACK (on_textview_resize), NULL);
+
ov->fp = NULL;
g_signal_connect (get_widget_assert (xml,"help_about"),
Index: ui/gui/output-viewer.h
===================================================================
RCS file: /cvsroot/pspp/pspp/src/ui/gui/output-viewer.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- ui/gui/output-viewer.h 16 Aug 2007 06:30:24 -0000 1.1
+++ ui/gui/output-viewer.h 25 Sep 2007 04:16:20 -0000 1.2
@@ -23,6 +23,9 @@
#include "window-manager.h"
+extern int viewer_length ;
+extern int viewer_width ;
+
struct output_viewer * new_output_viewer (void);
void reload_viewer (struct output_viewer *);
Index: ui/gui/psppire.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/ui/gui/psppire.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -b -r1.50 -r1.51
--- ui/gui/psppire.c 19 Sep 2007 06:21:20 -0000 1.50
+++ ui/gui/psppire.c 25 Sep 2007 04:16:20 -0000 1.51
@@ -85,7 +85,7 @@
fmt_init ();
fn_init ();
outp_init ();
- settings_init ();
+ settings_init (&viewer_width, &viewer_length);
fh_init ();
the_source_stream =
create_source_stream (
Index: ui/terminal/ChangeLog
===================================================================
RCS file: /cvsroot/pspp/pspp/src/ui/terminal/ChangeLog,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- ui/terminal/ChangeLog 23 Sep 2007 05:59:03 -0000 1.28
+++ ui/terminal/ChangeLog 25 Sep 2007 04:16:20 -0000 1.29
@@ -1,3 +1,9 @@
+2007-09-19 John Darrington <address@hidden>
+
+ * main.c: Moved get_termcap_viewport from src/data/settings.c
+ Added a handler for SIGWINCH to call this function. Adjusted
+ init_settings to suit new interface.
+
2007-09-22 Ben Pfaff <address@hidden>
Bug #21128. Reviewed by John Darrington.
Index: ui/terminal/main.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/ui/terminal/main.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- ui/terminal/main.c 23 Sep 2007 05:59:03 -0000 1.38
+++ ui/terminal/main.c 25 Sep 2007 04:16:20 -0000 1.39
@@ -78,6 +78,11 @@
static struct lexer *the_lexer;
static struct source_stream *the_source_stream ;
+static int view_length = -1;
+static int view_width = -1;
+
+static void get_termcap_viewport (int);
+
/* Program entry point. */
int
@@ -87,6 +92,7 @@
signal (SIGSEGV, bug_handler);
signal (SIGFPE, bug_handler);
signal (SIGINT, interrupt_handler);
+ signal (SIGWINCH, get_termcap_viewport);
set_program_name (argv[0]);
@@ -104,7 +110,8 @@
);
prompt_init ();
readln_initialize ();
- settings_init ();
+ get_termcap_viewport (0);
+ settings_init (&view_width, &view_length);
random_init ();
the_dataset = create_dataset ();
@@ -224,3 +231,71 @@
}
exit (success ? EXIT_SUCCESS : EXIT_FAILURE);
}
+
+
+
+#include "error.h"
+
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+
+static void
+set_fallback_viewport (void)
+{
+ if (view_width < 0 && getenv ("COLUMNS") != NULL)
+ view_width = atoi (getenv ("COLUMNS"));
+
+ if (view_length < 0 && getenv ("LINES") != NULL)
+ view_length = atoi (getenv ("LINES"));
+
+ if (view_width < 0)
+ view_width = 79;
+
+ if (view_length < 0)
+ view_length = 24;
+}
+
+/* Code that interfaces to ncurses. This must be at the very end
+ of this file because curses.h redefines "bool" on some systems
+ (e.g. OpenBSD), causing declaration mismatches with functions
+ that have parameters or return values of type "bool". */
+#if HAVE_LIBNCURSES
+#include <curses.h>
+#include <term.h>
+
+static void
+get_termcap_viewport (int sig UNUSED)
+{
+ char term_buffer [16384];
+
+ if (getenv ("TERM") == NULL)
+ goto fallback;
+
+ else if (tgetent (term_buffer, getenv ("TERM")) <= 0)
+ {
+ error (0,0, _("could not access definition for terminal `%s'"),
+ getenv ("TERM"));
+ goto fallback;
+ }
+
+ if (tgetnum ("li") > 0)
+ view_length = tgetnum ("li");
+
+ if (tgetnum ("co") > 1)
+ view_width = tgetnum ("co") - 1;
+
+ fallback:
+ set_fallback_viewport ();
+}
+
+#else /* !HAVE_LIBNCURSES */
+
+static void
+get_termcap_viewport (int sig UNUSED)
+{
+ set_fallback_viewport ();
+}
+
+#endif /* !HAVE_LIBNCURSES */
+
+
- [Pspp-cvs] pspp/src data/ChangeLog data/settings.c data/se...,
Ben Pfaff <=