Index: gcalctool/gtk.c
===================================================================
--- gcalctool/gtk.c	(revision 1709)
+++ gcalctool/gtk.c	(working copy)
@@ -167,6 +167,7 @@
 static GtkWidget *create_bit_panel(GtkWidget *);
 static GtkWidget *create_menu(enum menu_type, struct button *);
 static GtkWidget *create_mode_panel(GtkWidget *);
+static void create_rframe();
 static GtkWidget *make_menu_button(gchar *, int);
 static GtkWidget *make_but_panel(GtkWidget *, GtkWidget **,
                                  struct button *, int, int, char *);
@@ -175,7 +176,6 @@
 
 static gboolean aframe_key_cb(GtkWidget *, GdkEventKey *, gpointer);
 static gboolean dismiss_aframe(GtkWidget *, GdkEvent *, gpointer);
-static gboolean dismiss_rframe(GtkWidget *, GdkEvent *, gpointer);
 static gboolean dismiss_spframe(GtkWidget *, GdkEvent *, gpointer);
 static gboolean kframe_key_press_cb(GtkWidget *, GdkEventKey *, gpointer);
 static gboolean display_focus_in_cb(GtkWidget *, GdkEventKey *, gpointer);
@@ -215,7 +215,6 @@
 static void set_bit_panel();
 static void set_button_state(GtkWidget *, int);
 static void set_item(enum item_type itemtype, int val);
-static void set_memory_toggle(int);
 static void set_show_tsep_toggle(int);
 static void set_show_zeroes_toggle(int);
 static void set_show_bitcalculating_toggle(int);
@@ -1435,6 +1434,8 @@
 
     g_object_set(gtk_ui_manager_get_action(X->ui, "/MenuBar/ViewMenu/Memory"),
                  "sensitive", (v->modetype != BASIC), NULL);
+    g_object_set(gtk_ui_manager_get_action(X->ui, "/MenuBar/ViewMenu/Memory"),
+                 "active", v->rstate, NULL);
 
     X->scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
     gtk_widget_show(X->scrolledwindow);
@@ -1487,12 +1488,13 @@
     atk_object_set_role(gtk_widget_get_accessible(X->display_item), 
                                                   ATK_ROLE_EDITBAR);
     set_display("0.00", FALSE);
-
+    
     gtk_container_set_border_width(GTK_CONTAINER(X->display_item), 2);
     gtk_container_add(GTK_CONTAINER(event_box), X->scrolledwindow);
     gtk_widget_show(X->display_item);
-    gtk_box_pack_start(GTK_BOX(X->kvbox), event_box, FALSE, TRUE, 0);
     gtk_widget_show(event_box);
+    
+    gtk_box_pack_start(GTK_BOX(X->kvbox), event_box, FALSE, TRUE, 0);
 
     gtk_widget_realize(X->kframe);
     gtk_window_set_title(GTK_WINDOW(X->kframe), _(v->tool_label));
@@ -1504,6 +1506,8 @@
     X->mode_panel = create_mode_panel(X->kvbox);
     X->bit_panel  = create_bit_panel(X->kvbox);
 
+    gtk_box_pack_start(GTK_BOX(X->kvbox), X->rframe, FALSE, TRUE, 0);
+
     X->sci_panel = make_but_panel(X->kvbox, X->sci_buttons,
                                   s_buttons, SROWS, SCOLS, "sci");
     set_accuracy_tooltip(v->accuracy);
@@ -1582,6 +1586,8 @@
     X->paste = gtk_ui_manager_get_widget(X->ui, "/MenuBar/EditMenu/Paste");
     
     set_redo_and_undo_button_sensitivity(0, 0);
+    
+    gtk_widget_hide(X->rframe);
 }
 
 static void
@@ -1709,41 +1715,22 @@
     return(vbox);
 }
 
-
-/*ARGSUSED*/
 static void
-mem_response(GtkDialog *dialog, int response, gpointer user_data)
-{
-    set_memory_toggle(FALSE);
-    put_resource(R_REGS, "false");
-    gtk_widget_hide(X->rframe);
-}
-
-
-static void
 create_rframe()
 {
     char *line, *markup, *acc_name;
     char name[MAXLINE];
-    int i;
+    int i, row, col;
     AtkObject *atko[MAXREGS];
-    GtkWidget *label[MAXREGS], *table, *vbox;
+    GtkWidget *label[MAXREGS];
+    GtkSizeGroup *size_group;
 
-    X->rframe = gtk_dialog_new();
-    g_object_set_data(G_OBJECT(X->rframe), "rframe", X->rframe);
-    gtk_window_set_resizable(GTK_WINDOW(X->rframe), FALSE);
-    gtk_window_set_title(GTK_WINDOW(X->rframe), _("Memory Registers"));
+    X->rframe = gtk_table_new(2, 2, FALSE);
+    gtk_table_set_row_spacings(GTK_TABLE(X->rframe), 3);
+    gtk_table_set_col_spacings(GTK_TABLE(X->rframe), 3);
     gtk_container_set_border_width(GTK_CONTAINER(X->rframe), 5);
-    gtk_dialog_set_has_separator(GTK_DIALOG(X->rframe), FALSE);
-    gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(X->rframe)->vbox), 2);
 
-    vbox = GTK_DIALOG(X->rframe)->vbox;
-
-    table = gtk_table_new(10, 2, FALSE);
-    gtk_table_set_row_spacings(GTK_TABLE(table), 6);
-    gtk_table_set_col_spacings(GTK_TABLE(table), 12);
-    gtk_container_set_border_width(GTK_CONTAINER(table), 5);
-
+    size_group = gtk_size_group_new(GTK_SIZE_GROUP_BOTH);
     for (i = 0; i < MAXREGS; i++) {
         /* Translators: "R%d" is the abbreviation for "Register %d", used in the
          * memory register dialog.
@@ -1755,16 +1742,19 @@
         gtk_label_set_markup(GTK_LABEL(label[i]), markup);
         g_free(line);
         g_free(markup);
-        gtk_table_attach(GTK_TABLE(table), label[i], 0, 1, i, i+1,
+	col = i % 5 * 2;
+	row = i / 5;
+        gtk_table_attach(GTK_TABLE(X->rframe), label[i], col, col+1, row, row+1,
                          (GtkAttachOptions) (GTK_FILL),
                          (GtkAttachOptions) (0), 0, 0);
         gtk_misc_set_alignment(GTK_MISC(label[i]), 0, 0.5);
 
         X->regs[i] = gtk_entry_new();
+	gtk_size_group_add_widget(size_group, X->regs[i]);
         gtk_entry_set_text(GTK_ENTRY(X->regs[i]),
                            make_number(v->MPmvals[i], v->base, TRUE));
         gtk_editable_set_editable(GTK_EDITABLE(X->regs[i]), FALSE);
-        gtk_table_attach(GTK_TABLE(table), X->regs[i], 1, 2, i, i+1,
+        gtk_table_attach(GTK_TABLE(X->rframe), X->regs[i], col+1, col+2, row, row+1,
                          (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                          (GtkAttachOptions) (0), 0, 0);
 
@@ -1776,18 +1766,8 @@
         atk_object_set_name(atko[i], acc_name);
         g_free(acc_name);
     }
-    gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 0);
-
-    gtk_dialog_add_button(GTK_DIALOG(X->rframe), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
-
-    gtk_widget_show_all(vbox);
-
-    g_signal_connect(G_OBJECT(X->rframe), "delete_event",
-                     G_CALLBACK(dismiss_rframe), NULL);
-    g_signal_connect(X->rframe, "response",
-                     G_CALLBACK(mem_response), NULL);
-
-    gtk_widget_realize(X->rframe);
+    
+    gtk_widget_show_all(X->rframe);
 }
 
 
@@ -1803,16 +1783,6 @@
 
 /*ARGSUSED*/
 static gboolean
-dismiss_rframe(GtkWidget *widget, GdkEvent *event, gpointer user_data)
-{
-    gtk_dialog_response(GTK_DIALOG(widget), GTK_RESPONSE_DELETE_EVENT);
-
-    return(TRUE);
-}
-
-
-/*ARGSUSED*/
-static gboolean
 dismiss_spframe(GtkWidget *widget, GdkEvent *event, gpointer user_data)
 {
     X->spframe = NULL;
@@ -2374,8 +2344,8 @@
 
     X->clipboard_atom = gdk_atom_intern("CLIPBOARD", FALSE);
     X->primary_atom = gdk_atom_intern("PRIMARY", FALSE);
+    create_rframe();
     create_kframe();                     /* Create main gcalctool window. */
-    create_rframe();                     /* Create memory register window. */
     set_mode(v->modetype);
 
     n = (struct button *) g_object_get_data(G_OBJECT(BUT_ACC), "button");
@@ -3008,9 +2978,11 @@
     g_object_set(gtk_ui_manager_get_action(X->ui, "/MenuBar/ViewMenu/Memory"),
                  "sensitive", (v->modetype != BASIC), NULL);
     if (v->modetype == BASIC) {
-        dismiss_rframe(NULL, NULL, NULL);
+	gtk_widget_hide(X->rframe);
     }
-
+    else if(v->rstate)
+	gtk_widget_show(X->rframe);
+    
     switch (v->syntax) {
         case npa:
             show_display(v->MPdisp_val);
@@ -3402,17 +3374,6 @@
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(X->inv), state);
 }
 
-
-static void
-set_memory_toggle(int state)
-{
-    GtkAction *action;
-
-    action = gtk_action_group_get_action(X->actions, "Memory");
-    gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(action), state);
-}
-
-
 void
 set_mode(enum mode_type mode)
 {
@@ -3530,8 +3491,6 @@
 
     if (fcptype == FCP_KEY) {
         f = X->kframe;
-    } else if (fcptype == FCP_REG) {
-        f = X->rframe;
     }
     gtk_window_set_title(GTK_WINDOW(f), _(str));
 }
@@ -3707,23 +3666,14 @@
 {
     GtkWidget *f = NULL;
 
-    if (fcptype == FCP_REG) {
-        v->rstate = state;
-        f = X->rframe;
-    }
-
-    if (state && gdk_window_is_visible(f->window)) {
-        gdk_window_raise(f->window);
-        return;
-    }
+    f = X->rframe;
     if (state) {
-        if (fcptype == FCP_REG) {
-            ds_position_popup(X->kframe, f, DS_POPUP_ABOVE);
-        }
-    }
-    if (state) {
-        gtk_widget_show(f);
+	v->rstate = TRUE;
+	put_resource(R_REGS, "true");
+	gtk_widget_show(f);
     } else {
+	v->rstate = FALSE;
+	put_resource(R_REGS, "false");
         gtk_widget_hide(f);
     }
 }
