pspp-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pspp-cvs] pspp lib/gtksheet/ChangeLog lib/gtksheet/gtkshe...


From: John Darrington
Subject: [Pspp-cvs] pspp lib/gtksheet/ChangeLog lib/gtksheet/gtkshe...
Date: Thu, 04 May 2006 10:09:32 +0000

CVSROOT:        /sources/pspp
Module name:    pspp
Branch:         
Changes by:     John Darrington <address@hidden>        06/05/04 10:09:32

Modified files:
        lib/gtksheet   : ChangeLog gtksheet.c 
        src/libpspp    : ChangeLog message.c message.h 
        src/ui/gui     : ChangeLog automake.mk message-dialog.c 
                         message-dialog.h psppire-data-store.c psppire.c 

Log message:
        Added simple queueing to message dialogs.
        Fixed broken data sheet for very long strings.
        Fixed broken makefile dependency.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/lib/gtksheet/ChangeLog.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/lib/gtksheet/gtksheet.c.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/libpspp/ChangeLog.diff?tr1=1.17&tr2=1.18&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/libpspp/message.c.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/libpspp/message.h.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/ui/gui/ChangeLog.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/ui/gui/automake.mk.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/ui/gui/message-dialog.c.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/ui/gui/message-dialog.h.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/ui/gui/psppire-data-store.c.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/ui/gui/psppire.c.diff?tr1=1.5&tr2=1.6&r1=text&r2=text

Patches:
Index: pspp/lib/gtksheet/ChangeLog
diff -u pspp/lib/gtksheet/ChangeLog:1.1 pspp/lib/gtksheet/ChangeLog:1.2
--- pspp/lib/gtksheet/ChangeLog:1.1     Sat Mar  4 01:11:56 2006
+++ pspp/lib/gtksheet/ChangeLog Thu May  4 10:09:31 2006
@@ -1,3 +1,9 @@
+Thu May  4 17:55:48 WST 2006 John Darrington <address@hidden>
+
+    * gtksheet.c: Added callback on inserted rows.
+
+Sat Jan 28 08:48:08 2006 UTC John Darrington <address@hidden>
+
     * Separated the data out of the GtkSheet.  The gtksheet should now be
     regarded as a way of looking into the data.  The data is represented by a
     GSheetModel and the rows and columns by  GSheetRow and GSheetColumn.
Index: pspp/lib/gtksheet/gtksheet.c
diff -u pspp/lib/gtksheet/gtksheet.c:1.2 pspp/lib/gtksheet/gtksheet.c:1.3
--- pspp/lib/gtksheet/gtksheet.c:1.2    Tue Apr  4 12:43:21 2006
+++ pspp/lib/gtksheet/gtksheet.c        Thu May  4 10:09:31 2006
@@ -1123,14 +1123,18 @@
 }
 
 
+/* Callback which occurs whenever rows are inserted/deleted in the model */
 static void 
-rows_deleted_callback (GSheetModel *m, gint first_row, gint n_rows,
+rows_inserted_deleted_callback (GSheetModel *m, gint first_row, gint n_rows,
                      gpointer data)
 {
   GtkSheet *sheet = GTK_SHEET(data);
 
   GtkSheetRange range;
 
+  /* Need to update all the rows starting from the first row and onwards.
+   * Previous rows are unchanged, so don't need to be updated.
+   */
   range.row0 = first_row;
   range.col0 = 0;
   range.rowi = yyy_row_count(sheet) - 1;
@@ -1230,8 +1234,11 @@
   g_signal_connect(model, "range_changed", 
                   G_CALLBACK(range_update_callback), sheet);
 
+  g_signal_connect(model, "rows_inserted",
+                  G_CALLBACK(rows_inserted_deleted_callback), sheet);
+
   g_signal_connect(model, "rows_deleted",
-                  G_CALLBACK(rows_deleted_callback), sheet);
+                  G_CALLBACK(rows_inserted_deleted_callback), sheet);
 
 }
 
@@ -1481,7 +1488,6 @@
   g_return_if_fail (GTK_IS_SHEET (sheet));
   if (column >= xxx_column_count(sheet) || column < 0) return;
 
-  g_print("%s:%d Iterating rows\n",__FILE__, __LINE__);
   for (row = 0; row < yyy_row_count(sheet); row++){
     const gchar *text = gtk_sheet_cell_get_text(sheet, row, column);
     if (text && strlen(text) > 0){
@@ -4098,7 +4104,6 @@
 #endif
     gtk_sheet_draw_backing_pixmap(sheet, sheet->range);
     gtk_sheet_draw_border(sheet, sheet->range);
-
 }
 
 
Index: pspp/src/libpspp/ChangeLog
diff -u pspp/src/libpspp/ChangeLog:1.17 pspp/src/libpspp/ChangeLog:1.18
--- pspp/src/libpspp/ChangeLog:1.17     Tue May  2 22:46:00 2006
+++ pspp/src/libpspp/ChangeLog  Thu May  4 10:09:32 2006
@@ -1,3 +1,7 @@
+Thu May  4 18:01:37 WST 2006 John Darrington <address@hidden>
+
+       * message.c message.h: Added functions to create and copy a msg.
+
 Tue May  2 15:41:50 2006  Ben Pfaff  <address@hidden>
 
        * str.c (ds_append_uninit): No need to add 1 to arg passed to
Index: pspp/src/libpspp/message.c
diff -u pspp/src/libpspp/message.c:1.1 pspp/src/libpspp/message.c:1.2
--- pspp/src/libpspp/message.c:1.1      Tue Apr 25 18:11:08 2006
+++ pspp/src/libpspp/message.c  Thu May  4 10:09:32 2006
@@ -24,6 +24,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 #include <libpspp/alloc.h>
 #include <libpspp/version.h>
@@ -68,6 +69,27 @@
 {
 }
 
+
+/* Duplicate a message */
+struct msg * 
+msg_dup(const struct msg *m)
+{
+  struct msg *new_msg = xmalloc (sizeof *m);
+
+  *new_msg = *m;
+  new_msg->text = strdup(m->text);
+
+  return new_msg;
+}
+
+void
+msg_destroy(struct msg *m)
+{
+  free(m->text);
+  free(m);
+}
+
+
 /* Emits M as an error message.
    Frees allocated data in M. */
 void
Index: pspp/src/libpspp/message.h
diff -u pspp/src/libpspp/message.h:1.9 pspp/src/libpspp/message.h:1.10
--- pspp/src/libpspp/message.h:1.9      Tue Apr 25 18:03:03 2006
+++ pspp/src/libpspp/message.h  Thu May  4 10:09:32 2006
@@ -89,6 +89,9 @@
 void msg_init (void (*handler) (const struct msg *));
 void msg_done (void);
 
+struct msg * msg_dup(const struct msg *m);
+void msg_destroy(struct msg *m);
+
 /* Emitting messages. */
 void msg (enum msg_class, const char *format, ...)
      PRINTF_FORMAT (2, 3);
Index: pspp/src/ui/gui/ChangeLog
diff -u pspp/src/ui/gui/ChangeLog:1.8 pspp/src/ui/gui/ChangeLog:1.9
--- pspp/src/ui/gui/ChangeLog:1.8       Tue Apr 25 18:11:08 2006
+++ pspp/src/ui/gui/ChangeLog   Thu May  4 10:09:32 2006
@@ -1,3 +1,14 @@
+Thu May  4 18:04:04 WST 2006 John Darrington <address@hidden>
+
+       * message-dialog.c message-dialog.h: Added simple queuing to messages
+       reported, and ensure that dialog boxes dont appear when pointer grab
+       is active.
+
+       * psppire-data-store.c: Fix overflow on very long string variables.
+
+       * automake.mk: Fix broken dependency.
+
+
 Tue Apr 25 11:08:04 2006  Ben Pfaff  <address@hidden>
 
        Finish reforming error message support.  In this phase, move
Index: pspp/src/ui/gui/automake.mk
diff -u pspp/src/ui/gui/automake.mk:1.7 pspp/src/ui/gui/automake.mk:1.8
--- pspp/src/ui/gui/automake.mk:1.7     Tue Apr 25 18:11:08 2006
+++ pspp/src/ui/gui/automake.mk Thu May  4 10:09:32 2006
@@ -10,11 +10,11 @@
 src_ui_gui_psppire_LDADD = \
        $(GTK_LIBS) \
        $(GLADE_LIBS) \
-       -lgtksheet -L$(top_builddir)/lib/gtksheet \
-       -ldata -L$(top_builddir)/src/data \
-       -lpspp -L$(top_builddir)/src/libpspp \
-        -lgl -L$(top_builddir)/gl    \
-        @LIBINTL@ @LIBREADLINE@
+       $(top_builddir)/lib/gtksheet/libgtksheet.a \
+       $(top_builddir)/src/data/libdata.a \
+       $(top_builddir)/src/libpspp/libpspp.a \
+       $(top_builddir)/gl/libgl.a \
+       @LIBINTL@ @LIBREADLINE@
 
 src_ui_gui_psppiredir = $(pkgdatadir)
 
Index: pspp/src/ui/gui/message-dialog.c
diff -u pspp/src/ui/gui/message-dialog.c:1.10 
pspp/src/ui/gui/message-dialog.c:1.11
--- pspp/src/ui/gui/message-dialog.c:1.10       Tue Apr 25 18:03:03 2006
+++ pspp/src/ui/gui/message-dialog.c    Thu May  4 10:09:32 2006
@@ -31,6 +31,7 @@
 
 #include <gtk/gtk.h>
 #include <glade/glade.h>
+#include <glib.h>
 
 #include "helper.h"
 
@@ -39,11 +40,58 @@
 #define _(A) A
 
 static void handle_msg(const struct msg *);
+static void enqueue_msg(const struct msg *m);
+
+
+static GQueue *message_queue;
 
 void
 message_dialog_init (void) 
 {
-  msg_init(handle_msg);
+  message_queue = g_queue_new();
+  msg_init(enqueue_msg);
+}
+
+
+void
+message_dialog_done (void)
+{
+  msg_done();
+  g_queue_free(message_queue);
+}
+
+static gboolean 
+dequeue_message(gpointer data)
+{
+  struct msg * m ;
+
+  /* If a pointer grab is in effect, then the combination of that, and
+     a modal dialog box, will cause an impossible situation. 
+     So don't pop it up just yet.
+  */ 
+  if ( gdk_pointer_is_grabbed())
+    return TRUE;
+
+  m = g_queue_pop_tail(message_queue);
+
+  if ( m ) 
+    {
+      handle_msg(m);
+      msg_destroy(m);
+      return TRUE;
+    }
+  
+  return FALSE;
+}
+
+static void
+enqueue_msg(const struct msg *msg)
+{
+  struct msg *m = msg_dup(msg);
+
+  g_queue_push_head(message_queue, m);
+
+  g_idle_add(dequeue_message, 0);
 }
 
 static void
Index: pspp/src/ui/gui/message-dialog.h
diff -u pspp/src/ui/gui/message-dialog.h:1.4 
pspp/src/ui/gui/message-dialog.h:1.5
--- pspp/src/ui/gui/message-dialog.h:1.4        Tue Apr 25 18:03:03 2006
+++ pspp/src/ui/gui/message-dialog.h    Thu May  4 10:09:32 2006
@@ -25,5 +25,6 @@
 #include <libpspp/message.h>
 
 void message_dialog_init (void);
+void message_dialog_done (void);
 
 #endif
Index: pspp/src/ui/gui/psppire-data-store.c
diff -u pspp/src/ui/gui/psppire-data-store.c:1.3 
pspp/src/ui/gui/psppire-data-store.c:1.4
--- pspp/src/ui/gui/psppire-data-store.c:1.3    Tue Apr  4 12:43:22 2006
+++ pspp/src/ui/gui/psppire-data-store.c        Thu May  4 10:09:32 2006
@@ -329,10 +329,11 @@
 static const gchar *const 
 psppire_data_store_get_string(GSheetModel *model, gint row, gint column)
 {
+
   const struct fmt_spec *fp ;
   const struct PsppireVariable *pv ;
   const union value *v ;
-  static gchar s[255];
+  GString *s;
   PsppireDataStore *store = PSPPIRE_DATA_STORE(model);
 
   g_return_val_if_fail(store->dict, NULL);
@@ -344,6 +345,7 @@
   if ( row >= psppire_case_array_get_n_cases(store->cases))
     return NULL;
 
+
   pv = psppire_dict_get_variable(store->dict, column);
 
   v =  psppire_case_array_get_value(store->cases, row, 
@@ -362,21 +364,15 @@
 
   fp = psppire_variable_get_write_spec(pv);
 
-  if ( psppire_variable_get_type(pv) == NUMERIC ) 
-    {
-      /* Converts binary value V into printable form in the exactly
-        FP->W character in buffer S according to format specification
-        FP.  No null terminator is appended to the buffer.  */
-      data_out (s, fp, v);
-      s[fp->w] = '\0';
-    }
-  else
-    {
-      const gint len = psppire_variable_get_width(pv);
-      memcpy(s, v->s, len);
-      s[len] = '\0';
-    }
+  s = g_string_sized_new (fp->w);
+    
+  /* Converts binary value V into printable form in the exactly
+     FP->W character in buffer S according to format specification
+     FP.  No null terminator is appended to the buffer.  */
+  data_out (s->str, fp, v);
 
+  return g_string_free(s, FALSE);
+#if 0
   {
     static gchar buf[255];
     GError *err = NULL;
@@ -395,6 +391,7 @@
 
   return buf ;
   }
+#endif
 }
 
 
@@ -574,11 +571,12 @@
   /* FIXME: make this a member of the data store */
   static PangoLayout *layout = 0;
 
-
   gtk_sheet_get_attributes(sheet, row, col, &attributes);
 
   if (! layout ) 
     layout = gtk_widget_create_pango_layout (GTK_WIDGET(sheet), "M");
+
+  g_assert(layout);
   
   pango_layout_set_font_description (layout, 
                                     attributes.font_desc);
Index: pspp/src/ui/gui/psppire.c
diff -u pspp/src/ui/gui/psppire.c:1.5 pspp/src/ui/gui/psppire.c:1.6
--- pspp/src/ui/gui/psppire.c:1.5       Tue Apr 25 18:03:03 2006
+++ pspp/src/ui/gui/psppire.c   Thu May  4 10:09:32 2006
@@ -62,10 +62,11 @@
   GtkSheet *var_sheet ; 
   GtkSheet *data_sheet ;
 
+  gtk_init(&argc, &argv);
+
   if ( ! parse_command_line(&argc, &argv) ) 
     return 0;
 
-  gtk_init(&argc, &argv);
 
   glade_init();
 
@@ -105,6 +106,9 @@
 
   /* start the event loop */
   gtk_main();
+
+  message_dialog_done();
+
   return 0;
 }
 
@@ -141,7 +145,7 @@
          g_print(legal);
          return false;
        default:
-         assert (0);
+         return false;
        }
     }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]