diff options
-rw-r--r-- | mixgtk/mixgtk_device.c | 58 |
1 files changed, 42 insertions, 16 deletions
diff --git a/mixgtk/mixgtk_device.c b/mixgtk/mixgtk_device.c index ea84c18..3913bfa 100644 --- a/mixgtk/mixgtk_device.c +++ b/mixgtk/mixgtk_device.c @@ -1,7 +1,7 @@ /* -*-c-*- ---------------- mixgtk_device.c : * actual types for mixgtk devices * ------------------------------------------------------------------ - * Last change: Time-stamp: <2001-05-08 00:58:34 jao> + * Last change: Time-stamp: <2001-05-09 02:35:09 jao> * ------------------------------------------------------------------ * Copyright (C) 2001 Free Software Foundation, Inc. * @@ -41,7 +41,13 @@ struct mixgtk_device_t mix_device_t device; GtkWidget *widget; gint pos; +}; + +struct mixgtk_bin_device_t +{ + struct mixgtk_device_t gtk_device; guint last_insert; + GtkWidget *scroll; }; /* callbacks for output devices */ @@ -67,23 +73,28 @@ write_char_ (struct mixgtk_device_t *dev, const mix_word_t *block) } static void -write_bin_ (struct mixgtk_device_t *dev, const mix_word_t *block) +write_bin_ (struct mixgtk_bin_device_t *dev, const mix_word_t *block) { enum {BUFF_SIZE = 17}; static gchar BUFFER[BUFF_SIZE] = { 0 }; static gchar *DEFTEXT[BIN_DEV_COL_] = { "0", "0", "0", "0", "0" }; guint k, col, row; + GtkCList *list = GTK_CLIST (dev->gtk_device.widget); - for (k = 0; k < SIZES_[dev->device.type]; k++) + gtk_clist_freeze (list); + + for (k = 0; k < SIZES_[dev->gtk_device.device.type]; k++) { mix_word_print_to_buffer (block[k], BUFFER); row = dev->last_insert / BIN_DEV_COL_; col = dev->last_insert % BIN_DEV_COL_; - if (col == 0) gtk_clist_append (GTK_CLIST (dev->widget), DEFTEXT); - gtk_clist_set_text (GTK_CLIST (dev->widget), row, col, BUFFER); + if (col == 0) gtk_clist_append (list, DEFTEXT); + gtk_clist_set_text (list, row, col, BUFFER); dev->last_insert++; } + + gtk_clist_thaw (list); } static gboolean @@ -95,7 +106,7 @@ write_ (mix_device_t *dev, const mix_word_t *block) return FALSE; if (MODES_[dev->type] == mix_dev_CHAR) write_char_ (gtkdev, block); - else write_bin_ (gtkdev, block); + else write_bin_ ((struct mixgtk_bin_device_t *)gtkdev, block); gtk_notebook_set_page (container_, gtkdev->pos); @@ -112,7 +123,7 @@ read_ (mix_device_t *dev, mix_word_t *block) return FALSE; if (MODES_[dev->type] == mix_dev_CHAR) write_char_ (gtkdev, block); - else write_bin_ (gtkdev, block); + else write_bin_ ((struct mixgtk_bin_device_t *)gtkdev, block); gtk_notebook_set_page (container_, gtkdev->pos); @@ -136,7 +147,9 @@ destroy_ (mix_device_t *dev) { struct mixgtk_device_t *gtkdev = (struct mixgtk_device_t *)dev; gtk_notebook_remove_page (GTK_NOTEBOOK (container_), gtkdev->pos); - gtk_widget_destroy (gtkdev->widget); + gtk_widget_destroy (gtkdev->widget); + if (MODES_[dev->type] == mix_dev_BIN) + gtk_widget_destroy (((struct mixgtk_bin_device_t *)dev)->scroll); (DEF_DEV_VTABLE_->destroy) (dev); --last_pos_; } @@ -174,9 +187,12 @@ mixgtk_device_construct_gui_ (struct mixgtk_device_t *dev) else { gint k; - GtkWidget *scroll = gtk_scrolled_window_new (NULL, NULL); - g_assert (scroll); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), + struct mixgtk_bin_device_t *bindev = + (struct mixgtk_bin_device_t *)dev; + + bindev->scroll = gtk_scrolled_window_new (NULL, NULL); + g_assert (bindev->scroll); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (bindev->scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); dev->widget = gtk_clist_new (BIN_DEV_COL_); @@ -186,9 +202,9 @@ mixgtk_device_construct_gui_ (struct mixgtk_device_t *dev) gtk_clist_set_column_width (GTK_CLIST (dev->widget), k, 100); gtk_clist_set_column_auto_resize (GTK_CLIST (dev->widget), k, TRUE); } - gtk_container_add (GTK_CONTAINER (scroll), dev->widget); - gtk_notebook_insert_page (container_, scroll, label, dev->pos); - gtk_widget_show (scroll); + gtk_container_add (GTK_CONTAINER (bindev->scroll), dev->widget); + gtk_notebook_insert_page (container_, bindev->scroll, label, dev->pos); + gtk_widget_show (bindev->scroll); } gtk_widget_show (label); @@ -205,13 +221,23 @@ mixgtk_device_new_ (mix_device_type_t type) g_return_val_if_fail (type < mix_dev_INVALID, NULL); - dev = g_new (struct mixgtk_device_t, 1); + if (MODES_[type] == mix_dev_CHAR) + { + dev = g_new (struct mixgtk_device_t, 1); + } + else + { + dev = (struct mixgtk_device_t *) g_new (struct mixgtk_bin_device_t, 1); + ((struct mixgtk_bin_device_t *)dev)->last_insert = 0; + } + name = g_strconcat (g_get_home_dir(), "/", MIXGTK_FILES_DIR, "/", DEF_NAMES_[type], NULL); construct_device_with_name_ (&dev->device, type, name); g_free (name); + dev->device.vtable = &MIXGTK_VTABLE_; - dev->last_insert = 0; + mixgtk_device_construct_gui_ (dev); return (mix_device_t *)dev; |