summaryrefslogtreecommitdiffhomepage
path: root/mixgtk
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2004-06-11 23:35:59 +0000
committerJose Antonio Ortega Ruiz <jao@gnu.org>2004-06-11 23:35:59 +0000
commit2505eb439770002bd0ccf49866b820ce8aaa2fba (patch)
tree353f8ed7fca5b2563e0a1bad56bc4d641909f886 /mixgtk
parent42c9fa107e410a9ec8c4ebc640c885ebdd8731f8 (diff)
downloadmdk-2505eb439770002bd0ccf49866b820ce8aaa2fba.tar.gz
mdk-2505eb439770002bd0ccf49866b820ce8aaa2fba.tar.bz2
support for terminal device input in the form of a new dialog.
Diffstat (limited to 'mixgtk')
-rw-r--r--mixgtk/mixgtk.glade147
-rw-r--r--mixgtk/mixgtk_device.c128
-rw-r--r--mixgtk/mixgtk_widgets.c19
-rw-r--r--mixgtk/mixgtk_widgets.h11
4 files changed, 252 insertions, 53 deletions
diff --git a/mixgtk/mixgtk.glade b/mixgtk/mixgtk.glade
index b3021ca..8c8d137 100644
--- a/mixgtk/mixgtk.glade
+++ b/mixgtk/mixgtk.glade
@@ -5116,4 +5116,151 @@
</widget>
</widget>
+<widget>
+ <class>GtkDialog</class>
+ <name>input_dialog</name>
+ <visible>False</visible>
+ <signal>
+ <name>destroy</name>
+ <handler>gtk_true</handler>
+ <last_modification_time>Fri, 11 Jun 2004 20:59:50 GMT</last_modification_time>
+ </signal>
+ <signal>
+ <name>delete_event</name>
+ <handler>gtk_true</handler>
+ <last_modification_time>Fri, 11 Jun 2004 21:00:03 GMT</last_modification_time>
+ </signal>
+ <signal>
+ <name>destroy_event</name>
+ <handler>gtk_true</handler>
+ <last_modification_time>Fri, 11 Jun 2004 21:00:51 GMT</last_modification_time>
+ </signal>
+ <title>Terminal input</title>
+ <type>GTK_WINDOW_POPUP</type>
+ <position>GTK_WIN_POS_CENTER</position>
+ <modal>True</modal>
+ <default_width>510</default_width>
+ <allow_shrink>False</allow_shrink>
+ <allow_grow>False</allow_grow>
+ <auto_shrink>False</auto_shrink>
+
+ <widget>
+ <class>GtkVBox</class>
+ <child_name>Dialog:vbox</child_name>
+ <name>dialog-vbox12</name>
+ <homogeneous>False</homogeneous>
+ <spacing>0</spacing>
+
+ <widget>
+ <class>GtkHBox</class>
+ <child_name>Dialog:action_area</child_name>
+ <name>dialog-action_area12</name>
+ <border_width>1</border_width>
+ <homogeneous>True</homogeneous>
+ <spacing>5</spacing>
+ <child>
+ <padding>0</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ <pack>GTK_PACK_END</pack>
+ </child>
+
+ <widget>
+ <class>GtkHButtonBox</class>
+ <name>hbuttonbox11</name>
+ <layout_style>GTK_BUTTONBOX_END</layout_style>
+ <spacing>0</spacing>
+ <child_min_width>85</child_min_width>
+ <child_min_height>27</child_min_height>
+ <child_ipad_x>7</child_ipad_x>
+ <child_ipad_y>0</child_ipad_y>
+ <child>
+ <padding>0</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+
+ <widget>
+ <class>GtkButton</class>
+ <name>input_ok_button</name>
+ <can_default>True</can_default>
+ <can_focus>True</can_focus>
+ <signal>
+ <name>clicked</name>
+ <handler>on_input_ok_clicked</handler>
+ <last_modification_time>Fri, 11 Jun 2004 21:01:32 GMT</last_modification_time>
+ </signal>
+ <label>_OK</label>
+ <relief>GTK_RELIEF_NORMAL</relief>
+ </widget>
+
+ <widget>
+ <class>GtkButton</class>
+ <name>input_clear_button</name>
+ <can_default>True</can_default>
+ <can_focus>True</can_focus>
+ <signal>
+ <name>clicked</name>
+ <handler>on_input_clear_clicked</handler>
+ <last_modification_time>Fri, 11 Jun 2004 21:01:56 GMT</last_modification_time>
+ </signal>
+ <label>_Clear</label>
+ <relief>GTK_RELIEF_NORMAL</relief>
+ </widget>
+ </widget>
+ </widget>
+
+ <widget>
+ <class>GtkVBox</class>
+ <name>vbox6</name>
+ <border_width>5</border_width>
+ <homogeneous>True</homogeneous>
+ <spacing>0</spacing>
+ <child>
+ <padding>5</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+
+ <widget>
+ <class>GtkLabel</class>
+ <name>label240</name>
+ <label>The MIX terminal requests input. Please enter up to 70 characters:</label>
+ <justify>GTK_JUSTIFY_LEFT</justify>
+ <wrap>False</wrap>
+ <xalign>0.5</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <child>
+ <padding>2</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+ </widget>
+
+ <widget>
+ <class>GtkEntry</class>
+ <name>input_entry</name>
+ <can_focus>True</can_focus>
+ <has_focus>True</has_focus>
+ <signal>
+ <name>activate</name>
+ <handler>on_input_entry_activate</handler>
+ <last_modification_time>Fri, 11 Jun 2004 23:30:53 GMT</last_modification_time>
+ </signal>
+ <editable>True</editable>
+ <text_visible>True</text_visible>
+ <text_max_length>70</text_max_length>
+ <text></text>
+ <child>
+ <padding>4</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+ </widget>
+ </widget>
+ </widget>
+</widget>
+
</GTK-Interface>
diff --git a/mixgtk/mixgtk_device.c b/mixgtk/mixgtk_device.c
index 3c55021..5ba3f9f 100644
--- a/mixgtk/mixgtk_device.c
+++ b/mixgtk/mixgtk_device.c
@@ -1,24 +1,24 @@
/* -*-c-*- ---------------- mixgtk_device.c :
* actual types for mixgtk devices
* ------------------------------------------------------------------
- * $Id: mixgtk_device.c,v 1.19 2002/04/10 23:39:40 jao Exp $
+ * $Id: mixgtk_device.c,v 1.20 2004/06/11 23:35:59 jao Exp $
* ------------------------------------------------------------------
- * Copyright (C) 2001, 2002 Free Software Foundation, Inc.
- *
+ * Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc.
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
+ *
*/
@@ -45,6 +45,9 @@ static GtkNotebook *container_ = NULL;
/* devdir dialog */
static GtkWidget *devdir_dlg_ = NULL;
static GtkEntry *devdir_entry_ = NULL;
+/* terminal input dialog */
+static GtkWidget *input_dlg_ = NULL;
+static GtkEntry *input_dlg_entry_ = NULL;
/** configuration stuff */
#define LAST_BIN_DEV_ mix_dev_DISK_7
@@ -98,9 +101,9 @@ write_char_ (struct mixgtk_device_t *dev, const mix_word_t *block)
BUFFER[5 * k] = '\n';
BUFFER[5 * k + 1] = '\0';
-
+
gtk_text_insert (GTK_TEXT (dev->widget), NULL, NULL, NULL, BUFFER, -1);
-
+
}
static const gchar *
@@ -121,16 +124,16 @@ static void
write_bin_ (struct mixgtk_bin_device_t *dev, const mix_word_t *block)
{
static gchar *DEFTEXT[BIN_DEV_COL_] = { "0", "0", "0", "0", "0" };
-
+
guint k, col, row;
gboolean dec = FALSE;
-
+
GtkCList *list = GTK_CLIST (dev->gtk_device.widget);
-
+
dec = IS_DEC(decs_, dev->gtk_device.device.type);
gtk_clist_freeze (list);
-
+
for (k = 0; k < SIZES_[dev->gtk_device.device.type]; k++)
{
row = dev->last_insert / BIN_DEV_COL_;
@@ -139,14 +142,14 @@ write_bin_ (struct mixgtk_bin_device_t *dev, const mix_word_t *block)
{
int j;
mix_word_t *words = g_new (mix_word_t, 5);
- gtk_clist_append (list, DEFTEXT);
+ gtk_clist_append (list, DEFTEXT);
for (j = 0; j < 5; ++j) words[j] = block[k + j];
gtk_clist_set_row_data_full (list, row, (gpointer)words, g_free);
}
gtk_clist_set_text (list, row, col, get_word_string_ (block[k], dec));
dev->last_insert++;
}
-
+
gtk_clist_thaw (list);
}
@@ -157,14 +160,14 @@ redraw_bin_device_ (struct mixgtk_bin_device_t *dev)
gboolean dec = FALSE;
mix_word_t *words = NULL;
GtkCList *list;
-
+
if (!dev) return;
-
+
list = GTK_CLIST (dev->gtk_device.widget);
dec = IS_DEC(decs_, dev->gtk_device.device.type);
gtk_clist_freeze (list);
-
+
for (k = 0; k < dev->last_insert; ++k)
{
row = k / BIN_DEV_COL_;
@@ -173,52 +176,80 @@ redraw_bin_device_ (struct mixgtk_bin_device_t *dev)
words = gtk_clist_get_row_data (list, row);
gtk_clist_set_text (list, row, col, get_word_string_ (words[col], dec));
}
-
+
gtk_clist_thaw (list);
}
-
+
static gboolean
write_ (mix_device_t *dev, const mix_word_t *block)
{
struct mixgtk_device_t *gtkdev = (struct mixgtk_device_t *) dev;
-
+
if (dev->type != mix_dev_CONSOLE && !(DEF_DEV_VTABLE_->write)(dev, block))
return FALSE;
if (MODES_[dev->type] == mix_dev_CHAR) write_char_ (gtkdev, block);
else write_bin_ ((struct mixgtk_bin_device_t *)gtkdev, block);
-
+
gtk_notebook_set_page (container_, gtkdev->pos);
return TRUE;
}
+static gboolean
+read_cons_ (mix_word_t *block)
+{
+ gchar *text;
+ size_t i, j;
-static gboolean
+ if (input_dlg_ == NULL)
+ {
+ input_dlg_ = mixgtk_widget_factory_get_dialog (MIXGTK_INPUT_DIALOG);
+ g_assert (input_dlg_);
+ input_dlg_entry_ = GTK_ENTRY (mixgtk_widget_factory_get_child_by_name
+ (MIXGTK_INPUT_DIALOG, "input_entry"));
+ g_assert (input_dlg_entry_);
+ }
+
+ gtk_widget_show (input_dlg_);
+ gtk_main (); /* wait until dialog closes */
+ text = g_strdup_printf ("%-70s", gtk_entry_get_text (input_dlg_entry_));
+ for (i = 0; i < 70; ++i)
+ for (j = 0; j < 5; ++j)
+ mix_word_set_byte (block + i, j + 1,
+ mix_char_to_byte
+ (mix_ascii_to_char (text[5 * i + j])));
+ g_free (text);
+ return TRUE;
+}
+
+static gboolean
read_ (mix_device_t *dev, mix_word_t *block)
{
struct mixgtk_device_t *gtkdev = (struct mixgtk_device_t *) dev;
+ if (dev->type == mix_dev_CONSOLE && !read_cons_ (block)) return FALSE;
+
if (dev->type != mix_dev_CONSOLE && !(DEF_DEV_VTABLE_->read)(dev, block))
return FALSE;
if (MODES_[dev->type] == mix_dev_CHAR) write_char_ (gtkdev, block);
else write_bin_ ((struct mixgtk_bin_device_t *)gtkdev, block);
-
+
gtk_notebook_set_page (container_, gtkdev->pos);
return TRUE;
}
-static gboolean
+static gboolean
ioc_ (mix_device_t *dev, mix_short_t cmd)
{
return (DEF_DEV_VTABLE_->ioc)(dev, cmd);
}
static gboolean
-busy_ (const mix_device_t *dev)
+busy_ (const mix_device_t *dev)
{
return (DEF_DEV_VTABLE_->busy)(dev);
}
@@ -270,7 +301,7 @@ mixgtk_device_construct_gui_ (struct mixgtk_device_t *dev)
gint k;
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),
@@ -287,7 +318,7 @@ mixgtk_device_construct_gui_ (struct mixgtk_device_t *dev)
gtk_notebook_insert_page (container_, bindev->scroll, label, dev->pos);
gtk_widget_show (bindev->scroll);
}
-
+
gtk_widget_show (label);
gtk_widget_set_style (dev->widget,
gtk_widget_get_style (GTK_WIDGET (container_)));
@@ -300,7 +331,7 @@ static mix_device_t *
mixgtk_device_new_ (mix_device_type_t type)
{
struct mixgtk_device_t *dev = NULL;
-
+
g_return_val_if_fail (type < mix_dev_INVALID, NULL);
if (MODES_[type] == mix_dev_CHAR)
@@ -367,7 +398,7 @@ gboolean
mixgtk_device_init (GtkNotebook *container, mix_vm_t *vm)
{
gint k = 0;
-
+
g_return_val_if_fail (container != NULL, FALSE);
g_return_val_if_fail (vm != NULL, FALSE);
container_ = container;
@@ -376,6 +407,7 @@ mixgtk_device_init (GtkNotebook *container, mix_vm_t *vm)
devdlg_ = NULL;
devdir_dlg_ = NULL;
devdir_entry_ = NULL;
+ input_dlg_ = NULL;
dtoggle_ = NULL;
wtoggle_ = NULL;
combo_ = NULL;
@@ -384,11 +416,11 @@ mixgtk_device_init (GtkNotebook *container, mix_vm_t *vm)
gtk_notebook_remove_page (container_, 0);
mix_vm_set_device_factory (vm, mixgtk_device_new_);
-
+
/* read format configuration */
if (mixgtk_config_get (DEV_FORMAT_KEY_))
decs_ = atoi (mixgtk_config_get (DEV_FORMAT_KEY_));
-
+
/* re-create existing devices */
for (k = 0; k < mix_dev_INVALID; ++k)
{
@@ -403,7 +435,7 @@ mixgtk_device_init (GtkNotebook *container, mix_vm_t *vm)
/* set to first page */
gtk_notebook_set_page (container_, 0);
-
+
return TRUE;
}
@@ -411,11 +443,11 @@ void
mixgtk_device_set_format (mix_device_type_t dev, gboolean dec)
{
gboolean changed;
-
+
g_return_if_fail (dev < mix_dev_INVALID);
-
+
changed = (dec && !IS_DEC (decs_, dev)) || (!dec && IS_DEC (decs_, dev));
-
+
if (changed && (MODES_[dev] == mix_dev_BIN))
{
if (dec) SET_DEC (decs_, dev);
@@ -423,7 +455,7 @@ mixgtk_device_set_format (mix_device_type_t dev, gboolean dec)
redraw_bin_device_ ((struct mixgtk_bin_device_t *)
mix_vm_get_device (vm_, dev));
}
-
+
}
@@ -445,7 +477,7 @@ init_devform_ (void)
{
GList *names = NULL;
int k;
-
+
devdlg_ = mixgtk_widget_factory_get_dialog (MIXGTK_DEVFORM_DIALOG);
g_assert (devdlg_);
dtoggle_ = mixgtk_widget_factory_get_child_by_name
@@ -457,7 +489,7 @@ init_devform_ (void)
combo_ = mixgtk_widget_factory_get_child_by_name
(MIXGTK_DEVFORM_DIALOG, "dev_combo");
g_assert (combo_);
-
+
for (k = 0; k <= LAST_BIN_DEV_; ++k)
names = g_list_append (names, (gchar *)DEF_NAMES_[k]);
gtk_combo_set_popdown_strings (GTK_COMBO (combo_), names);
@@ -482,7 +514,6 @@ on_devform_activate ()
on_deventry_changed ();
}
-
void
on_decradio_toggled (GtkToggleButton *button)
{
@@ -570,3 +601,22 @@ on_devdir_ok_clicked ()
mixgtk_cmd_dispatcher_dispatch (cmd);
g_free (cmd);
}
+
+void
+on_input_ok_clicked ()
+{
+ gtk_widget_hide (input_dlg_);
+ gtk_main_quit ();
+}
+
+void
+on_input_clear_clicked ()
+{
+ gtk_entry_set_text (input_dlg_entry_, "");
+}
+
+void
+on_input_entry_activate ()
+{
+ on_input_ok_clicked ();
+}
diff --git a/mixgtk/mixgtk_widgets.c b/mixgtk/mixgtk_widgets.c
index 1cdbee2..9ff76a6 100644
--- a/mixgtk/mixgtk_widgets.c
+++ b/mixgtk/mixgtk_widgets.c
@@ -3,22 +3,22 @@
* ------------------------------------------------------------------
* Last change: Time-stamp: "2001-04-29 14:32:17 jao"
* ------------------------------------------------------------------
- * Copyright (C) 2001 Free Software Foundation, Inc.
- *
+ * Copyright (C) 2001, 2004 Free Software Foundation, Inc.
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
+ *
*/
@@ -43,6 +43,7 @@ static const gchar * dnames_[] = {
"devform_dialog",
"external_dialog",
"symbols_dialog",
+ "input_dialog",
"devdir_dialog"
};
@@ -134,9 +135,9 @@ gboolean
mixgtk_widget_factory_init (void)
{
gboolean split = mixgtk_config_is_split ();
-
+
about_ = NULL;
-
+
if (!file_)
{
const gchar *glade_file = GLADE_FILE;
@@ -152,9 +153,9 @@ mixgtk_widget_factory_init (void)
gint k;
for (k = 0; k < DLG_NO_; ++k) if (xml_[k]) xml_[k] = NULL;
}
-
+
split_ = split;
-
+
dnames_[MIXGTK_MAIN] = split_? SPLIT_MAIN_NAME_ : MAIN_NAME_;
init_xml_ (MIXGTK_MAIN);
diff --git a/mixgtk/mixgtk_widgets.h b/mixgtk/mixgtk_widgets.h
index a38d4e9..6d84fc5 100644
--- a/mixgtk/mixgtk_widgets.h
+++ b/mixgtk/mixgtk_widgets.h
@@ -3,22 +3,22 @@
* ------------------------------------------------------------------
* Last change: Time-stamp: <2001-04-27 23:32:16 jao>
* ------------------------------------------------------------------
- * Copyright (C) 2001 Free Software Foundation, Inc.
- *
+ * Copyright (C) 2001, 2004 Free Software Foundation, Inc.
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
+ *
*/
@@ -43,6 +43,7 @@ typedef enum {
MIXGTK_DEVFORM_DIALOG, /* device format config dialog */
MIXGTK_EXTERNPROG_DIALOG, /* external programs dialog */
MIXGTK_SYMBOLS_DIALOG, /* symbol table dialog */
+ MIXGTK_INPUT_DIALOG, /* console input dialog */
MIXGTK_DEVDIR_DIALOG
} mixgtk_dialog_id_t;