From 3ab6797d68162c6094964ad0c5c7e194bee06b80 Mon Sep 17 00:00:00 2001 From: jaortega Date: Tue, 13 Mar 2001 22:21:16 +0000 Subject: minor changes --- mixgtk/mixgtk.glade | 422 ++++++++++++++++++++++++++++++++++-------------- mixgtk/mixgtk_input.c | 42 ++--- mixgtk/mixgtk_mixvm.c | 51 +++++- mixgtk/mixgtk_widgets.c | 24 ++- mixgtk/mixgtk_widgets.h | 3 +- 5 files changed, 380 insertions(+), 162 deletions(-) (limited to 'mixgtk') diff --git a/mixgtk/mixgtk.glade b/mixgtk/mixgtk.glade index 247d08b..25df994 100644 --- a/mixgtk/mixgtk.glade +++ b/mixgtk/mixgtk.glade @@ -47,7 +47,7 @@ 0 False - False + True @@ -143,6 +143,30 @@ + + + GtkMenuItem + help + + True + + + GtkMenu + help_menu + + + GtkMenuItem + about + + activate + on_about_activate + Tue, 13 Mar 2001 01:37:20 GMT + + + True + + + @@ -231,10 +255,9 @@ rA_entry 40 24 - 118 - 22 + 120 + 24 True - GDK_BUTTON_PRESS_MASK button_press_event on_register_click @@ -251,8 +274,8 @@ rX_entry 248 24 - 118 - 22 + 120 + 24 True button_press_event @@ -597,58 +620,6 @@ 263 - - GtkScrolledWindow - memory_scroll - 392 - 16 - 215 - 248 - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS - - - GtkCList - memory_cells - 200 - 248 - True - 2 - 53,135 - GTK_SELECTION_SINGLE - True - GTK_SHADOW_IN - - - GtkLabel - CList:title - label165 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - GtkLabel - CList:title - label166 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - GtkEntry rI5_entry @@ -682,63 +653,6 @@ - - GtkRadioButton - lesser_radio - 264 - 128 - 35 - 24 - True - - toggled - on_cmp_l_toggled - Tue, 06 Mar 2001 21:21:51 GMT - - - False - True - cmp_group - - - - GtkRadioButton - equal_radio - 304 - 128 - 31 - 24 - True - - toggled - on_cmp_e_toggled - Tue, 06 Mar 2001 21:22:04 GMT - - - False - True - cmp_group - - - - GtkRadioButton - greater_radio - 336 - 128 - 32 - 24 - True - - toggled - on_cmp_g_toggled - Tue, 06 Mar 2001 21:21:40 GMT - - - False - True - cmp_group - - GtkLabel label167 @@ -846,6 +760,125 @@ False True + + + GtkScrolledWindow + memory_scroll + 398 + 16 + 225 + 248 + GTK_POLICY_NEVER + GTK_POLICY_ALWAYS + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + + GtkCList + memory_cells + 195 + 248 + Click cell to change value + True + + select_row + on_memory_cells_select_row + True + Tue, 13 Mar 2001 07:38:52 GMT + + 2 + 53,135 + GTK_SELECTION_SINGLE + True + GTK_SHADOW_IN + + + GtkLabel + CList:title + label165 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + CList:title + label166 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + + + GtkRadioButton + lesser_radio + 264 + 128 + 35 + 24 + Comparison flag: lesser + True + + toggled + on_cmp_l_toggled + Tue, 06 Mar 2001 21:21:51 GMT + + + False + True + cmp_group + + + + GtkRadioButton + equal_radio + 304 + 128 + 31 + 24 + Comparison flag: equal + True + + toggled + on_cmp_e_toggled + Tue, 06 Mar 2001 21:22:04 GMT + + + False + True + cmp_group + + + + GtkRadioButton + greater_radio + 336 + 128 + 32 + 24 + Comparison flag: greater + True + + toggled + on_cmp_g_toggled + Tue, 06 Mar 2001 21:21:40 GMT + + + False + True + cmp_group + @@ -863,7 +896,7 @@ GtkScrolledWindow - scrolledwindow28 + mixal_scrol GTK_POLICY_AUTOMATIC GTK_POLICY_AUTOMATIC GTK_UPDATE_CONTINUOUS @@ -1061,9 +1094,24 @@ GtkDialog word_dialog False + + destroy + gtk_widget_hide + Tue, 13 Mar 2001 00:53:39 GMT + + + destroy_event + gtk_widget_hide + Tue, 13 Mar 2001 00:55:38 GMT + + + delete_event + gtk_widget_hide + Tue, 13 Mar 2001 00:56:33 GMT + Enter value GTK_WINDOW_DIALOG - GTK_WIN_POS_NONE + GTK_WIN_POS_MOUSE True 250 False @@ -1154,7 +1202,7 @@ GtkFixed - fixed3 + word_layout 250 97 @@ -1171,6 +1219,7 @@ 143 22 True + True key_press_event on_word_dec_key_press @@ -1179,8 +1228,8 @@ True True - 0 - -63 + 11 + 0 @@ -1270,6 +1319,7 @@ 64 22 22 + True True key_press_event @@ -1289,8 +1339,13 @@ 88 64 16 - 22 + 24 True + + key_press_event + on_word_sign_key_press + Tue, 13 Mar 2001 00:15:28 GMT + True True 1 @@ -1348,4 +1403,129 @@ + + GtkWindow + about_dialog + 368 + 99 + False + + delete_event + gtk_widget_hide + Tue, 13 Mar 2001 13:13:42 GMT + + + destroy_event + gtk_widget_hide + Tue, 13 Mar 2001 13:14:02 GMT + + + destroy + gtk_widget_hide + Tue, 13 Mar 2001 13:14:25 GMT + + MDK + GTK_WINDOW_DIALOG + GTK_WIN_POS_CENTER + True + False + False + False + + + GtkLayout + layout1 + 375 + 190 + 200 + 120 + 0 + 0 + + + GtkLabel + label222 + 56 + 16 + 247 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + version_label + 152 + 40 + 56 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + label224 + 0 + 64 + 358 + 16 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkHSeparator + hseparator4 + 8 + 0 + 356 + 16 + + + + GtkHSeparator + hseparator5 + 8 + 80 + 356 + 16 + + + + GtkVSeparator + vseparator4 + 0 + 7 + 16 + 83 + + + + GtkVSeparator + vseparator5 + 352 + 8 + 16 + 83 + + + + diff --git a/mixgtk/mixgtk_input.c b/mixgtk/mixgtk_input.c index 8f4a777..fa98056 100644 --- a/mixgtk/mixgtk_input.c +++ b/mixgtk/mixgtk_input.c @@ -1,7 +1,7 @@ /* -*-c-*- -------------- mixgtk_input.c : * Implementation of the functions declared in mixgtk_input.h * ------------------------------------------------------------------ - * Last change: Time-stamp: "01/03/13 01:27:32 jose" + * Last change: Time-stamp: "01/03/13 08:31:20 jose" * ------------------------------------------------------------------ * Copyright (C) 2001 Free Software Foundation, Inc. * @@ -21,6 +21,7 @@ * */ +#include #include #include "mixgtk_widgets.h" #include "mixgtk_input.h" @@ -34,7 +35,6 @@ static const gchar *WGT_NAMES_[SIZE_] = { "word_b4", "word_b5", "word_decimal", "word_reset", "word_ok" }; - static GtkDialog *dialog_; static GtkWidget *childs_[SIZE_]; static input_callback_t callback_; @@ -53,8 +53,8 @@ mixgtk_input_init (void) childs_[k] = mixgtk_widget_factory_get_by_name (WGT_NAMES_[k]); g_return_val_if_fail (childs_[k] != NULL, FALSE); } - return TRUE; + } static void @@ -71,7 +71,7 @@ set_word_ (mix_word_t word) for (k = 1; k < 6; ++k) { mix_byte_t b = mix_word_get_byte (word, k); - snprintf (BUFFER, SIZE, "%02d", (int)b); + snprintf (BUFFER, SIZE, "%d", (int)b); gtk_entry_set_text (GTK_ENTRY (childs_[SIGN_ + k]), BUFFER); } } @@ -105,32 +105,29 @@ mixgtk_input_short (const gchar *message, mix_short_t def, gtk_widget_hide (childs_[B1_]); gtk_widget_hide (childs_[B2_]); gtk_widget_hide (childs_[B3_]); - /* gtk_widget_draw (GTK_WIDGET (dialog_));*/ } #include /* dec and bytes input handler */ -void +gboolean on_word_dec_key_press (GtkWidget *dec, GdkEvent *event, gpointer *data) { GdkEventKey *key = (GdkEventKey *)event; - if (key->string && strlen (key->string) > 0) + if (key->string && strlen (key->string) > 0 && !iscntrl (key->string[0])) { gchar *text = gtk_entry_get_text (GTK_ENTRY (childs_[DEC_])); gint val = atoi (text); set_word_ (mix_word_new (val)); } - if (key->keyval == GDK_KP_Tab || key->keyval == GDK_Tab || - key->keyval == GDK_ISO_Left_Tab) - gtk_window_set_focus (GTK_WINDOW (dialog_), childs_[SIGN_]); + return FALSE; } -void +gboolean on_word_byte_key_press (GtkWidget *widget, GdkEvent *event, gpointer *data) { GdkEventKey *key = (GdkEventKey *)event; - if (key->string && strlen (key->string) > 0) + if (key->string && strlen (key->string) > 0 && !iscntrl (key->string[0])) { mix_byte_t bytes[5]; gint k; @@ -147,20 +144,14 @@ on_word_byte_key_press (GtkWidget *widget, GdkEvent *event, gpointer *data) if (s && s[0] == '-') mix_word_reverse_sign (w); set_word_ (w); } - if (key->keyval == GDK_KP_Tab || key->keyval == GDK_Tab || - key->keyval == GDK_ISO_Left_Tab) - { - gint k = 0; - while (widget != childs_[k]) ++k; - gtk_window_set_focus (GTK_WINDOW (dialog_), childs_[(k + 1)%SIZE_]); - } + return FALSE; } -void +gboolean on_word_sign_key_press (GtkWidget *widget, GdkEvent *event, gpointer *data) { GdkEventKey *key = (GdkEventKey *)event; - if (key->string && strlen (key->string) > 0) + if (key->string && strlen (key->string) > 0 && !iscntrl (key->string[0])) { gchar s = key->string[0]; gchar *txt = gtk_entry_get_text (GTK_ENTRY (childs_[SIGN_])); @@ -173,9 +164,7 @@ on_word_sign_key_press (GtkWidget *widget, GdkEvent *event, gpointer *data) set_word_ (mix_word_negative (w)); } } - if (key->keyval == GDK_KP_Tab || key->keyval == GDK_Tab || - key->keyval == GDK_ISO_Left_Tab) - gtk_window_set_focus (GTK_WINDOW (dialog_), childs_[B1_]); + return FALSE; } void @@ -198,8 +187,3 @@ on_word_reset_clicked (GtkWidget *w, gpointer *data) { set_word_ (MIX_WORD_ZERO); } - - - - - diff --git a/mixgtk/mixgtk_mixvm.c b/mixgtk/mixgtk_mixvm.c index 1ef32a5..c90b453 100644 --- a/mixgtk/mixgtk_mixvm.c +++ b/mixgtk/mixgtk_mixvm.c @@ -1,7 +1,7 @@ /* -*-c-*- -------------- mixgtk_mixvm.c : * Implementation of the functions declared in mixgtk_mixvm.h * ------------------------------------------------------------------ - * Last change: Time-stamp: "01/03/13 00:24:56 jose" + * Last change: Time-stamp: "01/03/13 23:14:00 jose" * ------------------------------------------------------------------ * Copyright (C) 2001 Free Software Foundation, Inc. * @@ -39,21 +39,25 @@ static GtkLabel *laptime_; static GtkLabel *progtime_; static GtkLabel *uptime_; static mix_vm_t *vm_; - +static GtkTooltips *tips_; static void update_register_ (mixgtk_widget_id_t reg) { static gchar BUFFER[20]; + mix_word_t tipval = MIX_WORD_ZERO; switch (reg) { case MIXGTK_WIDGET_rA: - mix_word_print_to_buffer (mix_vm_get_rA (vm_), BUFFER); + tipval = mix_vm_get_rA (vm_); + mix_word_print_to_buffer (tipval, BUFFER); break; case MIXGTK_WIDGET_rX: - mix_word_print_to_buffer (mix_vm_get_rX (vm_), BUFFER); + tipval = mix_vm_get_rX (vm_); + mix_word_print_to_buffer (tipval, BUFFER); break; case MIXGTK_WIDGET_rJ: + tipval = mix_short_to_word_fast (mix_vm_get_rJ (vm_)); mix_short_print_to_buffer (mix_vm_get_rJ (vm_), BUFFER); break; case MIXGTK_WIDGET_rI1: @@ -62,14 +66,22 @@ update_register_ (mixgtk_widget_id_t reg) case MIXGTK_WIDGET_rI4: case MIXGTK_WIDGET_rI5: case MIXGTK_WIDGET_rI6: - mix_short_print_to_buffer (mix_vm_get_rI (vm_, - reg - MIXGTK_WIDGET_rI1 + 1), - BUFFER); + { + gint k = reg - MIXGTK_WIDGET_rI1 + 1; + tipval = mix_short_to_word_fast (mix_vm_get_rI (vm_, k)); + mix_short_print_to_buffer (mix_vm_get_rI (vm_, k), BUFFER); + } break; default: g_assert_not_reached (); } gtk_entry_set_text (reg_entries_[reg - MIXGTK_WIDGET_rA], BUFFER); + snprintf (BUFFER, 20, "%s%ld", mix_word_is_negative (tipval)? "-" : "", + mix_word_magnitude (tipval)); + gtk_tooltips_set_tip (tips_, + GTK_WIDGET (reg_entries_[reg - MIXGTK_WIDGET_rA]), + BUFFER, NULL); + } @@ -92,6 +104,8 @@ mixgtk_mixvm_init (mix_vm_t *vm) g_return_val_if_fail (vm != NULL, FALSE); vm_ = vm; + tips_ = gtk_tooltips_new (); + for (k = 0; k < REGISTER_NO_; ++k) { reg_entries_[k] = @@ -323,7 +337,7 @@ register_i_ (mix_word_t w, gpointer reg) update_register_ (MIXGTK_WIDGET_rI1 - 1 + GPOINTER_TO_INT (reg)); } -void +gboolean on_register_click (GtkWidget *w, GdkEvent *e, gpointer data) { enum {SIZE = 20}; @@ -348,4 +362,25 @@ on_register_click (GtkWidget *w, GdkEvent *e, gpointer data) break; } } + return FALSE; +} + +static void +mem_cell_ (mix_word_t w, gpointer a) +{ + mix_short_t addr = mix_short_new (GPOINTER_TO_INT (a)); + mix_vm_set_addr_contents (vm_, addr, w); + mixgtk_mixvm_update_cells (); +} + +void +on_memory_cells_select_row (GtkCList *w, gint row, gint col, + GdkEvent *e, gpointer data) +{ + enum {SIZE = 20}; + static gchar BUFFER[SIZE]; + snprintf (BUFFER, SIZE, "Memory cell no. %d", row); + mixgtk_input_word (BUFFER, + mix_vm_get_addr_contents (vm_, mix_short_new (row)), + mem_cell_, GINT_TO_POINTER (row)); } diff --git a/mixgtk/mixgtk_widgets.c b/mixgtk/mixgtk_widgets.c index 3ff6436..5a2cd91 100644 --- a/mixgtk/mixgtk_widgets.c +++ b/mixgtk/mixgtk_widgets.c @@ -1,7 +1,7 @@ /* -*-c-*- -------------- mixgtk_widgets.c : * Implementation of the functions declared in mixgtk_widgets.h * ------------------------------------------------------------------ - * Last change: Time-stamp: "01/03/09 22:29:47 jose" + * Last change: Time-stamp: "01/03/13 14:09:05 jose" * ------------------------------------------------------------------ * Copyright (C) 2001 Free Software Foundation, Inc. * @@ -22,9 +22,10 @@ */ -#include "mixgtk_widgets.h" #include +#include +#include "mixgtk_widgets.h" /* the glade spec */ static GladeXML *xml_ = NULL; @@ -33,6 +34,7 @@ static GladeXML *xml_ = NULL; static const gchar *names_[] = { "main_window", "word_dialog", + "about_dialog", "command_prompt", "command_log", "mixal_clist", @@ -61,17 +63,28 @@ static const gchar *names_[] = { #define WIDGET_NO_ (sizeof (names_) / sizeof (names_[0])) +#define VERSION_LABEL_ "version_label" +#define GPL_TEXT_ "gpl_text" +GtkWidget *about_; /* create a new factory from an xml glade file */ gboolean mixgtk_widget_factory_init (const char *glade_file) { + GtkWidget *label; glade_init (); xml_ = glade_xml_new (glade_file, NULL); if (!xml_) return FALSE; glade_xml_signal_autoconnect (xml_); + about_ = mixgtk_widget_factory_get (MIXGTK_WIDGET_ABOUT_DIALOG); + g_return_val_if_fail (about_ != NULL, FALSE); + label = mixgtk_widget_factory_get_by_name (VERSION_LABEL_); + g_return_val_if_fail (label != NULL, FALSE); + gtk_label_set_text (GTK_LABEL(label), VERSION); + gtk_widget_show (label); + g_print ("%s", VERSION); return TRUE; } @@ -90,4 +103,9 @@ mixgtk_widget_factory_get_by_name (const gchar *name) return glade_xml_get_widget (xml_, name); } - +/* about box */ +void +on_about_activate (GtkWidget *w, gpointer data) +{ + gtk_widget_show (about_); +} diff --git a/mixgtk/mixgtk_widgets.h b/mixgtk/mixgtk_widgets.h index e457518..43b1426 100644 --- a/mixgtk/mixgtk_widgets.h +++ b/mixgtk/mixgtk_widgets.h @@ -1,7 +1,7 @@ /* -*-c-*- ---------------- mixgtk_widgets.h : * glade-based factory of mixvm widgets * ------------------------------------------------------------------ - * Last change: Time-stamp: <01/03/11 14:07:32 jose> + * Last change: Time-stamp: <01/03/13 10:20:50 jose> * ------------------------------------------------------------------ * Copyright (C) 2001 Free Software Foundation, Inc. * @@ -32,6 +32,7 @@ typedef enum { MIXGTK_WIDGET_MAIN, /* main app window */ MIXGTK_WIDGET_WORD_DIALOG, /* input dialog for a mix word */ + MIXGTK_WIDGET_ABOUT_DIALOG, MIXGTK_WIDGET_PROMPT, /* command prompt */ MIXGTK_WIDGET_LOG, /* command output */ MIXGTK_WIDGET_MIXAL, /* mixal source file */ -- cgit v1.2.3