summaryrefslogtreecommitdiffhomepage
path: root/mixgtk
diff options
context:
space:
mode:
Diffstat (limited to 'mixgtk')
-rw-r--r--mixgtk/mixgtk_device.c99
1 files changed, 70 insertions, 29 deletions
diff --git a/mixgtk/mixgtk_device.c b/mixgtk/mixgtk_device.c
index 2a31afe..ea84c18 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-06 23:34:51 jao>
+ * Last change: Time-stamp: <2001-05-08 00:58:34 jao>
* ------------------------------------------------------------------
* Copyright (C) 2001 Free Software Foundation, Inc.
*
@@ -27,8 +27,11 @@
#include "mixgtk.h"
#include "mixgtk_device.h"
+#define BIN_DEV_COL_ 5
+
/* device container */
static GtkNotebook *container_ = NULL;
+static gint last_pos_ = 0;
/* virtual machine */
static mix_vm_t *vm_ = NULL;
@@ -36,8 +39,9 @@ static mix_vm_t *vm_ = NULL;
struct mixgtk_device_t
{
mix_device_t device;
- GtkText *widget;
+ GtkWidget *widget;
gint pos;
+ guint last_insert;
};
/* callbacks for output devices */
@@ -58,23 +62,27 @@ write_char_ (struct mixgtk_device_t *dev, const mix_word_t *block)
BUFFER[5 * k] = '\n';
BUFFER[5 * k + 1] = '\0';
- gtk_text_insert (dev->widget, NULL, NULL, NULL, BUFFER, -1);
+ gtk_text_insert (GTK_TEXT (dev->widget), NULL, NULL, NULL, BUFFER, -1);
}
static void
write_bin_ (struct mixgtk_device_t *dev, const mix_word_t *block)
{
- enum {BUFF_SIZE = 17, STEP = 10};
+ enum {BUFF_SIZE = 17};
static gchar BUFFER[BUFF_SIZE] = { 0 };
- guint k;
+ static gchar *DEFTEXT[BIN_DEV_COL_] = { "0", "0", "0", "0", "0" };
+
+ guint k, col, row;
for (k = 0; k < SIZES_[dev->device.type]; k++)
{
mix_word_print_to_buffer (block[k], BUFFER);
- gtk_text_insert (dev->widget, NULL, NULL, NULL, BUFFER, -1);
- gtk_text_insert (dev->widget, NULL, NULL, NULL,
- ((k+1)%STEP != 0) ? " " : "\n", -1);
+ 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);
+ dev->last_insert++;
}
}
@@ -123,35 +131,68 @@ busy_ (const mix_device_t *dev)
return (DEF_DEV_VTABLE_->busy)(dev);
}
-static mix_device_vtable_t MIXGTK_VTABLE_ = {write_, read_, ioc_, busy_};
+static void
+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);
+ (DEF_DEV_VTABLE_->destroy) (dev);
+ --last_pos_;
+}
+static mix_device_vtable_t MIXGTK_VTABLE_ = {
+ write_, read_, ioc_, busy_, destroy_
+};
/* create the gui part of the device */
static void
mixgtk_device_construct_gui_ (struct mixgtk_device_t *dev)
{
- static gint last_pos = 0;
GtkWidget *label = gtk_label_new (DEF_NAMES_[dev->device.type]);
- GtkWidget *box = gtk_hbox_new (0, 0);
- GtkWidget *scroll = NULL;
g_assert (label);
- g_assert (box);
-
- dev->widget = (GtkText *)gtk_text_new (NULL, NULL);
- g_assert (dev->widget);
- gtk_text_set_editable (dev->widget, FALSE);
-
- scroll = gtk_vscrollbar_new (dev->widget->vadj);
- gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (dev->widget),
- TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (box), scroll, FALSE, FALSE, 0);
- dev->pos = last_pos++;
- gtk_notebook_insert_page (container_, box, label, dev->pos);
- gtk_widget_show (box);
+
+ dev->pos = last_pos_++;
+ if (MODES_[dev->device.type] == mix_dev_CHAR)
+ {
+ GtkWidget *box = gtk_hbox_new (0, 0);
+ GtkWidget *scroll = NULL;
+ GtkAdjustment *vadj = NULL;
+ dev->widget = gtk_text_new (NULL, NULL);
+ g_assert (box);
+ g_assert (dev->widget);
+ gtk_text_set_editable (GTK_TEXT (dev->widget), FALSE);
+ vadj = GTK_TEXT (dev->widget)->vadj;
+ scroll = gtk_vscrollbar_new (vadj);
+ gtk_box_pack_start (GTK_BOX (box), dev->widget, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (box), scroll, FALSE, FALSE, 0);
+ gtk_notebook_insert_page (container_, box, label, dev->pos);
+ gtk_widget_show (box);
+ gtk_widget_show (scroll);
+ }
+ else
+ {
+ gint k;
+ GtkWidget *scroll = gtk_scrolled_window_new (NULL, NULL);
+ g_assert (scroll);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+ dev->widget = gtk_clist_new (BIN_DEV_COL_);
+ g_assert (dev->widget);
+ for (k =0; k < BIN_DEV_COL_; ++k)
+ {
+ 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_widget_show (label);
- gtk_widget_show (scroll);
- gtk_widget_show (GTK_WIDGET (dev->widget));
+ gtk_widget_show (dev->widget);
gtk_widget_draw (GTK_WIDGET (container_), NULL);
}
@@ -170,7 +211,7 @@ mixgtk_device_new_ (mix_device_type_t type)
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;
@@ -181,7 +222,7 @@ gboolean
mixgtk_device_init (GtkNotebook *container, mix_vm_t *vm)
{
static mix_device_type_t def_types[] = {
- mix_dev_CONSOLE, mix_dev_INVALID
+ /* mix_dev_CONSOLE,*/ mix_dev_INVALID
};
gint k = 0;