From: John Darrington Date: Thu, 4 May 2006 10:09:31 +0000 (+0000) Subject: Added simple queueing to message dialogs. X-Git-Tag: v0.6.0~903 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a55b554c0479168ef3e4879fe0fa517f7ca4def7;p=pspp-builds.git Added simple queueing to message dialogs. Fixed broken data sheet for very long strings. Fixed broken makefile dependency. --- diff --git a/lib/gtksheet/ChangeLog b/lib/gtksheet/ChangeLog index 0094fa46..6d4075d8 100644 --- a/lib/gtksheet/ChangeLog +++ b/lib/gtksheet/ChangeLog @@ -1,3 +1,9 @@ +Thu May 4 17:55:48 WST 2006 John Darrington + + * gtksheet.c: Added callback on inserted rows. + +Sat Jan 28 08:48:08 2006 UTC John Darrington + * 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. diff --git a/lib/gtksheet/gtksheet.c b/lib/gtksheet/gtksheet.c index fbaa73c2..648126f0 100644 --- a/lib/gtksheet/gtksheet.c +++ b/lib/gtksheet/gtksheet.c @@ -1123,14 +1123,18 @@ gtk_sheet_init (GtkSheet *sheet) } +/* 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 @@ gtk_sheet_set_model(GtkSheet *sheet, GSheetModel *model) 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 @@ gtk_sheet_autoresize_column (GtkSheet *sheet, gint column) 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 @@ gtk_sheet_draw_active_cell(GtkSheet *sheet) #endif gtk_sheet_draw_backing_pixmap(sheet, sheet->range); gtk_sheet_draw_border(sheet, sheet->range); - } diff --git a/src/libpspp/ChangeLog b/src/libpspp/ChangeLog index 6375857a..bbc3e839 100644 --- a/src/libpspp/ChangeLog +++ b/src/libpspp/ChangeLog @@ -1,3 +1,7 @@ +Thu May 4 18:01:37 WST 2006 John Darrington + + * message.c message.h: Added functions to create and copy a msg. + Tue May 2 15:41:50 2006 Ben Pfaff * str.c (ds_append_uninit): No need to add 1 to arg passed to diff --git a/src/libpspp/message.c b/src/libpspp/message.c index 34ca65ce..6bc8344a 100644 --- a/src/libpspp/message.c +++ b/src/libpspp/message.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -68,6 +69,27 @@ msg_done (void) { } + +/* 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 diff --git a/src/libpspp/message.h b/src/libpspp/message.h index 71fe1fa0..d46ea97d 100644 --- a/src/libpspp/message.h +++ b/src/libpspp/message.h @@ -89,6 +89,9 @@ struct msg 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); diff --git a/src/ui/gui/ChangeLog b/src/ui/gui/ChangeLog index 7f87bbda..6cd43309 100644 --- a/src/ui/gui/ChangeLog +++ b/src/ui/gui/ChangeLog @@ -1,3 +1,14 @@ +Thu May 4 18:04:04 WST 2006 John Darrington + + * 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 Finish reforming error message support. In this phase, move diff --git a/src/ui/gui/automake.mk b/src/ui/gui/automake.mk index 5365451c..6eba7189 100644 --- a/src/ui/gui/automake.mk +++ b/src/ui/gui/automake.mk @@ -10,11 +10,11 @@ src_ui_gui_psppire_LDFLAGS = \ 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) diff --git a/src/ui/gui/message-dialog.c b/src/ui/gui/message-dialog.c index cf1fb851..e5b27562 100644 --- a/src/ui/gui/message-dialog.c +++ b/src/ui/gui/message-dialog.c @@ -31,6 +31,7 @@ #include #include +#include #include "helper.h" @@ -39,11 +40,58 @@ extern GladeXML *xml; #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 diff --git a/src/ui/gui/message-dialog.h b/src/ui/gui/message-dialog.h index bda1608d..8d4526f0 100644 --- a/src/ui/gui/message-dialog.h +++ b/src/ui/gui/message-dialog.h @@ -25,5 +25,6 @@ #include void message_dialog_init (void); +void message_dialog_done (void); #endif diff --git a/src/ui/gui/psppire-data-store.c b/src/ui/gui/psppire-data-store.c index e8537bcc..0cb71904 100644 --- a/src/ui/gui/psppire-data-store.c +++ b/src/ui/gui/psppire-data-store.c @@ -329,10 +329,11 @@ psppire_data_store_finalize (GObject *object) 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 @@ psppire_data_store_get_string(GSheetModel *model, gint row, gint column) 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 @@ psppire_data_store_get_string(GSheetModel *model, gint row, gint column) 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 @@ psppire_data_store_get_string(GSheetModel *model, gint row, gint column) return buf ; } +#endif } @@ -574,11 +571,12 @@ M_width(GtkSheet *sheet, gint row, gint col) /* 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); diff --git a/src/ui/gui/psppire.c b/src/ui/gui/psppire.c index b291b0af..aefb26e7 100644 --- a/src/ui/gui/psppire.c +++ b/src/ui/gui/psppire.c @@ -62,10 +62,11 @@ main(int argc, char *argv[]) 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 @@ main(int argc, char *argv[]) /* start the event loop */ gtk_main(); + + message_dialog_done(); + return 0; } @@ -141,7 +145,7 @@ parse_command_line (int *argc, char ***argv) g_print(legal); return false; default: - assert (0); + return false; } }