mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Add extra toolbar buttons as shortcuts for some business functions, "New Invoice" for now.
The extra toolbar buttons are disabled until the user enables them manually in Preferences -> Business -> Extra buttons. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20304 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
d7073fb148
commit
80e4847f2a
@ -9,7 +9,7 @@
|
|||||||
<widget class="GtkTable" id="business_prefs">
|
<widget class="GtkTable" id="business_prefs">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="border_width">6</property>
|
<property name="border_width">6</property>
|
||||||
<property name="n_rows">8</property>
|
<property name="n_rows">9</property>
|
||||||
<property name="n_columns">4</property>
|
<property name="n_columns">4</property>
|
||||||
<property name="column_spacing">12</property>
|
<property name="column_spacing">12</property>
|
||||||
<child>
|
<child>
|
||||||
@ -33,8 +33,8 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="right_attach">2</property>
|
<property name="right_attach">2</property>
|
||||||
<property name="top_attach">3</property>
|
<property name="top_attach">4</property>
|
||||||
<property name="bottom_attach">4</property>
|
<property name="bottom_attach">5</property>
|
||||||
<property name="x_options">GTK_FILL</property>
|
<property name="x_options">GTK_FILL</property>
|
||||||
<property name="y_options"></property>
|
<property name="y_options"></property>
|
||||||
</packing>
|
</packing>
|
||||||
@ -50,8 +50,8 @@
|
|||||||
<property name="draw_indicator">True</property>
|
<property name="draw_indicator">True</property>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="top_attach">7</property>
|
<property name="top_attach">8</property>
|
||||||
<property name="bottom_attach">8</property>
|
<property name="bottom_attach">9</property>
|
||||||
<property name="x_options">GTK_FILL</property>
|
<property name="x_options">GTK_FILL</property>
|
||||||
<property name="y_options"></property>
|
<property name="y_options"></property>
|
||||||
<property name="x_padding">12</property>
|
<property name="x_padding">12</property>
|
||||||
@ -69,8 +69,8 @@
|
|||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">3</property>
|
<property name="left_attach">3</property>
|
||||||
<property name="right_attach">4</property>
|
<property name="right_attach">4</property>
|
||||||
<property name="top_attach">6</property>
|
<property name="top_attach">7</property>
|
||||||
<property name="bottom_attach">7</property>
|
<property name="bottom_attach">8</property>
|
||||||
<property name="x_options"></property>
|
<property name="x_options"></property>
|
||||||
<property name="y_options"></property>
|
<property name="y_options"></property>
|
||||||
</packing>
|
</packing>
|
||||||
@ -86,8 +86,8 @@
|
|||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">2</property>
|
<property name="left_attach">2</property>
|
||||||
<property name="right_attach">3</property>
|
<property name="right_attach">3</property>
|
||||||
<property name="top_attach">6</property>
|
<property name="top_attach">7</property>
|
||||||
<property name="bottom_attach">7</property>
|
<property name="bottom_attach">8</property>
|
||||||
<property name="x_options">GTK_FILL</property>
|
<property name="x_options">GTK_FILL</property>
|
||||||
<property name="y_options"></property>
|
<property name="y_options"></property>
|
||||||
</packing>
|
</packing>
|
||||||
@ -104,8 +104,8 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="right_attach">2</property>
|
<property name="right_attach">2</property>
|
||||||
<property name="top_attach">6</property>
|
<property name="top_attach">7</property>
|
||||||
<property name="bottom_attach">7</property>
|
<property name="bottom_attach">8</property>
|
||||||
<property name="x_options">GTK_FILL</property>
|
<property name="x_options">GTK_FILL</property>
|
||||||
<property name="y_options"></property>
|
<property name="y_options"></property>
|
||||||
<property name="x_padding">12</property>
|
<property name="x_padding">12</property>
|
||||||
@ -120,8 +120,8 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="right_attach">2</property>
|
<property name="right_attach">2</property>
|
||||||
<property name="top_attach">5</property>
|
<property name="top_attach">6</property>
|
||||||
<property name="bottom_attach">6</property>
|
<property name="bottom_attach">7</property>
|
||||||
<property name="x_options">GTK_FILL</property>
|
<property name="x_options">GTK_FILL</property>
|
||||||
<property name="y_options"></property>
|
<property name="y_options"></property>
|
||||||
</packing>
|
</packing>
|
||||||
@ -132,8 +132,8 @@
|
|||||||
<property name="xalign">0</property>
|
<property name="xalign">0</property>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="top_attach">4</property>
|
<property name="top_attach">5</property>
|
||||||
<property name="bottom_attach">5</property>
|
<property name="bottom_attach">6</property>
|
||||||
<property name="x_options">GTK_FILL</property>
|
<property name="x_options">GTK_FILL</property>
|
||||||
<property name="y_options"></property>
|
<property name="y_options"></property>
|
||||||
</packing>
|
</packing>
|
||||||
@ -150,8 +150,8 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="right_attach">2</property>
|
<property name="right_attach">2</property>
|
||||||
<property name="top_attach">4</property>
|
<property name="top_attach">5</property>
|
||||||
<property name="bottom_attach">5</property>
|
<property name="bottom_attach">6</property>
|
||||||
<property name="x_options">GTK_FILL</property>
|
<property name="x_options">GTK_FILL</property>
|
||||||
<property name="y_options"></property>
|
<property name="y_options"></property>
|
||||||
<property name="x_padding">12</property>
|
<property name="x_padding">12</property>
|
||||||
@ -169,8 +169,8 @@
|
|||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="right_attach">2</property>
|
<property name="right_attach">2</property>
|
||||||
<property name="top_attach">2</property>
|
<property name="top_attach">3</property>
|
||||||
<property name="bottom_attach">3</property>
|
<property name="bottom_attach">4</property>
|
||||||
<property name="x_options">GTK_FILL</property>
|
<property name="x_options">GTK_FILL</property>
|
||||||
<property name="y_options"></property>
|
<property name="y_options"></property>
|
||||||
<property name="x_padding">12</property>
|
<property name="x_padding">12</property>
|
||||||
@ -186,6 +186,37 @@
|
|||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
<property name="draw_indicator">True</property>
|
<property name="draw_indicator">True</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="right_attach">2</property>
|
||||||
|
<property name="top_attach">2</property>
|
||||||
|
<property name="bottom_attach">3</property>
|
||||||
|
<property name="x_options">GTK_FILL</property>
|
||||||
|
<property name="y_options"></property>
|
||||||
|
<property name="x_padding">12</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkLabel" id="label1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="yalign">0.47999998927116394</property>
|
||||||
|
<property name="label" translatable="yes"><b>General</b></property>
|
||||||
|
<property name="use_markup">True</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="x_options">GTK_FILL</property>
|
||||||
|
<property name="y_options"></property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkCheckButton" id="gconf/dialogs/business/invoice/enable_toolbuttons">
|
||||||
|
<property name="label" translatable="yes">Enable extra _buttons</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">False</property>
|
||||||
|
<property name="tooltip" translatable="yes">If active, extra toolbar buttons for common business functions are shown as well. Otherwise they are not shown.</property>
|
||||||
|
<property name="draw_indicator">True</property>
|
||||||
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="right_attach">2</property>
|
<property name="right_attach">2</property>
|
||||||
<property name="top_attach">1</property>
|
<property name="top_attach">1</property>
|
||||||
@ -244,17 +275,10 @@
|
|||||||
<placeholder/>
|
<placeholder/>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkLabel" id="label1">
|
<placeholder/>
|
||||||
<property name="visible">True</property>
|
</child>
|
||||||
<property name="xalign">0</property>
|
<child>
|
||||||
<property name="yalign">0.47999998927116394</property>
|
<placeholder/>
|
||||||
<property name="label" translatable="yes"><b>General</b></property>
|
|
||||||
<property name="use_markup">True</property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="x_options">GTK_FILL</property>
|
|
||||||
<property name="y_options"></property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
</child>
|
</child>
|
||||||
|
@ -46,11 +46,23 @@
|
|||||||
#include "gnc-file.h"
|
#include "gnc-file.h"
|
||||||
#include "guile-mappings.h"
|
#include "guile-mappings.h"
|
||||||
#include "gnc-session.h"
|
#include "gnc-session.h"
|
||||||
|
#include "gnome-utils/gnc-icons.h" /* for GNC_STOCK_INVOICE_NEW */
|
||||||
|
|
||||||
|
#include "core-utils/gnc-main.h" /* for GCONF_PATH */
|
||||||
|
#include "core-utils/gnc-gconf-utils.h"
|
||||||
|
#include "gnome-utils/gnc-main-window.h"
|
||||||
|
|
||||||
/* g_object functions */
|
/* g_object functions */
|
||||||
static void gnc_plugin_business_class_init (GncPluginBusinessClass *klass);
|
static void gnc_plugin_business_class_init (GncPluginBusinessClass *klass);
|
||||||
static void gnc_plugin_business_init (GncPluginBusiness *plugin);
|
static void gnc_plugin_business_init (GncPluginBusiness *plugin);
|
||||||
static void gnc_plugin_business_finalize (GObject *object);
|
static void gnc_plugin_business_finalize (GObject *object);
|
||||||
|
static void gnc_plugin_business_gconf_changed (GConfClient *client,
|
||||||
|
guint cnxn_id,
|
||||||
|
GConfEntry *entry,
|
||||||
|
gpointer user_data);
|
||||||
|
static void gnc_plugin_business_add_to_window (GncPlugin *plugin,
|
||||||
|
GncMainWindow *window,
|
||||||
|
GQuark type);
|
||||||
|
|
||||||
/* Command callbacks */
|
/* Command callbacks */
|
||||||
static void gnc_plugin_business_cmd_customer_new_customer (GtkAction *action,
|
static void gnc_plugin_business_cmd_customer_new_customer (GtkAction *action,
|
||||||
@ -282,6 +294,13 @@ static GtkActionEntry gnc_plugin_actions [] =
|
|||||||
N_("Initialize Test Data"),
|
N_("Initialize Test Data"),
|
||||||
G_CALLBACK (gnc_plugin_business_cmd_test_init_data)
|
G_CALLBACK (gnc_plugin_business_cmd_test_init_data)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/* Toolbar */
|
||||||
|
{
|
||||||
|
"ToolbarNewInvoiceAction", GNC_STOCK_INVOICE_NEW, N_("New _Invoice..."), NULL,
|
||||||
|
N_("Open the New Invoice dialog"),
|
||||||
|
G_CALLBACK (gnc_plugin_business_cmd_customer_new_invoice)
|
||||||
|
},
|
||||||
};
|
};
|
||||||
static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions);
|
static guint gnc_plugin_n_actions = G_N_ELEMENTS (gnc_plugin_actions);
|
||||||
|
|
||||||
@ -358,12 +377,18 @@ gnc_plugin_business_class_init (GncPluginBusinessClass *klass)
|
|||||||
/* plugin info */
|
/* plugin info */
|
||||||
plugin_class->plugin_name = GNC_PLUGIN_BUSINESS_NAME;
|
plugin_class->plugin_name = GNC_PLUGIN_BUSINESS_NAME;
|
||||||
|
|
||||||
|
/* function overrides */
|
||||||
|
plugin_class->add_to_window = gnc_plugin_business_add_to_window;
|
||||||
|
|
||||||
/* widget addition/removal */
|
/* widget addition/removal */
|
||||||
plugin_class->actions_name = PLUGIN_ACTIONS_NAME;
|
plugin_class->actions_name = PLUGIN_ACTIONS_NAME;
|
||||||
plugin_class->actions = gnc_plugin_actions;
|
plugin_class->actions = gnc_plugin_actions;
|
||||||
plugin_class->n_actions = gnc_plugin_n_actions;
|
plugin_class->n_actions = gnc_plugin_n_actions;
|
||||||
plugin_class->ui_filename = PLUGIN_UI_FILENAME;
|
plugin_class->ui_filename = PLUGIN_UI_FILENAME;
|
||||||
|
|
||||||
|
plugin_class->gconf_notifications = gnc_plugin_business_gconf_changed;
|
||||||
|
plugin_class->gconf_section = GCONF_SECTION_INVOICE;
|
||||||
|
|
||||||
g_type_class_add_private(klass, sizeof(GncPluginBusinessPrivate));
|
g_type_class_add_private(klass, sizeof(GncPluginBusinessPrivate));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -843,3 +868,75 @@ gnc_plugin_business_cmd_test_init_data (GtkAction *action,
|
|||||||
// Launch the invoice editor
|
// Launch the invoice editor
|
||||||
gnc_ui_invoice_edit(invoice);
|
gnc_ui_invoice_edit(invoice);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This is the list of actions which are switched invisible or visible
|
||||||
|
* depending on the preference "extra_toolbuttons". */
|
||||||
|
static const char* extra_toolbar_actions[] =
|
||||||
|
{
|
||||||
|
"ToolbarNewInvoiceAction",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
/* The code below will set the visibility of some extra toolbar
|
||||||
|
* buttons based on a gconf key setting. */
|
||||||
|
static void set_toolbuttons_visibility(GncMainWindow *mainwindow,
|
||||||
|
gboolean visible)
|
||||||
|
{
|
||||||
|
GtkActionGroup *action_group;
|
||||||
|
const char **iter;
|
||||||
|
|
||||||
|
/*g_warning("about to set button visibility %d", visible);*/
|
||||||
|
|
||||||
|
g_return_if_fail(mainwindow);
|
||||||
|
|
||||||
|
/* Get the action group */
|
||||||
|
action_group =
|
||||||
|
gnc_main_window_get_action_group(mainwindow, PLUGIN_ACTIONS_NAME);
|
||||||
|
g_assert(action_group);
|
||||||
|
|
||||||
|
for (iter = extra_toolbar_actions; *iter; ++iter)
|
||||||
|
{
|
||||||
|
/* Set the action's visibility */
|
||||||
|
GtkAction *action = gtk_action_group_get_action (action_group, *iter);
|
||||||
|
gtk_action_set_visible(action, visible);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void update_extra_toolbuttons(GncMainWindow *mainwindow)
|
||||||
|
{
|
||||||
|
gboolean value = gnc_gconf_get_bool(GCONF_SECTION_INVOICE,
|
||||||
|
"enable_toolbuttons", NULL);
|
||||||
|
set_toolbuttons_visibility(mainwindow, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This function is called whenever an entry in the business invoice
|
||||||
|
* section of gconf is changed. If the modified gconf entry concerns
|
||||||
|
* our toolbar buttons, we update their visibility status. */
|
||||||
|
static void
|
||||||
|
gnc_plugin_business_gconf_changed (GConfClient *client,
|
||||||
|
guint cnxn_id,
|
||||||
|
GConfEntry *entry,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GncMainWindow *mainwindow = user_data;
|
||||||
|
const char* full_gconf_path =
|
||||||
|
GCONF_PATH "/" GCONF_SECTION_INVOICE "/enable_toolbuttons";
|
||||||
|
const char* entry_key = gconf_entry_get_key(entry);
|
||||||
|
|
||||||
|
if (!entry_key)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (safe_strcmp(entry_key, full_gconf_path) == 0)
|
||||||
|
{
|
||||||
|
update_extra_toolbuttons(mainwindow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Update the toolbar button visibility each time our plugin is added
|
||||||
|
* to a new GncMainWindow. */
|
||||||
|
static void gnc_plugin_business_add_to_window (GncPlugin *plugin,
|
||||||
|
GncMainWindow *mainwindow,
|
||||||
|
GQuark type)
|
||||||
|
{
|
||||||
|
update_extra_toolbuttons(mainwindow);
|
||||||
|
}
|
||||||
|
@ -47,6 +47,21 @@
|
|||||||
</locale>
|
</locale>
|
||||||
</schema>
|
</schema>
|
||||||
|
|
||||||
|
<schema>
|
||||||
|
<key>/schemas/apps/gnucash/dialogs/business/invoice/enable_toolbuttons</key>
|
||||||
|
<applyto>/apps/gnucash/dialogs/business/invoice/enable_toolbuttons</applyto>
|
||||||
|
<owner>gnucash</owner>
|
||||||
|
<type>bool</type>
|
||||||
|
<default>FALSE</default>
|
||||||
|
<locale name="C">
|
||||||
|
<short>Enable extra toolbar buttons for business</short>
|
||||||
|
<long>
|
||||||
|
If active, extra toolbar buttons for common business
|
||||||
|
functions are shown as well. Otherwise they are not shown.
|
||||||
|
</long>
|
||||||
|
</locale>
|
||||||
|
</schema>
|
||||||
|
|
||||||
<schema>
|
<schema>
|
||||||
<key>/schemas/apps/gnucash/dialogs/business/invoice/use_new_window</key>
|
<key>/schemas/apps/gnucash/dialogs/business/invoice/use_new_window</key>
|
||||||
<applyto>/apps/gnucash/dialogs/business/invoice/use_new_window</applyto>
|
<applyto>/apps/gnucash/dialogs/business/invoice/use_new_window</applyto>
|
||||||
|
@ -56,4 +56,11 @@
|
|||||||
</menu>
|
</menu>
|
||||||
|
|
||||||
</menubar>
|
</menubar>
|
||||||
|
|
||||||
|
<toolbar name="DefaultToolbar">
|
||||||
|
<placeholder name="DefaultToolbarPlaceholder">
|
||||||
|
<toolitem name="ToolbarInvoiceNew" action="ToolbarNewInvoiceAction"/>
|
||||||
|
</placeholder>
|
||||||
|
</toolbar>
|
||||||
|
|
||||||
</ui>
|
</ui>
|
||||||
|
Loading…
Reference in New Issue
Block a user