From 8f9cef7439c54600f536b04ae82047da6fa16646 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Mon, 18 Jun 2001 22:27:36 +0000 Subject: gmixvm symbols dialog --- mixgtk/mixgtk_mixal.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) (limited to 'mixgtk/mixgtk_mixal.c') diff --git a/mixgtk/mixgtk_mixal.c b/mixgtk/mixgtk_mixal.c index db2218a..ed10602 100644 --- a/mixgtk/mixgtk_mixal.c +++ b/mixgtk/mixgtk_mixal.c @@ -37,6 +37,49 @@ static GtkStatusbar *status_; static gint status_context_; static GPtrArray *tips_text_ = NULL; +static GtkWidget *symbols_dlg_ = NULL; +static GtkWidget *symbols_clist_ = NULL; +static const gchar *SYMBOLS_CLIST_NAME_ = "symbols_clist"; + +static void +init_symbols_ (void) +{ + symbols_dlg_ = mixgtk_widget_factory_get_dialog (MIXGTK_SYMBOLS_DIALOG); + g_assert (symbols_dlg_); + symbols_clist_ = mixgtk_widget_factory_get_child_by_name + (MIXGTK_SYMBOLS_DIALOG, SYMBOLS_CLIST_NAME_); + g_assert (symbols_clist_); + gtk_clist_set_sort_type (GTK_CLIST (symbols_clist_), GTK_SORT_ASCENDING); + gtk_clist_set_auto_sort (GTK_CLIST (symbols_clist_), TRUE); +} + +static void +insert_symbol_ (gpointer symbol, gpointer value, gpointer list) +{ + enum {DEC_SIZE = 25, WORD_SIZE = 20}; + static gchar DEC[DEC_SIZE], WORD[WORD_SIZE]; + + gchar *text[] = {(gchar *)symbol, DEC, WORD}; + mix_word_t w = (mix_word_t)GPOINTER_TO_INT (value); + snprintf (DEC, DEC_SIZE, "%s%ld", + mix_word_is_negative (w)? "-" : "+", + mix_word_magnitude (w)); + mix_word_print_to_buffer (w, WORD); + gtk_clist_append ((GtkCList *)list, text); +} + +static void +fill_symbols_ (const mix_symbol_table_t *table) +{ + if (symbols_clist_) + gtk_clist_clear (GTK_CLIST (symbols_clist_)); + else + init_symbols_ (); + + mix_symbol_table_foreach (((mix_symbol_table_t *)table), + insert_symbol_, (gpointer)symbols_clist_); +} + static GdkColor colors_[3][2]; static GdkColormap *colormap_ = NULL; static const char* default_colors_[3][2] = { @@ -69,7 +112,8 @@ color_to_string_ (const GdkColor *color) { enum {LEN = 100}; static gchar buffer[LEN]; - g_snprintf (buffer, LEN, "%hd %hd %hd", color->red, color->green, color->blue); + g_snprintf (buffer, LEN, "%hd %hd %hd", + color->red, color->green, color->blue); return buffer; } @@ -223,6 +267,7 @@ mixgtk_mixal_load_file (void) if (table) update_tips_ (table, line); } + if (table) fill_symbols_ (table); gtk_clist_append (clist_, NULL_TEXT); gtk_clist_set_row_data (clist_, k, GINT_TO_POINTER (MIX_VM_CELL_NO)); gtk_clist_unselect_row (clist_, 0, 0); @@ -352,3 +397,16 @@ on_mixal_motion_notify_event (GtkWidget *list, GdkEventMotion *event, } return FALSE; } + +void +on_symbol_ok_clicked () +{ + gtk_widget_hide (symbols_dlg_); +} + +void +on_symbols_activate () +{ + if (!symbols_dlg_) init_symbols_ (); + gtk_widget_show (symbols_dlg_); +} -- cgit v1.2.3