r22862 - gnucash/trunk/src/gnome - Vary some menu labels and tooltips based on cursor class: transaction or split.

J. Alex Aycinena alex.aycinena at code.gnucash.org
Mon Apr 1 20:49:20 EDT 2013


Author: alex.aycinena
Date: 2013-04-01 20:49:19 -0400 (Mon, 01 Apr 2013)
New Revision: 22862
Trac: http://svn.gnucash.org/trac/changeset/22862

Modified:
   gnucash/trunk/src/gnome/gnc-plugin-page-register.c
Log:
Vary some menu labels and tooltips based on cursor class: transaction or split.

Modified: gnucash/trunk/src/gnome/gnc-plugin-page-register.c
===================================================================
--- gnucash/trunk/src/gnome/gnc-plugin-page-register.c	2013-04-01 19:37:31 UTC (rev 22861)
+++ gnucash/trunk/src/gnome/gnc-plugin-page-register.c	2013-04-02 00:49:19 UTC (rev 22862)
@@ -183,6 +183,27 @@
 /*                          Actions                         */
 /************************************************************/
 
+#define CUT_TRANSACTION_LABEL         N_("Cu_t Transaction")
+#define COPY_TRANSACTION_LABEL        N_("_Copy Transaction")
+#define PASTE_TRANSACTION_LABEL       N_("_Paste Transaction")
+#define DUPLICATE_TRANSACTION_LABEL   N_("Dup_licate Transaction")
+#define DELETE_TRANSACTION_LABEL      N_("_Delete Transaction")
+#define CUT_SPLIT_LABEL               N_("Cu_t Split")
+#define COPY_SPLIT_LABEL              N_("_Copy Split")
+#define PASTE_SPLIT_LABEL             N_("_Paste Split")
+#define DUPLICATE_SPLIT_LABEL         N_("Dup_licate Split")
+#define DELETE_SPLIT_LABEL            N_("_Delete Split")
+#define CUT_TRANSACTION_TIP           N_("Cut the selected transaction into clipboard")
+#define COPY_TRANSACTION_TIP          N_("Copy the selected transaction into clipboard")
+#define PASTE_TRANSACTION_TIP         N_("Paste the transaction from the clipboard")
+#define DUPLICATE_TRANSACTION_TIP     N_("Make a copy of the current transaction")
+#define DELETE_TRANSACTION_TIP        N_("Delete the current transaction")
+#define CUT_SPLIT_TIP                 N_("Cut the selected split into clipboard")
+#define COPY_SPLIT_TIP                N_("Copy the selected split into clipboard")
+#define PASTE_SPLIT_TIP               N_("Paste the split from the clipboard")
+#define DUPLICATE_SPLIT_TIP           N_("Make a copy of the current split")
+#define DELETE_SPLIT_TIP              N_("Delete the current split")
+
 static GtkActionEntry gnc_plugin_page_register_actions [] =
 {
     /* File menu */
@@ -223,28 +244,28 @@
     /* Transaction menu */
 
     {
-        "CutTransactionAction", GTK_STOCK_CUT, N_("Cu_t Transaction"), "",
-        N_("Cut the selected transaction into clipboard"),
+        "CutTransactionAction", GTK_STOCK_CUT, CUT_TRANSACTION_LABEL, "",
+        CUT_TRANSACTION_TIP,
         G_CALLBACK (gnc_plugin_page_register_cmd_cut_transaction)
     },
     {
-        "CopyTransactionAction", GTK_STOCK_COPY, N_("_Copy Transaction"), "",
-        N_("Copy the selected transaction into clipboard"),
+        "CopyTransactionAction", GTK_STOCK_COPY, COPY_TRANSACTION_LABEL, "",
+        COPY_TRANSACTION_TIP,
         G_CALLBACK (gnc_plugin_page_register_cmd_copy_transaction)
     },
     {
-        "PasteTransactionAction", GTK_STOCK_PASTE, N_("_Paste Transaction"), "",
-        N_("Paste the transaction from the clipboard"),
+        "PasteTransactionAction", GTK_STOCK_PASTE, PASTE_TRANSACTION_LABEL, "",
+        PASTE_TRANSACTION_TIP,
         G_CALLBACK (gnc_plugin_page_register_cmd_paste_transaction)
     },
     {
-        "DuplicateTransactionAction", GTK_STOCK_COPY, N_("Dup_licate Transaction"), "",
-        N_("Make a copy of the current transaction"),
+        "DuplicateTransactionAction", GTK_STOCK_COPY, DUPLICATE_TRANSACTION_LABEL, "",
+        DUPLICATE_TRANSACTION_TIP,
         G_CALLBACK (gnc_plugin_page_register_cmd_duplicate_transaction)
     },
     {
-        "DeleteTransactionAction", GTK_STOCK_DELETE, N_("_Delete Transaction"), NULL,
-        N_("Delete the current transaction"),
+        "DeleteTransactionAction", GTK_STOCK_DELETE, DELETE_TRANSACTION_LABEL, NULL,
+        DELETE_TRANSACTION_TIP,
         G_CALLBACK (gnc_plugin_page_register_cmd_delete_transaction)
     },
     {
@@ -766,6 +787,62 @@
     NULL
 };
 
+/* This is the list of actions whose text needs to be changed based on whether */
+/* the current cursor class is transaction or split. */
+static const char* tran_vs_split_actions[] =
+{
+    "CutTransactionAction",
+    "CopyTransactionAction",
+    "PasteTransactionAction",
+    "DuplicateTransactionAction",
+    "DeleteTransactionAction",
+    NULL
+};
+
+/* This is the list of labels for when the current cursor class is transaction. */
+static const char* tran_action_labels[] =
+{
+    CUT_TRANSACTION_LABEL,
+    COPY_TRANSACTION_LABEL,
+    PASTE_TRANSACTION_LABEL,
+    DUPLICATE_TRANSACTION_LABEL,
+    DELETE_TRANSACTION_LABEL,
+    NULL
+};
+
+/* This is the list of tooltips for when the current cursor class is transaction. */
+static const char* tran_action_tips[] =
+{
+    CUT_TRANSACTION_TIP,
+    COPY_TRANSACTION_TIP,
+    PASTE_TRANSACTION_TIP,
+    DUPLICATE_TRANSACTION_TIP,
+    DELETE_TRANSACTION_TIP,
+    NULL
+};
+
+/* This is the list of labels for when the current cursor class is split. */
+static const char* split_action_labels[] =
+{
+    CUT_SPLIT_LABEL,
+    COPY_SPLIT_LABEL,
+    PASTE_SPLIT_LABEL,
+    DUPLICATE_SPLIT_LABEL,
+    DELETE_SPLIT_LABEL,
+    NULL
+};
+
+/* This is the list of tooltips for when the current cursor class is split. */
+static const char* split_action_tips[] =
+{
+    CUT_SPLIT_TIP,
+    COPY_SPLIT_TIP,
+    PASTE_SPLIT_TIP,
+    DUPLICATE_SPLIT_TIP,
+    DELETE_SPLIT_TIP,
+    NULL
+};
+
 static void
 gnc_plugin_page_register_ui_update (gpointer various, GncPluginPageRegister *page)
 {
@@ -809,7 +886,46 @@
             GtkAction *action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), *iter);
             gtk_action_set_sensitive(action, FALSE);
         }
+    }
 
+    /* Modifying action descriptions based on cursor class */
+    {
+        const char **iter, **label_iter, **tooltip_iter;
+        gboolean curr_label_trans = FALSE;
+        CursorClass cursor_class = gnc_split_register_get_current_cursor_class (reg);
+        iter = tran_vs_split_actions;
+        action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), *iter);
+        label_iter = tran_action_labels;
+        if (g_strcmp0 (gtk_action_get_label(action), _(*label_iter)) == 0)
+            curr_label_trans = TRUE;
+        if ((cursor_class == CURSOR_CLASS_SPLIT) && curr_label_trans)
+        {
+            label_iter = split_action_labels;
+            tooltip_iter = split_action_tips;
+            for (iter = tran_vs_split_actions; *iter; ++iter)
+            {
+                /* Adjust the action's label and tooltip */
+                action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), *iter);
+                gtk_action_set_label(action, _(*label_iter));
+                gtk_action_set_tooltip(action, _(*tooltip_iter));
+                ++label_iter;
+                ++tooltip_iter;
+            }
+        }
+        else if ((cursor_class == CURSOR_CLASS_TRANS) && !curr_label_trans)
+        {
+            label_iter = tran_action_labels;
+            tooltip_iter = tran_action_tips;
+            for (iter = tran_vs_split_actions; *iter; ++iter)
+            {
+                /* Adjust the action's label and tooltip */
+                action = gnc_plugin_page_get_action (GNC_PLUGIN_PAGE(page), *iter);
+                gtk_action_set_label(action, _(*label_iter));
+                gtk_action_set_tooltip(action, _(*tooltip_iter));
+                ++label_iter;
+                ++tooltip_iter;
+            }
+        }
     }
 }
 



More information about the gnucash-changes mailing list