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.glade | 156 +++++++++++++++++++++++++++++++++++++++++++++++- mixgtk/mixgtk_mixal.c | 60 ++++++++++++++++++- mixgtk/mixgtk_widgets.c | 3 +- mixgtk/mixgtk_widgets.h | 3 +- 4 files changed, 218 insertions(+), 4 deletions(-) (limited to 'mixgtk') diff --git a/mixgtk/mixgtk.glade b/mixgtk/mixgtk.glade index 8bb2211..2e227f4 100644 --- a/mixgtk/mixgtk.glade +++ b/mixgtk/mixgtk.glade @@ -204,6 +204,24 @@ False + + + GtkMenuItem + symbols + Show the symbol table + + GDK_MOD1_MASK + GDK_Y + activate + + + activate + on_symbols_activate + Mon, 18 Jun 2001 22:17:06 GMT + + + False + @@ -357,7 +375,7 @@ False - True + False @@ -2754,4 +2772,140 @@ + + GtkDialog + symbols_dialog + False + + delete_event + gtk_widget_hide + Mon, 18 Jun 2001 21:10:39 GMT + + + destroy_event + gtk_widget_hide + Mon, 18 Jun 2001 21:10:53 GMT + + + destroy + gtk_widget_hide + Mon, 18 Jun 2001 21:11:08 GMT + + Symbol table + GTK_WINDOW_DIALOG + GTK_WIN_POS_CENTER + False + 350 + 265 + True + True + False + + + GtkVBox + Dialog:vbox + dialog-vbox10 + False + 0 + + + GtkHBox + Dialog:action_area + dialog-action_area10 + 10 + True + 5 + + 0 + False + True + GTK_PACK_END + + + + GtkButton + button1 + 77 + True + + clicked + on_symbol_ok_clicked + Mon, 18 Jun 2001 21:10:02 GMT + + + GTK_RELIEF_NORMAL + + 0 + False + False + + + + + + GtkScrolledWindow + scrolledwindow26 + GTK_POLICY_ALWAYS + GTK_POLICY_ALWAYS + GTK_UPDATE_CONTINUOUS + GTK_UPDATE_CONTINUOUS + + 0 + True + True + + + + GtkCList + symbols_clist + True + 3 + 80,112,80 + GTK_SELECTION_SINGLE + True + GTK_SHADOW_IN + + + GtkLabel + CList:title + label236 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + CList:title + label237 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + GtkLabel + CList:title + label238 + + GTK_JUSTIFY_CENTER + False + 0.5 + 0.5 + 0 + 0 + + + + + + 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_); +} diff --git a/mixgtk/mixgtk_widgets.c b/mixgtk/mixgtk_widgets.c index d5ac7b1..d665cc6 100644 --- a/mixgtk/mixgtk_widgets.c +++ b/mixgtk/mixgtk_widgets.c @@ -38,7 +38,8 @@ static const gchar * dnames_[] = { "colorsel_dialog", "fontsel_dialog", "devform_dialog", - "external_dialog" + "external_dialog", + "symbols_dialog" }; #define DLG_NO_ (sizeof (dnames_) / sizeof(dnames_[0])) diff --git a/mixgtk/mixgtk_widgets.h b/mixgtk/mixgtk_widgets.h index ed7cf7e..b50fa10 100644 --- a/mixgtk/mixgtk_widgets.h +++ b/mixgtk/mixgtk_widgets.h @@ -38,7 +38,8 @@ typedef enum { MIXGTK_COLORSEL_DIALOG, /* color selection dialog */ MIXGTK_FONTSEL_DIALOG, /* font selection dialog */ MIXGTK_DEVFORM_DIALOG, /* device format config dialog */ - MIXGTK_EXTERNPROG_DIALOG /* external programs dialog */ + MIXGTK_EXTERNPROG_DIALOG, /* external programs dialog */ + MIXGTK_SYMBOLS_DIALOG /* symbol table dialog */ } mixgtk_dialog_id_t; /* enumeration of mixvm widget ids */ -- cgit v1.2.3