GnuCash de0bfde+
Loading...
Searching...
No Matches
Main Window functions.

Files

file  gnc-main-window.h
 Functions for adding content to a window.

Data Structures

struct  GncMainWindow
 The instance data structure for a main window object. More...
struct  GncMainWindowPrivate
 The instance private data structure for an embedded window object. More...
struct  GncMainWindowSaveData
struct  menu_update
 This data structure is used to describe the requested state of a GAction, and is used to pass data among several functions. More...
struct  TabWidth
 This data structure allows the passing of the tab width and whether the tab layout is on the left or right. More...
struct  GncMenuUpdate
struct  GncMainWindowClass
 The class data structure for a main window object. More...
struct  GncMainWindowActionData
struct  GncToolBarShortNames
 A structure for defining alternate action names for use in the toolbar. More...

Macros

#define PLUGIN_PAGE_LABEL   "plugin-page"
 This label is used to provide a mapping from a visible page widget back to the corresponding GncPluginPage object.
#define PLUGIN_PAGE_CLOSE_BUTTON   "close-button"
#define PLUGIN_PAGE_TAB_LABEL   "label"
#define GNC_PREF_SHOW_CLOSE_BUTTON   "tab-close-buttons"
#define GNC_PREF_TAB_NEXT_RECENT   "tab-next-recent"
#define GNC_PREF_TAB_POSITION_TOP   "tab-position-top"
#define GNC_PREF_TAB_POSITION_BOTTOM   "tab-position-bottom"
#define GNC_PREF_TAB_POSITION_LEFT   "tab-position-left"
#define GNC_PREF_TAB_POSITION_RIGHT   "tab-position-right"
#define GNC_PREF_TAB_WIDTH   "tab-width"
#define GNC_PREF_TAB_COLOR   "show-account-color-tabs"
#define GNC_PREF_SAVE_CLOSE_EXPIRES   "save-on-close-expires"
#define GNC_PREF_SAVE_CLOSE_WAIT_TIME   "save-on-close-wait-time"
#define GNC_PREF_TAB_OPEN_ADJACENT   "tab-open-adjacent"
#define GNC_MAIN_WINDOW_NAME   "GncMainWindow"
#define DIALOG_BOOK_OPTIONS_CM_CLASS   "dialog-book-options"
#define MSG_AUTO_SAVE   _("Changes will be saved automatically in %u seconds")
#define WINDOW_COUNT   "WindowCount"
#define WINDOW_STRING   "Window %d"
#define WINDOW_GEOMETRY   "WindowGeometry"
#define WINDOW_POSITION   "WindowPosition"
#define WINDOW_MAXIMIZED   "WindowMaximized"
#define TOOLBAR_VISIBLE   "ToolbarVisible"
#define STATUSBAR_VISIBLE   "StatusbarVisible"
#define SUMMARYBAR_VISIBLE   "SummarybarVisible"
#define WINDOW_FIRSTPAGE   "FirstPage"
#define WINDOW_PAGECOUNT   "PageCount"
#define WINDOW_PAGEORDER   "PageOrder"
#define PAGE_TYPE   "PageType"
#define PAGE_NAME   "PageName"
#define PAGE_STRING   "Page %d"
#define DEFAULT_MARGIN   5
#define GNC_TYPE_MAIN_WINDOW   (gnc_main_window_get_type ())
#define GNC_MAIN_WINDOW(obj)
#define GNC_MAIN_WINDOW_CLASS(klass)
#define GNC_IS_MAIN_WINDOW(obj)
#define GNC_IS_MAIN_WINDOW_CLASS(klass)
#define GNC_MAIN_WINDOW_GET_CLASS(obj)
#define PLUGIN_PAGE_IMMUTABLE   "page-immutable"

Typedefs

typedef void(* GncMainWindowFunc) (GncMainWindow *window, GncPluginPage *page)
typedef void(* GncMainWindowPageFunc) (GncPluginPage *page, gpointer user_data)

Enumerations

enum  { PAGE_ADDED , PAGE_CHANGED , MENU_CHANGED , LAST_SIGNAL }
 Names of signals generated by the main window. More...

Functions

gboolean gnc_book_options_dialog_apply_helper (GncOptionDB *options)
 Processes selected options in the Book Options dialog: checks book_currency and use_split_action_for_num to see if features kvp should be set.
 G_DEFINE_TYPE_WITH_CODE (GncMainWindow, gnc_main_window, GTK_TYPE_APPLICATION_WINDOW, G_IMPLEMENT_INTERFACE(GNC_TYPE_WINDOW, gnc_window_main_window_init)) static guint main_window_signals[LAST_SIGNAL]
 A holding place for all the signals generated by the main window code.
gboolean gnc_main_window_is_restoring_pages (GncMainWindow *window)
 Check if the main window is restoring the plugin pages.
void gnc_main_window_foreach_page (GncMainWindowPageFunc fn, gpointer user_data)
 Iterator function to walk all pages in all windows, calling the specified function for each page.
void gnc_main_window_restore_all_windows (const GKeyFile *keyfile)
 Restore the persistent state of all windows.
void gnc_main_window_restore_default_state (GncMainWindow *window)
 Restore the persistent state of one window to a sane default.
void gnc_main_window_save_all_windows (GKeyFile *keyfile)
 Save the persistent state of all windows.
gboolean gnc_main_window_finish_pending (GncMainWindow *window)
 Tell a window to finish any outstanding activities.
gboolean gnc_main_window_all_finish_pending (void)
 Tell all pages in all windows to finish any outstanding activities.
gboolean gnc_main_window_is_quitting (GncMainWindow *window)
 Check if the main window is quitting.
void main_window_update_page_long_name (GncPluginPage *page, const gchar *long_name_in)
 Update the long name of the page in the main window.
void main_window_update_page_name (GncPluginPage *page, const gchar *name_in)
 Update the name of the page in the main window.
void main_window_update_page_color (GncPluginPage *page, const gchar *color_in)
 Update the color on the page tabs in the main window.
void main_window_update_page_set_read_only_icon (GncPluginPage *page, gboolean read_only)
 Update the icon on the page tabs in the main window.
GncMainWindow * gnc_main_window_new (void)
 Create a new gnc main window plugin.
void gnc_main_window_display_page (GncPluginPage *page)
 Bring the window containing the specified page to the top of the window stack, then switch the notebook to show the specified page.
void gnc_main_window_open_page (GncMainWindow *window, GncPluginPage *page)
 Display a data plugin page in a window.
void gnc_main_window_close_page (GncPluginPage *page)
 Remove a data plugin page from a window and display the previous page.
GncPluginPage * gnc_main_window_get_current_page (GncMainWindow *window)
 Retrieve a pointer to the page that is currently at the front of the specified window.
void gnc_main_window_manual_merge_actions (GncMainWindow *window, const gchar *group_name, GSimpleActionGroup *group)
 Manually add a set of actions to the specified window.
void gnc_main_window_merge_actions (GncMainWindow *window, const gchar *group_name, GActionEntry *entries, guint n_entries, const gchar **ui_updates, const gchar *ui_filename, gpointer user_data)
 Add a set of actions to the specified window.
void gnc_main_window_unmerge_actions (GncMainWindow *window, const gchar *group_name)
 Remove a set of actions from the specified window.
GAction * gnc_main_window_find_action (GncMainWindow *window, const gchar *action_name)
 Find the GAction in the main window.
GAction * gnc_main_window_find_action_in_group (GncMainWindow *window, const gchar *group_name, const gchar *action_name)
 Find the GAction in a specific action group for window.
GSimpleActionGroup * gnc_main_window_get_action_group (GncMainWindow *window, const gchar *group_name)
 Retrieve a specific set of user interface actions from a window.
GtkWidget * gnc_main_window_toolbar_find_tool_item (GncMainWindow *window, const gchar *action_name)
 Find the toolbar item with the given action name for the window specified.
GtkWidget * gnc_main_window_menu_find_menu_item (GncMainWindow *window, const gchar *action_name)
 Find the menu item with the given action name for the window specified.
void gnc_main_window_menu_add_accelerator_keys (GncMainWindow *window)
 Scan the main window menu and add accelerator keys to main window accelerator group.
gboolean gnc_main_window_update_menu_for_action (GncMainWindow *window, const gchar *action_name, const gchar *label, const gchar *tooltip)
 Find the GMenuModel item given the action name for the window specified.
void gnc_main_window_set_vis_of_items_by_action (GncMainWindow *window, const gchar **action_names, gboolean vis)
 Show or hide menu and toolbar items based on a NULL terminated list of action names.
void gnc_main_window_init_short_names (GncMainWindow *window, GncToolBarShortNames *toolbar_labels)
 Update the labels of the toolbar items with short names.
void gnc_main_window_update_menu_and_toolbar (GncMainWindow *window, GncPluginPage *page, const gchar **ui_updates)
 Update the main window menu with the placeholders listed in ui_updates and load the page specific toolbar.
void gnc_book_option_num_field_source_change_cb (gboolean num_action)
 Calls gnc_book_option_num_field_source_change to initiate registered callbacks when num_field_source book option changes so that registers/reports can update themselves; sets feature flag.
GtkWidget * gnc_book_options_dialog_cb (gboolean modal, gchar *title, GtkWindow *parent)
 Opens the Book Options dialog.
void gnc_main_window_show_all_windows (void)
 Shows all main windows.
GtkWindow * gnc_ui_get_gtk_window (GtkWidget *widget)
 Get a pointer to the widget's immediate top level GtkWindow.
GtkWindow * gnc_ui_get_main_window (GtkWidget *widget)
 Get a pointer to the final GncMainWindow widget is rooted in.
void gnc_main_window_set_progressbar_window (GncMainWindow *window)
 Set the window where all progressbar updates should occur.
gboolean gnc_main_window_popup_menu_cb (GtkWidget *widget, GncPluginPage *page)
 Callback function invoked when the user requests that Gnucash popup the contextual menu via the keyboard context-menu request key combination (Shift-F10 by default).
gboolean gnc_main_window_button_press_cb (GtkWidget *whatever, GdkEventButton *event, GncPluginPage *page)
 Callback function invoked when the user clicks in the content of any Gnucash window.
void gnc_main_window_all_action_set_sensitive (const gchar *action_name, gboolean sensitive)
 Change the sensitivity of a command in all windows.
GMenuModel * gnc_main_window_get_menu_model (GncMainWindow *window)
 Return the GMenuModel for the main window menu bar.
gboolean gnc_main_window_just_plugin_prefs (GncMainWindow *window)
GType gnc_main_window_get_type (void)
 Get the type of a gnc main window.

Variables

constexpr auto gnc_main_window_max_number {10}
 Max number of windows allowed.

Detailed Description

Macro Definition Documentation

◆ DEFAULT_MARGIN

#define DEFAULT_MARGIN   5

Definition at line 5256 of file gnc-main-window.cpp.

◆ DIALOG_BOOK_OPTIONS_CM_CLASS

#define DIALOG_BOOK_OPTIONS_CM_CLASS   "dialog-book-options"

Definition at line 120 of file gnc-main-window.cpp.

◆ GNC_IS_MAIN_WINDOW

#define GNC_IS_MAIN_WINDOW ( obj)
Value:
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_MAIN_WINDOW))

Definition at line 51 of file gnc-main-window.h.

◆ GNC_IS_MAIN_WINDOW_CLASS

#define GNC_IS_MAIN_WINDOW_CLASS ( klass)
Value:
(G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_MAIN_WINDOW))

Definition at line 52 of file gnc-main-window.h.

◆ GNC_MAIN_WINDOW

#define GNC_MAIN_WINDOW ( obj)
Value:
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_MAIN_WINDOW, GncMainWindow))

Definition at line 49 of file gnc-main-window.h.

◆ GNC_MAIN_WINDOW_CLASS

#define GNC_MAIN_WINDOW_CLASS ( klass)
Value:
(G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_MAIN_WINDOW, GncMainWindowClass))
The class data structure for a main window object.

Definition at line 50 of file gnc-main-window.h.

◆ GNC_MAIN_WINDOW_GET_CLASS

#define GNC_MAIN_WINDOW_GET_CLASS ( obj)
Value:
(G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_MAIN_WINDOW, GncMainWindowClass))

Definition at line 53 of file gnc-main-window.h.

◆ GNC_MAIN_WINDOW_NAME

#define GNC_MAIN_WINDOW_NAME   "GncMainWindow"

Definition at line 118 of file gnc-main-window.cpp.

◆ GNC_PREF_SAVE_CLOSE_EXPIRES

#define GNC_PREF_SAVE_CLOSE_EXPIRES   "save-on-close-expires"

Definition at line 114 of file gnc-main-window.cpp.

◆ GNC_PREF_SAVE_CLOSE_WAIT_TIME

#define GNC_PREF_SAVE_CLOSE_WAIT_TIME   "save-on-close-wait-time"

Definition at line 115 of file gnc-main-window.cpp.

◆ GNC_PREF_SHOW_CLOSE_BUTTON

#define GNC_PREF_SHOW_CLOSE_BUTTON   "tab-close-buttons"

Definition at line 106 of file gnc-main-window.cpp.

◆ GNC_PREF_TAB_COLOR

#define GNC_PREF_TAB_COLOR   "show-account-color-tabs"

Definition at line 113 of file gnc-main-window.cpp.

◆ GNC_PREF_TAB_NEXT_RECENT

#define GNC_PREF_TAB_NEXT_RECENT   "tab-next-recent"

Definition at line 107 of file gnc-main-window.cpp.

◆ GNC_PREF_TAB_OPEN_ADJACENT

#define GNC_PREF_TAB_OPEN_ADJACENT   "tab-open-adjacent"

Definition at line 116 of file gnc-main-window.cpp.

◆ GNC_PREF_TAB_POSITION_BOTTOM

#define GNC_PREF_TAB_POSITION_BOTTOM   "tab-position-bottom"

Definition at line 109 of file gnc-main-window.cpp.

◆ GNC_PREF_TAB_POSITION_LEFT

#define GNC_PREF_TAB_POSITION_LEFT   "tab-position-left"

Definition at line 110 of file gnc-main-window.cpp.

◆ GNC_PREF_TAB_POSITION_RIGHT

#define GNC_PREF_TAB_POSITION_RIGHT   "tab-position-right"

Definition at line 111 of file gnc-main-window.cpp.

◆ GNC_PREF_TAB_POSITION_TOP

#define GNC_PREF_TAB_POSITION_TOP   "tab-position-top"

Definition at line 108 of file gnc-main-window.cpp.

◆ GNC_PREF_TAB_WIDTH

#define GNC_PREF_TAB_WIDTH   "tab-width"

Definition at line 112 of file gnc-main-window.cpp.

◆ GNC_TYPE_MAIN_WINDOW

#define GNC_TYPE_MAIN_WINDOW   (gnc_main_window_get_type ())

Definition at line 48 of file gnc-main-window.h.

◆ MSG_AUTO_SAVE

#define MSG_AUTO_SAVE   _("Changes will be saved automatically in %u seconds")

Definition at line 150 of file gnc-main-window.cpp.

◆ PAGE_NAME

#define PAGE_NAME   "PageName"

Definition at line 393 of file gnc-main-window.cpp.

◆ PAGE_STRING

#define PAGE_STRING   "Page %d"

Definition at line 394 of file gnc-main-window.cpp.

◆ PAGE_TYPE

#define PAGE_TYPE   "PageType"

Definition at line 392 of file gnc-main-window.cpp.

◆ PLUGIN_PAGE_CLOSE_BUTTON

#define PLUGIN_PAGE_CLOSE_BUTTON   "close-button"

Definition at line 103 of file gnc-main-window.cpp.

◆ PLUGIN_PAGE_IMMUTABLE

#define PLUGIN_PAGE_IMMUTABLE   "page-immutable"

Definition at line 55 of file gnc-main-window.h.

◆ PLUGIN_PAGE_LABEL

#define PLUGIN_PAGE_LABEL   "plugin-page"

This label is used to provide a mapping from a visible page widget back to the corresponding GncPluginPage object.

Definition at line 101 of file gnc-main-window.cpp.

◆ PLUGIN_PAGE_TAB_LABEL

#define PLUGIN_PAGE_TAB_LABEL   "label"

Definition at line 104 of file gnc-main-window.cpp.

◆ STATUSBAR_VISIBLE

#define STATUSBAR_VISIBLE   "StatusbarVisible"

Definition at line 387 of file gnc-main-window.cpp.

◆ SUMMARYBAR_VISIBLE

#define SUMMARYBAR_VISIBLE   "SummarybarVisible"

Definition at line 388 of file gnc-main-window.cpp.

◆ TOOLBAR_VISIBLE

#define TOOLBAR_VISIBLE   "ToolbarVisible"

Definition at line 386 of file gnc-main-window.cpp.

◆ WINDOW_COUNT

#define WINDOW_COUNT   "WindowCount"

Definition at line 381 of file gnc-main-window.cpp.

◆ WINDOW_FIRSTPAGE

#define WINDOW_FIRSTPAGE   "FirstPage"

Definition at line 389 of file gnc-main-window.cpp.

◆ WINDOW_GEOMETRY

#define WINDOW_GEOMETRY   "WindowGeometry"

Definition at line 383 of file gnc-main-window.cpp.

◆ WINDOW_MAXIMIZED

#define WINDOW_MAXIMIZED   "WindowMaximized"

Definition at line 385 of file gnc-main-window.cpp.

◆ WINDOW_PAGECOUNT

#define WINDOW_PAGECOUNT   "PageCount"

Definition at line 390 of file gnc-main-window.cpp.

◆ WINDOW_PAGEORDER

#define WINDOW_PAGEORDER   "PageOrder"

Definition at line 391 of file gnc-main-window.cpp.

◆ WINDOW_POSITION

#define WINDOW_POSITION   "WindowPosition"

Definition at line 384 of file gnc-main-window.cpp.

◆ WINDOW_STRING

#define WINDOW_STRING   "Window %d"

Definition at line 382 of file gnc-main-window.cpp.

Typedef Documentation

◆ GncMainWindowFunc

typedef void(* GncMainWindowFunc) (GncMainWindow *window, GncPluginPage *page)

Definition at line 88 of file gnc-main-window.h.

◆ GncMainWindowPageFunc

typedef void(* GncMainWindowPageFunc) (GncPluginPage *page, gpointer user_data)

Definition at line 89 of file gnc-main-window.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Names of signals generated by the main window.

Definition at line 91 of file gnc-main-window.cpp.

92{
93 PAGE_ADDED,
94 PAGE_CHANGED,
95 MENU_CHANGED,
96 LAST_SIGNAL
97};

Function Documentation

◆ gnc_book_option_num_field_source_change_cb()

void gnc_book_option_num_field_source_change_cb ( gboolean num_action)

Calls gnc_book_option_num_field_source_change to initiate registered callbacks when num_field_source book option changes so that registers/reports can update themselves; sets feature flag.

Definition at line 4689 of file gnc-main-window.cpp.

4690{
4691 gnc_suspend_gui_refresh ();
4692 if (num_action)
4693 {
4694 /* Set a feature flag in the book for use of the split action field as number.
4695 * This will prevent older GnuCash versions that don't support this feature
4696 * from opening this file. */
4697 gnc_features_set_used (gnc_get_current_book(),
4698 GNC_FEATURE_NUM_FIELD_SOURCE);
4699 }
4700 gnc_book_option_num_field_source_change (num_action);
4701 gnc_resume_gui_refresh ();
4702}
void gnc_features_set_used(QofBook *book, const gchar *feature)
Indicate that the current book uses the given feature.

◆ gnc_book_options_dialog_apply_helper()

gboolean gnc_book_options_dialog_apply_helper ( GncOptionDB * options)
extern

Processes selected options in the Book Options dialog: checks book_currency and use_split_action_for_num to see if features kvp should be set.

To be used where ever a new book situation requires book option selection (e.g., not just in Book Options dialog opened from main window but also in new-file assistant).

Parameters
GncOptionDB* options.
Returns
TRUE if gnc_gui_refresh_all should be called; otherwise FALSE.

Definition at line 4613 of file gnc-main-window.cpp.

4614{
4615 QofBook *book = gnc_get_current_book ();
4616 gboolean use_split_action_for_num_before =
4618 gint use_read_only_threshold_before =
4620 gboolean use_split_action_for_num_after;
4621 gint use_read_only_threshold_after;
4622 gboolean return_val = FALSE;
4623 GList *results = nullptr, *iter;
4624
4625 if (!options) return return_val;
4626
4627 results = gnc_option_db_commit (options);
4628 for (iter = results; iter; iter = iter->next)
4629 {
4630 GtkWidget *dialog = gtk_message_dialog_new(gnc_ui_get_main_window (nullptr),
4631 (GtkDialogFlags)0,
4632 GTK_MESSAGE_ERROR,
4633 GTK_BUTTONS_OK,
4634 "%s",
4635 (char*)iter->data);
4636 gtk_dialog_run(GTK_DIALOG(dialog));
4637 gtk_widget_destroy(dialog);
4638 g_free (iter->data);
4639 }
4640 g_list_free (results);
4641 qof_book_begin_edit (book);
4642 qof_book_save_options (book, gnc_option_db_save, options, TRUE);
4643 use_split_action_for_num_after =
4645
4646 // mark cached value as invalid so we get new value
4647 qof_book_reset_num_days_autoreadonly_cache (book);
4648 use_read_only_threshold_after = qof_book_get_num_days_autoreadonly (book);
4649
4650 if (use_split_action_for_num_before != use_split_action_for_num_after)
4651 {
4653 use_split_action_for_num_after);
4654 return_val = TRUE;
4655 }
4656 if (use_read_only_threshold_before != use_read_only_threshold_after)
4657 return_val = TRUE;
4658
4659 qof_book_commit_edit (book);
4660 return return_val;
4661}
gint qof_book_get_num_days_autoreadonly(const QofBook *book)
Returns the number of days for auto-read-only transactions.
Definition qofbook.cpp:986
void qof_book_save_options(QofBook *book, GncOptionSave save_cb, GncOptionDB *odb, gboolean clear)
Save a GncOptionsDB back to the book's KVP.
Definition qofbook.cpp:1340
gboolean qof_book_use_split_action_for_num_field(const QofBook *book)
Returns TRUE if this book uses split action field as the 'Num' field, FALSE if it uses transaction nu...
void gnc_book_option_num_field_source_change_cb(gboolean num_action)
Calls gnc_book_option_num_field_source_change to initiate registered callbacks when num_field_source ...
GtkWindow * gnc_ui_get_main_window(GtkWidget *widget)
Get a pointer to the final GncMainWindow widget is rooted in.
void gnc_option_db_save(GncOptionDB *odb, QofBook *book, gboolean clear_options)
Save the GncOptionDB contents into a book's options store.
GList * gnc_option_db_commit(GncOptionDB *odb)
Write all changed ui_item values to their options.
QofBook reference.
Definition qofbook-p.hpp:47

◆ gnc_book_options_dialog_cb()

GtkWidget * gnc_book_options_dialog_cb ( gboolean modal,
gchar * title,
GtkWindow * parent )

Opens the Book Options dialog.

Parameters
modalTrue to open in modal mode, false otherwise.
titleTitle of the dialog; "Book Options" if NULL.
parentThe toplevel GdkWindow with which the dialog will be transient for.
Returns
A pointer to the GtkWidget for the dialog that can be used when started in modal mode.

Definition at line 4719 of file gnc-main-window.cpp.

4720{
4721 auto book = gnc_get_current_book ();
4722
4723 auto options = gnc_option_db_new();
4726 gnc_option_db_clean (options);
4727
4728 /* Only allow one Book Options dialog if called from file->properties
4729 menu */
4730 if (gnc_forall_gui_components(DIALOG_BOOK_OPTIONS_CM_CLASS,
4731 show_handler, nullptr))
4732 {
4733 return nullptr;
4734 }
4735 auto optionwin = new GncOptionsDialog (modal,
4736 (title ? title : _( "Book Options")),
4737 DIALOG_BOOK_OPTIONS_CM_CLASS, parent);
4738 optionwin->build_contents(options);
4739 optionwin->set_book_help_cb();
4740 optionwin->set_apply_cb(gnc_book_options_dialog_apply_cb,
4741 (gpointer)options);
4742 optionwin->set_close_cb ( gnc_book_options_dialog_close_cb,
4743 (gpointer)options);
4744 if (modal)
4746 return optionwin->get_widget();
4747}
void gnc_options_dialog_set_new_book_option_values(GncOptionDB *odb)
Set the initial values of new book options to values specified in user preferences.
void qof_book_load_options(QofBook *book, GncOptionLoad load_cb, GncOptionDB *odb)
Load a GncOptionsDB from KVP data.
Definition qofbook.cpp:1334
GncOptionDB * gnc_option_db_new(void)
Create an empty option database.
void gnc_option_db_clean(GncOptionDB *odb)
Reset all ui_items to the option value.
void gnc_option_db_book_options(GncOptionDB *odb)
Register the standard option set for a QofBook.
void gnc_option_db_load(GncOptionDB *odb, QofBook *book)
Load a book's options into the GncOptionDB.

◆ gnc_main_window_all_action_set_sensitive()

void gnc_main_window_all_action_set_sensitive ( const gchar * action_name,
gboolean sensitive )

Change the sensitivity of a command in all windows.

This can be used to serialize access to a command so that in cannot be reinvoked until the current invocation is finished.

Parameters
action_nameThe name of the command to modity.
sensitiveWhether or not the user should be able to invoke this action.

Definition at line 5912 of file gnc-main-window.cpp.

5914{
5915 for (auto tmp = active_windows; tmp; tmp = g_list_next(tmp))
5916 {
5917 auto action{gnc_main_window_find_action (static_cast<GncMainWindow*>(tmp->data), action_name)};
5918 g_simple_action_set_enabled (G_SIMPLE_ACTION(action), sensitive);
5919 }
5920}
GAction * gnc_main_window_find_action(GncMainWindow *window, const gchar *action_name)
Find the GAction in the main window.

◆ gnc_main_window_all_finish_pending()

gboolean gnc_main_window_all_finish_pending ( void )

Tell all pages in all windows to finish any outstanding activities.

This function will call gnc_plugin_page_finish_pending for each installed page. If any page returns a failure indication, then the function stops walking pages and immediately returns a failure.

Returns
FALSE if any page could not or would not comply, which should cancel the pending operation. TRUE otherwise

Definition at line 1114 of file gnc-main-window.cpp.

1115{
1116 const GList *windows, *item;
1117
1118 windows = gnc_gobject_tracking_get_list(GNC_MAIN_WINDOW_NAME);
1119 for (item = windows; item; item = g_list_next(item))
1120 {
1121 if (!gnc_main_window_finish_pending(static_cast<GncMainWindow*>(item->data)))
1122 {
1123 return FALSE;
1124 }
1125 }
1126 if (gnc_gui_refresh_suspended ())
1127 {
1128 gnc_warning_dialog (nullptr, "%s", "An operation is still running, wait for it to complete before quitting.");
1129 return FALSE;
1130 }
1131 return TRUE;
1132}
gboolean gnc_main_window_finish_pending(GncMainWindow *window)
Tell a window to finish any outstanding activities.
const GList * gnc_gobject_tracking_get_list(const gchar *name)
Get a list of all known objects of a specified type.

◆ gnc_main_window_button_press_cb()

gboolean gnc_main_window_button_press_cb ( GtkWidget * whatever,
GdkEventButton * event,
GncPluginPage * page )

Callback function invoked when the user clicks in the content of any Gnucash window.

If this was a "right-click" then Gnucash will popup the contextual menu.

Parameters
whateverWhatever widget had focus when the user issued the keyboard context-menu request.
eventThe event parameter describing where on the screen the mouse was pointing when clicked, type of click, modifiers, etc.
pageThis is the GncPluginPage corresponding to the visible page.
Returns
Returns TRUE if this was a right-click, meaning Gnucash handled the click.

Definition at line 5892 of file gnc-main-window.cpp.

5895{
5896 g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), FALSE);
5897
5898 ENTER("widget %p, event %p, page %p", whatever, event, page);
5899 /* Ignore double-clicks and triple-clicks */
5900 if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
5901 {
5902 do_popup_menu(page, event);
5903 LEAVE("menu shown");
5904 return TRUE;
5905 }
5906
5907 LEAVE("other click");
5908 return FALSE;
5909}
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition qoflog.h:282
#define ENTER(format, args...)
Print a function entry debugging message.
Definition qoflog.h:272

◆ gnc_main_window_close_page()

void gnc_main_window_close_page ( GncPluginPage * page)

Remove a data plugin page from a window and display the previous page.

If the page removed was the last page in the window, and there is more than one window open, then the entire window will be destroyed.

Parameters
pageThe page of data to be removed.

Definition at line 3432 of file gnc-main-window.cpp.

3433{
3434 GncMainWindow *window;
3436
3437 if (!page || !page->notebook_page)
3438 return;
3439
3441 return;
3442
3443 if (!GNC_IS_MAIN_WINDOW (page->window))
3444 return;
3445
3446 window = GNC_MAIN_WINDOW (page->window);
3447 if (!window)
3448 {
3449 g_warning("Page is not in a window.");
3450 return;
3451 }
3452
3453 gnc_main_window_disconnect(window, page);
3455 g_object_unref(page);
3456
3457 /* If this isn't the last window, go ahead and destroy the window. */
3458 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3459 if (priv->installed_pages == nullptr)
3460 {
3461 if (window->window_quitting)
3462 {
3463 GncPluginManager *manager = gnc_plugin_manager_get ();
3464 GList *plugins = gnc_plugin_manager_get_plugins (manager);
3465
3466 /* remove only the preference callbacks from the window plugins */
3467 window->just_plugin_prefs = TRUE;
3468 g_list_foreach (plugins, gnc_main_window_remove_plugin, window);
3469 window->just_plugin_prefs = FALSE;
3470 g_list_free (plugins);
3471
3472 /* remove the preference callbacks from the main window */
3473 gnc_main_window_remove_prefs (window);
3474 }
3475 if (window && (gnc_list_length_cmp (active_windows, 1) > 0))
3476 gtk_widget_destroy (GTK_WIDGET(window));
3477 }
3478}
void gnc_plugin_page_destroy_widget(GncPluginPage *plugin_page)
Destroy the display widget that corresponds to this plugin.
gboolean gnc_plugin_page_finish_pending(GncPluginPage *page)
Tell a page to finish any outstanding activities.
gint gnc_list_length_cmp(const GList *list, size_t len)
Scans the GList elements the minimum number of iterations required to test it against a specified siz...
GList * gnc_plugin_manager_get_plugins(GncPluginManager *manager)
Get a list of all plugins being held by the plugin manager.
GncPluginManager * gnc_plugin_manager_get(void)
Retrieve a pointer to the plugin manager.
The instance private data structure for an embedded window object.
GList * installed_pages
A list of all pages that are installed in this window.
GtkWidget * window
The window that contains the display widget for this plugin.
GtkWidget * notebook_page
The display widget for this plugin.

◆ gnc_main_window_display_page()

void gnc_main_window_display_page ( GncPluginPage * page)

Bring the window containing the specified page to the top of the window stack, then switch the notebook to show the specified page.

Parameters
pageThe existing page to be displayed.

Definition at line 3230 of file gnc-main-window.cpp.

3231{
3232 GncMainWindow *window;
3234 GtkNotebook *notebook;
3235 gint page_num;
3236
3237 window = GNC_MAIN_WINDOW (page->window);
3238 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3239 notebook = GTK_NOTEBOOK (priv->notebook);
3240 page_num = gtk_notebook_page_num(notebook, page->notebook_page);
3241 gtk_notebook_set_current_page (notebook, page_num);
3242 gtk_window_present(GTK_WINDOW(window));
3243}
GtkWidget * notebook
The notebook containing all the pages in this window.

◆ gnc_main_window_find_action()

GAction * gnc_main_window_find_action ( GncMainWindow * window,
const gchar * action_name )

Find the GAction in the main window.

Parameters
windowThe window which should be checked for the action.
action_nameThe name of the command to be retrieved.
Returns
A pointer to a GAction that was added with the specified name. If the name cannot be found, then NULL will be returned.

Definition at line 3623 of file gnc-main-window.cpp.

3624{
3625 GAction *action = nullptr;
3626
3627 g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr);
3628 g_return_val_if_fail (action_name != nullptr, nullptr);
3629
3630 action = g_action_map_lookup_action (G_ACTION_MAP(window),
3631 action_name);
3632
3633 return action;
3634}

◆ gnc_main_window_find_action_in_group()

GAction * gnc_main_window_find_action_in_group ( GncMainWindow * window,
const gchar * group_name,
const gchar * action_name )

Find the GAction in a specific action group for window.

Parameters
windowThe window which should be checked for the action.
group_nameThe name of the action group to search.
nameThe name of the command to be retrieved.
Returns
A pointer to the GAction if found or NULL will be returned.

Definition at line 3637 of file gnc-main-window.cpp.

3640{
3641 GAction *action = nullptr;
3642
3643 g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr);
3644 g_return_val_if_fail (group_name != nullptr, nullptr);
3645 g_return_val_if_fail (action_name != nullptr, nullptr);
3646
3647 auto action_group = gtk_widget_get_action_group (GTK_WIDGET(window), group_name);
3648
3649 if (action_group)
3650 action = g_action_map_lookup_action (G_ACTION_MAP(action_group), action_name);
3651
3652 return action;
3653}

◆ gnc_main_window_finish_pending()

gboolean gnc_main_window_finish_pending ( GncMainWindow * window)

Tell a window to finish any outstanding activities.

This function will call gnc_plugin_page_finish_pending for each installed page. If any page returns a failure indication, then the function stops walking pages and immediately returns a failure.

Parameters
windowThe window whose pages should be checked.
Returns
FALSE if any page could not or would not comply, which should cancel the pending operation. TRUE otherwise

Definition at line 1094 of file gnc-main-window.cpp.

1095{
1097 GList *item;
1098
1099 g_return_val_if_fail(GNC_IS_MAIN_WINDOW(window), TRUE);
1100
1101 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
1102 for (item = priv->installed_pages; item; item = g_list_next(item))
1103 {
1104 if (!gnc_plugin_page_finish_pending(static_cast<GncPluginPage*>(item->data)))
1105 {
1106 return FALSE;
1107 }
1108 }
1109 return TRUE;
1110}
The instance data structure for a content plugin.

◆ gnc_main_window_foreach_page()

void gnc_main_window_foreach_page ( GncMainWindowPageFunc fn,
gpointer user_data )

Iterator function to walk all pages in all windows, calling the specified function for each page.

Parameters
entryA pointer to the function to be called.
user_dataA data pointer passed to each call of the function.

Definition at line 417 of file gnc-main-window.cpp.

418{
419 ENTER(" ");
420 for (auto w = active_windows; w; w = g_list_next(w))
421 {
422 auto window{static_cast<GncMainWindow*>(w->data)};
423 auto priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
424 for (auto p = priv->installed_pages; p; p = g_list_next(p))
425 {
426 auto page{static_cast<GncPluginPage*>(p->data)};
427 fn(page, user_data);
428 }
429 }
430 LEAVE(" ");
431}

◆ gnc_main_window_get_action_group()

GSimpleActionGroup * gnc_main_window_get_action_group ( GncMainWindow * window,
const gchar * group_name )

Retrieve a specific set of user interface actions from a window.

This function can be used to get an group of action to be manipulated when the front page of a window has changed.

Parameters
windowThe window to check when looking for the action group.
group_nameThe name of a set of actions. This must be a name provided when the actions were installed.
Returns
A pointer to a GSimpleActionGroup that was added with the specified name. If the name cannot be found, then NULL will be returned.

Definition at line 3661 of file gnc-main-window.cpp.

3663{
3664 g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr);
3665 g_return_val_if_fail (group_name != nullptr, nullptr);
3666
3667 auto action_group = gtk_widget_get_action_group (GTK_WIDGET(window), group_name);
3668 return (GSimpleActionGroup*)action_group;
3669}

◆ gnc_main_window_get_current_page()

GncPluginPage * gnc_main_window_get_current_page ( GncMainWindow * window)

Retrieve a pointer to the page that is currently at the front of the specified window.

Any plugin that needs to manipulate its menus based upon the currently selected menu page should connect to the "page_changed" signal on a window. The callback function from that signal can then call this function to obtain a pointer to the current page.

Parameters
windowA pointer to the window whose front page should be returned.
Returns
A pointer to the GncPluginPage currently at the front of the specified window. If the window pointer is invalid or the window is empty, this function will return NULL.

Definition at line 3489 of file gnc-main-window.cpp.

3490{
3492
3493 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3494 return priv->current_page;
3495}
GncPluginPage * current_page
The currently selected page.

◆ gnc_main_window_get_menu_model()

GMenuModel * gnc_main_window_get_menu_model ( GncMainWindow * window)

Return the GMenuModel for the main window menu bar.

Parameters
windowThe window for the menu bar.
Returns
The GMenuModel or NULL.

Definition at line 5923 of file gnc-main-window.cpp.

5924{
5926
5927 g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr);
5928
5929 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
5930
5931 return priv->menubar_model;
5932}
GMenuModel * menubar_model
The menubar_model.

◆ gnc_main_window_get_type()

GType gnc_main_window_get_type ( void )

Get the type of a gnc main window.

Returns
A GType.

◆ gnc_main_window_init_short_names()

void gnc_main_window_init_short_names ( GncMainWindow * window,
GncToolBarShortNames * toolbar_labels )

Update the labels of the toolbar items with short names.

Parameters
windowThe window that conatins a tool bar to update.
toolbar_labelsA pointer to a NULL terminated array of data GncToolBarShortNames items.

Definition at line 3786 of file gnc-main-window.cpp.

3788{
3790
3791 g_return_if_fail (GNC_IS_MAIN_WINDOW(window));
3792 g_return_if_fail (toolbar_labels != nullptr);
3793
3794 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3795
3796 gnc_plugin_init_short_names (priv->toolbar, toolbar_labels);
3797}
void gnc_plugin_init_short_names(GtkWidget *toolbar, GncToolBarShortNames *toolbar_labels)
Add "short" labels to existing actions.
Definition gnc-plugin.c:229
GtkWidget * toolbar
The toolbar.

◆ gnc_main_window_is_quitting()

gboolean gnc_main_window_is_quitting ( GncMainWindow * window)

Check if the main window is quitting.

Parameters
windowThe main window.
Returns
TRUE if window is quitting

Definition at line 1403 of file gnc-main-window.cpp.

1404{
1405 g_return_val_if_fail(GNC_IS_MAIN_WINDOW(window), FALSE);
1406 return window->window_quitting;
1407}

◆ gnc_main_window_is_restoring_pages()

gboolean gnc_main_window_is_restoring_pages ( GncMainWindow * window)

Check if the main window is restoring the plugin pages.

This is used on report pages to delay the creation of the report till the page is focused.

Parameters
windowThe window whose pages should be checked.
Returns
TRUE if pages are being restored

Definition at line 407 of file gnc-main-window.cpp.

408{
409 GncMainWindowPrivate *priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
410 return priv->restoring_pages;
411}
gboolean restoring_pages
Set when restoring plugin pages.

◆ gnc_main_window_just_plugin_prefs()

gboolean gnc_main_window_just_plugin_prefs ( GncMainWindow * window)

Definition at line 5935 of file gnc-main-window.cpp.

5936{
5937 return window->just_plugin_prefs;
5938}

◆ gnc_main_window_manual_merge_actions()

void gnc_main_window_manual_merge_actions ( GncMainWindow * window,
const gchar * group_name,
GSimpleActionGroup * group )

Manually add a set of actions to the specified window.

Plugins whose user interface is not hard coded (e.g. the menu-additions * plugin) must create their actions at run time, then use this * function to install them into the window.

Parameters
windowA pointer to the window whose user interface should be updated.
group_nameThe name for this set of actions. This name should be unique among all groups added to the window, and will be needed to remove the actions from this window.
groupA pointer to the GSimpleActionGroup.

Definition at line 3504 of file gnc-main-window.cpp.

3507{
3508 g_return_if_fail (GNC_IS_MAIN_WINDOW(window));
3509 g_return_if_fail (group_name != nullptr);
3510 g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(group));
3511
3512 gtk_widget_insert_action_group (GTK_WIDGET(window), group_name,
3513 G_ACTION_GROUP(group));
3514}

◆ gnc_main_window_menu_add_accelerator_keys()

void gnc_main_window_menu_add_accelerator_keys ( GncMainWindow * window)

Scan the main window menu and add accelerator keys to main window accelerator group.

Parameters
windowA pointer to the window whose user interface should be updated.

Definition at line 3708 of file gnc-main-window.cpp.

3709{
3711
3712 g_return_if_fail (GNC_IS_MAIN_WINDOW(window));
3713
3714 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3715
3717}
void gnc_add_accelerator_keys_for_menu(GtkWidget *menu, GMenuModel *model, GtkAccelGroup *accel_group)
Add accelerator keys for menu item widgets.
GtkAccelGroup * accel_group
The accelerator group for the window.
GtkWidget * menubar
The menubar.

◆ gnc_main_window_menu_find_menu_item()

GtkWidget * gnc_main_window_menu_find_menu_item ( GncMainWindow * window,
const gchar * action_name )

Find the menu item with the given action name for the window specified.

Parameters
windowA pointer to the window whose user interface should be updated.
action_nameThe action name of the tool item to find.
Returns
The found menu item widget or NULL.

Definition at line 3685 of file gnc-main-window.cpp.

3686{
3688 GtkWidget *menu_item;
3689
3690 g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr);
3691 g_return_val_if_fail (action_name != nullptr, nullptr);
3692
3693 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3694
3695 menu_item = GTK_WIDGET(g_hash_table_lookup (priv->display_item_hash, action_name));
3696
3697 if (!menu_item)
3698 {
3699 menu_item = gnc_menubar_model_find_menu_item (priv->menubar_model, priv->menubar, action_name);
3700
3701 g_hash_table_insert (priv->display_item_hash, g_strdup (action_name), menu_item);
3702 }
3703 return menu_item;
3704}
GtkWidget * gnc_menubar_model_find_menu_item(GMenuModel *menu_model, GtkWidget *menu, const gchar *action_name)
Find a GtkMenu item from the action name.

◆ gnc_main_window_merge_actions()

void gnc_main_window_merge_actions ( GncMainWindow * window,
const gchar * group_name,
GActionEntry * entries,
guint n_entries,
const gchar ** ui_updates,
const gchar * ui_filename,
gpointer user_data )

Add a set of actions to the specified window.

This function should not need to be called directly by plugin implementors. Correctly assigning values to the GncPluginClass fields during plugin initialization will cause this routine to be automatically called.

Parameters
windowA pointer to the window whose user interface should be updated.
group_nameThe name for this set of actions. This name should be unique among all groups added to the window, and will be needed to remove the actions from this window.
entriesA pointer to an array of GActionEntry. These are the actions that will be added to the user interface.
n_entriesThe number of actions in the array.
filenameThe filename containing the user interface definition that goes with this set of actions.
user_dataThe data to be provided to all callback functions.

Definition at line 3572 of file gnc-main-window.cpp.

3579{
3581 GSimpleActionGroup *simple_action_group;
3582
3583 g_return_if_fail (GNC_IS_MAIN_WINDOW(window));
3584 g_return_if_fail (group_name != nullptr);
3585 g_return_if_fail (actions != nullptr);
3586 g_return_if_fail (n_actions > 0);
3587
3588 data = g_new0 (GncMainWindowActionData, 1);
3589 data->window = window;
3590 data->data = user_data;
3591
3592 simple_action_group = g_simple_action_group_new ();
3593
3594 g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group),
3595 actions,
3596 n_actions,
3597 data);
3598
3599 gtk_widget_insert_action_group (GTK_WIDGET(window), group_name,
3600 G_ACTION_GROUP(simple_action_group));
3601
3602 if (ui_filename)
3603 update_menu_model (window, ui_filename, ui_updates);
3604}

◆ gnc_main_window_new()

GncMainWindow * gnc_main_window_new ( void )

Create a new gnc main window plugin.

Returns
A pointer to the new object.

Definition at line 3028 of file gnc-main-window.cpp.

3029{
3030 auto window{static_cast<GncMainWindow*>(g_object_new (GNC_TYPE_MAIN_WINDOW, nullptr))};
3031 gtk_window_set_default_size(GTK_WINDOW(window), 800, 600);
3032
3033 auto old_window = gnc_ui_get_main_window (nullptr);
3034 if (old_window)
3035 {
3036 gint width, height;
3037 gtk_window_get_size (old_window, &width, &height);
3038 gtk_window_resize (GTK_WINDOW (window), width, height);
3039 if ((gdk_window_get_state((gtk_widget_get_window (GTK_WIDGET(old_window))))
3040 & GDK_WINDOW_STATE_MAXIMIZED) != 0)
3041 {
3042 gtk_window_maximize (GTK_WINDOW (window));
3043 }
3044 }
3045 active_windows = g_list_append (active_windows, window);
3046 gnc_main_window_update_title(window);
3047 window->window_quitting = FALSE;
3048 window->just_plugin_prefs = FALSE;
3049#ifdef MAC_INTEGRATION
3050 gnc_quartz_set_menu(window);
3051#else
3052 gnc_main_window_update_all_menu_items();
3053#endif
3054 gnc_engine_add_commit_error_callback( gnc_main_window_engine_commit_error_callback, window );
3055
3056 // set up a callback for notebook navigation
3057 g_signal_connect (G_OBJECT(window), "key-press-event",
3058 G_CALLBACK(gnc_main_window_key_press_event),
3059 NULL);
3060
3061 return window;
3062}
void gnc_engine_add_commit_error_callback(EngineCommitErrorCallback cb, gpointer data)
Set a callback function to be called in case an engine commit fails.

◆ gnc_main_window_open_page()

void gnc_main_window_open_page ( GncMainWindow * window,
GncPluginPage * page )

Display a data plugin page in a window.

If the page already exists in any window, then that window will be brought to the front and the notebook switch to display the specified page. If the page is new then it will be added to the specified window (unless the page itself requests otherwise.). If the window is NULL, the new page will be added to the first window.

Parameters
windowThe window to display a new page in.
pageThe new page of data to be displayed, or the existing page of data the should be brought to the top and displayed.

Definition at line 3254 of file gnc-main-window.cpp.

3256{
3258 GtkWidget *tab_container, *tab_clickable_area;
3259 GtkWidget *label, *entry;
3260 const gchar *icon, *text, *color_string, *lab_text;
3261 GtkWidget *image;
3262 GList *tmp;
3263 TabWidth *tw;
3264
3265 ENTER("window %p, page %p", window, page);
3266 if (window)
3267 g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
3268 g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
3269 g_return_if_fail (gnc_plugin_page_has_books(page));
3270
3271 if (gnc_main_window_page_exists(page))
3272 {
3274 return;
3275 }
3276
3277 /* Does the page want to be in a new window? */
3279 {
3280 /* See if there's a blank window. If so, use that. */
3281 for (tmp = active_windows; tmp; tmp = g_list_next(tmp))
3282 {
3283 window = GNC_MAIN_WINDOW(tmp->data);
3284 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3285 if (priv->installed_pages == nullptr)
3286 {
3287 break;
3288 }
3289 }
3290 if (tmp == nullptr)
3291 window = gnc_main_window_new ();
3292 gtk_widget_show(GTK_WIDGET(window));
3293 }
3294 else if ((window == nullptr) && active_windows)
3295 {
3296 window = static_cast<GncMainWindow*>(active_windows->data);
3297 }
3298
3299 page->window = GTK_WIDGET(window);
3301 g_object_set_data (G_OBJECT (page->notebook_page),
3302 PLUGIN_PAGE_LABEL, page);
3303
3304 /*
3305 * The page tab.
3306 * Component structure:
3307 *
3308 * tab_container (GtkBox)
3309 * ├── tab_clickable_area (GtkEventBox)
3310 * │ └── tab_content (GtkBox)
3311 * │ ├── image (GtkImage, optional)
3312 * │ ├── label (GtkLabel)
3313 * │ └── entry (GtkEntry, hidden)
3314 * └── close_button (GtkButton, if not immutable)
3315 */
3316 icon = GNC_PLUGIN_PAGE_GET_CLASS(page)->tab_icon;
3317 lab_text = gnc_plugin_page_get_page_name(page);
3318 label = gtk_label_new (lab_text);
3319 g_object_set_data (G_OBJECT (page), PLUGIN_PAGE_TAB_LABEL, label);
3320
3321 tw = populate_tab_width_struct ();
3322 gnc_main_window_update_tab_width_one_page (page, tw);
3323 g_free (tw);
3324
3325 gtk_widget_show (label);
3326
3327 tab_container = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
3328
3330 if (text)
3331 {
3332 gtk_widget_set_tooltip_text(tab_container, text);
3333 }
3334
3335 if (g_strcmp0 (gnc_plugin_page_get_plugin_name (page), "GncPluginPageAccountTree") == 0)
3336 gtk_widget_set_name (GTK_WIDGET(tab_container), "gnc-id-account-page-tab-box");
3337
3338 gtk_box_set_homogeneous (GTK_BOX (tab_container), FALSE);
3339 gtk_widget_show (tab_container);
3340
3341 // Create a custom clickable area for the tab to support middle-clicking
3342 tab_clickable_area = gtk_event_box_new();
3343 gtk_widget_show(tab_clickable_area);
3344 gtk_box_pack_start (GTK_BOX (tab_container), tab_clickable_area, TRUE, TRUE, 0);
3345
3346 // Create a box for the tab's content
3347 // Give it a name so we can find it later (see main_window_find_tab_items)
3348 GtkWidget *tab_content = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
3349 gtk_widget_set_name(tab_content, "tab-content");
3350 gtk_container_add(GTK_CONTAINER(tab_clickable_area), tab_content);
3351 gtk_widget_show(tab_content);
3352
3353 if (icon != nullptr)
3354 {
3355 image = gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_MENU);
3356 gtk_widget_show (image);
3357 gtk_box_pack_start (GTK_BOX (tab_content), image, FALSE, FALSE, 0);
3358 gtk_widget_set_margin_start (GTK_WIDGET(image), 5);
3359 gtk_box_pack_start (GTK_BOX (tab_content), label, TRUE, TRUE, 0);
3360 }
3361 else
3362 gtk_box_pack_start (GTK_BOX (tab_content), label, TRUE, TRUE, 0);
3363
3364 entry = gtk_entry_new();
3365 gtk_widget_hide (entry);
3366 gtk_box_pack_start (GTK_BOX (tab_content), entry, TRUE, TRUE, 0);
3367 g_signal_connect(G_OBJECT(entry), "activate",
3368 G_CALLBACK(gnc_main_window_tab_entry_activate), page);
3369 g_signal_connect(G_OBJECT(entry), "focus-out-event",
3370 G_CALLBACK(gnc_main_window_tab_entry_focus_out_event),
3371 page);
3372 g_signal_connect(G_OBJECT(entry), "key-press-event",
3373 G_CALLBACK(gnc_main_window_tab_entry_key_press_event),
3374 page);
3375 g_signal_connect(G_OBJECT(entry), "editing-done",
3376 G_CALLBACK(gnc_main_window_tab_entry_editing_done),
3377 page);
3378
3379 /* Add close button - Not for immutable pages */
3380 if (!g_object_get_data (G_OBJECT (page), PLUGIN_PAGE_IMMUTABLE))
3381 {
3382 GtkWidget *close_image, *close_button;
3383 GtkRequisition requisition;
3384
3385 close_button = gtk_button_new();
3386 gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE);
3387 close_image = gtk_image_new_from_icon_name ("window-close", GTK_ICON_SIZE_MENU);
3388 gtk_widget_show(close_image);
3389 gtk_widget_get_preferred_size (close_image, &requisition, nullptr);
3390 gtk_widget_set_size_request(close_button, requisition.width + 4,
3391 requisition.height + 2);
3392 gtk_container_add(GTK_CONTAINER(close_button), close_image);
3393 if (gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_SHOW_CLOSE_BUTTON))
3394 gtk_widget_show (close_button);
3395 else
3396 gtk_widget_hide (close_button);
3397
3398 // Custom handler to close on middle-clicks
3399 g_signal_connect(G_OBJECT(tab_clickable_area), "button-press-event",
3400 G_CALLBACK(gnc_tab_clicked_cb), page);
3401
3402 g_signal_connect_swapped (G_OBJECT (close_button), "clicked",
3403 G_CALLBACK(gnc_main_window_close_page), page);
3404
3405 gtk_box_pack_start (GTK_BOX (tab_container), close_button, FALSE, FALSE, 0);
3406 gtk_widget_set_margin_end (GTK_WIDGET(close_button), 5);
3407 g_object_set_data (G_OBJECT (page), PLUGIN_PAGE_CLOSE_BUTTON, close_button);
3408 }
3409
3410 /*
3411 * The popup menu
3412 */
3413 label = gtk_label_new (gnc_plugin_page_get_page_name(page));
3414
3415 /*
3416 * Now install it all in the window.
3417 */
3418 gnc_main_window_connect(window, page, tab_container, label);
3419
3420 color_string = gnc_plugin_page_get_page_color(page);
3421 main_window_update_page_color (page, color_string);
3422 LEAVE("");
3423}
const gchar * gnc_plugin_page_get_plugin_name(GncPluginPage *plugin_page)
Retrieve the textual name of a plugin.
gboolean gnc_plugin_page_has_books(GncPluginPage *page)
Query a page to see if it has a reference to any book.
GtkWidget * gnc_plugin_page_create_widget(GncPluginPage *plugin_page)
Create the display widget that corresponds to this plugin.
const gchar * gnc_plugin_page_get_page_long_name(GncPluginPage *page)
Retrieve the long name of this page.
const gchar * gnc_plugin_page_get_page_name(GncPluginPage *page)
Retrieve the name of this page.
gboolean gnc_plugin_page_get_use_new_window(GncPluginPage *page)
Retrieve the "use new window" setting associated with this page.
const gchar * gnc_plugin_page_get_page_color(GncPluginPage *page)
Retrieve the color of this page.
void gnc_main_window_display_page(GncPluginPage *page)
Bring the window containing the specified page to the top of the window stack, then switch the notebo...
void main_window_update_page_color(GncPluginPage *page, const gchar *color_in)
Update the color on the page tabs in the main window.
GncMainWindow * gnc_main_window_new(void)
Create a new gnc main window plugin.
void gnc_main_window_close_page(GncPluginPage *page)
Remove a data plugin page from a window and display the previous page.
#define PLUGIN_PAGE_LABEL
This label is used to provide a mapping from a visible page widget back to the corresponding GncPlugi...
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.
This data structure allows the passing of the tab width and whether the tab layout is on the left or ...

◆ gnc_main_window_popup_menu_cb()

gboolean gnc_main_window_popup_menu_cb ( GtkWidget * widget,
GncPluginPage * page )

Callback function invoked when the user requests that Gnucash popup the contextual menu via the keyboard context-menu request key combination (Shift-F10 by default).

Parameters
pageThis is the GncPluginPage corresponding to the visible page.
widgetWhatever widget had focus when the user issued the keyboard context-menu request.
Returns
Always returns TRUE to indicate that the menu request was handled.

Definition at line 5877 of file gnc-main-window.cpp.

5879{
5880 ENTER("widget %p, page %p", widget, page);
5881 do_popup_menu(page, nullptr);
5882 LEAVE(" ");
5883 return TRUE;
5884}

◆ gnc_main_window_restore_all_windows()

void gnc_main_window_restore_all_windows ( const GKeyFile * keyfile)

Restore the persistent state of all windows.

Parameters
keyfileThe GKeyFile containing persistent window state.

Definition at line 877 of file gnc-main-window.cpp.

878{
879 gint i, window_count;
880 GError *error = nullptr;
882
883 /* We use the same struct for reading and for writing, so we cast
884 away the const. */
885 data.key_file = (GKeyFile *) keyfile;
886 window_count = g_key_file_get_integer(data.key_file, STATE_FILE_TOP,
887 WINDOW_COUNT, &error);
888 if (error)
889 {
890 g_warning("error reading group %s key %s: %s",
891 STATE_FILE_TOP, WINDOW_COUNT, error->message);
892 g_error_free(error);
893 LEAVE("can't read count");
894 return;
895 }
896
897 /* Restore all state information on the open windows. Window
898 numbers in state file are 1-based. GList indices are 0-based. */
899 gnc_set_busy_cursor (nullptr, TRUE);
900 for (i = 0; i < window_count; i++)
901 {
902 data.window_num = i;
903 auto window{static_cast<GncMainWindow*>(g_list_nth_data(active_windows,
904 i))};
905 gnc_main_window_restore_window(window, &data);
906 }
907 gnc_unset_busy_cursor (nullptr);
908
909 statusbar_notification_lastmodified();
910}

◆ gnc_main_window_restore_default_state()

void gnc_main_window_restore_default_state ( GncMainWindow * window)

Restore the persistent state of one window to a sane default.

Definition at line 913 of file gnc-main-window.cpp.

914{
915 GAction *action;
916
917 /* The default state should be to have an Account Tree page open
918 * in the window. */
919 DEBUG("no saved state file");
920 if (!window)
921 window = static_cast<GncMainWindow*>(g_list_nth_data(active_windows, 0));
922 gtk_widget_show (GTK_WIDGET(window));
924 "gnc-plugin-account-tree-actions",
925 "ViewAccountTreeAction");
926 g_action_activate (action, nullptr);
927}
GAction * gnc_main_window_find_action_in_group(GncMainWindow *window, const gchar *group_name, const gchar *action_name)
Find the GAction in a specific action group for window.
#define DEBUG(format, args...)
Print a debugging message.
Definition qoflog.h:264

◆ gnc_main_window_save_all_windows()

void gnc_main_window_save_all_windows ( GKeyFile * keyfile)

Save the persistent state of all windows.

Parameters
keyfileThe GKeyFile to contain persistent window state.

Definition at line 1076 of file gnc-main-window.cpp.

1077{
1079
1080 /* Set up the iterator data structures */
1081 data.key_file = keyfile;
1082 data.window_num = 1;
1083 data.page_num = 1;
1084
1085 g_key_file_set_integer(data.key_file,
1086 STATE_FILE_TOP, WINDOW_COUNT,
1087 g_list_length(active_windows));
1088 /* Dump all state information on the open windows */
1089 g_list_foreach(active_windows, (GFunc)gnc_main_window_save_window, &data);
1090}

◆ gnc_main_window_set_progressbar_window()

void gnc_main_window_set_progressbar_window ( GncMainWindow * window)

Set the window where all progressbar updates should occur.

This is a wrapper around the gnc_window_set_progressbar_window() function.

Parameters
windowThe window to use for all progressbar updates.

Definition at line 5781 of file gnc-main-window.cpp.

5782{
5783 GncWindow *gncwin;
5784 gncwin = GNC_WINDOW(window);
5785 gnc_window_set_progressbar_window(gncwin);
5786}

◆ gnc_main_window_set_vis_of_items_by_action()

void gnc_main_window_set_vis_of_items_by_action ( GncMainWindow * window,
const gchar ** action_names,
gboolean vis )

Show or hide menu and toolbar items based on a NULL terminated list of action names.

Parameters
windowA pointer to the window whose user interface should be updated.
action_namesA NULL terminated list of actions names that should be modified.
visWhether to show or hide the widget items

Definition at line 3747 of file gnc-main-window.cpp.

3750{
3752
3753 g_return_if_fail (GNC_IS_MAIN_WINDOW(window));
3754
3755 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3756
3757 for (gint i = 0; action_names[i]; i++)
3758 {
3759 GtkWidget *tool_item = gnc_find_toolbar_item (priv->toolbar, action_names[i]);
3760 GtkWidget *menu_item = gnc_main_window_menu_find_menu_item (window, action_names[i]);
3761
3762 if (menu_item)
3763 {
3764 PINFO("Found menu_item %p with action name '%s', seting vis to '%s'",
3765 menu_item, action_names[i], vis ? "true" : "false");
3766 gtk_widget_set_visible (menu_item, vis);
3767 }
3768 else
3769 PINFO("Did not find menu_item with action name '%s' to set vis '%s'",
3770 action_names[i], vis ? "true" : "false");
3771
3772 if (tool_item)
3773 {
3774 PINFO("Found tool_item %p with action name '%s', seting vis to '%s'",
3775 tool_item, action_names[i], vis ? "true" : "false");
3776 gtk_widget_set_visible (tool_item, vis);
3777 }
3778 else
3779 PINFO("Did not find tool_item with action name '%s' to set vis '%s'",
3780 action_names[i], vis ? "true" : "false");
3781 }
3782}
GtkWidget * gnc_main_window_menu_find_menu_item(GncMainWindow *window, const gchar *action_name)
Find the menu item with the given action name for the window specified.
GtkWidget * gnc_find_toolbar_item(GtkWidget *toolbar, const gchar *action_name)
Search the toolbar for the tool item based on the action name.
#define PINFO(format, args...)
Print an informational note.
Definition qoflog.h:256

◆ gnc_main_window_show_all_windows()

void gnc_main_window_show_all_windows ( void )

Shows all main windows.

Definition at line 5583 of file gnc-main-window.cpp.

5584{
5585 GList *window_iter;
5586#ifdef MAC_INTEGRATION
5587 auto theApp{static_cast<GtkosxApplication *>(g_object_new(GTKOSX_TYPE_APPLICATION, nullptr))};
5588#endif
5589 for (window_iter = active_windows; window_iter != nullptr; window_iter = window_iter->next)
5590 {
5591 gtk_widget_show(GTK_WIDGET(window_iter->data));
5592 }
5593#ifdef MAC_INTEGRATION
5594 g_signal_connect(theApp, "NSApplicationWillTerminate",
5595 G_CALLBACK(gnc_quartz_shutdown), nullptr);
5596 gtkosx_application_ready(theApp);
5597 g_object_unref (theApp);
5598#endif
5599}

◆ gnc_main_window_toolbar_find_tool_item()

GtkWidget * gnc_main_window_toolbar_find_tool_item ( GncMainWindow * window,
const gchar * action_name )

Find the toolbar item with the given action name for the window specified.

Parameters
windowA pointer to the window whose user interface should be updated.
action_nameThe action name of the tool item to find.
Returns
The found tool item widget or NULL.

Definition at line 3672 of file gnc-main-window.cpp.

3673{
3675
3676 g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr);
3677 g_return_val_if_fail (action_name != nullptr, nullptr);
3678
3679 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3680
3681 return gnc_find_toolbar_item (priv->toolbar, action_name);
3682}

◆ gnc_main_window_unmerge_actions()

void gnc_main_window_unmerge_actions ( GncMainWindow * window,
const gchar * group_name )

Remove a set of actions from the specified window.

This function should not need to be called directly by plugin implementors. It will automatically be called when a plugin is removed from a window.

Parameters
windowA pointer to the window whose user interface should be updated.
group_nameThe name for this set of actions. This must be the same name provided when the actions were installed.

Definition at line 3613 of file gnc-main-window.cpp.

3615{
3616 g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
3617 g_return_if_fail (group_name != nullptr);
3618
3619 gtk_widget_insert_action_group (GTK_WIDGET(window), group_name, nullptr);
3620}

◆ gnc_main_window_update_menu_and_toolbar()

void gnc_main_window_update_menu_and_toolbar ( GncMainWindow * window,
GncPluginPage * page,
const gchar ** ui_updates )

Update the main window menu with the placeholders listed in ui_updates and load the page specific toolbar.

Parameters
windowThe window which should be checked for the action.
pageThe plugin page calling this function.
ui_updatesA NULL terminated list of placeholders to load

Definition at line 3850 of file gnc-main-window.cpp.

3853{
3855 const gchar *plugin_page_actions_group_name;
3856 GtkBuilder *builder;
3857 const gchar *menu_qualifier;
3858
3859 GMenuModel *menu_model_part;
3860#ifdef MAC_INTEGRATION
3861 auto theApp{static_cast<GtkosxApplication *>(g_object_new(GTKOSX_TYPE_APPLICATION, nullptr))};
3862#endif
3863 g_return_if_fail (GNC_IS_MAIN_WINDOW(window));
3864 g_return_if_fail (page != nullptr);
3865 g_return_if_fail (ui_updates != nullptr);
3866
3867 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3868
3869 builder = gnc_plugin_page_get_builder (page);
3870
3871 if (!builder)
3872 return;
3873
3874 menu_qualifier = gnc_plugin_page_get_menu_qualifier (page);
3875
3876 plugin_page_actions_group_name = gnc_plugin_page_get_simple_action_group_name (page);
3877
3878 if (!plugin_page_actions_group_name)
3879 return;
3880
3881 gtk_widget_insert_action_group (GTK_WIDGET(window), gnc_plugin_page_get_simple_action_group_name (page),
3882 G_ACTION_GROUP(gnc_plugin_page_get_action_group (page)));
3883
3884 if ((g_strcmp0 (priv->previous_plugin_page_name,
3885 plugin_page_actions_group_name) == 0) &&
3886 (g_strcmp0 (priv->previous_menu_qualifier,
3887 menu_qualifier) == 0))
3888 return;
3889
3890 priv->previous_plugin_page_name = plugin_page_actions_group_name;
3891 priv->previous_menu_qualifier = menu_qualifier;
3892
3893 gnc_main_window_update_toolbar (window, page, menu_qualifier);
3894
3895 // reset hash table and remove added menu items
3896 g_hash_table_remove_all (priv->display_item_hash);
3898 GNC_MENU_ATTRIBUTE_TEMPORARY);
3899
3900 GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1);
3901 for (gint i = 0; ui_updates[i]; i++)
3902 {
3903 gchar *menu_name;
3904
3905 if (menu_qualifier)
3906 menu_name = g_strconcat (ui_updates[i], "-", menu_qualifier, nullptr);
3907 else
3908 menu_name = g_strdup (ui_updates[i]);
3909
3910 menu_model_part = (GMenuModel *)gtk_builder_get_object (builder, menu_name);
3911
3912 if (!menu_model_part)
3913 menu_model_part = (GMenuModel *)gtk_builder_get_object (builder, ui_updates[i]);
3914
3915 gsm->search_action_label = nullptr;
3916 gsm->search_action_name = ui_updates[i];
3917 gsm->search_action_target = nullptr;
3918
3920 g_menu_insert_section (G_MENU(gsm->model), gsm->index,
3921 nullptr, G_MENU_MODEL(menu_model_part));
3922 else
3923 PERR("Could not find '%s' in menu model", ui_updates[i]);
3924
3925 g_free (menu_name);
3926 }
3927
3928 // add tooltip redirect call backs
3930
3931 // need to add the accelerator keys
3933#ifdef MAC_INTEGRATION
3934 gtkosx_application_sync_menubar (theApp);
3935 g_object_unref (theApp);
3936#endif
3937 // need to signal menu has been changed
3938 g_signal_emit_by_name (window, "menu_changed", page);
3939
3940 g_free (gsm);
3941}
const gchar * gnc_plugin_page_get_simple_action_group_name(GncPluginPage *page)
Retrieve the simple action group name associated with this plugin page.
const gchar * gnc_plugin_page_get_menu_qualifier(GncPluginPage *page)
Retrieve the menu qualifier for this page.
GSimpleActionGroup * gnc_plugin_page_get_action_group(GncPluginPage *page)
Retrieve the GSimpleActionGroup object associated with this page.
GtkBuilder * gnc_plugin_page_get_builder(GncPluginPage *page)
Retrieve the GtkBuilder object associated with this page.
void gnc_menubar_model_remove_items_with_attrib(GMenuModel *menu_model, const gchar *attrib)
Remove GMenuModel entries based on having an attribute value equal to attrib, it does not matter what...
gboolean gnc_menubar_model_find_item(GMenuModel *menu_model, GncMenuModelSearch *gsm)
Find a GtkMenu item from the action name.
#define PERR(format, args...)
Log a serious error.
Definition qoflog.h:244
void gnc_plugin_add_menu_tooltip_callbacks(GtkWidget *menubar, GMenuModel *menubar_model, GtkWidget *statusbar)
This function adds the tooltip callbacks to make the tooltips appear in the status bar.
Definition gnc-plugin.c:268
GtkWidget * statusbar
A pointer to the status bar at the bottom edge of the window.

◆ gnc_main_window_update_menu_for_action()

gboolean gnc_main_window_update_menu_for_action ( GncMainWindow * window,
const gchar * action_name,
const gchar * label,
const gchar * tooltip )

Find the GMenuModel item given the action name for the window specified.

Parameters
windowA pointer to the window whose user interface should be updated.
action_nameThe action name of the menu item to find.
labelThe new label for the menu item.
tooltipThe new tooltip for the menu item, optional.
Returns
TRUE if menu item found and updated or FALSE.

Definition at line 3721 of file gnc-main-window.cpp.

3725{
3727 gboolean found = false;
3728
3729 g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), false);
3730 g_return_val_if_fail (action_name != nullptr, false);
3731 g_return_val_if_fail (label != nullptr, false);
3732
3733 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3734
3735 found = gnc_menubar_model_update_item (priv->menubar_model, action_name,
3736 nullptr, _(label), nullptr, _(tooltip));
3737
3738 // add tooltip redirect call backs
3740 priv->menubar_model,
3741 priv->statusbar);
3742
3743 return found;
3744}
gboolean gnc_menubar_model_update_item(GMenuModel *menu_model, const gchar *action_name, const gchar *target, const gchar *label, const gchar *accel_name, const gchar *tooltip)
Update the GMenuModel item based on the action name by copying existing item, removing it and inserti...

◆ gnc_ui_get_gtk_window()

GtkWindow * gnc_ui_get_gtk_window ( GtkWidget * widget)

Get a pointer to the widget's immediate top level GtkWindow.

This can be a dialog window or a GncMainWindow. If the widget is not a child of a GtkWindow (yet), NULL is returned.

Parameters
widgetthe widget to find a GtkWindow for.
Returns
A pointer to a GtkWindow object or NULL if no toplevel was found.

Definition at line 5602 of file gnc-main-window.cpp.

5603{
5604 GtkWidget *toplevel;
5605
5606 if (!widget)
5607 return nullptr;
5608
5609 toplevel = gtk_widget_get_toplevel (widget);
5610 if (toplevel && GTK_IS_WINDOW (toplevel))
5611 return GTK_WINDOW (toplevel);
5612 else
5613 return nullptr;
5614}

◆ gnc_ui_get_main_window()

GtkWindow * gnc_ui_get_main_window ( GtkWidget * widget)

Get a pointer to the final GncMainWindow widget is rooted in.

If widget is a child of a GncMainWindow return that window. If it's a child of a dialog window recursively query the dialog's transient parent until the first parent that's a GncMainWindow and return that. If widget is NULL or not part of any GtkWindow, get a pointer to the first active top level window. If there is none, return the first mapped window. If there's no mapped window return NULL.

An example of why searching for a GncMainWindow makes sense: suppose a user has opened a search dialog for vendors and in that dialog has clicked "View vendor invoices". This opens another search window in which the user can click "View/Edit bill". Clicking that button should open a new tab in the GncMainWindow from which the first search dialog was opened.

Parameters
widgetthe widget to find a GncMainWindow for.
Returns
A pointer to a GtkWindow object.

Definition at line 5617 of file gnc-main-window.cpp.

5618{
5619 GList *window;
5620
5621 GtkWindow *toplevel = gnc_ui_get_gtk_window (widget);
5622 while (toplevel && !GNC_IS_MAIN_WINDOW (toplevel))
5623 toplevel = gtk_window_get_transient_for(toplevel);
5624
5625 if (toplevel)
5626 return toplevel;
5627
5628 for (window = active_windows; window; window = window->next)
5629 if (gtk_window_is_active (GTK_WINDOW (window->data)))
5630 return static_cast<GtkWindow*>(window->data);
5631
5632 for (window = active_windows; window; window = window->next)
5633 if (gtk_widget_get_mapped (GTK_WIDGET(window->data)))
5634 return static_cast<GtkWindow*>(window->data);
5635
5636 return nullptr;
5637}
GtkWindow * gnc_ui_get_gtk_window(GtkWidget *widget)
Get a pointer to the widget's immediate top level GtkWindow.

◆ main_window_update_page_color()

void main_window_update_page_color ( GncPluginPage * page,
const gchar * color_in )

Update the color on the page tabs in the main window.

Parameters
pageThe page to be updated.
color_inThe new color string for the page tab.

Definition at line 2481 of file gnc-main-window.cpp.

2483{
2484 GncMainWindow *window;
2486 GtkWidget *tab_widget;
2487 GdkRGBA tab_color;
2488 gchar *color_string = nullptr;
2489 gboolean want_color = FALSE;
2490
2491 ENTER(" ");
2492 if (color_in)
2493 color_string = g_strstrip(g_strdup(color_in));
2494
2495 if (color_string && *color_string != '\0')
2496 want_color = TRUE;
2497
2498 /* Update the plugin */
2499 window = GNC_MAIN_WINDOW(page->window);
2500 if (want_color)
2501 gnc_plugin_page_set_page_color(page, color_string);
2502 else
2503 gnc_plugin_page_set_page_color(page, nullptr);
2504
2505 /* Update the notebook tab */
2506 main_window_find_tab_widget (window, page, &tab_widget);
2507 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
2508
2509 GtkStyleContext *stylectxt = gtk_widget_get_style_context (GTK_WIDGET(tab_widget));
2510 const gchar *tab_css_class = "tab-bg-color";
2511
2512 if (want_color && gdk_rgba_parse(&tab_color, color_string) && priv->show_color_tabs)
2513 {
2514 GtkCssProvider *provider = gtk_css_provider_new();
2515 gchar *col_str = gdk_rgba_to_string (&tab_color);
2516 gchar *widget_css = g_strconcat (".", tab_css_class, " {\n background-color:", col_str, ";\n}\n", nullptr);
2517
2518 gtk_css_provider_load_from_data (provider, widget_css, -1, nullptr);
2519 gtk_style_context_add_provider (stylectxt, GTK_STYLE_PROVIDER (provider),
2520 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
2521 gtk_style_context_add_class (stylectxt, tab_css_class);
2522 g_object_unref (provider);
2523 g_free (col_str);
2524 g_free (widget_css);
2525 }
2526 else
2527 gtk_style_context_remove_class (stylectxt, tab_css_class);
2528
2529 g_free(color_string);
2530 LEAVE("done");
2531}
gboolean show_color_tabs
Show account color as background on tabs.

◆ main_window_update_page_long_name()

void main_window_update_page_long_name ( GncPluginPage * page,
const gchar * long_name_in )

Update the long name of the page in the main window.

Parameters
pageThe page to be updated.
long_name_inThe new long name for the page.

Definition at line 2376 of file gnc-main-window.cpp.

2378{
2379 GtkWidget *tab_widget;
2380
2381 ENTER(" ");
2382
2383 if ((long_name_in == nullptr) || (*long_name_in == '\0'))
2384 {
2385 LEAVE("no string");
2386 return;
2387 }
2388 gchar *long_name = g_strstrip (g_strdup (long_name_in));
2389 const gchar *old_long_name = gnc_plugin_page_get_page_long_name (page);
2390
2391 /* Optimization, if the long_name hasn't changed, don't update X. */
2392 if (*long_name == '\0' || strcmp (long_name, old_long_name) == 0)
2393 {
2394 g_free (long_name);
2395 LEAVE("empty string or name unchanged");
2396 return;
2397 }
2398
2399 gnc_plugin_page_set_page_long_name (page, long_name);
2400
2401 GncMainWindow *window = GNC_MAIN_WINDOW(page->window);
2402 if (!window)
2403 {
2404 g_free (long_name);
2405 LEAVE("no window widget available");
2406 return;
2407 }
2408
2409 /* Update the notebook tab tooltip */
2410 if (main_window_find_tab_widget (window, page, &tab_widget))
2411 gtk_widget_set_tooltip_text (tab_widget, long_name);
2412
2413 g_free (long_name);
2414 LEAVE("");
2415}

◆ main_window_update_page_name()

void main_window_update_page_name ( GncPluginPage * page,
const gchar * name_in )

Update the name of the page in the main window.

Parameters
pageThe page to be updated.
name_inThe new name for the page.

Definition at line 2418 of file gnc-main-window.cpp.

2420{
2421 GncMainWindow *window;
2423 GtkWidget *label, *entry;
2424 gchar *name;
2425 TabWidth *tw;
2426
2427 ENTER(" ");
2428
2429 if ((name_in == nullptr) || (*name_in == '\0'))
2430 {
2431 LEAVE("no string");
2432 return;
2433 }
2434 name = g_strstrip(g_strdup(name_in));
2435
2436 /* Optimization, if the name hasn't changed, don't update X. */
2437 if (*name == '\0' || 0 == strcmp(name, gnc_plugin_page_get_page_name(page)))
2438 {
2439 g_free(name);
2440 LEAVE("empty string or name unchanged");
2441 return;
2442 }
2443
2444 /* Update the plugin */
2445 gnc_plugin_page_set_page_name(page, name);
2446
2447 /* Update the notebook tab */
2448 window = GNC_MAIN_WINDOW(page->window);
2449 if (!window)
2450 {
2451 g_free(name);
2452 LEAVE("no window widget available");
2453 return;
2454 }
2455
2456 if (main_window_find_tab_items(window, page, &label, &entry))
2457 gtk_label_set_text(GTK_LABEL(label), name);
2458
2459 /* Adjust the label width for new text */
2460 tw = populate_tab_width_struct ();
2461 gnc_main_window_update_tab_width_one_page (page, tw);
2462 g_free (tw);
2463
2464 /* Update the notebook menu */
2465 if (page->notebook_page)
2466 {
2467 priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
2468 label = gtk_notebook_get_menu_label (GTK_NOTEBOOK(priv->notebook),
2469 page->notebook_page);
2470 gtk_label_set_text(GTK_LABEL(label), name);
2471 }
2472
2473 /* Force an update of the window title */
2474 gnc_main_window_update_title(window);
2475 g_free(name);
2476 LEAVE("done");
2477}

◆ main_window_update_page_set_read_only_icon()

void main_window_update_page_set_read_only_icon ( GncPluginPage * page,
gboolean read_only )

Update the icon on the page tabs in the main window.

Parameters
pageThe page to be updated.
read_onlyIf set a padlock icon will be displayed for the page tab icon if it had one.

Definition at line 2535 of file gnc-main-window.cpp.

2537{
2538 GncMainWindow *window;
2539 GtkWidget *tab_widget;
2540 GtkWidget *image = NULL;
2541 GList *children;
2542 gchar *image_name = NULL;
2543 const gchar *icon_name;
2544
2545 ENTER(" ");
2546
2547 g_return_if_fail (page && page->window);
2548
2549 if (!GNC_IS_MAIN_WINDOW (page->window))
2550 return;
2551
2552 window = GNC_MAIN_WINDOW(page->window);
2553
2554 /* Get the notebook tab widget */
2555 main_window_find_tab_widget (window, page, &tab_widget);
2556
2557 if (!tab_widget)
2558 {
2559 LEAVE("no tab widget");
2560 return;
2561 }
2562
2563 if (GTK_IS_EVENT_BOX(tab_widget))
2564 tab_widget = gtk_bin_get_child (GTK_BIN(tab_widget));
2565
2566 children = gtk_container_get_children (GTK_CONTAINER(tab_widget));
2567 /* For each, walk the list of container children to get image widget */
2568 for (GList *child = children; child; child = g_list_next (child))
2569 {
2570 GtkWidget *widget = static_cast<GtkWidget*>(child->data);
2571 if (GTK_IS_IMAGE(widget))
2572 image = widget;
2573 }
2574 g_list_free (children);
2575
2576 if (!image)
2577 {
2578 LEAVE("no image to replace");
2579 return;
2580 }
2581
2582 g_object_get (image, "icon-name", &image_name, NULL);
2583
2584 if (read_only)
2585 icon_name = "changes-prevent-symbolic";
2586 else
2587 icon_name = GNC_PLUGIN_PAGE_GET_CLASS(page)->tab_icon;
2588
2589 if (g_strcmp0 (icon_name, image_name) == 0)
2590 {
2591 LEAVE("page icon the same, no need to replace");
2592 g_free (image_name);
2593 return;
2594 }
2595 gtk_container_remove (GTK_CONTAINER(tab_widget), image);
2596 image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
2597 gtk_widget_show (image);
2598
2599 gtk_container_add (GTK_CONTAINER(tab_widget), image);
2600 gtk_widget_set_margin_start (GTK_WIDGET(image), 5);
2601 gtk_box_reorder_child (GTK_BOX(tab_widget), image, 0);
2602
2603 g_free (image_name);
2604 LEAVE("done");
2605}

Variable Documentation

◆ gnc_main_window_max_number

auto gnc_main_window_max_number {10}
constexpr

Max number of windows allowed.

Definition at line 136 of file gnc-main-window.cpp.

136{10};