mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Provide the right edit menu sensitivity for the register page.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13384 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
e82d670961
commit
a1dbbfe230
10
ChangeLog
10
ChangeLog
@ -1,5 +1,15 @@
|
|||||||
2006-02-24 David Hampton <hampton@employees.org>
|
2006-02-24 David Hampton <hampton@employees.org>
|
||||||
|
|
||||||
|
* src/register/register-gnome/gnucash-sheet.[ch]:
|
||||||
|
* src/register/register-gnome/gnucash-item-edit.[ch]:
|
||||||
|
* src/gnome/gnc-plugin-page-register.c: Override the generic edit
|
||||||
|
menu sensitivity code to provide the right sensitivity for the
|
||||||
|
entry widget buried in the register.
|
||||||
|
|
||||||
|
* src/gnome-utils/gnc-main-window.c:
|
||||||
|
* src/gnome-utils/gnc-plugin-page.h: Provide a hook for pages to
|
||||||
|
override the generic edit menu sensitivity code.
|
||||||
|
|
||||||
* src/gnome-utils/ui/gnc-main-window-ui.xml:
|
* src/gnome-utils/ui/gnc-main-window-ui.xml:
|
||||||
* src/gnome-utils/gnc-main-window.c: Remove unnecessary menu
|
* src/gnome-utils/gnc-main-window.c: Remove unnecessary menu
|
||||||
item. The same functionality exists in the "Menus & Toolbars"
|
item. The same functionality exists in the "Menus & Toolbars"
|
||||||
|
@ -354,9 +354,6 @@ static const gchar *gnc_menu_important_actions[] = {
|
|||||||
* have meaning. */
|
* have meaning. */
|
||||||
static const gchar *always_insensitive_actions[] = {
|
static const gchar *always_insensitive_actions[] = {
|
||||||
"FilePrintAction",
|
"FilePrintAction",
|
||||||
"EditCutAction",
|
|
||||||
"EditCopyAction",
|
|
||||||
"EditPasteAction",
|
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2171,10 +2168,19 @@ gnc_main_window_update_toolbar (GncMainWindow *window)
|
|||||||
static void
|
static void
|
||||||
gnc_main_window_update_edit_actions_sensitivity (GncMainWindow *window, gboolean hide)
|
gnc_main_window_update_edit_actions_sensitivity (GncMainWindow *window, gboolean hide)
|
||||||
{
|
{
|
||||||
|
GncMainWindowPrivate *priv;
|
||||||
|
GncPluginPage *page;
|
||||||
GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (window));
|
GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (window));
|
||||||
GtkAction *action;
|
GtkAction *action;
|
||||||
gboolean can_copy = FALSE, can_cut = FALSE, can_paste = FALSE;
|
gboolean can_copy = FALSE, can_cut = FALSE, can_paste = FALSE;
|
||||||
|
|
||||||
|
priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
|
||||||
|
page = priv->current_page;
|
||||||
|
if (GNC_PLUGIN_PAGE_GET_CLASS(page)->update_edit_menu_actions) {
|
||||||
|
(GNC_PLUGIN_PAGE_GET_CLASS(page)->update_edit_menu_actions)(page, hide);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (GTK_IS_EDITABLE (widget))
|
if (GTK_IS_EDITABLE (widget))
|
||||||
{
|
{
|
||||||
gboolean has_selection;
|
gboolean has_selection;
|
||||||
|
@ -165,6 +165,16 @@ typedef struct {
|
|||||||
* @param name The new name for this page. */
|
* @param name The new name for this page. */
|
||||||
void (* page_name_changed) (GncPluginPage *plugin_page,
|
void (* page_name_changed) (GncPluginPage *plugin_page,
|
||||||
const gchar *name);
|
const gchar *name);
|
||||||
|
|
||||||
|
/** This function vector allows page specific actions to
|
||||||
|
* override the generic code for setting the sensitivity of
|
||||||
|
* items in the Edit menu.
|
||||||
|
*
|
||||||
|
* @param page The front page in a main window..
|
||||||
|
*
|
||||||
|
* @param hide Whether the widgets should be shown or
|
||||||
|
* hidden. */
|
||||||
|
void (* update_edit_menu_actions) (GncPluginPage *plugin_page, gboolean hide);
|
||||||
} GncPluginPageClass;
|
} GncPluginPageClass;
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,6 +93,7 @@ static void gnc_plugin_page_register_destroy_widget (GncPluginPage *plugin_page)
|
|||||||
static void gnc_plugin_page_register_window_changed (GncPluginPage *plugin_page, GtkWidget *window);
|
static void gnc_plugin_page_register_window_changed (GncPluginPage *plugin_page, GtkWidget *window);
|
||||||
static void gnc_plugin_page_register_save_page (GncPluginPage *plugin_page, GKeyFile *file, const gchar *group);
|
static void gnc_plugin_page_register_save_page (GncPluginPage *plugin_page, GKeyFile *file, const gchar *group);
|
||||||
static GncPluginPage *gnc_plugin_page_register_recreate_page (GtkWidget *window, GKeyFile *file, const gchar *group);
|
static GncPluginPage *gnc_plugin_page_register_recreate_page (GtkWidget *window, GKeyFile *file, const gchar *group);
|
||||||
|
static void gnc_plugin_page_register_update_edit_menu (GncPluginPage *page, gboolean hide);
|
||||||
|
|
||||||
static gchar *gnc_plugin_page_register_get_tab_name (GncPluginPage *plugin_page);
|
static gchar *gnc_plugin_page_register_get_tab_name (GncPluginPage *plugin_page);
|
||||||
|
|
||||||
@ -502,6 +503,7 @@ gnc_plugin_page_register_class_init (GncPluginPageRegisterClass *klass)
|
|||||||
gnc_plugin_class->window_changed = gnc_plugin_page_register_window_changed;
|
gnc_plugin_class->window_changed = gnc_plugin_page_register_window_changed;
|
||||||
gnc_plugin_class->save_page = gnc_plugin_page_register_save_page;
|
gnc_plugin_class->save_page = gnc_plugin_page_register_save_page;
|
||||||
gnc_plugin_class->recreate_page = gnc_plugin_page_register_recreate_page;
|
gnc_plugin_class->recreate_page = gnc_plugin_page_register_recreate_page;
|
||||||
|
gnc_plugin_class->update_edit_menu_actions = gnc_plugin_page_register_update_edit_menu;
|
||||||
|
|
||||||
g_type_class_add_private(klass, sizeof(GncPluginPageRegisterPrivate));
|
g_type_class_add_private(klass, sizeof(GncPluginPageRegisterPrivate));
|
||||||
}
|
}
|
||||||
@ -988,6 +990,38 @@ gnc_plugin_page_register_recreate_page (GtkWidget *window,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Based on code from Epiphany (src/ephy-window.c)
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
gnc_plugin_page_register_update_edit_menu (GncPluginPage *page, gboolean hide)
|
||||||
|
{
|
||||||
|
GncPluginPageRegisterPrivate *priv;
|
||||||
|
GncPluginPageRegister *reg_page;
|
||||||
|
GtkAction *action;
|
||||||
|
gboolean can_copy = FALSE, can_cut = FALSE, can_paste = FALSE;
|
||||||
|
gboolean has_selection;
|
||||||
|
|
||||||
|
reg_page = GNC_PLUGIN_PAGE_REGISTER(page);
|
||||||
|
priv = GNC_PLUGIN_PAGE_REGISTER_GET_PRIVATE(reg_page);
|
||||||
|
has_selection = gnucash_register_has_selection (priv->gsr->reg);
|
||||||
|
|
||||||
|
can_copy = has_selection;
|
||||||
|
can_cut = has_selection;
|
||||||
|
can_paste = TRUE;
|
||||||
|
|
||||||
|
action = gnc_plugin_page_get_action (page, "EditCopyAction");
|
||||||
|
gtk_action_set_sensitive (action, can_copy);
|
||||||
|
gtk_action_set_visible (action, !hide || can_copy);
|
||||||
|
action = gnc_plugin_page_get_action (page, "EditCutAction");
|
||||||
|
gtk_action_set_sensitive (action, can_cut);
|
||||||
|
gtk_action_set_visible (action, !hide || can_cut);
|
||||||
|
action = gnc_plugin_page_get_action (page, "EditPasteAction");
|
||||||
|
gtk_action_set_sensitive (action, can_paste);
|
||||||
|
gtk_action_set_visible (action, !hide || can_paste);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static gchar *
|
static gchar *
|
||||||
gnc_plugin_page_register_get_tab_name (GncPluginPage *plugin_page)
|
gnc_plugin_page_register_get_tab_name (GncPluginPage *plugin_page)
|
||||||
{
|
{
|
||||||
|
@ -1541,6 +1541,18 @@ gnc_item_edit_set_has_selection (GncItemEdit *item_edit, gboolean has_selection)
|
|||||||
item_edit->has_selection = has_selection;
|
item_edit->has_selection = has_selection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gnc_item_edit_get_has_selection (GncItemEdit *item_edit)
|
||||||
|
{
|
||||||
|
GtkEditable *editable;
|
||||||
|
|
||||||
|
g_return_val_if_fail ((item_edit != NULL), FALSE);
|
||||||
|
g_return_val_if_fail (GNC_IS_ITEM_EDIT (item_edit), FALSE);
|
||||||
|
|
||||||
|
editable = GTK_EDITABLE (item_edit->editor);
|
||||||
|
return gtk_editable_get_selection_bounds(editable, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gnc_item_edit_selection_clear (GncItemEdit *item_edit,
|
gnc_item_edit_selection_clear (GncItemEdit *item_edit,
|
||||||
GdkEventSelection *event)
|
GdkEventSelection *event)
|
||||||
|
@ -157,6 +157,7 @@ void gnc_item_edit_paste_clipboard (GncItemEdit *item_edit, guint32 time);
|
|||||||
void gnc_item_edit_paste_primary (GncItemEdit *item_edit, guint32 time);
|
void gnc_item_edit_paste_primary (GncItemEdit *item_edit, guint32 time);
|
||||||
|
|
||||||
void gnc_item_edit_set_has_selection (GncItemEdit *item_edit, gboolean has_selection);
|
void gnc_item_edit_set_has_selection (GncItemEdit *item_edit, gboolean has_selection);
|
||||||
|
gboolean gnc_item_edit_get_has_selection (GncItemEdit *item_edit);
|
||||||
|
|
||||||
gboolean gnc_item_edit_selection_clear (GncItemEdit *item_edit,
|
gboolean gnc_item_edit_selection_clear (GncItemEdit *item_edit,
|
||||||
GdkEventSelection *event);
|
GdkEventSelection *event);
|
||||||
|
@ -1367,6 +1367,21 @@ gnucash_button_press_event (GtkWidget *widget, GdkEventButton *event)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gnucash_register_has_selection (GnucashRegister *reg)
|
||||||
|
{
|
||||||
|
GnucashSheet *sheet;
|
||||||
|
GncItemEdit *item_edit;
|
||||||
|
|
||||||
|
g_return_val_if_fail((reg != NULL), FALSE);
|
||||||
|
g_return_val_if_fail(GNUCASH_IS_REGISTER(reg), FALSE);
|
||||||
|
|
||||||
|
sheet = GNUCASH_SHEET(reg->sheet);
|
||||||
|
item_edit = GNC_ITEM_EDIT(sheet->item_editor);
|
||||||
|
|
||||||
|
return gnc_item_edit_get_has_selection(item_edit);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gnucash_register_cut_clipboard (GnucashRegister *reg)
|
gnucash_register_cut_clipboard (GnucashRegister *reg)
|
||||||
{
|
{
|
||||||
|
@ -209,6 +209,7 @@ void gnucash_register_attach_popup(GnucashRegister *reg, GtkWidget *popup,
|
|||||||
|
|
||||||
void gnucash_register_set_initial_rows(guint num_rows);
|
void gnucash_register_set_initial_rows(guint num_rows);
|
||||||
|
|
||||||
|
gboolean gnucash_register_has_selection (GnucashRegister *reg);
|
||||||
void gnucash_register_cut_clipboard (GnucashRegister *reg);
|
void gnucash_register_cut_clipboard (GnucashRegister *reg);
|
||||||
void gnucash_register_copy_clipboard (GnucashRegister *reg);
|
void gnucash_register_copy_clipboard (GnucashRegister *reg);
|
||||||
void gnucash_register_paste_clipboard (GnucashRegister *reg);
|
void gnucash_register_paste_clipboard (GnucashRegister *reg);
|
||||||
|
Loading…
Reference in New Issue
Block a user