~ubuntu-branches/ubuntu/quantal/gnusim8085/quantal

« back to all changes in this revision

Viewing changes to src/callbacks.c

  • Committer: Bazaar Package Importer
  • Author(s): Onkar Shinde
  • Date: 2011-02-21 00:01:55 UTC
  • mfrom: (4.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110221000155-8k286v0kurbve3fp
Tags: 1.3.7-1
* New upstream release.
* debian/control
  - Update standards version to 3.9.1.
  - Reduce debhelper version required to 5 as no dh7 features are used.
  - Remove autotools-dev build-dep. Not needed anymore.
* debian/copyright
  - Update as per latest source.
* debian/rules
  - Exclude asm-guide.txt from compression as it is loaded by application.
* debian/source/format
  - Specify 1.0 source format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
  Copyright (C) 2003  Sridhar Ratnakumar <srid@nearfar.org>
 
2
  Copyright (C) 2003  Sridhar Ratnakumar <sridhar.ratna@gmail.com>
3
3
        
4
4
  This file is part of GNUSim8085.
5
5
 
15
15
 
16
16
  You should have received a copy of the GNU General Public License
17
17
  along with GNUSim8085; if not, write to the Free Software
18
 
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
  Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
 
19
  02110-1301, USA.
19
20
*/
20
21
#ifdef HAVE_CONFIG_H
21
22
#  include <config.h>
31
32
#include "bridge.h"
32
33
#include "asm-listing.h"
33
34
#include "file-op.h"
 
35
#include "gui-list-memory.h"
 
36
#include "gui-list-io.h"
34
37
 
35
38
#define DEFAULT_LOAD_ADDR 0x4200
36
39
 
38
41
 
39
42
GUIEditor *edit = NULL;
40
43
GtkWidget *wind = NULL;
 
44
GtkWidget *tutorial = NULL;
41
45
GtkWidget *filew = NULL;
42
46
 
43
47
gboolean
125
129
  gui_editor_print (app->editor);
126
130
}
127
131
 
 
132
void on_font_select_activate (GtkAction * menuitem, gpointer user_data)
 
133
{
 
134
  GtkWidget *font_selection_dialog = NULL;
 
135
  const gchar *font_name = gui_editor_get_font (app->editor);
 
136
  gint action = 0;
 
137
  g_assert (app->editor);
 
138
  font_selection_dialog = gtk_font_selection_dialog_new (_("Select font"));
 
139
  gtk_font_selection_dialog_set_font_name (GTK_FONT_SELECTION_DIALOG (font_selection_dialog), font_name);
 
140
  action = gtk_dialog_run (GTK_DIALOG (font_selection_dialog));
 
141
  switch (action) 
 
142
  {
 
143
    case GTK_RESPONSE_OK:
 
144
      font_name = gtk_font_selection_dialog_get_font_name (GTK_FONT_SELECTION_DIALOG (font_selection_dialog));
 
145
      if (font_name)
 
146
      {
 
147
        gui_editor_set_font (app->editor, font_name);
 
148
      }
 
149
      break;
 
150
    default:
 
151
      break;
 
152
  }
 
153
  
 
154
  gtk_widget_destroy(font_selection_dialog);
 
155
}
128
156
 
129
157
void
130
158
on_quit1_activate (GtkMenuItem * menuitem, gpointer user_data)
159
187
{
160
188
  eef_reset_io ();
161
189
  gui_view_update_io_mem ();
 
190
  gui_list_io_update ();
162
191
}
163
192
 
164
193
 
167
196
{
168
197
  eef_reset_mem ();
169
198
  gui_view_update_io_mem ();
 
199
  gui_list_memory_update ();
170
200
}
171
201
 
172
202
 
176
206
  eef_reset_all ();
177
207
  gui_view_update_reg_flag (TRUE);
178
208
  gui_view_update_io_mem ();
 
209
  gui_list_io_update ();
 
210
  gui_list_memory_update ();
179
211
}
180
212
 
181
213
 
329
361
void
330
362
on_assembler_tutorial1_activate (GtkMenuItem * menuitem, gpointer user_data)
331
363
{
332
 
  gtk_widget_show (create_window_start ());
 
364
  show_tutorial ();
333
365
}
334
366
 
335
367
 
386
418
        }
387
419
 
388
420
  base[(gint) gtk_spin_button_get_value (sb)] = val;
 
421
  if (!strcmp (entry_name,"main_mem_entry"))
 
422
    gui_list_memory_update_single (gtk_spin_button_get_value_as_int (sb));
 
423
  if (!strcmp (entry_name,"main_io_entry"))
 
424
    gui_list_io_update_single (gtk_spin_button_get_value_as_int (sb));
389
425
}
390
426
 
391
427
static void
553
589
void
554
590
on_start_but_tutorial_clicked (GtkButton * button, gpointer user_data)
555
591
{
556
 
  gchar *msg =
557
 
        _("Do the following\n\n\
558
 
1. Read \"asm-guide.txt\" for assembler tutorial\n\
559
 
2. Open \"examples/nqueens.asm\" and simulate it.\n\n\
560
 
Usually these files will be found in your system document directory,\n\
561
 
which can be one of the following\n\n\
562
 
/usr/local/doc/GNUSim8085\n\
563
 
/usr/local/share/doc/GNUSim8085\n\
564
 
/usr/share/doc/GNUSim8085\n\n\
565
 
These files are also available in \"doc\" directory\n\
566
 
of GNUSim8085 source tarball (tar.gz file)\n");
567
 
        
568
 
  gui_app_show_msg (GTK_MESSAGE_INFO, msg);
 
592
  show_tutorial ();
569
593
  on_start_but_close_clicked (button, NULL);
570
594
}
571
595
 
586
610
  swd = lookup_widget (GTK_WIDGET (button), "window_start");
587
611
  gtk_widget_destroy (swd);
588
612
}
 
613
 
 
614
void
 
615
on_mem_list_start_clicked (GtkButton * button, gpointer user_data)
 
616
{
 
617
  GtkWidget *start_entry;
 
618
  gint start_addr;
 
619
  gchar *text;
 
620
        
 
621
  start_entry = lookup_widget (app->window_main, "mem_list_start");
 
622
  g_assert (start_entry);
 
623
        
 
624
  if (!asm_util_parse_number (text = (gchar *)gtk_entry_get_text (GTK_ENTRY (start_entry)), &start_addr))
 
625
  {
 
626
    gui_app_show_msg (GTK_MESSAGE_INFO, _("Enter a valid number within range (0-65535 or 0h-FFFFh)"));
 
627
    return;
 
628
  }
 
629
  gui_list_memory_set_start (start_addr);
 
630
  gui_list_memory_update ();
 
631
  text[strlen (text)] = 'h';
 
632
  gtk_entry_set_text (GTK_ENTRY (start_entry), text);
 
633
}
 
634
 
 
635
void
 
636
on_mem_list_start_changed (GtkEntry *entry, gpointer user_data)
 
637
{
 
638
  gint start_addr;
 
639
  gchar *text;
 
640
  g_assert (entry);
 
641
        
 
642
  if (!asm_util_parse_number (text = (gchar *)gtk_entry_get_text (GTK_ENTRY (entry)),&start_addr))
 
643
  {
 
644
    gui_app_show_msg (GTK_MESSAGE_INFO, _("Enter a valid number within range (0-65535 or 0h-FFFFh)"));
 
645
    return;
 
646
  }
 
647
  gui_list_memory_set_start (start_addr);
 
648
  gui_list_memory_update ();
 
649
  text[strlen (text)] = 'h';
 
650
  gtk_entry_set_text (GTK_ENTRY (entry), text);
 
651
}
 
652
 
 
653
void
 
654
on_io_list_start_clicked (GtkButton * button, gpointer user_data)
 
655
{
 
656
  GtkWidget *start_entry;
 
657
  gint start_addr;
 
658
  gchar *text;
 
659
 
 
660
  start_entry = lookup_widget (app->window_main, "io_list_start");
 
661
  g_assert (start_entry);
 
662
 
 
663
  if (!asm_util_parse_number (text = (gchar *)gtk_entry_get_text (GTK_ENTRY (start_entry)), &start_addr))
 
664
  {
 
665
    gui_app_show_msg (GTK_MESSAGE_INFO, _("Enter a valid number within range (0-255 / 0h-00FFh)"));
 
666
    return;
 
667
  }
 
668
  gui_list_io_set_start (start_addr);
 
669
  gui_list_io_update ();
 
670
  text[strlen (text)] = 'h';
 
671
  gtk_entry_set_text (GTK_ENTRY (start_entry), text);
 
672
}
 
673
 
 
674
void
 
675
on_io_list_start_changed (GtkEntry *entry, gpointer user_data)
 
676
{
 
677
  gint start_addr;
 
678
  gchar *text;
 
679
  g_assert (entry);
 
680
 
 
681
  if (!asm_util_parse_number (text = (gchar *)gtk_entry_get_text (GTK_ENTRY (entry)),&start_addr))
 
682
  {
 
683
    gui_app_show_msg (GTK_MESSAGE_INFO, _("Enter a valid number within range (0-255 / 0h-00FFh)"));
 
684
    return;
 
685
  }
 
686
  gui_list_io_set_start (start_addr);
 
687
  gui_list_io_update ();
 
688
  text[strlen (text)] = 'h';
 
689
  gtk_entry_set_text (GTK_ENTRY (entry), text);
 
690
}
 
691
 
 
692
void
 
693
show_tutorial ()
 
694
{
 
695
  GString* tutorial_text = read_tutorial ();
 
696
  GtkWidget *cont;
 
697
 
 
698
  /* show */
 
699
  tutorial = create_window_tutorial ();
 
700
  cont = lookup_widget (tutorial, "tutorial_vbox");
 
701
  g_assert (cont);
 
702
  edit = gui_editor_new ();
 
703
  g_assert (edit);
 
704
  gui_editor_show (edit);
 
705
  if (tutorial_text == NULL)
 
706
  {
 
707
    tutorial_text = g_string_new (_("The tutorial file, asm-guide.txt, was not found. It should be present in directory - "));
 
708
    g_string_append (tutorial_text, PACKAGE_DOC_DIR);  
 
709
  }
 
710
  gui_editor_set_text (edit, tutorial_text->str);
 
711
  gui_editor_set_readonly (edit, TRUE);
 
712
  gui_editor_set_show_line_numbers (edit, FALSE);
 
713
  gtk_box_pack_end_defaults (GTK_BOX (cont), edit->scroll);
 
714
  gtk_window_maximize (GTK_WINDOW (tutorial));
 
715
  gtk_widget_show_all (tutorial);
 
716
 
 
717
  /* clean up */
 
718
  g_string_free (tutorial_text, TRUE);
 
719
}
 
720
 
 
721
void
 
722
on_line_mark_activated (GtkSourceView *view, GtkTextIter *iter,
 
723
                        GdkEventButton *event, gpointer editor)
 
724
{
 
725
  if ((event->button == 1) && (event->type == GDK_BUTTON_PRESS))
 
726
  {
 
727
    gint line_no = gtk_text_iter_get_line (iter);
 
728
    gui_editor_toggle_mark_at_line ((GUIEditor *) editor, line_no);
 
729
  }
 
730
}
 
731