GnuCash  4.901-15-g732a005710
Files | Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
Main Window functions.

Files

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

Data Structures

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  GncMainWindow
 The instance data structure for a main window object. More...
 
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. More...
 
#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 GNC_TYPE_MAIN_WINDOW   (gnc_main_window_get_type ())
 
#define GNC_MAIN_WINDOW(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_MAIN_WINDOW, GncMainWindow))
 
#define GNC_MAIN_WINDOW_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_MAIN_WINDOW, GncMainWindowClass))
 
#define GNC_IS_MAIN_WINDOW(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_MAIN_WINDOW))
 
#define GNC_IS_MAIN_WINDOW_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_MAIN_WINDOW))
 
#define GNC_MAIN_WINDOW_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_MAIN_WINDOW, GncMainWindowClass))
 
#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. More...
 
 GNC_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. More...
 
gboolean gnc_main_window_is_restoring_pages (GncMainWindow *window)
 Check if the main window is restoring the plugin pages. More...
 
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. More...
 
void gnc_main_window_restore_all_windows (const GKeyFile *keyfile)
 Restore the persistent state of all windows. More...
 
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. More...
 
gboolean gnc_main_window_finish_pending (GncMainWindow *window)
 Tell a window to finish any outstanding activities. More...
 
gboolean gnc_main_window_all_finish_pending (void)
 Tell all pages in all windows to finish any outstanding activities. More...
 
void main_window_update_page_name (GncPluginPage *page, const gchar *name_in)
 Update the name of the page in the main window. More...
 
void main_window_update_page_color (GncPluginPage *page, const gchar *color_in)
 Update the color on the page tabs in the main window. More...
 
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. More...
 
GncMainWindowgnc_main_window_new (void)
 Create a new gnc main window plugin. More...
 
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. More...
 
void gnc_main_window_open_page (GncMainWindow *window, GncPluginPage *page)
 Display a data plugin page in a window. More...
 
void gnc_main_window_close_page (GncPluginPage *page)
 Remove a data plugin page from a window and display the previous page. More...
 
GncPluginPagegnc_main_window_get_current_page (GncMainWindow *window)
 Retrieve a pointer to the page that is currently at the front of the specified window. More...
 
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. More...
 
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. More...
 
void gnc_main_window_unmerge_actions (GncMainWindow *window, const gchar *group_name)
 Remove a set of actions from the specified window. More...
 
GAction * gnc_main_window_find_action (GncMainWindow *window, const gchar *action_name)
 Find the GAction in the main window. More...
 
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. More...
 
GSimpleActionGroup * gnc_main_window_get_action_group (GncMainWindow *window, const gchar *group_name)
 Retrieve a specific set of user interface actions from a window. More...
 
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. More...
 
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. More...
 
void gnc_main_window_menu_add_accelerator_keys (GncMainWindow *window)
 Scan the main window menu and add accelerator keys to main window accelerator group. More...
 
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. More...
 
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. More...
 
void gnc_main_window_init_short_names (GncMainWindow *window, GncToolBarShortNames *toolbar_labels)
 Update the labels of the toolbar items with short names. More...
 
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. More...
 
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. More...
 
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. More...
 
GtkWindow * gnc_ui_get_main_window (GtkWidget *widget)
 Get a pointer to the final GncMainWindow widget is rooted in. More...
 
void gnc_main_window_set_progressbar_window (GncMainWindow *window)
 Set the window where all progressbar updates should occur. More...
 
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). More...
 
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. More...
 
void gnc_main_window_all_action_set_sensitive (const gchar *action_name, gboolean sensitive)
 Change the sensitivity of a command in all windows. More...
 
GMenuModel * gnc_main_window_get_menu_model (GncMainWindow *window)
 Return the GMenuModel for the main window menu bar. More...
 
GType gnc_main_window_get_type (void)
 Get the type of a gnc main window. More...
 

Variables

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

Detailed Description

Macro Definition Documentation

◆ 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.

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_options_dialog_apply_helper()

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.

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 4498 of file gnc-main-window.cpp.

4499 {
4500  QofBook *book = gnc_get_current_book ();
4501  gboolean use_split_action_for_num_before =
4503  gint use_read_only_threshold_before =
4505  gboolean use_split_action_for_num_after;
4506  gint use_read_only_threshold_after;
4507  gboolean return_val = FALSE;
4508  GList *results = nullptr, *iter;
4509 
4510  if (!options) return return_val;
4511 
4512  results = gnc_option_db_commit (options);
4513  for (iter = results; iter; iter = iter->next)
4514  {
4515  GtkWidget *dialog = gtk_message_dialog_new(gnc_ui_get_main_window (nullptr),
4516  (GtkDialogFlags)0,
4517  GTK_MESSAGE_ERROR,
4518  GTK_BUTTONS_OK,
4519  "%s",
4520  (char*)iter->data);
4521  gtk_dialog_run(GTK_DIALOG(dialog));
4522  gtk_widget_destroy(dialog);
4523  g_free (iter->data);
4524  }
4525  g_list_free (results);
4526  qof_book_begin_edit (book);
4527  qof_book_save_options (book, gnc_option_db_save, options, TRUE);
4528  use_split_action_for_num_after =
4530 
4531  // mark cached value as invalid so we get new value
4532  book->cached_num_days_autoreadonly_isvalid = FALSE;
4533  use_read_only_threshold_after = qof_book_get_num_days_autoreadonly (book);
4534 
4535  if (use_split_action_for_num_before != use_split_action_for_num_after)
4536  {
4538  use_split_action_for_num_after);
4539  return_val = TRUE;
4540  }
4541  if (use_read_only_threshold_before != use_read_only_threshold_after)
4542  return_val = TRUE;
4543 
4544  qof_book_commit_edit (book);
4545  return return_val;
4546 }
GtkWindow * gnc_ui_get_main_window(GtkWidget *widget)
Get a pointer to the final GncMainWindow widget is rooted in.
gint qof_book_get_num_days_autoreadonly(const QofBook *book)
Returns the number of days for auto-read-only transactions.
Definition: qofbook.cpp:965
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_option_db_save(GncOptionDB *odb, QofBook *book, gboolean clear_options)
Save the GncOptionDB contents into a book's options store.
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 ...
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:1281
GList * gnc_option_db_commit(GncOptionDB *odb)
Write all changed ui_item values to their options.

◆ 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 4604 of file gnc-main-window.cpp.

4605 {
4606  auto book = gnc_get_current_book ();
4607 
4608  auto options = gnc_option_db_new();
4609  gnc_option_db_book_options(options);
4610  qof_book_load_options (book, gnc_option_db_load, options);
4611  gnc_option_db_clean (options);
4612 
4613  /* Only allow one Book Options dialog if called from file->properties
4614  menu */
4615  if (gnc_forall_gui_components(DIALOG_BOOK_OPTIONS_CM_CLASS,
4616  show_handler, nullptr))
4617  {
4618  return nullptr;
4619  }
4620  auto optionwin = new GncOptionsDialog (modal,
4621  (title ? title : _( "Book Options")),
4622  DIALOG_BOOK_OPTIONS_CM_CLASS, parent);
4623  optionwin->build_contents(options);
4624  optionwin->set_book_help_cb();
4625  optionwin->set_apply_cb(gnc_book_options_dialog_apply_cb,
4626  (gpointer)options);
4627  optionwin->set_close_cb ( gnc_book_options_dialog_close_cb,
4628  (gpointer)options);
4629  if (modal)
4631  return optionwin->get_widget();
4632 }
void gnc_option_db_clean(GncOptionDB *odb)
Reset all ui_items to the option value.
void qof_book_load_options(QofBook *book, GncOptionLoad load_cb, GncOptionDB *odb)
Load a GncOptionsDB from KVP data.
Definition: qofbook.cpp:1275
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 gnc_option_db_load(GncOptionDB *odb, QofBook *book)
Load a book's options into the GncOptionDB.
void gnc_option_db_book_options(GncOptionDB *odb)
Register the standard option set for a QofBook.
GncOptionDB * gnc_option_db_new(void)
Create an empty option database.

◆ GNC_DEFINE_TYPE_WITH_CODE()

GNC_DEFINE_TYPE_WITH_CODE ( GncMainWindow  ,
gnc_main_window  ,
GTK_TYPE_APPLICATION_WINDOW  ,
G_IMPLEMENT_INTERFACE(GNC_TYPE_WINDOW, gnc_window_main_window_init)   
)

A holding place for all the signals generated by the main window code.

◆ 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 5576 of file gnc-main-window.cpp.

5578 {
5579  for (auto tmp = active_windows; tmp; tmp = g_list_next(tmp))
5580  {
5581  auto action{gnc_main_window_find_action (static_cast<GncMainWindow*>(tmp->data), action_name)};
5582  g_simple_action_set_enabled (G_SIMPLE_ACTION(action), sensitive);
5583  }
5584 }
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 1071 of file gnc-main-window.cpp.

1072 {
1073  const GList *windows, *item;
1074 
1075  windows = gnc_gobject_tracking_get_list(GNC_MAIN_WINDOW_NAME);
1076  for (item = windows; item; item = g_list_next(item))
1077  {
1078  if (!gnc_main_window_finish_pending(static_cast<GncMainWindow*>(item->data)))
1079  {
1080  return FALSE;
1081  }
1082  }
1083  if (gnc_gui_refresh_suspended ())
1084  {
1085  gnc_warning_dialog (nullptr, "%s", "An operation is still running, wait for it to complete before quitting.");
1086  return FALSE;
1087  }
1088  return TRUE;
1089 }
const GList * gnc_gobject_tracking_get_list(const gchar *name)
Get a list of all known objects of a specified type.
gboolean gnc_main_window_finish_pending(GncMainWindow *window)
Tell a window to finish any outstanding activities.

◆ 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 5556 of file gnc-main-window.cpp.

5559 {
5560  g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), FALSE);
5561 
5562  ENTER("widget %p, event %p, page %p", whatever, event, page);
5563  /* Ignore double-clicks and triple-clicks */
5564  if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
5565  {
5566  do_popup_menu(page, event);
5567  LEAVE("menu shown");
5568  return TRUE;
5569  }
5570 
5571  LEAVE("other click");
5572  return FALSE;
5573 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 3319 of file gnc-main-window.cpp.

3320 {
3321  GncMainWindow *window;
3322  GncMainWindowPrivate *priv;
3323 
3324  if (!page || !page->notebook_page)
3325  return;
3326 
3327  if (!gnc_plugin_page_finish_pending(page))
3328  return;
3329 
3330  if (!GNC_IS_MAIN_WINDOW (page->window))
3331  return;
3332 
3333  window = GNC_MAIN_WINDOW (page->window);
3334  if (!window)
3335  {
3336  g_warning("Page is not in a window.");
3337  return;
3338  }
3339 
3340  gnc_main_window_disconnect(window, page);
3342  g_object_unref(page);
3343 
3344  /* If this isn't the last window, go ahead and destroy the window. */
3345  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3346  if (priv->installed_pages == nullptr)
3347  {
3348  if (window->window_quitting)
3349  {
3351  GList *plugins = gnc_plugin_manager_get_plugins (manager);
3352 
3353  /* remove only the preference callbacks from the window plugins */
3354  window->just_plugin_prefs = TRUE;
3355  g_list_foreach (plugins, gnc_main_window_remove_plugin, window);
3356  window->just_plugin_prefs = FALSE;
3357  g_list_free (plugins);
3358 
3359  /* remove the preference callbacks from the main window */
3360  gnc_main_window_remove_prefs (window);
3361  }
3362  if (window && (gnc_list_length_cmp (active_windows, 1) > 0))
3363  gtk_widget_destroy (GTK_WIDGET(window));
3364  }
3365 }
gboolean gnc_plugin_page_finish_pending(GncPluginPage *page)
Tell a page to finish any outstanding activities.
void gnc_plugin_page_destroy_widget(GncPluginPage *plugin_page)
Destroy the display widget that corresponds to this plugin.
GtkWidget * window
The window that contains the display widget for this plugin.
The instance private data structure for an embedded window object.
GncPluginManager * gnc_plugin_manager_get(void)
Retrieve a pointer to the plugin manager.
GList * gnc_plugin_manager_get_plugins(GncPluginManager *manager)
Get a list of all plugins being held by the plugin manager.
GList * installed_pages
A list of all pages that are installed in this window.
The instance data structure for a main window object.
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...
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 3142 of file gnc-main-window.cpp.

3143 {
3144  GncMainWindow *window;
3145  GncMainWindowPrivate *priv;
3146  GtkNotebook *notebook;
3147  gint page_num;
3148 
3149  window = GNC_MAIN_WINDOW (page->window);
3150  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3151  notebook = GTK_NOTEBOOK (priv->notebook);
3152  page_num = gtk_notebook_page_num(notebook, page->notebook_page);
3153  gtk_notebook_set_current_page (notebook, page_num);
3154  gtk_window_present(GTK_WINDOW(window));
3155 }
GtkWidget * window
The window that contains the display widget for this plugin.
GtkWidget * notebook
The notebook containing all the pages in this window.
The instance private data structure for an embedded window object.
The instance data structure for a main window object.
GtkWidget * notebook_page
The display widget for this plugin.

◆ 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 3512 of file gnc-main-window.cpp.

3513 {
3514  GncMainWindowPrivate *priv;
3515  GAction *action = nullptr;
3516 
3517  g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr);
3518  g_return_val_if_fail (action_name != nullptr, nullptr);
3519 
3520  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3521 
3522  action = g_action_map_lookup_action (G_ACTION_MAP(window),
3523  action_name);
3524 
3525  return action;
3526 }
The instance private data structure for an embedded window object.

◆ 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 3529 of file gnc-main-window.cpp.

3532 {
3533  GAction *action = nullptr;
3534 
3535  g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr);
3536  g_return_val_if_fail (group_name != nullptr, nullptr);
3537  g_return_val_if_fail (action_name != nullptr, nullptr);
3538 
3539  auto action_group = gtk_widget_get_action_group (GTK_WIDGET(window), group_name);
3540  if (action_group)
3541  action = g_action_map_lookup_action (G_ACTION_MAP(window), action_name);
3542 
3543  return action;
3544 }

◆ 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 1051 of file gnc-main-window.cpp.

1052 {
1053  GncMainWindowPrivate *priv;
1054  GList *item;
1055 
1056  g_return_val_if_fail(GNC_IS_MAIN_WINDOW(window), TRUE);
1057 
1058  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
1059  for (item = priv->installed_pages; item; item = g_list_next(item))
1060  {
1061  if (!gnc_plugin_page_finish_pending(static_cast<GncPluginPage*>(item->data)))
1062  {
1063  return FALSE;
1064  }
1065  }
1066  return TRUE;
1067 }
gboolean gnc_plugin_page_finish_pending(GncPluginPage *page)
Tell a page to finish any outstanding activities.
The instance private data structure for an embedded window object.
GList * installed_pages
A list of all pages that are installed in this window.

◆ 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 431 of file gnc-main-window.cpp.

432 {
433  ENTER(" ");
434  for (auto w = active_windows; w; w = g_list_next(w))
435  {
436  auto window{static_cast<GncMainWindow*>(w->data)};
437  auto priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
438  for (auto p = priv->installed_pages; p; p = g_list_next(p))
439  {
440  auto page{static_cast<GncPluginPage*>(p->data)};
441  fn(page, user_data);
442  }
443  }
444  LEAVE(" ");
445 }
The instance data structure for a content plugin.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282
The instance data structure for a main window object.

◆ 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 3552 of file gnc-main-window.cpp.

3554 {
3555  g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr);
3556  g_return_val_if_fail (group_name != nullptr, nullptr);
3557 
3558  auto action_group = gtk_widget_get_action_group (GTK_WIDGET(window), group_name);
3559  return (GSimpleActionGroup*)action_group;
3560 }

◆ 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 3376 of file gnc-main-window.cpp.

3377 {
3378  GncMainWindowPrivate *priv;
3379 
3380  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3381  return priv->current_page;
3382 }
The instance private data structure for an embedded window object.
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 5587 of file gnc-main-window.cpp.

5588 {
5589  GncMainWindowPrivate *priv;
5590 
5591  g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr);
5592 
5593  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
5594 
5595  return priv->menubar_model;
5596 }
GMenuModel * menubar_model
The menubar_model.
The instance private data structure for an embedded window object.

◆ 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 3677 of file gnc-main-window.cpp.

3679 {
3680  GncMainWindowPrivate *priv;
3681 
3682  g_return_if_fail (GNC_IS_MAIN_WINDOW(window));
3683  g_return_if_fail (toolbar_labels != nullptr);
3684 
3685  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3686 
3687  gnc_plugin_init_short_names (priv->toolbar, toolbar_labels);
3688 }
GtkWidget * toolbar
The toolbar.
The instance private data structure for an embedded window object.
void gnc_plugin_init_short_names(GtkWidget *toolbar, GncToolBarShortNames *toolbar_labels)
Add "short" labels to existing actions.
Definition: gnc-plugin.c:225

◆ 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 421 of file gnc-main-window.cpp.

422 {
423  GncMainWindowPrivate *priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
424  return priv->restoring_pages;
425 }
gboolean restoring_pages
Set when restoring plugin pages.
The instance private data structure for an embedded window object.

◆ 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 3391 of file gnc-main-window.cpp.

3394 {
3395  g_return_if_fail (GNC_IS_MAIN_WINDOW(window));
3396  g_return_if_fail (group_name != nullptr);
3397  g_return_if_fail (G_IS_SIMPLE_ACTION_GROUP(group));
3398 
3399  gtk_widget_insert_action_group (GTK_WIDGET(window), group_name,
3400  G_ACTION_GROUP(group));
3401 }

◆ 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 3599 of file gnc-main-window.cpp.

3600 {
3601  GncMainWindowPrivate *priv;
3602 
3603  g_return_if_fail (GNC_IS_MAIN_WINDOW(window));
3604 
3605  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3606 
3608 }
GtkAccelGroup * accel_group
The accelerator group for the window.
void gnc_add_accelerator_keys_for_menu(GtkWidget *menu, GtkAccelGroup *accel_group)
Add accelerator keys for menu item widgets.
The instance private data structure for an embedded window object.
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 3576 of file gnc-main-window.cpp.

3577 {
3578  GncMainWindowPrivate *priv;
3579  GtkWidget *menu_item;
3580 
3581  g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr);
3582  g_return_val_if_fail (action_name != nullptr, nullptr);
3583 
3584  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3585 
3586  menu_item = GTK_WIDGET(g_hash_table_lookup (priv->display_item_hash, action_name));
3587 
3588  if (!menu_item)
3589  {
3590  menu_item = gnc_menubar_model_find_menu_item (priv->menubar_model, priv->menubar, action_name);
3591 
3592  g_hash_table_insert (priv->display_item_hash, g_strdup (action_name), menu_item);
3593  }
3594  return menu_item;
3595 }
GMenuModel * menubar_model
The menubar_model.
The instance private data structure for an embedded window object.
GtkWidget * gnc_menubar_model_find_menu_item(GMenuModel *menu_model, GtkWidget *menu, const gchar *action_name)
Find a GtkMenu item from the action name.
GtkWidget * menubar
The menubar.

◆ 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 3458 of file gnc-main-window.cpp.

3465 {
3466  GncMainWindowPrivate *priv;
3468  GSimpleActionGroup *simple_action_group;
3469 
3470  g_return_if_fail (GNC_IS_MAIN_WINDOW(window));
3471  g_return_if_fail (group_name != nullptr);
3472  g_return_if_fail (actions != nullptr);
3473  g_return_if_fail (n_actions > 0);
3474 
3475  data = g_new0 (GncMainWindowActionData, 1);
3476  data->window = window;
3477  data->data = user_data;
3478 
3479  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3480 
3481  simple_action_group = g_simple_action_group_new ();
3482 
3483  g_action_map_add_action_entries (G_ACTION_MAP(simple_action_group),
3484  actions,
3485  n_actions,
3486  data);
3487 
3488  gtk_widget_insert_action_group (GTK_WIDGET(window), group_name,
3489  G_ACTION_GROUP(simple_action_group));
3490 
3491  if (ui_filename)
3492  update_menu_model (window, ui_filename, ui_updates);
3493 }
The instance private data structure for an embedded window object.

◆ 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 2942 of file gnc-main-window.cpp.

2943 {
2944  auto window{static_cast<GncMainWindow*>(g_object_new (GNC_TYPE_MAIN_WINDOW, nullptr))};
2945  gtk_window_set_default_size(GTK_WINDOW(window), 800, 600);
2946 
2947  auto old_window = gnc_ui_get_main_window (nullptr);
2948  if (old_window)
2949  {
2950  gint width, height;
2951  gtk_window_get_size (old_window, &width, &height);
2952  gtk_window_resize (GTK_WINDOW (window), width, height);
2953  if ((gdk_window_get_state((gtk_widget_get_window (GTK_WIDGET(old_window))))
2954  & GDK_WINDOW_STATE_MAXIMIZED) != 0)
2955  {
2956  gtk_window_maximize (GTK_WINDOW (window));
2957  }
2958  }
2959  active_windows = g_list_append (active_windows, window);
2960  gnc_main_window_update_title(window);
2961  window->window_quitting = FALSE;
2962  window->just_plugin_prefs = FALSE;
2963 #ifdef MAC_INTEGRATION
2964  gnc_quartz_set_menu(window);
2965 #else
2966  gnc_main_window_update_all_menu_items();
2967 #endif
2968  gnc_engine_add_commit_error_callback( gnc_main_window_engine_commit_error_callback, window );
2969 
2970  // set up a callback for notebook navigation
2971  g_signal_connect (G_OBJECT(window), "key-press-event",
2972  G_CALLBACK(gnc_main_window_key_press_event),
2973  NULL);
2974 
2975  return window;
2976 }
GtkWindow * gnc_ui_get_main_window(GtkWidget *widget)
Get a pointer to the final GncMainWindow widget is rooted in.
void gnc_engine_add_commit_error_callback(EngineCommitErrorCallback cb, gpointer data)
Set a callback function to be called in case an engine commit fails.
Definition: gnc-engine.c:166
The instance data structure for a main window object.

◆ 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 3166 of file gnc-main-window.cpp.

3168 {
3169  GncMainWindowPrivate *priv;
3170  GtkWidget *tab_hbox;
3171  GtkWidget *label, *entry;
3172  const gchar *icon, *text, *color_string, *lab_text;
3173  GtkWidget *image;
3174  GList *tmp;
3175  TabWidth *tw;
3176 
3177  ENTER("window %p, page %p", window, page);
3178  if (window)
3179  g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
3180  g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
3181  g_return_if_fail (gnc_plugin_page_has_books(page));
3182 
3183  if (gnc_main_window_page_exists(page))
3184  {
3186  return;
3187  }
3188 
3189  /* Does the page want to be in a new window? */
3191  {
3192  /* See if there's a blank window. If so, use that. */
3193  for (tmp = active_windows; tmp; tmp = g_list_next(tmp))
3194  {
3195  window = GNC_MAIN_WINDOW(tmp->data);
3196  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3197  if (priv->installed_pages == nullptr)
3198  {
3199  break;
3200  }
3201  }
3202  if (tmp == nullptr)
3203  window = gnc_main_window_new ();
3204  gtk_widget_show(GTK_WIDGET(window));
3205  }
3206  else if ((window == nullptr) && active_windows)
3207  {
3208  window = static_cast<GncMainWindow*>(active_windows->data);
3209  }
3210 
3211  page->window = GTK_WIDGET(window);
3213  g_object_set_data (G_OBJECT (page->notebook_page),
3214  PLUGIN_PAGE_LABEL, page);
3215 
3216  /*
3217  * The page tab.
3218  */
3219  icon = GNC_PLUGIN_PAGE_GET_CLASS(page)->tab_icon;
3220  lab_text = gnc_plugin_page_get_page_name(page);
3221  label = gtk_label_new (lab_text);
3222  g_object_set_data (G_OBJECT (page), PLUGIN_PAGE_TAB_LABEL, label);
3223 
3224  tw = populate_tab_width_struct ();
3225  gnc_main_window_update_tab_width_one_page (page, tw);
3226  g_free (tw);
3227 
3228  gtk_widget_show (label);
3229 
3230  tab_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
3231 
3232  if (g_strcmp0 (gnc_plugin_page_get_plugin_name (page), "GncPluginPageAccountTree") == 0)
3233  gtk_widget_set_name (GTK_WIDGET(tab_hbox), "gnc-id-account-page-tab-box");
3234 
3235  gtk_box_set_homogeneous (GTK_BOX (tab_hbox), FALSE);
3236  gtk_widget_show (tab_hbox);
3237 
3238  if (icon != nullptr)
3239  {
3240  image = gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_MENU);
3241  gtk_widget_show (image);
3242  gtk_box_pack_start (GTK_BOX (tab_hbox), image, FALSE, FALSE, 0);
3243  gtk_widget_set_margin_start (GTK_WIDGET(image), 5);
3244  gtk_box_pack_start (GTK_BOX (tab_hbox), label, TRUE, TRUE, 0);
3245  }
3246  else
3247  gtk_box_pack_start (GTK_BOX (tab_hbox), label, TRUE, TRUE, 0);
3248 
3250  if (text)
3251  {
3252  gtk_widget_set_tooltip_text(tab_hbox, text);
3253  }
3254 
3255  entry = gtk_entry_new();
3256  gtk_widget_hide (entry);
3257  gtk_box_pack_start (GTK_BOX (tab_hbox), entry, TRUE, TRUE, 0);
3258  g_signal_connect(G_OBJECT(entry), "activate",
3259  G_CALLBACK(gnc_main_window_tab_entry_activate), page);
3260  g_signal_connect(G_OBJECT(entry), "focus-out-event",
3261  G_CALLBACK(gnc_main_window_tab_entry_focus_out_event),
3262  page);
3263  g_signal_connect(G_OBJECT(entry), "key-press-event",
3264  G_CALLBACK(gnc_main_window_tab_entry_key_press_event),
3265  page);
3266  g_signal_connect(G_OBJECT(entry), "editing-done",
3267  G_CALLBACK(gnc_main_window_tab_entry_editing_done),
3268  page);
3269 
3270  /* Add close button - Not for immutable pages */
3271  if (!g_object_get_data (G_OBJECT (page), PLUGIN_PAGE_IMMUTABLE))
3272  {
3273  GtkWidget *close_image, *close_button;
3274  GtkRequisition requisition;
3275 
3276  close_button = gtk_button_new();
3277  gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE);
3278  close_image = gtk_image_new_from_icon_name ("window-close", GTK_ICON_SIZE_MENU);
3279  gtk_widget_show(close_image);
3280  gtk_widget_get_preferred_size (close_image, &requisition, nullptr);
3281  gtk_widget_set_size_request(close_button, requisition.width + 4,
3282  requisition.height + 2);
3283  gtk_container_add(GTK_CONTAINER(close_button), close_image);
3284  if (gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_SHOW_CLOSE_BUTTON))
3285  gtk_widget_show (close_button);
3286  else
3287  gtk_widget_hide (close_button);
3288 
3289  g_signal_connect_swapped (G_OBJECT (close_button), "clicked",
3290  G_CALLBACK(gnc_main_window_close_page), page);
3291 
3292  gtk_box_pack_start (GTK_BOX (tab_hbox), close_button, FALSE, FALSE, 0);
3293  gtk_widget_set_margin_end (GTK_WIDGET(close_button), 5);
3294  g_object_set_data (G_OBJECT (page), PLUGIN_PAGE_CLOSE_BUTTON, close_button);
3295  }
3296 
3297  /*
3298  * The popup menu
3299  */
3300  label = gtk_label_new (gnc_plugin_page_get_page_name(page));
3301 
3302  /*
3303  * Now install it all in the window.
3304  */
3305  gnc_main_window_connect(window, page, tab_hbox, label);
3306 
3307  color_string = gnc_plugin_page_get_page_color(page);
3308  main_window_update_page_color (page, color_string);
3309  LEAVE("");
3310 }
gboolean gnc_plugin_page_has_books(GncPluginPage *page)
Query a page to see if it has a reference to any book.
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_long_name(GncPluginPage *page)
Retrieve the long name of this page.
This data structure allows the passing of the tab width and whether the tab layout is on the left or ...
const gchar * gnc_plugin_page_get_page_name(GncPluginPage *page)
Retrieve the name of this page.
GtkWidget * window
The window that contains the display widget for this plugin.
const gchar * gnc_plugin_page_get_page_color(GncPluginPage *page)
Retrieve the color of this page.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
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.
The instance private data structure for an embedded window object.
#define PLUGIN_PAGE_LABEL
This label is used to provide a mapping from a visible page widget back to the corresponding GncPlugi...
GncMainWindow * gnc_main_window_new(void)
Create a new gnc main window plugin.
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.
void gnc_main_window_close_page(GncPluginPage *page)
Remove a data plugin page from a window and display the previous page.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282
GList * installed_pages
A list of all pages that are installed in this window.
The instance data structure for a main window object.
GtkWidget * notebook_page
The display widget for this plugin.
GtkWidget * gnc_plugin_page_create_widget(GncPluginPage *plugin_page)
Create the display widget that corresponds to this plugin.
const gchar * gnc_plugin_page_get_plugin_name(GncPluginPage *plugin_page)
Retrieve the textual name of a plugin.

◆ 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 5541 of file gnc-main-window.cpp.

5543 {
5544  ENTER("widget %p, page %p", widget, page);
5545  do_popup_menu(page, nullptr);
5546  LEAVE(" ");
5547  return TRUE;
5548 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ 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 834 of file gnc-main-window.cpp.

835 {
836  gint i, window_count;
837  GError *error = nullptr;
839 
840  /* We use the same struct for reading and for writing, so we cast
841  away the const. */
842  data.key_file = (GKeyFile *) keyfile;
843  window_count = g_key_file_get_integer(data.key_file, STATE_FILE_TOP,
844  WINDOW_COUNT, &error);
845  if (error)
846  {
847  g_warning("error reading group %s key %s: %s",
848  STATE_FILE_TOP, WINDOW_COUNT, error->message);
849  g_error_free(error);
850  LEAVE("can't read count");
851  return;
852  }
853 
854  /* Restore all state information on the open windows. Window
855  numbers in state file are 1-based. GList indices are 0-based. */
856  gnc_set_busy_cursor (nullptr, TRUE);
857  for (i = 0; i < window_count; i++)
858  {
859  data.window_num = i;
860  auto window{static_cast<GncMainWindow*>(g_list_nth_data(active_windows,
861  i))};
862  gnc_main_window_restore_window(window, &data);
863  }
864  gnc_unset_busy_cursor (nullptr);
865 
866  statusbar_notification_lastmodified();
867 }
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282
The instance data structure for a main window object.

◆ 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 1033 of file gnc-main-window.cpp.

1034 {
1035  GncMainWindowSaveData data;
1036 
1037  /* Set up the iterator data structures */
1038  data.key_file = keyfile;
1039  data.window_num = 1;
1040  data.page_num = 1;
1041 
1042  g_key_file_set_integer(data.key_file,
1043  STATE_FILE_TOP, WINDOW_COUNT,
1044  g_list_length(active_windows));
1045  /* Dump all state information on the open windows */
1046  g_list_foreach(active_windows, (GFunc)gnc_main_window_save_window, &data);
1047 }

◆ 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 5458 of file gnc-main-window.cpp.

5459 {
5460  GncWindow *gncwin;
5461  gncwin = GNC_WINDOW(window);
5462  gnc_window_set_progressbar_window(gncwin);
5463 }

◆ 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 3638 of file gnc-main-window.cpp.

3641 {
3642  GncMainWindowPrivate *priv;
3643 
3644  g_return_if_fail (GNC_IS_MAIN_WINDOW(window));
3645 
3646  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3647 
3648  for (gint i = 0; action_names[i]; i++)
3649  {
3650  GtkWidget *tool_item = gnc_find_toolbar_item (priv->toolbar, action_names[i]);
3651  GtkWidget *menu_item = gnc_main_window_menu_find_menu_item (window, action_names[i]);
3652 
3653  if (menu_item)
3654  {
3655  PINFO("Found menu_item %p with action name '%s', seting vis to '%s'",
3656  menu_item, action_names[i], vis ? "true" : "false");
3657  gtk_widget_set_visible (menu_item, vis);
3658  }
3659  else
3660  PINFO("Did not find menu_item with action name '%s' to set vis '%s'",
3661  action_names[i], vis ? "true" : "false");
3662 
3663  if (tool_item)
3664  {
3665  PINFO("Found tool_item %p with action name '%s', seting vis to '%s'",
3666  tool_item, action_names[i], vis ? "true" : "false");
3667  gtk_widget_set_visible (tool_item, vis);
3668  }
3669  else
3670  PINFO("Did not find tool_item with action name '%s' to set vis '%s'",
3671  action_names[i], vis ? "true" : "false");
3672  }
3673 }
#define PINFO(format, args...)
Print an informational note.
Definition: qoflog.h:256
GtkWidget * toolbar
The toolbar.
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.
The instance private data structure for an embedded window object.
GtkWidget * gnc_find_toolbar_item(GtkWidget *toolbar, const gchar *action_name)
Search the toolbar for the tool item based on the action name.

◆ 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 3563 of file gnc-main-window.cpp.

3564 {
3565  GncMainWindowPrivate *priv;
3566 
3567  g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr);
3568  g_return_val_if_fail (action_name != nullptr, nullptr);
3569 
3570  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3571 
3572  return gnc_find_toolbar_item (priv->toolbar, action_name);
3573 }
GtkWidget * toolbar
The toolbar.
The instance private data structure for an embedded window object.
GtkWidget * gnc_find_toolbar_item(GtkWidget *toolbar, const gchar *action_name)
Search the toolbar for the tool item based on the action name.

◆ 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 3502 of file gnc-main-window.cpp.

3504 {
3505  g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
3506  g_return_if_fail (group_name != nullptr);
3507 
3508  gtk_widget_insert_action_group (GTK_WIDGET(window), group_name, nullptr);
3509 }

◆ 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 3741 of file gnc-main-window.cpp.

3744 {
3745  GncMainWindowPrivate *priv;
3746  const gchar *plugin_page_actions_group_name;
3747  GtkBuilder *builder;
3748  const gchar *menu_qualifier;
3749 
3750  GMenuModel *menu_model_part;
3751  GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1);
3752 
3753  g_return_if_fail (GNC_IS_MAIN_WINDOW(window));
3754  g_return_if_fail (page != nullptr);
3755  g_return_if_fail (ui_updates != nullptr);
3756 
3757  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3758 
3759  builder = gnc_plugin_page_get_builder (page);
3760 
3761  if (!builder)
3762  return;
3763 
3764  menu_qualifier = gnc_plugin_page_get_menu_qualifier (page);
3765 
3766  plugin_page_actions_group_name = gnc_plugin_page_get_simple_action_group_name (page);
3767 
3768  if (!plugin_page_actions_group_name)
3769  return;
3770 
3771  gtk_widget_insert_action_group (GTK_WIDGET(window), gnc_plugin_page_get_simple_action_group_name (page),
3772  G_ACTION_GROUP(gnc_plugin_page_get_action_group (page)));
3773 
3774  if ((g_strcmp0 (priv->previous_plugin_page_name,
3775  plugin_page_actions_group_name) == 0) &&
3776  (g_strcmp0 (priv->previous_menu_qualifier,
3777  menu_qualifier) == 0))
3778  return;
3779 
3780  priv->previous_plugin_page_name = plugin_page_actions_group_name;
3781  priv->previous_menu_qualifier = menu_qualifier;
3782 
3783  gnc_main_window_update_toolbar (window, page, menu_qualifier);
3784 
3785  // reset hash table and remove added menu items
3786  g_hash_table_remove_all (priv->display_item_hash);
3788  GNC_MENU_ATTRIBUTE_TEMPORARY);
3789 
3790  for (gint i = 0; ui_updates[i]; i++)
3791  {
3792  gchar *menu_name;
3793 
3794  if (menu_qualifier)
3795  menu_name = g_strconcat (ui_updates[i], "-", menu_qualifier, nullptr);
3796  else
3797  menu_name = g_strdup (ui_updates[i]);
3798 
3799  menu_model_part = (GMenuModel *)gtk_builder_get_object (builder, menu_name);
3800 
3801  if (!menu_model_part)
3802  menu_model_part = (GMenuModel *)gtk_builder_get_object (builder, ui_updates[i]);
3803 
3804  gsm->search_action_label = nullptr;
3805  gsm->search_action_name = ui_updates[i];
3806 
3807  if (gnc_menubar_model_find_item (priv->menubar_model, gsm))
3808  g_menu_insert_section (G_MENU(gsm->model), gsm->index,
3809  nullptr, G_MENU_MODEL(menu_model_part));
3810  else
3811  PERR("Could not find '%s' in menu model", ui_updates[i]);
3812 
3813  g_free (menu_name);
3814  }
3815 
3816  // add tooltip redirect call backs
3818 
3819  // need to add the accelerator keys
3821 
3822  // need to signal menu has been changed
3823  g_signal_emit_by_name (window, "menu_changed", page);
3824 
3825  g_free (gsm);
3826 }
GtkWidget * statusbar
A pointer to the status bar at the bottom edge of the window.
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...
GtkAccelGroup * accel_group
The accelerator group for the window.
gboolean gnc_menubar_model_find_item(GMenuModel *menu_model, GncMenuModelSearch *gsm)
Find a GtkMenu item from the action name.
void gnc_add_accelerator_keys_for_menu(GtkWidget *menu, GtkAccelGroup *accel_group)
Add accelerator keys for menu item widgets.
GMenuModel * menubar_model
The menubar_model.
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.
const gchar * gnc_plugin_page_get_menu_qualifier(GncPluginPage *page)
Retrieve the menu qualifier for this page.
#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:264
The instance private data structure for an embedded window object.
const gchar * gnc_plugin_page_get_simple_action_group_name(GncPluginPage *page)
Retrieve the simple action group name associated with this plugin page.
GtkWidget * menubar
The menubar.

◆ 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 3612 of file gnc-main-window.cpp.

3616 {
3617  GncMainWindowPrivate *priv;
3618  gboolean found = false;
3619 
3620  g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), false);
3621  g_return_val_if_fail (action_name != nullptr, false);
3622  g_return_val_if_fail (label != nullptr, false);
3623 
3624  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3625 
3626  found = gnc_menubar_model_update_item (priv->menubar_model, action_name,
3627  _(label), _(tooltip));
3628 
3629  // add tooltip redirect call backs
3631  priv->menubar_model,
3632  priv->statusbar);
3633 
3634  return found;
3635 }
GtkWidget * statusbar
A pointer to the status bar at the bottom edge of the window.
gboolean gnc_menubar_model_update_item(GMenuModel *menu_model, const gchar *action_name, const gchar *label, const gchar *tooltip)
Update the GMenuModel item based on the action name by copying existing item, removing it and inserti...
GMenuModel * menubar_model
The menubar_model.
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:264
The instance private data structure for an embedded window object.
GtkWidget * menubar
The menubar.

◆ 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 5296 of file gnc-main-window.cpp.

5297 {
5298  GtkWidget *toplevel;
5299 
5300  if (!widget)
5301  return nullptr;
5302 
5303  toplevel = gtk_widget_get_toplevel (widget);
5304  if (toplevel && GTK_IS_WINDOW (toplevel))
5305  return GTK_WINDOW (toplevel);
5306  else
5307  return nullptr;
5308 }

◆ 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 5311 of file gnc-main-window.cpp.

5312 {
5313  GList *window;
5314 
5315  GtkWindow *toplevel = gnc_ui_get_gtk_window (widget);
5316  while (toplevel && !GNC_IS_MAIN_WINDOW (toplevel))
5317  toplevel = gtk_window_get_transient_for(toplevel);
5318 
5319  if (toplevel)
5320  return toplevel;
5321 
5322  for (window = active_windows; window; window = window->next)
5323  if (gtk_window_is_active (GTK_WINDOW (window->data)))
5324  return static_cast<GtkWindow*>(window->data);
5325 
5326  for (window = active_windows; window; window = window->next)
5327  if (gtk_widget_get_mapped (GTK_WIDGET(window->data)))
5328  return static_cast<GtkWindow*>(window->data);
5329 
5330  return nullptr;
5331 }
GtkWindow * gnc_ui_get_gtk_window(GtkWidget *widget)
Get a pointer to the widget&#39;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 2381 of file gnc-main-window.cpp.

2383 {
2384  GncMainWindow *window;
2385  GncMainWindowPrivate *priv;
2386  GtkWidget *tab_widget;
2387  GdkRGBA tab_color;
2388  gchar *color_string = nullptr;
2389  gboolean want_color = FALSE;
2390 
2391  ENTER(" ");
2392  if (color_in)
2393  color_string = g_strstrip(g_strdup(color_in));
2394 
2395  if (color_string && *color_string != '\0')
2396  want_color = TRUE;
2397 
2398  /* Update the plugin */
2399  window = GNC_MAIN_WINDOW(page->window);
2400  if (want_color)
2401  gnc_plugin_page_set_page_color(page, color_string);
2402  else
2403  gnc_plugin_page_set_page_color(page, nullptr);
2404 
2405  /* Update the notebook tab */
2406  main_window_find_tab_widget (window, page, &tab_widget);
2407  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
2408 
2409  if (want_color && gdk_rgba_parse(&tab_color, color_string) && priv->show_color_tabs)
2410  {
2411  GtkCssProvider *provider = gtk_css_provider_new();
2412  GtkStyleContext *stylectxt;
2413  gchar *col_str, *widget_css;
2414 
2415  if (!GTK_IS_EVENT_BOX (tab_widget))
2416  {
2417  GtkWidget *event_box = gtk_event_box_new ();
2418  g_object_ref (tab_widget);
2419  gtk_notebook_set_tab_label (GTK_NOTEBOOK(priv->notebook),
2420  page->notebook_page, event_box);
2421  gtk_container_add (GTK_CONTAINER(event_box), tab_widget);
2422  g_object_unref (tab_widget);
2423  tab_widget = event_box;
2424  }
2425 
2426  stylectxt = gtk_widget_get_style_context (GTK_WIDGET (tab_widget));
2427  col_str = gdk_rgba_to_string (&tab_color);
2428  widget_css = g_strconcat ("*{\n background-color:", col_str, ";\n}\n", nullptr);
2429 
2430  gtk_css_provider_load_from_data (provider, widget_css, -1, nullptr);
2431  gtk_style_context_add_provider (stylectxt, GTK_STYLE_PROVIDER (provider),
2432  GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
2433  g_object_unref (provider);
2434  g_free (col_str);
2435  g_free (widget_css);
2436  }
2437  else
2438  {
2439  if (GTK_IS_EVENT_BOX (tab_widget))
2440  {
2441  GtkWidget *tab_hbox = gtk_bin_get_child(GTK_BIN(tab_widget));
2442  g_object_ref (tab_hbox);
2443  gtk_container_remove (GTK_CONTAINER(tab_widget), tab_hbox);
2444  gtk_notebook_set_tab_label (GTK_NOTEBOOK(priv->notebook),
2445  page->notebook_page, tab_hbox);
2446  g_object_unref (tab_hbox);
2447  }
2448  }
2449  g_free(color_string);
2450  LEAVE("done");
2451 }
GtkWidget * window
The window that contains the display widget for this plugin.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
GtkWidget * notebook
The notebook containing all the pages in this window.
The instance private data structure for an embedded window object.
gboolean show_color_tabs
Show account color as background on tabs.
void gnc_plugin_page_set_page_color(GncPluginPage *page, const char *color)
Set the color of this page.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282
The instance data structure for a main window object.
GtkWidget * notebook_page
The display widget for this plugin.

◆ 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 2292 of file gnc-main-window.cpp.

2294 {
2295  GncMainWindow *window;
2296  GncMainWindowPrivate *priv;
2297  GtkWidget *label, *entry;
2298  gchar *name, *old_page_name, *old_page_long_name;
2299  TabWidth *tw;
2300 
2301  ENTER(" ");
2302 
2303  if ((name_in == nullptr) || (*name_in == '\0'))
2304  {
2305  LEAVE("no string");
2306  return;
2307  }
2308  name = g_strstrip(g_strdup(name_in));
2309 
2310  /* Optimization, if the name hasn't changed, don't update X. */
2311  if (*name == '\0' || 0 == strcmp(name, gnc_plugin_page_get_page_name(page)))
2312  {
2313  g_free(name);
2314  LEAVE("empty string or name unchanged");
2315  return;
2316  }
2317 
2318  old_page_name = g_strdup( gnc_plugin_page_get_page_name(page));
2319  old_page_long_name = g_strdup( gnc_plugin_page_get_page_long_name(page));
2320 
2321  /* Update the plugin */
2322  gnc_plugin_page_set_page_name(page, name);
2323 
2324  /* Update the notebook tab */
2325  window = GNC_MAIN_WINDOW(page->window);
2326  if (!window)
2327  {
2328  g_free(old_page_name);
2329  g_free(old_page_long_name);
2330  g_free(name);
2331  LEAVE("no window widget available");
2332  return;
2333  }
2334 
2335  if (main_window_find_tab_items(window, page, &label, &entry))
2336  gtk_label_set_text(GTK_LABEL(label), name);
2337 
2338  /* Adjust the label width for new text */
2339  tw = populate_tab_width_struct ();
2340  gnc_main_window_update_tab_width_one_page (page, tw);
2341  g_free (tw);
2342 
2343  /* Update Tooltip on notebook Tab */
2344  if (old_page_long_name && old_page_name
2345  && g_strrstr(old_page_long_name, old_page_name) != nullptr)
2346  {
2347  gchar *new_page_long_name;
2348  gint string_position;
2349  GtkWidget *tab_widget;
2350 
2351  string_position = strlen(old_page_long_name) - strlen(old_page_name);
2352  new_page_long_name = g_strconcat(g_strndup(old_page_long_name, string_position), name, nullptr);
2353 
2354  gnc_plugin_page_set_page_long_name(page, new_page_long_name);
2355 
2356  if (main_window_find_tab_widget(window, page, &tab_widget))
2357  gtk_widget_set_tooltip_text(tab_widget, new_page_long_name);
2358 
2359  g_free(new_page_long_name);
2360  }
2361 
2362  /* Update the notebook menu */
2363  if (page->notebook_page)
2364  {
2365  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
2366  label = gtk_notebook_get_menu_label (GTK_NOTEBOOK(priv->notebook),
2367  page->notebook_page);
2368  gtk_label_set_text(GTK_LABEL(label), name);
2369  }
2370 
2371  /* Force an update of the window title */
2372  gnc_main_window_update_title(window);
2373  g_free(old_page_long_name);
2374  g_free(old_page_name);
2375  g_free(name);
2376  LEAVE("done");
2377 }
const gchar * gnc_plugin_page_get_page_long_name(GncPluginPage *page)
Retrieve the long name of this page.
This data structure allows the passing of the tab width and whether the tab layout is on the left or ...
const gchar * gnc_plugin_page_get_page_name(GncPluginPage *page)
Retrieve the name of this page.
GtkWidget * window
The window that contains the display widget for this plugin.
void gnc_plugin_page_set_page_long_name(GncPluginPage *page, const char *name)
Set the long name of this page.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
GtkWidget * notebook
The notebook containing all the pages in this window.
The instance private data structure for an embedded window object.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282
void gnc_plugin_page_set_page_name(GncPluginPage *page, const char *name)
Set the name of this page.
The instance data structure for a main window object.
GtkWidget * notebook_page
The display widget for this plugin.

◆ 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 2455 of file gnc-main-window.cpp.

2457 {
2458  GncMainWindow *window;
2459  GncMainWindowPrivate *priv;
2460  GtkWidget *tab_widget;
2461  GtkWidget *image = NULL;
2462  GList *children;
2463  gchar *image_name = NULL;
2464  const gchar *icon_name;
2465 
2466  ENTER(" ");
2467 
2468  g_return_if_fail (page && page->window);
2469 
2470  if (!GNC_IS_MAIN_WINDOW (page->window))
2471  return;
2472 
2473  window = GNC_MAIN_WINDOW(page->window);
2474 
2475  /* Get the notebook tab widget */
2476  main_window_find_tab_widget (window, page, &tab_widget);
2477  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
2478 
2479  if (!tab_widget)
2480  {
2481  LEAVE("no tab widget");
2482  return;
2483  }
2484 
2485  if (GTK_IS_EVENT_BOX(tab_widget))
2486  tab_widget = gtk_bin_get_child (GTK_BIN(tab_widget));
2487 
2488  children = gtk_container_get_children (GTK_CONTAINER(tab_widget));
2489  /* For each, walk the list of container children to get image widget */
2490  for (GList *child = children; child; child = g_list_next (child))
2491  {
2492  GtkWidget *widget = static_cast<GtkWidget*>(child->data);
2493  if (GTK_IS_IMAGE(widget))
2494  image = widget;
2495  }
2496  g_list_free (children);
2497 
2498  if (!image)
2499  {
2500  LEAVE("no image to replace");
2501  return;
2502  }
2503 
2504  g_object_get (image, "icon-name", &image_name, NULL);
2505 
2506  if (read_only)
2507  icon_name = "changes-prevent-symbolic";
2508  else
2509  icon_name = GNC_PLUGIN_PAGE_GET_CLASS(page)->tab_icon;
2510 
2511  if (g_strcmp0 (icon_name, image_name) == 0)
2512  {
2513  LEAVE("page icon the same, no need to replace");
2514  g_free (image_name);
2515  return;
2516  }
2517  gtk_container_remove (GTK_CONTAINER(tab_widget), image);
2518  image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
2519  gtk_widget_show (image);
2520 
2521  gtk_container_add (GTK_CONTAINER(tab_widget), image);
2522  gtk_widget_set_margin_start (GTK_WIDGET(image), 5);
2523  gtk_box_reorder_child (GTK_BOX(tab_widget), image, 0);
2524 
2525  g_free (image_name);
2526  LEAVE("done");
2527 }
GtkWidget * window
The window that contains the display widget for this plugin.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
The instance private data structure for an embedded window object.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282
The instance data structure for a main window object.