GnuCash  5.6-150-g038405b370+
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  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. 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...
 
 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. 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_long_name (GncPluginPage *page, const gchar *long_name_in)
 Update the long name of the page in the main window. 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...
 
GncMainWindow * gnc_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...
 
gboolean gnc_main_window_just_plugin_prefs (GncMainWindow *window)
 
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

◆ G_DEFINE_TYPE_WITH_CODE()

G_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_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 4608 of file gnc-main-window.cpp.

4609 {
4610  QofBook *book = gnc_get_current_book ();
4611  gboolean use_split_action_for_num_before =
4613  gint use_read_only_threshold_before =
4615  gboolean use_split_action_for_num_after;
4616  gint use_read_only_threshold_after;
4617  gboolean return_val = FALSE;
4618  GList *results = nullptr, *iter;
4619 
4620  if (!options) return return_val;
4621 
4622  results = gnc_option_db_commit (options);
4623  for (iter = results; iter; iter = iter->next)
4624  {
4625  GtkWidget *dialog = gtk_message_dialog_new(gnc_ui_get_main_window (nullptr),
4626  (GtkDialogFlags)0,
4627  GTK_MESSAGE_ERROR,
4628  GTK_BUTTONS_OK,
4629  "%s",
4630  (char*)iter->data);
4631  gtk_dialog_run(GTK_DIALOG(dialog));
4632  gtk_widget_destroy(dialog);
4633  g_free (iter->data);
4634  }
4635  g_list_free (results);
4636  qof_book_begin_edit (book);
4637  qof_book_save_options (book, gnc_option_db_save, options, TRUE);
4638  use_split_action_for_num_after =
4640 
4641  // mark cached value as invalid so we get new value
4642  book->cached_num_days_autoreadonly_isvalid = FALSE;
4643  use_read_only_threshold_after = qof_book_get_num_days_autoreadonly (book);
4644 
4645  if (use_split_action_for_num_before != use_split_action_for_num_after)
4646  {
4648  use_split_action_for_num_after);
4649  return_val = TRUE;
4650  }
4651  if (use_read_only_threshold_before != use_read_only_threshold_after)
4652  return_val = TRUE;
4653 
4654  qof_book_commit_edit (book);
4655  return return_val;
4656 }
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:968
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:1322
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 4714 of file gnc-main-window.cpp.

4715 {
4716  auto book = gnc_get_current_book ();
4717 
4718  auto options = gnc_option_db_new();
4719  gnc_option_db_book_options(options);
4720  qof_book_load_options (book, gnc_option_db_load, options);
4721  gnc_option_db_clean (options);
4722 
4723  /* Only allow one Book Options dialog if called from file->properties
4724  menu */
4725  if (gnc_forall_gui_components(DIALOG_BOOK_OPTIONS_CM_CLASS,
4726  show_handler, nullptr))
4727  {
4728  return nullptr;
4729  }
4730  auto optionwin = new GncOptionsDialog (modal,
4731  (title ? title : _( "Book Options")),
4732  DIALOG_BOOK_OPTIONS_CM_CLASS, parent);
4733  optionwin->build_contents(options);
4734  optionwin->set_book_help_cb();
4735  optionwin->set_apply_cb(gnc_book_options_dialog_apply_cb,
4736  (gpointer)options);
4737  optionwin->set_close_cb ( gnc_book_options_dialog_close_cb,
4738  (gpointer)options);
4739  if (modal)
4741  return optionwin->get_widget();
4742 }
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:1316
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_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 5713 of file gnc-main-window.cpp.

5715 {
5716  for (auto tmp = active_windows; tmp; tmp = g_list_next(tmp))
5717  {
5718  auto action{gnc_main_window_find_action (static_cast<GncMainWindow*>(tmp->data), action_name)};
5719  g_simple_action_set_enabled (G_SIMPLE_ACTION(action), sensitive);
5720  }
5721 }
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 1096 of file gnc-main-window.cpp.

1097 {
1098  const GList *windows, *item;
1099 
1100  windows = gnc_gobject_tracking_get_list(GNC_MAIN_WINDOW_NAME);
1101  for (item = windows; item; item = g_list_next(item))
1102  {
1103  if (!gnc_main_window_finish_pending(static_cast<GncMainWindow*>(item->data)))
1104  {
1105  return FALSE;
1106  }
1107  }
1108  if (gnc_gui_refresh_suspended ())
1109  {
1110  gnc_warning_dialog (nullptr, "%s", "An operation is still running, wait for it to complete before quitting.");
1111  return FALSE;
1112  }
1113  return TRUE;
1114 }
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 5693 of file gnc-main-window.cpp.

5696 {
5697  g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), FALSE);
5698 
5699  ENTER("widget %p, event %p, page %p", whatever, event, page);
5700  /* Ignore double-clicks and triple-clicks */
5701  if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
5702  {
5703  do_popup_menu(page, event);
5704  LEAVE("menu shown");
5705  return TRUE;
5706  }
5707 
5708  LEAVE("other click");
5709  return FALSE;
5710 }
#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 3427 of file gnc-main-window.cpp.

3428 {
3429  GncMainWindow *window;
3430  GncMainWindowPrivate *priv;
3431 
3432  if (!page || !page->notebook_page)
3433  return;
3434 
3435  if (!gnc_plugin_page_finish_pending(page))
3436  return;
3437 
3438  if (!GNC_IS_MAIN_WINDOW (page->window))
3439  return;
3440 
3441  window = GNC_MAIN_WINDOW (page->window);
3442  if (!window)
3443  {
3444  g_warning("Page is not in a window.");
3445  return;
3446  }
3447 
3448  gnc_main_window_disconnect(window, page);
3450  g_object_unref(page);
3451 
3452  /* If this isn't the last window, go ahead and destroy the window. */
3453  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3454  if (priv->installed_pages == nullptr)
3455  {
3456  if (window->window_quitting)
3457  {
3458  GncPluginManager *manager = gnc_plugin_manager_get ();
3459  GList *plugins = gnc_plugin_manager_get_plugins (manager);
3460 
3461  /* remove only the preference callbacks from the window plugins */
3462  window->just_plugin_prefs = TRUE;
3463  g_list_foreach (plugins, gnc_main_window_remove_plugin, window);
3464  window->just_plugin_prefs = FALSE;
3465  g_list_free (plugins);
3466 
3467  /* remove the preference callbacks from the main window */
3468  gnc_main_window_remove_prefs (window);
3469  }
3470  if (window && (gnc_list_length_cmp (active_windows, 1) > 0))
3471  gtk_widget_destroy (GTK_WIDGET(window));
3472  }
3473 }
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.
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 3225 of file gnc-main-window.cpp.

3226 {
3227  GncMainWindow *window;
3228  GncMainWindowPrivate *priv;
3229  GtkNotebook *notebook;
3230  gint page_num;
3231 
3232  window = GNC_MAIN_WINDOW (page->window);
3233  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3234  notebook = GTK_NOTEBOOK (priv->notebook);
3235  page_num = gtk_notebook_page_num(notebook, page->notebook_page);
3236  gtk_notebook_set_current_page (notebook, page_num);
3237  gtk_window_present(GTK_WINDOW(window));
3238 }
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.
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 3618 of file gnc-main-window.cpp.

3619 {
3620  GAction *action = nullptr;
3621 
3622  g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr);
3623  g_return_val_if_fail (action_name != nullptr, nullptr);
3624 
3625  action = g_action_map_lookup_action (G_ACTION_MAP(window),
3626  action_name);
3627 
3628  return action;
3629 }

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

3635 {
3636  GAction *action = nullptr;
3637 
3638  g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr);
3639  g_return_val_if_fail (group_name != nullptr, nullptr);
3640  g_return_val_if_fail (action_name != nullptr, nullptr);
3641 
3642  auto action_group = gtk_widget_get_action_group (GTK_WIDGET(window), group_name);
3643 
3644  if (action_group)
3645  action = g_action_map_lookup_action (G_ACTION_MAP(action_group), action_name);
3646 
3647  return action;
3648 }

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

1077 {
1078  GncMainWindowPrivate *priv;
1079  GList *item;
1080 
1081  g_return_val_if_fail(GNC_IS_MAIN_WINDOW(window), TRUE);
1082 
1083  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
1084  for (item = priv->installed_pages; item; item = g_list_next(item))
1085  {
1086  if (!gnc_plugin_page_finish_pending(static_cast<GncPluginPage*>(item->data)))
1087  {
1088  return FALSE;
1089  }
1090  }
1091  return TRUE;
1092 }
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 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 }
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

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

3658 {
3659  g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr);
3660  g_return_val_if_fail (group_name != nullptr, nullptr);
3661 
3662  auto action_group = gtk_widget_get_action_group (GTK_WIDGET(window), group_name);
3663  return (GSimpleActionGroup*)action_group;
3664 }

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

3485 {
3486  GncMainWindowPrivate *priv;
3487 
3488  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3489  return priv->current_page;
3490 }
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 5724 of file gnc-main-window.cpp.

5725 {
5726  GncMainWindowPrivate *priv;
5727 
5728  g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr);
5729 
5730  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
5731 
5732  return priv->menubar_model;
5733 }
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 3781 of file gnc-main-window.cpp.

3783 {
3784  GncMainWindowPrivate *priv;
3785 
3786  g_return_if_fail (GNC_IS_MAIN_WINDOW(window));
3787  g_return_if_fail (toolbar_labels != nullptr);
3788 
3789  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3790 
3791  gnc_plugin_init_short_names (priv->toolbar, toolbar_labels);
3792 }
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:229

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

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

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

3704 {
3705  GncMainWindowPrivate *priv;
3706 
3707  g_return_if_fail (GNC_IS_MAIN_WINDOW(window));
3708 
3709  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3710 
3712 }
GtkAccelGroup * accel_group
The accelerator group for the window.
GMenuModel * menubar_model
The menubar_model.
The instance private data structure for an embedded window object.
GtkWidget * menubar
The menubar.
void gnc_add_accelerator_keys_for_menu(GtkWidget *menu, GMenuModel *model, GtkAccelGroup *accel_group)
Add accelerator keys for menu item widgets.

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

3681 {
3682  GncMainWindowPrivate *priv;
3683  GtkWidget *menu_item;
3684 
3685  g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr);
3686  g_return_val_if_fail (action_name != nullptr, nullptr);
3687 
3688  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3689 
3690  menu_item = GTK_WIDGET(g_hash_table_lookup (priv->display_item_hash, action_name));
3691 
3692  if (!menu_item)
3693  {
3694  menu_item = gnc_menubar_model_find_menu_item (priv->menubar_model, priv->menubar, action_name);
3695 
3696  g_hash_table_insert (priv->display_item_hash, g_strdup (action_name), menu_item);
3697  }
3698  return menu_item;
3699 }
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 3567 of file gnc-main-window.cpp.

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

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

3024 {
3025  auto window{static_cast<GncMainWindow*>(g_object_new (GNC_TYPE_MAIN_WINDOW, nullptr))};
3026  gtk_window_set_default_size(GTK_WINDOW(window), 800, 600);
3027 
3028  auto old_window = gnc_ui_get_main_window (nullptr);
3029  if (old_window)
3030  {
3031  gint width, height;
3032  gtk_window_get_size (old_window, &width, &height);
3033  gtk_window_resize (GTK_WINDOW (window), width, height);
3034  if ((gdk_window_get_state((gtk_widget_get_window (GTK_WIDGET(old_window))))
3035  & GDK_WINDOW_STATE_MAXIMIZED) != 0)
3036  {
3037  gtk_window_maximize (GTK_WINDOW (window));
3038  }
3039  }
3040  active_windows = g_list_append (active_windows, window);
3041  gnc_main_window_update_title(window);
3042  window->window_quitting = FALSE;
3043  window->just_plugin_prefs = FALSE;
3044 #ifdef MAC_INTEGRATION
3045  gnc_quartz_set_menu(window);
3046 #else
3047  gnc_main_window_update_all_menu_items();
3048 #endif
3049  gnc_engine_add_commit_error_callback( gnc_main_window_engine_commit_error_callback, window );
3050 
3051  // set up a callback for notebook navigation
3052  g_signal_connect (G_OBJECT(window), "key-press-event",
3053  G_CALLBACK(gnc_main_window_key_press_event),
3054  NULL);
3055 
3056  return window;
3057 }
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.cpp:166

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

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

5680 {
5681  ENTER("widget %p, page %p", widget, page);
5682  do_popup_menu(page, nullptr);
5683  LEAVE(" ");
5684  return TRUE;
5685 }
#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 859 of file gnc-main-window.cpp.

860 {
861  gint i, window_count;
862  GError *error = nullptr;
864 
865  /* We use the same struct for reading and for writing, so we cast
866  away the const. */
867  data.key_file = (GKeyFile *) keyfile;
868  window_count = g_key_file_get_integer(data.key_file, STATE_FILE_TOP,
869  WINDOW_COUNT, &error);
870  if (error)
871  {
872  g_warning("error reading group %s key %s: %s",
873  STATE_FILE_TOP, WINDOW_COUNT, error->message);
874  g_error_free(error);
875  LEAVE("can't read count");
876  return;
877  }
878 
879  /* Restore all state information on the open windows. Window
880  numbers in state file are 1-based. GList indices are 0-based. */
881  gnc_set_busy_cursor (nullptr, TRUE);
882  for (i = 0; i < window_count; i++)
883  {
884  data.window_num = i;
885  auto window{static_cast<GncMainWindow*>(g_list_nth_data(active_windows,
886  i))};
887  gnc_main_window_restore_window(window, &data);
888  }
889  gnc_unset_busy_cursor (nullptr);
890 
891  statusbar_notification_lastmodified();
892 }
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

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

1059 {
1060  GncMainWindowSaveData data;
1061 
1062  /* Set up the iterator data structures */
1063  data.key_file = keyfile;
1064  data.window_num = 1;
1065  data.page_num = 1;
1066 
1067  g_key_file_set_integer(data.key_file,
1068  STATE_FILE_TOP, WINDOW_COUNT,
1069  g_list_length(active_windows));
1070  /* Dump all state information on the open windows */
1071  g_list_foreach(active_windows, (GFunc)gnc_main_window_save_window, &data);
1072 }

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

5583 {
5584  GncWindow *gncwin;
5585  gncwin = GNC_WINDOW(window);
5586  gnc_window_set_progressbar_window(gncwin);
5587 }

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

3745 {
3746  GncMainWindowPrivate *priv;
3747 
3748  g_return_if_fail (GNC_IS_MAIN_WINDOW(window));
3749 
3750  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3751 
3752  for (gint i = 0; action_names[i]; i++)
3753  {
3754  GtkWidget *tool_item = gnc_find_toolbar_item (priv->toolbar, action_names[i]);
3755  GtkWidget *menu_item = gnc_main_window_menu_find_menu_item (window, action_names[i]);
3756 
3757  if (menu_item)
3758  {
3759  PINFO("Found menu_item %p with action name '%s', seting vis to '%s'",
3760  menu_item, action_names[i], vis ? "true" : "false");
3761  gtk_widget_set_visible (menu_item, vis);
3762  }
3763  else
3764  PINFO("Did not find menu_item with action name '%s' to set vis '%s'",
3765  action_names[i], vis ? "true" : "false");
3766 
3767  if (tool_item)
3768  {
3769  PINFO("Found tool_item %p with action name '%s', seting vis to '%s'",
3770  tool_item, action_names[i], vis ? "true" : "false");
3771  gtk_widget_set_visible (tool_item, vis);
3772  }
3773  else
3774  PINFO("Did not find tool_item with action name '%s' to set vis '%s'",
3775  action_names[i], vis ? "true" : "false");
3776  }
3777 }
#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 3667 of file gnc-main-window.cpp.

3668 {
3669  GncMainWindowPrivate *priv;
3670 
3671  g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), nullptr);
3672  g_return_val_if_fail (action_name != nullptr, nullptr);
3673 
3674  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3675 
3676  return gnc_find_toolbar_item (priv->toolbar, action_name);
3677 }
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 3608 of file gnc-main-window.cpp.

3610 {
3611  g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
3612  g_return_if_fail (group_name != nullptr);
3613 
3614  gtk_widget_insert_action_group (GTK_WIDGET(window), group_name, nullptr);
3615 }

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

3848 {
3849  GncMainWindowPrivate *priv;
3850  const gchar *plugin_page_actions_group_name;
3851  GtkBuilder *builder;
3852  const gchar *menu_qualifier;
3853 
3854  GMenuModel *menu_model_part;
3855 #ifdef MAC_INTEGRATION
3856  auto theApp{static_cast<GtkosxApplication *>(g_object_new(GTKOSX_TYPE_APPLICATION, nullptr))};
3857 #endif
3858  g_return_if_fail (GNC_IS_MAIN_WINDOW(window));
3859  g_return_if_fail (page != nullptr);
3860  g_return_if_fail (ui_updates != nullptr);
3861 
3862  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3863 
3864  builder = gnc_plugin_page_get_builder (page);
3865 
3866  if (!builder)
3867  return;
3868 
3869  menu_qualifier = gnc_plugin_page_get_menu_qualifier (page);
3870 
3871  plugin_page_actions_group_name = gnc_plugin_page_get_simple_action_group_name (page);
3872 
3873  if (!plugin_page_actions_group_name)
3874  return;
3875 
3876  gtk_widget_insert_action_group (GTK_WIDGET(window), gnc_plugin_page_get_simple_action_group_name (page),
3877  G_ACTION_GROUP(gnc_plugin_page_get_action_group (page)));
3878 
3879  if ((g_strcmp0 (priv->previous_plugin_page_name,
3880  plugin_page_actions_group_name) == 0) &&
3881  (g_strcmp0 (priv->previous_menu_qualifier,
3882  menu_qualifier) == 0))
3883  return;
3884 
3885  priv->previous_plugin_page_name = plugin_page_actions_group_name;
3886  priv->previous_menu_qualifier = menu_qualifier;
3887 
3888  gnc_main_window_update_toolbar (window, page, menu_qualifier);
3889 
3890  // reset hash table and remove added menu items
3891  g_hash_table_remove_all (priv->display_item_hash);
3893  GNC_MENU_ATTRIBUTE_TEMPORARY);
3894 
3895  GncMenuModelSearch *gsm = g_new0 (GncMenuModelSearch, 1);
3896  for (gint i = 0; ui_updates[i]; i++)
3897  {
3898  gchar *menu_name;
3899 
3900  if (menu_qualifier)
3901  menu_name = g_strconcat (ui_updates[i], "-", menu_qualifier, nullptr);
3902  else
3903  menu_name = g_strdup (ui_updates[i]);
3904 
3905  menu_model_part = (GMenuModel *)gtk_builder_get_object (builder, menu_name);
3906 
3907  if (!menu_model_part)
3908  menu_model_part = (GMenuModel *)gtk_builder_get_object (builder, ui_updates[i]);
3909 
3910  gsm->search_action_label = nullptr;
3911  gsm->search_action_name = ui_updates[i];
3912  gsm->search_action_target = nullptr;
3913 
3914  if (gnc_menubar_model_find_item (priv->menubar_model, gsm))
3915  g_menu_insert_section (G_MENU(gsm->model), gsm->index,
3916  nullptr, G_MENU_MODEL(menu_model_part));
3917  else
3918  PERR("Could not find '%s' in menu model", ui_updates[i]);
3919 
3920  g_free (menu_name);
3921  }
3922 
3923  // add tooltip redirect call backs
3925 
3926  // need to add the accelerator keys
3928 #ifdef MAC_INTEGRATION
3929  gtkosx_application_sync_menubar (theApp);
3930  g_object_unref (theApp);
3931 #endif
3932  // need to signal menu has been changed
3933  g_signal_emit_by_name (window, "menu_changed", page);
3934 
3935  g_free (gsm);
3936 }
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.
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:268
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.
void gnc_add_accelerator_keys_for_menu(GtkWidget *menu, GMenuModel *model, GtkAccelGroup *accel_group)
Add accelerator keys for menu item widgets.

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

3720 {
3721  GncMainWindowPrivate *priv;
3722  gboolean found = false;
3723 
3724  g_return_val_if_fail (GNC_IS_MAIN_WINDOW(window), false);
3725  g_return_val_if_fail (action_name != nullptr, false);
3726  g_return_val_if_fail (label != nullptr, false);
3727 
3728  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3729 
3730  found = gnc_menubar_model_update_item (priv->menubar_model, action_name,
3731  nullptr, _(label), nullptr, _(tooltip));
3732 
3733  // add tooltip redirect call backs
3735  priv->menubar_model,
3736  priv->statusbar);
3737 
3738  return found;
3739 }
GtkWidget * statusbar
A pointer to the status bar at the bottom edge of the window.
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:268
The instance private data structure for an embedded window object.
GtkWidget * menubar
The menubar.
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 5403 of file gnc-main-window.cpp.

5404 {
5405  GtkWidget *toplevel;
5406 
5407  if (!widget)
5408  return nullptr;
5409 
5410  toplevel = gtk_widget_get_toplevel (widget);
5411  if (toplevel && GTK_IS_WINDOW (toplevel))
5412  return GTK_WINDOW (toplevel);
5413  else
5414  return nullptr;
5415 }

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

5419 {
5420  GList *window;
5421 
5422  GtkWindow *toplevel = gnc_ui_get_gtk_window (widget);
5423  while (toplevel && !GNC_IS_MAIN_WINDOW (toplevel))
5424  toplevel = gtk_window_get_transient_for(toplevel);
5425 
5426  if (toplevel)
5427  return toplevel;
5428 
5429  for (window = active_windows; window; window = window->next)
5430  if (gtk_window_is_active (GTK_WINDOW (window->data)))
5431  return static_cast<GtkWindow*>(window->data);
5432 
5433  for (window = active_windows; window; window = window->next)
5434  if (gtk_widget_get_mapped (GTK_WIDGET(window->data)))
5435  return static_cast<GtkWindow*>(window->data);
5436 
5437  return nullptr;
5438 }
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 2456 of file gnc-main-window.cpp.

2458 {
2459  GncMainWindow *window;
2460  GncMainWindowPrivate *priv;
2461  GtkWidget *tab_widget;
2462  GdkRGBA tab_color;
2463  gchar *color_string = nullptr;
2464  gboolean want_color = FALSE;
2465 
2466  ENTER(" ");
2467  if (color_in)
2468  color_string = g_strstrip(g_strdup(color_in));
2469 
2470  if (color_string && *color_string != '\0')
2471  want_color = TRUE;
2472 
2473  /* Update the plugin */
2474  window = GNC_MAIN_WINDOW(page->window);
2475  if (want_color)
2476  gnc_plugin_page_set_page_color(page, color_string);
2477  else
2478  gnc_plugin_page_set_page_color(page, nullptr);
2479 
2480  /* Update the notebook tab */
2481  main_window_find_tab_widget (window, page, &tab_widget);
2482  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
2483 
2484  if (want_color && gdk_rgba_parse(&tab_color, color_string) && priv->show_color_tabs)
2485  {
2486  GtkCssProvider *provider = gtk_css_provider_new();
2487  GtkStyleContext *stylectxt;
2488  gchar *col_str, *widget_css;
2489 
2490  if (!GTK_IS_EVENT_BOX (tab_widget))
2491  {
2492  GtkWidget *event_box = gtk_event_box_new ();
2493  g_object_ref (tab_widget);
2494  gtk_notebook_set_tab_label (GTK_NOTEBOOK(priv->notebook),
2495  page->notebook_page, event_box);
2496  gtk_container_add (GTK_CONTAINER(event_box), tab_widget);
2497  g_object_unref (tab_widget);
2498  tab_widget = event_box;
2499  }
2500 
2501  stylectxt = gtk_widget_get_style_context (GTK_WIDGET (tab_widget));
2502  col_str = gdk_rgba_to_string (&tab_color);
2503  widget_css = g_strconcat ("*{\n background-color:", col_str, ";\n}\n", nullptr);
2504 
2505  gtk_css_provider_load_from_data (provider, widget_css, -1, nullptr);
2506  gtk_style_context_add_provider (stylectxt, GTK_STYLE_PROVIDER (provider),
2507  GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
2508  g_object_unref (provider);
2509  g_free (col_str);
2510  g_free (widget_css);
2511  }
2512  else
2513  {
2514  if (GTK_IS_EVENT_BOX (tab_widget))
2515  {
2516  GtkWidget *tab_hbox = gtk_bin_get_child(GTK_BIN(tab_widget));
2517  g_object_ref (tab_hbox);
2518  gtk_container_remove (GTK_CONTAINER(tab_widget), tab_hbox);
2519  gtk_notebook_set_tab_label (GTK_NOTEBOOK(priv->notebook),
2520  page->notebook_page, tab_hbox);
2521  g_object_unref (tab_hbox);
2522  }
2523  }
2524  g_free(color_string);
2525  LEAVE("done");
2526 }
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
GtkWidget * notebook_page
The display widget for this plugin.

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

2353 {
2354  GtkWidget *tab_widget;
2355 
2356  ENTER(" ");
2357 
2358  if ((long_name_in == nullptr) || (*long_name_in == '\0'))
2359  {
2360  LEAVE("no string");
2361  return;
2362  }
2363  gchar *long_name = g_strstrip (g_strdup (long_name_in));
2364  const gchar *old_long_name = gnc_plugin_page_get_page_long_name (page);
2365 
2366  /* Optimization, if the long_name hasn't changed, don't update X. */
2367  if (*long_name == '\0' || strcmp (long_name, old_long_name) == 0)
2368  {
2369  g_free (long_name);
2370  LEAVE("empty string or name unchanged");
2371  return;
2372  }
2373 
2374  gnc_plugin_page_set_page_long_name (page, long_name);
2375 
2376  GncMainWindow *window = GNC_MAIN_WINDOW(page->window);
2377  if (!window)
2378  {
2379  g_free (long_name);
2380  LEAVE("no window widget available");
2381  return;
2382  }
2383 
2384  /* Update the notebook tab tooltip */
2385  if (main_window_find_tab_widget (window, page, &tab_widget))
2386  gtk_widget_set_tooltip_text (tab_widget, long_name);
2387 
2388  g_free (long_name);
2389  LEAVE("");
2390 }
const gchar * gnc_plugin_page_get_page_long_name(GncPluginPage *page)
Retrieve the long 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
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

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

2395 {
2396  GncMainWindow *window;
2397  GncMainWindowPrivate *priv;
2398  GtkWidget *label, *entry;
2399  gchar *name;
2400  TabWidth *tw;
2401 
2402  ENTER(" ");
2403 
2404  if ((name_in == nullptr) || (*name_in == '\0'))
2405  {
2406  LEAVE("no string");
2407  return;
2408  }
2409  name = g_strstrip(g_strdup(name_in));
2410 
2411  /* Optimization, if the name hasn't changed, don't update X. */
2412  if (*name == '\0' || 0 == strcmp(name, gnc_plugin_page_get_page_name(page)))
2413  {
2414  g_free(name);
2415  LEAVE("empty string or name unchanged");
2416  return;
2417  }
2418 
2419  /* Update the plugin */
2420  gnc_plugin_page_set_page_name(page, name);
2421 
2422  /* Update the notebook tab */
2423  window = GNC_MAIN_WINDOW(page->window);
2424  if (!window)
2425  {
2426  g_free(name);
2427  LEAVE("no window widget available");
2428  return;
2429  }
2430 
2431  if (main_window_find_tab_items(window, page, &label, &entry))
2432  gtk_label_set_text(GTK_LABEL(label), name);
2433 
2434  /* Adjust the label width for new text */
2435  tw = populate_tab_width_struct ();
2436  gnc_main_window_update_tab_width_one_page (page, tw);
2437  g_free (tw);
2438 
2439  /* Update the notebook menu */
2440  if (page->notebook_page)
2441  {
2442  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
2443  label = gtk_notebook_get_menu_label (GTK_NOTEBOOK(priv->notebook),
2444  page->notebook_page);
2445  gtk_label_set_text(GTK_LABEL(label), name);
2446  }
2447 
2448  /* Force an update of the window title */
2449  gnc_main_window_update_title(window);
2450  g_free(name);
2451  LEAVE("done");
2452 }
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.
#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.
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 2530 of file gnc-main-window.cpp.

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