[gcalctool] Remove memory buttons from basic mode Use "M" instead of "R" for memory buttons Replace backspace wi



commit d95fdbe1fc86dd94c88c0977eaf237ad0db6ba9e
Author: Robert Ancell <robert ancell gmail com>
Date:   Wed May 12 18:30:00 2010 +0200

    Remove memory buttons from basic mode
    Use "M" instead of "R" for memory buttons
    Replace backspace with undo, have it in all modes
    Make solve button bigger

 data/buttons-advanced.ui  |   38 +++++++-------
 data/buttons-basic.ui     |  119 ++++++++------------------------------------
 data/buttons-financial.ui |   76 +++++++++--------------------
 src/math-buttons.c        |   53 ++++++++++++--------
 4 files changed, 96 insertions(+), 190 deletions(-)
---
diff --git a/data/buttons-advanced.ui b/data/buttons-advanced.ui
index 5d80dff..35d08ed 100644
--- a/data/buttons-advanced.ui
+++ b/data/buttons-advanced.ui
@@ -477,10 +477,8 @@
                 <signal name="clicked" handler="clear_cb"/>
               </object>
               <packing>
-                <property name="left_attach">4</property>
-                <property name="right_attach">5</property>
-                <property name="top_attach">3</property>
-                <property name="bottom_attach">4</property>
+                <property name="left_attach">5</property>
+                <property name="right_attach">6</property>
                 <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
                 <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
@@ -595,6 +593,8 @@
               <packing>
                 <property name="left_attach">4</property>
                 <property name="right_attach">5</property>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
                 <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
                 <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
@@ -612,6 +612,8 @@
               <packing>
                 <property name="left_attach">5</property>
                 <property name="right_attach">6</property>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
                 <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
                 <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
@@ -657,8 +659,8 @@
               <packing>
                 <property name="left_attach">4</property>
                 <property name="right_attach">5</property>
-                <property name="top_attach">1</property>
-                <property name="bottom_attach">2</property>
+                <property name="top_attach">2</property>
+                <property name="bottom_attach">3</property>
                 <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
                 <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
@@ -704,8 +706,8 @@
               <packing>
                 <property name="left_attach">5</property>
                 <property name="right_attach">6</property>
-                <property name="top_attach">1</property>
-                <property name="bottom_attach">2</property>
+                <property name="top_attach">2</property>
+                <property name="bottom_attach">3</property>
                 <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
                 <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
@@ -902,20 +904,18 @@
               </packing>
             </child>
             <child>
-              <object class="GtkButton" id="calc_backspace_button">
-                <property name="label" translatable="yes" comments="Label on the clear display button">BS</property>
+              <object class="GtkButton" id="calc_undo_button">
+                <property name="label" translatable="yes" comments="Label on the undo button">Undo</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
                 <property name="use_underline">True</property>
                 <property name="focus_on_click">False</property>
-                <signal name="clicked" handler="backspace_cb"/>
+                <signal name="clicked" handler="undo_cb"/>
               </object>
               <packing>
-                <property name="left_attach">5</property>
-                <property name="right_attach">6</property>
-                <property name="top_attach">3</property>
-                <property name="bottom_attach">4</property>
+                <property name="left_attach">4</property>
+                <property name="right_attach">5</property>
                 <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
                 <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
@@ -939,8 +939,8 @@
               <packing>
                 <property name="left_attach">4</property>
                 <property name="right_attach">5</property>
-                <property name="top_attach">2</property>
-                <property name="bottom_attach">3</property>
+                <property name="top_attach">3</property>
+                <property name="bottom_attach">4</property>
                 <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
                 <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
@@ -964,8 +964,8 @@
               <packing>
                 <property name="left_attach">5</property>
                 <property name="right_attach">6</property>
-                <property name="top_attach">2</property>
-                <property name="bottom_attach">3</property>
+                <property name="top_attach">3</property>
+                <property name="bottom_attach">4</property>
                 <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
                 <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
               </packing>
diff --git a/data/buttons-basic.ui b/data/buttons-basic.ui
index 5c60b91..c9c74fa 100644
--- a/data/buttons-basic.ui
+++ b/data/buttons-basic.ui
@@ -309,7 +309,7 @@
           </object>
           <packing>
             <property name="left_attach">4</property>
-            <property name="right_attach">5</property>
+            <property name="right_attach">6</property>
             <property name="top_attach">3</property>
             <property name="bottom_attach">4</property>
             <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
@@ -329,6 +329,8 @@
           <packing>
             <property name="left_attach">4</property>
             <property name="right_attach">5</property>
+            <property name="top_attach">1</property>
+            <property name="bottom_attach">2</property>
             <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
             <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
           </packing>
@@ -346,6 +348,8 @@
           <packing>
             <property name="left_attach">5</property>
             <property name="right_attach">6</property>
+            <property name="top_attach">1</property>
+            <property name="bottom_attach">2</property>
             <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
             <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
           </packing>
@@ -363,102 +367,6 @@
           <packing>
             <property name="left_attach">5</property>
             <property name="right_attach">6</property>
-            <property name="top_attach">3</property>
-            <property name="bottom_attach">4</property>
-            <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
-            <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkButton" id="calc_recall_button">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">True</property>
-            <property name="focus_on_click">False</property>
-            <child internal-child="accessible">
-              <object class="AtkObject" id="calc_recall_button-atkobject">
-                <property name="AtkObject::accessible-name" translatable="yes" comments="Accessible name for the recall value button">Recall</property>
-              </object>
-            </child>
-            <signal name="clicked" handler="recall_cb"/>
-            <child>
-              <object class="GtkHBox" id="hbox19">
-                <property name="visible">True</property>
-                <property name="spacing">3</property>
-                <child>
-                  <object class="GtkLabel" id="label22">
-                    <property name="visible">True</property>
-                    <property name="label" translatable="yes" comments="The label on the memory recall button">&#x2190; R</property>
-                  </object>
-                  <packing>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkArrow" id="arrow13">
-                    <property name="visible">True</property>
-                    <property name="arrow_type">down</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="left_attach">4</property>
-            <property name="right_attach">5</property>
-            <property name="top_attach">1</property>
-            <property name="bottom_attach">2</property>
-            <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
-            <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkButton" id="calc_store_button">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">True</property>
-            <property name="focus_on_click">False</property>
-            <child internal-child="accessible">
-              <object class="AtkObject" id="calc_store_button-atkobject">
-                <property name="AtkObject::accessible-name" translatable="yes" comments="Accessible name for the store value button">Store</property>
-              </object>
-            </child>
-            <signal name="clicked" handler="store_cb"/>
-            <child>
-              <object class="GtkHBox" id="hbox20">
-                <property name="visible">True</property>
-                <property name="spacing">3</property>
-                <child>
-                  <object class="GtkLabel" id="label23">
-                    <property name="visible">True</property>
-                    <property name="label" translatable="yes" comments="The label on the memory store button">&#x2192; R</property>
-                  </object>
-                  <packing>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkArrow" id="arrow14">
-                    <property name="visible">True</property>
-                    <property name="arrow_type">down</property>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="left_attach">5</property>
-            <property name="right_attach">6</property>
-            <property name="top_attach">1</property>
-            <property name="bottom_attach">2</property>
             <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
             <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
           </packing>
@@ -511,6 +419,23 @@
             <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
           </packing>
         </child>
+        <child>
+          <object class="GtkButton" id="calc_undo_button">
+            <property name="label" translatable="yes" comments="Label on the undo button">Undo</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="use_underline">True</property>
+            <property name="focus_on_click">False</property>
+            <signal name="clicked" handler="undo_cb"/>
+          </object>
+          <packing>
+            <property name="left_attach">4</property>
+            <property name="right_attach">5</property>
+            <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
+            <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
+          </packing>
+        </child>
       </object>
     </child>
   </object>
diff --git a/data/buttons-financial.ui b/data/buttons-financial.ui
index 19f9ae2..37fde7b 100644
--- a/data/buttons-financial.ui
+++ b/data/buttons-financial.ui
@@ -50,8 +50,8 @@
           <packing>
             <property name="left_attach">5</property>
             <property name="right_attach">6</property>
-            <property name="top_attach">1</property>
-            <property name="bottom_attach">2</property>
+            <property name="top_attach">2</property>
+            <property name="bottom_attach">3</property>
             <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
             <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
           </packing>
@@ -97,54 +97,6 @@
           <packing>
             <property name="left_attach">4</property>
             <property name="right_attach">5</property>
-            <property name="top_attach">1</property>
-            <property name="bottom_attach">2</property>
-            <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
-            <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkButton" id="calc_root_button">
-            <property name="label">&#x221A;</property>
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">True</property>
-            <property name="use_underline">True</property>
-            <property name="focus_on_click">False</property>
-            <signal name="clicked" handler="button_cb"/>
-          </object>
-          <packing>
-            <property name="left_attach">5</property>
-            <property name="right_attach">6</property>
-            <property name="top_attach">2</property>
-            <property name="bottom_attach">3</property>
-            <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
-            <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkButton" id="calc_x_pow_y_button">
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">True</property>
-            <property name="focus_on_click">False</property>
-            <child internal-child="accessible">
-              <object class="AtkObject" id="calc_x_pow_y_button-atkobject">
-                <property name="AtkObject::accessible-name" translatable="yes" comments="Accessible name for the exponentiation (x to the power of y) button">Exponent</property>
-              </object>
-            </child>
-            <signal name="clicked" handler="button_cb"/>
-            <child>
-              <object class="GtkLabel" id="x_pow_y_label">
-                <property name="visible">True</property>
-                <property name="label">&lt;i&gt;x&lt;/i&gt;&lt;sup&gt;&lt;i&gt;y&lt;/i&gt;&lt;/sup&gt;</property>
-                <property name="use_markup">True</property>
-              </object>
-            </child>
-          </object>
-          <packing>
-            <property name="left_attach">4</property>
-            <property name="right_attach">5</property>
             <property name="top_attach">2</property>
             <property name="bottom_attach">3</property>
             <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
@@ -469,7 +421,7 @@
           </object>
           <packing>
             <property name="left_attach">4</property>
-            <property name="right_attach">5</property>
+            <property name="right_attach">6</property>
             <property name="top_attach">3</property>
             <property name="bottom_attach">4</property>
             <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
@@ -489,6 +441,8 @@
           <packing>
             <property name="left_attach">4</property>
             <property name="right_attach">5</property>
+            <property name="top_attach">1</property>
+            <property name="bottom_attach">2</property>
             <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
             <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
           </packing>
@@ -506,6 +460,8 @@
           <packing>
             <property name="left_attach">5</property>
             <property name="right_attach">6</property>
+            <property name="top_attach">1</property>
+            <property name="bottom_attach">2</property>
             <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
             <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
           </packing>
@@ -523,8 +479,6 @@
           <packing>
             <property name="left_attach">5</property>
             <property name="right_attach">6</property>
-            <property name="top_attach">3</property>
-            <property name="bottom_attach">4</property>
             <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
             <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
           </packing>
@@ -731,6 +685,22 @@
             <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
           </packing>
         </child>
+        <child>
+          <object class="GtkButton" id="calc_undo_button">
+            <property name="label" translatable="yes" comments="Label on the clear display button">Undo</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+            <property name="use_underline">True</property>
+            <property name="focus_on_click">False</property>
+          </object>
+          <packing>
+            <property name="left_attach">4</property>
+            <property name="right_attach">5</property>
+            <property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
+            <property name="y_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
+          </packing>
+        </child>
       </object>
     </child>
   </object>
diff --git a/src/math-buttons.c b/src/math-buttons.c
index 1bad5fc..0078f0f 100644
--- a/src/math-buttons.c
+++ b/src/math-buttons.c
@@ -84,8 +84,7 @@ typedef enum
     FUNCTION,
     MEMORY,
     GROUP,
-    ACTION,
-    ACTION_BOLD
+    ACTION
 } ButtonClass;
 
 typedef struct {
@@ -227,21 +226,18 @@ static ButtonData button_data[] = {
     {"character", NULL, MEMORY,
       /* Tooltip for the insert character code button */
       N_("Insert Character Code")},
-    {"result", NULL, ACTION_BOLD,
+    {"result", NULL, ACTION,
       /* Tooltip for the solve button */
       N_("Calculate Result")},
-    {"factor", NULL, ACTION_BOLD,
+    {"factor", NULL, ACTION,
       /* Tooltip for the factor button */
       N_("Factorize [Ctrl+F]")},
-    {"clear", NULL, ACTION,
+    {"clear", NULL, GROUP,
       /* Tooltip for the clear button */
       N_("Clear Display [Escape]")},
-    {"backspace", NULL, ACTION,
-      /* Tooltip for the backspace button */
-      N_("Backspace")},  
-    {"delete", NULL, ACTION,
-      /* Tooltip for the delete button */
-      N_("Delete")},  
+    {"undo", NULL, GROUP,
+      /* Tooltip for the undo button */
+      N_("Undo [Ctrl+Z]")},
     {"shift_left", NULL, ACTION,
       /* Tooltip for the shift left button */
       N_("Shift Left")},  
@@ -723,9 +719,6 @@ load_mode(MathButtons *buttons, ButtonMode mode)
             set_tint(button, &buttons->priv->color_group, 1);
             break;
         case ACTION:
-            set_tint(button, &buttons->priv->color_action, 1);
-            break;
-        case ACTION_BOLD:
             set_tint(button, &buttons->priv->color_action, 2);
             break;
         }
@@ -979,9 +972,9 @@ delete_cb(GtkWidget *widget, MathButtons *buttons)
 
 G_MODULE_EXPORT
 void
-backspace_cb(GtkWidget *widget, MathButtons *buttons)
+undo_cb(GtkWidget *widget, MathButtons *buttons)
 {
-    math_equation_backspace(buttons->priv->equation);
+    math_equation_undo(buttons->priv->equation);
 }
 
 
@@ -1018,14 +1011,21 @@ popup_button_menu(GtkWidget *widget, GtkMenu *menu)
 
 
 static void
+save_variable_cb(GtkWidget *widget, MathButtons *buttons)
+{
+  printf("save\n");
+}
+
+
+static void
 delete_variable_cb(GtkWidget *widget, MathButtons *buttons)
 {
-  printf("!\n");
+  printf("delete\n");
 }
 
 
 static GtkWidget *
-make_register_menu_item(MathButtons *buttons, const gchar *name, const MPNumber *value, gboolean can_delete, GCallback callback)
+make_register_menu_item(MathButtons *buttons, const gchar *name, const MPNumber *value, gboolean can_modify, GCallback callback)
 {
     gchar text[1024] = "", *mstr;
     GtkWidget *item, *label;
@@ -1044,16 +1044,25 @@ make_register_menu_item(MathButtons *buttons, const gchar *name, const MPNumber
     item = gtk_menu_item_new();
 
     // FIXME: Buttons don't work inside menus...
-    if (0){//can_delete) {
+    if (0) {//can_modify) {
         GtkWidget *hbox, *button;
+
         hbox = gtk_hbox_new(FALSE, 6);
+        gtk_container_add(GTK_CONTAINER(item), hbox);
+
         gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
+
         button = gtk_button_new();
         gtk_button_set_image(GTK_BUTTON(button), gtk_image_new_from_stock(GTK_STOCK_DELETE, GTK_ICON_SIZE_MENU));
         gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
         gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, TRUE, 0);
         g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(delete_variable_cb), buttons);
-        gtk_container_add(GTK_CONTAINER(item), hbox);
+
+        button = gtk_button_new();
+        gtk_button_set_image(GTK_BUTTON(button), gtk_image_new_from_stock(GTK_STOCK_SAVE, GTK_ICON_SIZE_MENU));
+        gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
+        gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, TRUE, 0);
+        g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(save_variable_cb), buttons);
     }
     else
         gtk_container_add(GTK_CONTAINER(item), label);
@@ -1101,7 +1110,9 @@ store_cb(GtkWidget *widget, MathButtons *buttons)
 
     g_strfreev(names);
 
-    gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new());
+    // FIXME
+    //item = gtk_menu_item_new_with_label(_("Add variable"));
+    //gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
 
     gtk_widget_show_all(menu);
     popup_button_menu(widget, GTK_MENU(menu));



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]