GnuCash  4.11-517-g41de4cefce
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 GtkRadioAction, and us 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  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
 

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, 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_WINDOW, G_IMPLEMENT_INTERFACE(GNC_TYPE_WINDOW, gnc_window_main_window_init)) typedef struct
 This data structure maintains information about one action groups that has been installed in this window. 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)
 
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, GtkActionGroup *group, guint merge_id)
 Manually add a set of actions to the specified window. More...
 
void gnc_main_window_merge_actions (GncMainWindow *window, const gchar *group_name, GtkActionEntry *entries, guint n_entries, GtkToggleActionEntry *toggle_entries, guint n_toggle_entries, const gchar *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...
 
void gnc_main_window_actions_updated (GncMainWindow *window)
 Force a full update of the user interface for the specified window. More...
 
GtkAction * gnc_main_window_find_action (GncMainWindow *window, const gchar *name)
 Find action in main window. More...
 
GtkActionGroup * gnc_main_window_get_action_group (GncMainWindow *window, const gchar *group_name)
 Retrieve a specific set of user interface actions from a window. 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...
 
GtkUIManager * gnc_main_window_get_uimanager (GncMainWindow *window)
 Returns the pointer to the GtkUIManager which is used for the menu item merging. More...
 
GType gnc_main_window_get_type (void)
 Get the type of a gnc main window. More...
 

Variables

 MergedActionEntry
 

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

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Names of signals generated by the main window.

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

95 {
96  PAGE_ADDED,
97  PAGE_CHANGED,
98  LAST_SIGNAL
99 };

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

4289 {
4290  QofBook *book = gnc_get_current_book ();
4291  gboolean use_split_action_for_num_before =
4293  gint use_read_only_threshold_before =
4295  gboolean use_split_action_for_num_after;
4296  gint use_read_only_threshold_after;
4297  gboolean return_val = FALSE;
4298  GList *results = nullptr, *iter;
4299 
4300  if (!options) return return_val;
4301 
4302  results = gnc_option_db_commit (options);
4303  for (iter = results; iter; iter = iter->next)
4304  {
4305  GtkWidget *dialog = gtk_message_dialog_new(gnc_ui_get_main_window (nullptr),
4306  (GtkDialogFlags)0,
4307  GTK_MESSAGE_ERROR,
4308  GTK_BUTTONS_OK,
4309  "%s",
4310  (char*)iter->data);
4311  gtk_dialog_run(GTK_DIALOG(dialog));
4312  gtk_widget_destroy(dialog);
4313  g_free (iter->data);
4314  }
4315  g_list_free (results);
4316  qof_book_begin_edit (book);
4317  qof_book_save_options (book, gnc_option_db_save, options, TRUE);
4318  use_split_action_for_num_after =
4320 
4321  // mark cached value as invalid so we get new value
4322  book->cached_num_days_autoreadonly_isvalid = FALSE;
4323  use_read_only_threshold_after = qof_book_get_num_days_autoreadonly (book);
4324 
4325  if (use_split_action_for_num_before != use_split_action_for_num_after)
4326  {
4328  use_split_action_for_num_after);
4329  return_val = TRUE;
4330  }
4331  if (use_read_only_threshold_before != use_read_only_threshold_after)
4332  return_val = TRUE;
4333 
4334  qof_book_commit_edit (book);
4335  return return_val;
4336 }
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:972
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:1166
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 4394 of file gnc-main-window.cpp.

4395 {
4396  auto book = gnc_get_current_book ();
4397 
4398  auto options = gnc_option_db_new();
4399  gnc_option_db_book_options(options);
4400  qof_book_load_options (book, gnc_option_db_load, options);
4401  gnc_option_db_clean (options);
4402 
4403  /* Only allow one Book Options dialog if called from file->properties
4404  menu */
4405  if (gnc_forall_gui_components(DIALOG_BOOK_OPTIONS_CM_CLASS,
4406  show_handler, nullptr))
4407  {
4408  return nullptr;
4409  }
4410  auto optionwin = new GncOptionsDialog (modal,
4411  (title ? title : _( "Book Options")),
4412  DIALOG_BOOK_OPTIONS_CM_CLASS, parent);
4413  optionwin->build_contents(options);
4414  optionwin->set_book_help_cb();
4415  optionwin->set_apply_cb(gnc_book_options_dialog_apply_cb,
4416  (gpointer)options);
4417  optionwin->set_close_cb ( gnc_book_options_dialog_close_cb,
4418  (gpointer)options);
4419  if (modal)
4421  return optionwin->get_widget();
4422 }
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:1160
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_WINDOW  ,
G_IMPLEMENT_INTERFACE(GNC_TYPE_WINDOW, gnc_window_main_window_init)   
)

This data structure maintains information about one action groups that has been installed in this window.

The merge identifier for this action group. This number is provided by the UI manager.
The action group itself. This contains all actions added by a single menu or content plugin.

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

271 {
274  guint merge_id;
277  GtkActionGroup *action_group;
278 } MergedActionEntry;

◆ gnc_main_window_actions_updated()

void gnc_main_window_actions_updated ( GncMainWindow window)

Force a full update of the user interface for the specified window.

This can be an expensive function, but is needed because the gtk ui manager doesn't always seem to update properly when actions are changed.

Parameters
windowA pointer to the window whose user interface should be updated.
Attention
Is this function still needed?

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

3590 {
3591  GtkActionGroup *force;
3592 
3593  g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
3594 
3595  /* Unfortunately gtk_ui_manager_ensure_update doesn't work
3596  * here. Force a full update by adding and removing an empty
3597  * action group.
3598  */
3599  force = gtk_action_group_new("force_update");
3600  gtk_ui_manager_insert_action_group (window->ui_merge, force, 0);
3601  gtk_ui_manager_ensure_update (window->ui_merge);
3602  gtk_ui_manager_remove_action_group (window->ui_merge, force);
3603  g_object_unref(force);
3604 }

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

5212 {
5213  for (auto tmp = active_windows; tmp; tmp = g_list_next(tmp))
5214  {
5215  auto action{gnc_main_window_find_action (static_cast<GncMainWindow*>(tmp->data), action_name)};
5216  gtk_action_set_sensitive (action, sensitive);
5217  }
5218 }
GtkAction * gnc_main_window_find_action(GncMainWindow *window, const gchar *name)
Find action in 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 1196 of file gnc-main-window.cpp.

1197 {
1198  const GList *windows, *item;
1199 
1200  windows = gnc_gobject_tracking_get_list(GNC_MAIN_WINDOW_NAME);
1201  for (item = windows; item; item = g_list_next(item))
1202  {
1203  if (!gnc_main_window_finish_pending(static_cast<GncMainWindow*>(item->data)))
1204  {
1205  return FALSE;
1206  }
1207  }
1208  if (gnc_gui_refresh_suspended ())
1209  {
1210  gnc_warning_dialog (nullptr, "%s", "An operation is still running, wait for it to complete before quitting.");
1211  return FALSE;
1212  }
1213  return TRUE;
1214 }
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 5190 of file gnc-main-window.cpp.

5193 {
5194  g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), FALSE);
5195 
5196  ENTER("widget %p, event %p, page %p", whatever, event, page);
5197  /* Ignore double-clicks and triple-clicks */
5198  if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
5199  {
5200  do_popup_menu(page, event);
5201  LEAVE("menu shown");
5202  return TRUE;
5203  }
5204 
5205  LEAVE("other click");
5206  return FALSE;
5207 }
#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 3394 of file gnc-main-window.cpp.

3395 {
3396  GncMainWindow *window;
3397  GncMainWindowPrivate *priv;
3398 
3399  if (!page || !page->notebook_page)
3400  return;
3401 
3402  if (!gnc_plugin_page_finish_pending(page))
3403  return;
3404 
3405  if (!GNC_IS_MAIN_WINDOW (page->window))
3406  return;
3407 
3408  window = GNC_MAIN_WINDOW (page->window);
3409  if (!window)
3410  {
3411  g_warning("Page is not in a window.");
3412  return;
3413  }
3414 
3415  gnc_main_window_disconnect(window, page);
3417  g_object_unref(page);
3418 
3419  /* If this isn't the last window, go ahead and destroy the window. */
3420  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3421  if (priv->installed_pages == nullptr)
3422  {
3423  if (window->window_quitting)
3424  {
3426  GList *plugins = gnc_plugin_manager_get_plugins (manager);
3427 
3428  /* remove only the preference callbacks from the window plugins */
3429  window->just_plugin_prefs = TRUE;
3430  g_list_foreach (plugins, gnc_main_window_remove_plugin, window);
3431  window->just_plugin_prefs = FALSE;
3432  g_list_free (plugins);
3433 
3434  /* remove the preference callbacks from the main window */
3435  gnc_main_window_remove_prefs (window);
3436  }
3437  if (window && (gnc_list_length_cmp (active_windows, 1) > 0))
3438  gtk_widget_destroy (GTK_WIDGET(window));
3439  }
3440 }
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 3217 of file gnc-main-window.cpp.

3218 {
3219  GncMainWindow *window;
3220  GncMainWindowPrivate *priv;
3221  GtkNotebook *notebook;
3222  gint page_num;
3223 
3224  window = GNC_MAIN_WINDOW (page->window);
3225  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3226  notebook = GTK_NOTEBOOK (priv->notebook);
3227  page_num = gtk_notebook_page_num(notebook, page->notebook_page);
3228  gtk_notebook_set_current_page (notebook, page_num);
3229  gtk_window_present(GTK_WINDOW(window));
3230 }
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()

GtkAction * gnc_main_window_find_action ( GncMainWindow window,
const gchar *  name 
)

Find action in main window.

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

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

3609 {
3610  GtkAction *action = nullptr;
3611  const GList *groups, *tmp;
3612 
3613  groups = gtk_ui_manager_get_action_groups(window->ui_merge);
3614  for (tmp = groups; tmp; tmp = g_list_next(tmp))
3615  {
3616  action = gtk_action_group_get_action(GTK_ACTION_GROUP(tmp->data), name);
3617  if (action)
3618  break;
3619  }
3620  return action;
3621 }

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

1177 {
1178  GncMainWindowPrivate *priv;
1179  GList *item;
1180 
1181  g_return_val_if_fail(GNC_IS_MAIN_WINDOW(window), TRUE);
1182 
1183  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
1184  for (item = priv->installed_pages; item; item = g_list_next(item))
1185  {
1186  if (!gnc_plugin_page_finish_pending(static_cast<GncPluginPage*>(item->data)))
1187  {
1188  return FALSE;
1189  }
1190  }
1191  return TRUE;
1192 }
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_get_action_group()

GtkActionGroup * 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 GtkActionGroup that was added with the specified name. If the name cannot be found, then NULL will be returned.

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

3631 {
3632  GncMainWindowPrivate *priv;
3633 
3634  g_return_val_if_fail (GNC_IS_MAIN_WINDOW (window), nullptr);
3635  g_return_val_if_fail (group_name != nullptr, nullptr);
3636 
3637  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3638  if (priv->merged_actions_table == nullptr)
3639  return nullptr;
3640  auto entry{static_cast<MergedActionEntry *>(g_hash_table_lookup (priv->merged_actions_table, group_name))};
3641 
3642  if (entry == nullptr)
3643  return nullptr;
3644 
3645  return entry->action_group;
3646 }
The instance private data structure for an embedded window object.
GHashTable * merged_actions_table
A hash table of all action groups that have been installed into this window.

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

3452 {
3453  GncMainWindowPrivate *priv;
3454 
3455  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3456  return priv->current_page;
3457 }
The instance private data structure for an embedded window object.
GncPluginPage * current_page
The currently selected page.

◆ 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_get_uimanager()

GtkUIManager * gnc_main_window_get_uimanager ( GncMainWindow window)

Returns the pointer to the GtkUIManager which is used for the menu item merging.

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

5221 {
5222  g_assert(window);
5223  return window->ui_merge;
5224 }

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

585 {
586  GncMainWindowPrivate *priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
587  return priv->restoring_pages;
588 }
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,
GtkActionGroup *  group,
guint  merge_id 
)

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 an array of GtkActions. These are the actions that will be added to the user interface.
merge_idA merge identifier retrieved from a call to gtk_ui_manager_new_merge_id().

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

3470 {
3471  GncMainWindowPrivate *priv;
3472  MergedActionEntry *entry;
3473 
3474  g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
3475  g_return_if_fail (group_name != nullptr);
3476  g_return_if_fail (GTK_IS_ACTION_GROUP(group));
3477  g_return_if_fail (merge_id > 0);
3478 
3479  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3480  entry = g_new0 (MergedActionEntry, 1);
3481  entry->action_group = group;
3482  entry->merge_id = merge_id;
3483  gtk_ui_manager_ensure_update (window->ui_merge);
3484  g_hash_table_insert (priv->merged_actions_table, g_strdup (group_name), entry);
3485 }
The instance private data structure for an embedded window object.
GHashTable * merged_actions_table
A hash table of all action groups that have been installed into this window.

◆ gnc_main_window_merge_actions()

void gnc_main_window_merge_actions ( GncMainWindow window,
const gchar *  group_name,
GtkActionEntry *  entries,
guint  n_entries,
GtkToggleActionEntry *  toggle_entries,
guint  n_toggle_entries,
const gchar *  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 GtkActionEntry. These are the actions that will be added to the user interface.
n_entriesThe number of actions in the array.
toggle_entriesA pointer to an array of GtkToggleActionEntry. These are the toggle actions that will be added to the user interface.
n_toggle_entriesThe number of toggle 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 3495 of file gnc-main-window.cpp.

3503 {
3504  GncMainWindowPrivate *priv;
3506  GError *error = nullptr;
3507  gchar *pathname;
3508 
3509  g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
3510  g_return_if_fail (group_name != nullptr);
3511  g_return_if_fail (actions != nullptr);
3512  g_return_if_fail (n_actions > 0);
3513  g_return_if_fail (filename != nullptr);
3514 
3515  pathname = gnc_filepath_locate_ui_file (filename);
3516  if (pathname == nullptr)
3517  return;
3518 
3519  data = g_new0 (GncMainWindowActionData, 1);
3520  data->window = window;
3521  data->data = user_data;
3522 
3523  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3524  auto entry{static_cast<MergedActionEntry*>(g_new0 (MergedActionEntry, 1))};
3525  entry->action_group = gtk_action_group_new (group_name);
3526  gtk_action_group_set_translation_domain (entry->action_group, PROJECT_NAME);
3527  gtk_action_group_add_actions (entry->action_group, actions, n_actions, data);
3528  if (toggle_actions != nullptr && n_toggle_actions > 0)
3529  {
3530  gtk_action_group_add_toggle_actions (entry->action_group,
3531  toggle_actions, n_toggle_actions,
3532  data);
3533  }
3534  gtk_ui_manager_insert_action_group (window->ui_merge, entry->action_group, 0);
3535  entry->merge_id = gtk_ui_manager_add_ui_from_file (window->ui_merge, pathname, &error);
3536  g_assert(entry->merge_id || error);
3537  if (entry->merge_id)
3538  {
3539  gtk_ui_manager_ensure_update (window->ui_merge);
3540  g_hash_table_insert (priv->merged_actions_table, g_strdup (group_name), entry);
3541  }
3542  else
3543  {
3544  g_critical("Failed to load ui file.\n Filename %s\n Error %s",
3545  filename, error->message);
3546  g_error_free(error);
3547  g_free(entry);
3548  }
3549  g_free(pathname);
3550 }
gchar * gnc_filepath_locate_ui_file(const gchar *name)
Given a ui file name, find the file in the ui directory associated with this application.
The instance private data structure for an embedded window object.
GHashTable * merged_actions_table
A hash table of all action groups that have been installed into this window.

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

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

3243 {
3244  GncMainWindowPrivate *priv;
3245  GtkWidget *tab_hbox;
3246  GtkWidget *label, *entry;
3247  const gchar *icon, *text, *color_string, *lab_text;
3248  GtkWidget *image;
3249  GList *tmp;
3250  TabWidth *tw;
3251 
3252  ENTER("window %p, page %p", window, page);
3253  if (window)
3254  g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
3255  g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
3256  g_return_if_fail (gnc_plugin_page_has_books(page));
3257 
3258  if (gnc_main_window_page_exists(page))
3259  {
3261  return;
3262  }
3263 
3264  /* Does the page want to be in a new window? */
3266  {
3267  /* See if there's a blank window. If so, use that. */
3268  for (tmp = active_windows; tmp; tmp = g_list_next(tmp))
3269  {
3270  window = GNC_MAIN_WINDOW(tmp->data);
3271  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3272  if (priv->installed_pages == nullptr)
3273  {
3274  break;
3275  }
3276  }
3277  if (tmp == nullptr)
3278  window = gnc_main_window_new ();
3279  gtk_widget_show(GTK_WIDGET(window));
3280  }
3281  else if ((window == nullptr) && active_windows)
3282  {
3283  window = static_cast<GncMainWindow*>(active_windows->data);
3284  }
3285 
3286  page->window = GTK_WIDGET(window);
3288  g_object_set_data (G_OBJECT (page->notebook_page),
3289  PLUGIN_PAGE_LABEL, page);
3290 
3291  /*
3292  * The page tab.
3293  */
3294  icon = GNC_PLUGIN_PAGE_GET_CLASS(page)->tab_icon;
3295  lab_text = gnc_plugin_page_get_page_name(page);
3296  label = gtk_label_new (lab_text);
3297  g_object_set_data (G_OBJECT (page), PLUGIN_PAGE_TAB_LABEL, label);
3298 
3299  tw = populate_tab_width_struct ();
3300  gnc_main_window_update_tab_width_one_page (page, tw);
3301  g_free (tw);
3302 
3303  gtk_widget_show (label);
3304 
3305  tab_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
3306 
3307  if (g_strcmp0 (gnc_plugin_page_get_plugin_name (page), "GncPluginPageAccountTree") == 0)
3308  gtk_widget_set_name (GTK_WIDGET(tab_hbox), "gnc-id-account-page-tab-box");
3309 
3310  gtk_box_set_homogeneous (GTK_BOX (tab_hbox), FALSE);
3311  gtk_widget_show (tab_hbox);
3312 
3313  if (icon != nullptr)
3314  {
3315  image = gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_MENU);
3316  gtk_widget_show (image);
3317  gtk_box_pack_start (GTK_BOX (tab_hbox), image, FALSE, FALSE, 0);
3318  gtk_widget_set_margin_start (GTK_WIDGET(image), 5);
3319  gtk_box_pack_start (GTK_BOX (tab_hbox), label, TRUE, TRUE, 0);
3320  }
3321  else
3322  gtk_box_pack_start (GTK_BOX (tab_hbox), label, TRUE, TRUE, 0);
3323 
3325  if (text)
3326  {
3327  gtk_widget_set_tooltip_text(tab_hbox, text);
3328  }
3329 
3330  entry = gtk_entry_new();
3331  gtk_widget_hide (entry);
3332  gtk_box_pack_start (GTK_BOX (tab_hbox), entry, TRUE, TRUE, 0);
3333  g_signal_connect(G_OBJECT(entry), "activate",
3334  G_CALLBACK(gnc_main_window_tab_entry_activate), page);
3335  g_signal_connect(G_OBJECT(entry), "focus-out-event",
3336  G_CALLBACK(gnc_main_window_tab_entry_focus_out_event),
3337  page);
3338  g_signal_connect(G_OBJECT(entry), "key-press-event",
3339  G_CALLBACK(gnc_main_window_tab_entry_key_press_event),
3340  page);
3341  g_signal_connect(G_OBJECT(entry), "editing-done",
3342  G_CALLBACK(gnc_main_window_tab_entry_editing_done),
3343  page);
3344 
3345  /* Add close button - Not for immutable pages */
3346  if (!g_object_get_data (G_OBJECT (page), PLUGIN_PAGE_IMMUTABLE))
3347  {
3348  GtkWidget *close_image, *close_button;
3349  GtkRequisition requisition;
3350 
3351  close_button = gtk_button_new();
3352  gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE);
3353  close_image = gtk_image_new_from_icon_name ("window-close", GTK_ICON_SIZE_MENU);
3354  gtk_widget_show(close_image);
3355  gtk_widget_get_preferred_size (close_image, &requisition, nullptr);
3356  gtk_widget_set_size_request(close_button, requisition.width + 4,
3357  requisition.height + 2);
3358  gtk_container_add(GTK_CONTAINER(close_button), close_image);
3359  if (gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_SHOW_CLOSE_BUTTON))
3360  gtk_widget_show (close_button);
3361  else
3362  gtk_widget_hide (close_button);
3363 
3364  g_signal_connect_swapped (G_OBJECT (close_button), "clicked",
3365  G_CALLBACK(gnc_main_window_close_page), page);
3366 
3367  gtk_box_pack_start (GTK_BOX (tab_hbox), close_button, FALSE, FALSE, 0);
3368  gtk_widget_set_margin_end (GTK_WIDGET(close_button), 5);
3369  g_object_set_data (G_OBJECT (page), PLUGIN_PAGE_CLOSE_BUTTON, close_button);
3370  }
3371 
3372  /*
3373  * The popup menu
3374  */
3375  label = gtk_label_new (gnc_plugin_page_get_page_name(page));
3376 
3377  /*
3378  * Now install it all in the window.
3379  */
3380  gnc_main_window_connect(window, page, tab_hbox, label);
3381 
3382  color_string = gnc_plugin_page_get_page_color(page);
3383  main_window_update_page_color (page, color_string);
3384  LEAVE("");
3385 }
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 5175 of file gnc-main-window.cpp.

5177 {
5178  ENTER("widget %p, page %p", widget, page);
5179  do_popup_menu(page, nullptr);
5180  LEAVE(" ");
5181  return TRUE;
5182 }
#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 976 of file gnc-main-window.cpp.

977 {
978  gint i, window_count;
979  GError *error = nullptr;
981 
982  /* We use the same struct for reading and for writing, so we cast
983  away the const. */
984  data.key_file = (GKeyFile *) keyfile;
985  window_count = g_key_file_get_integer(data.key_file, STATE_FILE_TOP,
986  WINDOW_COUNT, &error);
987  if (error)
988  {
989  g_warning("error reading group %s key %s: %s",
990  STATE_FILE_TOP, WINDOW_COUNT, error->message);
991  g_error_free(error);
992  LEAVE("can't read count");
993  return;
994  }
995 
996  /* Restore all state information on the open windows. Window
997  numbers in state file are 1-based. GList indices are 0-based. */
998  gnc_set_busy_cursor (nullptr, TRUE);
999  for (i = 0; i < window_count; i++)
1000  {
1001  data.window_num = i;
1002  auto window{static_cast<GncMainWindow*>(g_list_nth_data(active_windows,
1003  i))};
1004  gnc_main_window_restore_window(window, &data);
1005  }
1006  gnc_unset_busy_cursor (nullptr);
1007 
1008  statusbar_notification_lastmodified();
1009 }
#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 1158 of file gnc-main-window.cpp.

1159 {
1160  GncMainWindowSaveData data;
1161 
1162  /* Set up the iterator data structures */
1163  data.key_file = keyfile;
1164  data.window_num = 1;
1165  data.page_num = 1;
1166 
1167  g_key_file_set_integer(data.key_file,
1168  STATE_FILE_TOP, WINDOW_COUNT,
1169  g_list_length(active_windows));
1170  /* Dump all state information on the open windows */
1171  g_list_foreach(active_windows, (GFunc)gnc_main_window_save_window, &data);
1172 }

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

5114 {
5115  GncWindow *gncwin;
5116  gncwin = GNC_WINDOW(window);
5117  gnc_window_set_progressbar_window(gncwin);
5118 }

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

3561 {
3562  GncMainWindowPrivate *priv;
3563 
3564  g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
3565  g_return_if_fail (group_name != nullptr);
3566 
3567  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3568  if (priv->merged_actions_table == nullptr)
3569  return;
3570  auto entry{static_cast<MergedActionEntry *>(g_hash_table_lookup (priv->merged_actions_table, group_name))};
3571 
3572  if (entry == nullptr)
3573  return;
3574 
3575  gtk_ui_manager_remove_action_group (window->ui_merge, entry->action_group);
3576  gtk_ui_manager_remove_ui (window->ui_merge, entry->merge_id);
3577  gtk_ui_manager_ensure_update (window->ui_merge);
3578 
3579  g_hash_table_remove (priv->merged_actions_table, group_name);
3580 }
The instance private data structure for an embedded window object.
GHashTable * merged_actions_table
A hash table of all action groups that have been installed into this window.

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

4980 {
4981  GtkWidget *toplevel;
4982 
4983  if (!widget)
4984  return nullptr;
4985 
4986  toplevel = gtk_widget_get_toplevel (widget);
4987  if (toplevel && GTK_IS_WINDOW (toplevel))
4988  return GTK_WINDOW (toplevel);
4989  else
4990  return nullptr;
4991 }

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

4995 {
4996  GList *window;
4997 
4998  GtkWindow *toplevel = gnc_ui_get_gtk_window (widget);
4999  while (toplevel && !GNC_IS_MAIN_WINDOW (toplevel))
5000  toplevel = gtk_window_get_transient_for(toplevel);
5001 
5002  if (toplevel)
5003  return toplevel;
5004 
5005  for (window = active_windows; window; window = window->next)
5006  if (gtk_window_is_active (GTK_WINDOW (window->data)))
5007  return static_cast<GtkWindow*>(window->data);
5008 
5009  for (window = active_windows; window; window = window->next)
5010  if (gtk_widget_get_mapped (GTK_WIDGET(window->data)))
5011  return static_cast<GtkWindow*>(window->data);
5012 
5013  return nullptr;
5014 }
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 2477 of file gnc-main-window.cpp.

2479 {
2480  GncMainWindow *window;
2481  GncMainWindowPrivate *priv;
2482  GtkWidget *tab_widget;
2483  GdkRGBA tab_color;
2484  gchar *color_string = nullptr;
2485  gboolean want_color = FALSE;
2486 
2487  ENTER(" ");
2488  if (color_in)
2489  color_string = g_strstrip(g_strdup(color_in));
2490 
2491  if (color_string && *color_string != '\0')
2492  want_color = TRUE;
2493 
2494  /* Update the plugin */
2495  window = GNC_MAIN_WINDOW(page->window);
2496  if (want_color)
2497  gnc_plugin_page_set_page_color(page, color_string);
2498  else
2499  gnc_plugin_page_set_page_color(page, nullptr);
2500 
2501  /* Update the notebook tab */
2502  main_window_find_tab_widget (window, page, &tab_widget);
2503  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
2504 
2505  if (want_color && gdk_rgba_parse(&tab_color, color_string) && priv->show_color_tabs)
2506  {
2507  GtkCssProvider *provider = gtk_css_provider_new();
2508  GtkStyleContext *stylectxt;
2509  gchar *col_str, *widget_css;
2510 
2511  if (!GTK_IS_EVENT_BOX (tab_widget))
2512  {
2513  GtkWidget *event_box = gtk_event_box_new ();
2514  g_object_ref (tab_widget);
2515  gtk_notebook_set_tab_label (GTK_NOTEBOOK(priv->notebook),
2516  page->notebook_page, event_box);
2517  gtk_container_add (GTK_CONTAINER(event_box), tab_widget);
2518  g_object_unref (tab_widget);
2519  tab_widget = event_box;
2520  }
2521 
2522  stylectxt = gtk_widget_get_style_context (GTK_WIDGET (tab_widget));
2523  col_str = gdk_rgba_to_string (&tab_color);
2524  widget_css = g_strconcat ("*{\n background-color:", col_str, ";\n}\n", nullptr);
2525 
2526  gtk_css_provider_load_from_data (provider, widget_css, -1, nullptr);
2527  gtk_style_context_add_provider (stylectxt, GTK_STYLE_PROVIDER (provider),
2528  GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
2529  g_object_unref (provider);
2530  g_free (col_str);
2531  g_free (widget_css);
2532  }
2533  else
2534  {
2535  if (GTK_IS_EVENT_BOX (tab_widget))
2536  {
2537  GtkWidget *tab_hbox = gtk_bin_get_child(GTK_BIN(tab_widget));
2538  g_object_ref (tab_hbox);
2539  gtk_container_remove (GTK_CONTAINER(tab_widget), tab_hbox);
2540  gtk_notebook_set_tab_label (GTK_NOTEBOOK(priv->notebook),
2541  page->notebook_page, tab_hbox);
2542  g_object_unref (tab_hbox);
2543  }
2544  }
2545  g_free(color_string);
2546  LEAVE("done");
2547 }
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 2388 of file gnc-main-window.cpp.

2390 {
2391  GncMainWindow *window;
2392  GncMainWindowPrivate *priv;
2393  GtkWidget *label, *entry;
2394  gchar *name, *old_page_name, *old_page_long_name;
2395  TabWidth *tw;
2396 
2397  ENTER(" ");
2398 
2399  if ((name_in == nullptr) || (*name_in == '\0'))
2400  {
2401  LEAVE("no string");
2402  return;
2403  }
2404  name = g_strstrip(g_strdup(name_in));
2405 
2406  /* Optimization, if the name hasn't changed, don't update X. */
2407  if (*name == '\0' || 0 == strcmp(name, gnc_plugin_page_get_page_name(page)))
2408  {
2409  g_free(name);
2410  LEAVE("empty string or name unchanged");
2411  return;
2412  }
2413 
2414  old_page_name = g_strdup( gnc_plugin_page_get_page_name(page));
2415  old_page_long_name = g_strdup( gnc_plugin_page_get_page_long_name(page));
2416 
2417  /* Update the plugin */
2418  gnc_plugin_page_set_page_name(page, name);
2419 
2420  /* Update the notebook tab */
2421  window = GNC_MAIN_WINDOW(page->window);
2422  if (!window)
2423  {
2424  g_free(old_page_name);
2425  g_free(old_page_long_name);
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 Tooltip on notebook Tab */
2440  if (old_page_long_name && old_page_name
2441  && g_strrstr(old_page_long_name, old_page_name) != nullptr)
2442  {
2443  gchar *new_page_long_name;
2444  gint string_position;
2445  GtkWidget *tab_widget;
2446 
2447  string_position = strlen(old_page_long_name) - strlen(old_page_name);
2448  new_page_long_name = g_strconcat(g_strndup(old_page_long_name, string_position), name, nullptr);
2449 
2450  gnc_plugin_page_set_page_long_name(page, new_page_long_name);
2451 
2452  if (main_window_find_tab_widget(window, page, &tab_widget))
2453  gtk_widget_set_tooltip_text(tab_widget, new_page_long_name);
2454 
2455  g_free(new_page_long_name);
2456  }
2457 
2458  /* Update the notebook menu */
2459  if (page->notebook_page)
2460  {
2461  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
2462  label = gtk_notebook_get_menu_label (GTK_NOTEBOOK(priv->notebook),
2463  page->notebook_page);
2464  gtk_label_set_text(GTK_LABEL(label), name);
2465  }
2466 
2467  /* Force an update of the window title */
2468  gnc_main_window_update_title(window);
2469  g_free(old_page_long_name);
2470  g_free(old_page_name);
2471  g_free(name);
2472  LEAVE("done");
2473 }
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 2551 of file gnc-main-window.cpp.

2553 {
2554  GncMainWindow *window;
2555  GncMainWindowPrivate *priv;
2556  GtkWidget *tab_widget;
2557  GtkWidget *image = NULL;
2558  GList *children;
2559  gchar *image_name = NULL;
2560  const gchar *icon_name;
2561 
2562  ENTER(" ");
2563 
2564  g_return_if_fail (page && page->window);
2565 
2566  if (!GNC_IS_MAIN_WINDOW (page->window))
2567  return;
2568 
2569  window = GNC_MAIN_WINDOW(page->window);
2570 
2571  /* Get the notebook tab widget */
2572  main_window_find_tab_widget (window, page, &tab_widget);
2573  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
2574 
2575  if (!tab_widget)
2576  {
2577  LEAVE("no tab widget");
2578  return;
2579  }
2580 
2581  if (GTK_IS_EVENT_BOX(tab_widget))
2582  tab_widget = gtk_bin_get_child (GTK_BIN(tab_widget));
2583 
2584  children = gtk_container_get_children (GTK_CONTAINER(tab_widget));
2585  /* For each, walk the list of container children to get image widget */
2586  for (GList *child = children; child; child = g_list_next (child))
2587  {
2588  GtkWidget *widget = static_cast<GtkWidget*>(child->data);
2589  if (GTK_IS_IMAGE(widget))
2590  image = widget;
2591  }
2592  g_list_free (children);
2593 
2594  if (!image)
2595  {
2596  LEAVE("no image to replace");
2597  return;
2598  }
2599 
2600  g_object_get (image, "icon-name", &image_name, NULL);
2601 
2602  if (read_only)
2603  icon_name = "changes-prevent-symbolic";
2604  else
2605  icon_name = GNC_PLUGIN_PAGE_GET_CLASS(page)->tab_icon;
2606 
2607  if (g_strcmp0 (icon_name, image_name) == 0)
2608  {
2609  LEAVE("page icon the same, no need to replace");
2610  g_free (image_name);
2611  return;
2612  }
2613  gtk_container_remove (GTK_CONTAINER(tab_widget), image);
2614  image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
2615  gtk_widget_show (image);
2616 
2617  gtk_container_add (GTK_CONTAINER(tab_widget), image);
2618  gtk_widget_set_margin_start (GTK_WIDGET(image), 5);
2619  gtk_box_reorder_child (GTK_BOX(tab_widget), image, 0);
2620 
2621  g_free (image_name);
2622  LEAVE("done");
2623 }
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.