GnuCash  4.11-11-ge9df8d41d2+
Files | Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
Main Window functions.

Files

file  gnc-main-window.c
 Functions for adding content to a window.
 
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  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

 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. 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...
 
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...
 
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.
 
void gnc_book_option_book_currency_selected_cb (gboolean use_book_currency)
 Calls gnc_book_option_book_currency_selected to initiate registered callbacks when currency accounting book option changes to book-currency 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 98 of file gnc-main-window.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Names of signals generated by the main window.

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

90 {
91  PAGE_ADDED,
92  PAGE_CHANGED,
93  LAST_SIGNAL
94 };

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 4176 of file gnc-main-window.c.

4177 {
4178  QofBook *book = gnc_get_current_book ();
4179  gboolean use_split_action_for_num_before =
4181  gboolean use_book_currency_before =
4183  gint use_read_only_threshold_before =
4185  gboolean use_split_action_for_num_after;
4186  gboolean use_book_currency_after;
4187  gint use_read_only_threshold_after;
4188  gboolean return_val = FALSE;
4189  GList *results = NULL, *iter;
4190 
4191  if (!options) return return_val;
4192 
4193  results = gnc_option_db_commit (options);
4194  for (iter = results; iter; iter = iter->next)
4195  {
4196  GtkWidget *dialog = gtk_message_dialog_new(gnc_ui_get_main_window (NULL),
4197  0,
4198  GTK_MESSAGE_ERROR,
4199  GTK_BUTTONS_OK,
4200  "%s",
4201  (char*)iter->data);
4202  gtk_dialog_run(GTK_DIALOG(dialog));
4203  gtk_widget_destroy(dialog);
4204  g_free (iter->data);
4205  }
4206  g_list_free (results);
4207  qof_book_begin_edit (book);
4208  qof_book_save_options (book, gnc_option_db_save, options, TRUE);
4209  use_split_action_for_num_after =
4211  use_book_currency_after = gnc_book_use_book_currency (book);
4212 
4213  // mark cached value as invalid so we get new value
4214  book->cached_num_days_autoreadonly_isvalid = FALSE;
4215  use_read_only_threshold_after = qof_book_get_num_days_autoreadonly (book);
4216 
4217  if (use_split_action_for_num_before != use_split_action_for_num_after)
4218  {
4220  use_split_action_for_num_after);
4221  return_val = TRUE;
4222  }
4223  if (use_book_currency_before != use_book_currency_after)
4224  {
4225  gnc_book_option_book_currency_selected_cb (use_book_currency_after);
4226  return_val = TRUE;
4227  }
4228  if (use_read_only_threshold_before != use_read_only_threshold_after)
4229  return_val = TRUE;
4230 
4231  qof_book_commit_edit (book);
4232  return return_val;
4233 }
gboolean gnc_book_use_book_currency(QofBook *book)
Returns TRUE if both book-currency and default gain/loss policy KVPs exist and are valid and trading ...
Definition: gnc-ui-util.c:446
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:1092
gboolean qof_book_use_split_action_for_num_field(const QofBook *book)
Returns TRUE if this book uses split action field as the 'Num' field, FALSE if it uses transaction nu...
void gnc_book_option_num_field_source_change_cb(gboolean num_action)
Calls gnc_book_option_num_field_source_change to initiate registered callbacks when num_field_source ...
void gnc_book_option_book_currency_selected_cb(gboolean use_book_currency)
Calls gnc_book_option_book_currency_selected to initiate registered callbacks when currency accountin...
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:1265

◆ 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 4312 of file gnc-main-window.c.

4313 {
4314  QofBook *book = gnc_get_current_book ();
4315  GNCOptionDB *options;
4316  GNCOptionWin *optionwin;
4317 
4318  options = gnc_option_db_new_for_type (QOF_ID_BOOK);
4319  qof_book_load_options (book, gnc_option_db_load, options);
4320  gnc_option_db_clean (options);
4321 
4322  /* Only allow one Book Options dialog if called from file->properties
4323  menu */
4324  if (gnc_forall_gui_components(DIALOG_BOOK_OPTIONS_CM_CLASS,
4325  show_handler, NULL))
4326  {
4327  return NULL;
4328  }
4329  optionwin = gnc_options_dialog_new_modal (
4330  modal,
4331  (title ? title : _( "Book Options")),
4332  DIALOG_BOOK_OPTIONS_CM_CLASS, parent);
4333  gnc_options_dialog_build_contents (optionwin, options);
4334 
4336 
4337  gnc_options_dialog_set_apply_cb (optionwin,
4338  gnc_book_options_dialog_apply_cb,
4339  (gpointer)options);
4340  gnc_options_dialog_set_close_cb (optionwin,
4341  gnc_book_options_dialog_close_cb,
4342  (gpointer)options);
4343  if (modal)
4345  return gnc_options_dialog_widget (optionwin);
4346 }
void gnc_options_dialog_set_book_options_help_cb(GNCOptionWin *win)
Set the help callback to 'gnc_book_options_help_cb' to open a help browser and point it to the Book O...
void qof_book_load_options(QofBook *book, GNCOptionLoad load_cb, GNCOptionDB *odb)
Load a GNCOptionsDB from KVP data.
Definition: qofbook.cpp:1259
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.

◆ 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 241 of file gnc-main-window.c.

252 {
255  guint merge_id;
258  GtkActionGroup *action_group;
259 } 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 3513 of file gnc-main-window.c.

3514 {
3515  GtkActionGroup *force;
3516 
3517  g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
3518 
3519  /* Unfortunately gtk_ui_manager_ensure_update doesn't work
3520  * here. Force a full update by adding and removing an empty
3521  * action group.
3522  */
3523  force = gtk_action_group_new("force_update");
3524  gtk_ui_manager_insert_action_group (window->ui_merge, force, 0);
3525  gtk_ui_manager_ensure_update (window->ui_merge);
3526  gtk_ui_manager_remove_action_group (window->ui_merge, force);
3527  g_object_unref(force);
3528 }

◆ 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 5031 of file gnc-main-window.c.

5033 {
5034  GList *tmp;
5035  GtkAction *action;
5036 
5037  for (tmp = active_windows; tmp; tmp = g_list_next(tmp))
5038  {
5039  action = gnc_main_window_find_action (tmp->data, action_name);
5040  gtk_action_set_sensitive (action, sensitive);
5041  }
5042 }
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 1154 of file gnc-main-window.c.

1155 {
1156  const GList *windows, *item;
1157 
1158  windows = gnc_gobject_tracking_get_list(GNC_MAIN_WINDOW_NAME);
1159  for (item = windows; item; item = g_list_next(item))
1160  {
1161  if (!gnc_main_window_finish_pending(item->data))
1162  {
1163  return FALSE;
1164  }
1165  }
1166  if (gnc_gui_refresh_suspended ())
1167  {
1168  gnc_warning_dialog (NULL, "%s", "An operation is still running, wait for it to complete before quitting.");
1169  return FALSE;
1170  }
1171  return TRUE;
1172 }
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 5011 of file gnc-main-window.c.

5014 {
5015  g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), FALSE);
5016 
5017  ENTER("widget %p, event %p, page %p", whatever, event, page);
5018  /* Ignore double-clicks and triple-clicks */
5019  if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
5020  {
5021  do_popup_menu(page, event);
5022  LEAVE("menu shown");
5023  return TRUE;
5024  }
5025 
5026  LEAVE("other click");
5027  return FALSE;
5028 }
#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 3316 of file gnc-main-window.c.

3317 {
3318  GncMainWindow *window;
3319  GncMainWindowPrivate *priv;
3320 
3321  if (!page || !page->notebook_page)
3322  return;
3323 
3324  if (!gnc_plugin_page_finish_pending(page))
3325  return;
3326 
3327  if (!GNC_IS_MAIN_WINDOW (page->window))
3328  return;
3329 
3330  window = GNC_MAIN_WINDOW (page->window);
3331  if (!window)
3332  {
3333  g_warning("Page is not in a window.");
3334  return;
3335  }
3336 
3337  gnc_main_window_disconnect(window, page);
3339  g_object_unref(page);
3340 
3341  /* If this isn't the last window, go ahead and destroy the window. */
3342  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3343  if (priv->installed_pages == NULL)
3344  {
3345  if (window->window_quitting)
3346  {
3348  GList *plugins = gnc_plugin_manager_get_plugins (manager);
3349 
3350  /* remove only the preference callbacks from the window plugins */
3351  window->just_plugin_prefs = TRUE;
3352  g_list_foreach (plugins, gnc_main_window_remove_plugin, window);
3353  window->just_plugin_prefs = FALSE;
3354  g_list_free (plugins);
3355 
3356  /* remove the preference callbacks from the main window */
3357  gnc_main_window_remove_prefs (window);
3358  }
3359  if (window && (gnc_list_length_cmp (active_windows, 1) > 0))
3360  gtk_widget_destroy (GTK_WIDGET(window));
3361  }
3362 }
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 3140 of file gnc-main-window.c.

3141 {
3142  GncMainWindow *window;
3143  GncMainWindowPrivate *priv;
3144  GtkNotebook *notebook;
3145  gint page_num;
3146 
3147  window = GNC_MAIN_WINDOW (page->window);
3148  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3149  notebook = GTK_NOTEBOOK (priv->notebook);
3150  page_num = gtk_notebook_page_num(notebook, page->notebook_page);
3151  gtk_notebook_set_current_page (notebook, page_num);
3152  gtk_window_present(GTK_WINDOW(window));
3153 }
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 3532 of file gnc-main-window.c.

3533 {
3534  GtkAction *action = NULL;
3535  const GList *groups, *tmp;
3536 
3537  groups = gtk_ui_manager_get_action_groups(window->ui_merge);
3538  for (tmp = groups; tmp; tmp = g_list_next(tmp))
3539  {
3540  action = gtk_action_group_get_action(GTK_ACTION_GROUP(tmp->data), name);
3541  if (action)
3542  break;
3543  }
3544  return action;
3545 }

◆ 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 1134 of file gnc-main-window.c.

1135 {
1136  GncMainWindowPrivate *priv;
1137  GList *item;
1138 
1139  g_return_val_if_fail(GNC_IS_MAIN_WINDOW(window), TRUE);
1140 
1141  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
1142  for (item = priv->installed_pages; item; item = g_list_next(item))
1143  {
1144  if (!gnc_plugin_page_finish_pending(item->data))
1145  {
1146  return FALSE;
1147  }
1148  }
1149  return TRUE;
1150 }
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 3553 of file gnc-main-window.c.

3555 {
3556  GncMainWindowPrivate *priv;
3557  MergedActionEntry *entry;
3558 
3559  g_return_val_if_fail (GNC_IS_MAIN_WINDOW (window), NULL);
3560  g_return_val_if_fail (group_name != NULL, NULL);
3561 
3562  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3563  if (priv->merged_actions_table == NULL)
3564  return NULL;
3565  entry = g_hash_table_lookup (priv->merged_actions_table, group_name);
3566 
3567  if (entry == NULL)
3568  return NULL;
3569 
3570  return entry->action_group;
3571 }
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 3373 of file gnc-main-window.c.

3374 {
3375  GncMainWindowPrivate *priv;
3376 
3377  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3378  return priv->current_page;
3379 }
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 5044 of file gnc-main-window.c.

5045 {
5046  g_assert(window);
5047  return window->ui_merge;
5048 }

◆ 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 538 of file gnc-main-window.c.

539 {
540  GncMainWindowPrivate *priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
541  return priv->restoring_pages;
542 }
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 3388 of file gnc-main-window.c.

3392 {
3393  GncMainWindowPrivate *priv;
3394  MergedActionEntry *entry;
3395 
3396  g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
3397  g_return_if_fail (group_name != NULL);
3398  g_return_if_fail (GTK_IS_ACTION_GROUP(group));
3399  g_return_if_fail (merge_id > 0);
3400 
3401  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3402  entry = g_new0 (MergedActionEntry, 1);
3403  entry->action_group = group;
3404  entry->merge_id = merge_id;
3405  gtk_ui_manager_ensure_update (window->ui_merge);
3406  g_hash_table_insert (priv->merged_actions_table, g_strdup (group_name), entry);
3407 }
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 3417 of file gnc-main-window.c.

3425 {
3426  GncMainWindowPrivate *priv;
3428  MergedActionEntry *entry;
3429  GError *error = NULL;
3430  gchar *pathname;
3431 
3432  g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
3433  g_return_if_fail (group_name != NULL);
3434  g_return_if_fail (actions != NULL);
3435  g_return_if_fail (n_actions > 0);
3436  g_return_if_fail (filename != NULL);
3437 
3438  pathname = gnc_filepath_locate_ui_file (filename);
3439  if (pathname == NULL)
3440  return;
3441 
3442  data = g_new0 (GncMainWindowActionData, 1);
3443  data->window = window;
3444  data->data = user_data;
3445 
3446  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3447  entry = g_new0 (MergedActionEntry, 1);
3448  entry->action_group = gtk_action_group_new (group_name);
3449  gtk_action_group_set_translation_domain (entry->action_group, PROJECT_NAME);
3450  gtk_action_group_add_actions (entry->action_group, actions, n_actions, data);
3451  if (toggle_actions != NULL && n_toggle_actions > 0)
3452  {
3453  gtk_action_group_add_toggle_actions (entry->action_group,
3454  toggle_actions, n_toggle_actions,
3455  data);
3456  }
3457  gtk_ui_manager_insert_action_group (window->ui_merge, entry->action_group, 0);
3458  entry->merge_id = gtk_ui_manager_add_ui_from_file (window->ui_merge, pathname, &error);
3459  g_assert(entry->merge_id || error);
3460  if (entry->merge_id)
3461  {
3462  gtk_ui_manager_ensure_update (window->ui_merge);
3463  g_hash_table_insert (priv->merged_actions_table, g_strdup (group_name), entry);
3464  }
3465  else
3466  {
3467  g_critical("Failed to load ui file.\n Filename %s\n Error %s",
3468  filename, error->message);
3469  g_error_free(error);
3470  g_free(entry);
3471  }
3472  g_free(pathname);
3473 }
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 2935 of file gnc-main-window.c.

2936 {
2937  GncMainWindow *window;
2938  GtkWindow *old_window;
2939 
2940  window = g_object_new (GNC_TYPE_MAIN_WINDOW, NULL);
2941  gtk_window_set_default_size(GTK_WINDOW(window), 800, 600);
2942 
2943  old_window = gnc_ui_get_main_window (NULL);
2944  if (old_window)
2945  {
2946  gint width, height;
2947  gtk_window_get_size (old_window, &width, &height);
2948  gtk_window_resize (GTK_WINDOW (window), width, height);
2949  if ((gdk_window_get_state((gtk_widget_get_window (GTK_WIDGET(old_window))))
2950  & GDK_WINDOW_STATE_MAXIMIZED) != 0)
2951  {
2952  gtk_window_maximize (GTK_WINDOW (window));
2953  }
2954  }
2955  active_windows = g_list_append (active_windows, window);
2956  gnc_main_window_update_title(window);
2957  window->window_quitting = FALSE;
2958  window->just_plugin_prefs = FALSE;
2959 #ifdef MAC_INTEGRATION
2960  gnc_quartz_set_menu(window);
2961 #else
2962  gnc_main_window_update_all_menu_items();
2963 #endif
2964  gnc_engine_add_commit_error_callback( gnc_main_window_engine_commit_error_callback, window );
2965 
2966  // set up a callback for noteboook navigation
2967  g_signal_connect (G_OBJECT(window), "key-press-event",
2968  G_CALLBACK(gnc_main_window_key_press_event),
2969  NULL);
2970 
2971  return window;
2972 }
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 3164 of file gnc-main-window.c.

3166 {
3167  GncMainWindowPrivate *priv;
3168  GtkWidget *tab_hbox;
3169  GtkWidget *label, *entry;
3170  const gchar *icon, *text, *color_string, *lab_text;
3171  GtkWidget *image;
3172  GList *tmp;
3173  gint width;
3174 
3175  ENTER("window %p, page %p", window, page);
3176  if (window)
3177  g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
3178  g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
3179  g_return_if_fail (gnc_plugin_page_has_books(page));
3180 
3181  if (gnc_main_window_page_exists(page))
3182  {
3184  return;
3185  }
3186 
3187  /* Does the page want to be in a new window? */
3189  {
3190  /* See if there's a blank window. If so, use that. */
3191  for (tmp = active_windows; tmp; tmp = g_list_next(tmp))
3192  {
3193  window = GNC_MAIN_WINDOW(tmp->data);
3194  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3195  if (priv->installed_pages == NULL)
3196  {
3197  break;
3198  }
3199  }
3200  if (tmp == NULL)
3201  window = gnc_main_window_new ();
3202  gtk_widget_show(GTK_WIDGET(window));
3203  }
3204  else if ((window == NULL) && active_windows)
3205  {
3206  window = active_windows->data;
3207  }
3208 
3209  page->window = GTK_WIDGET(window);
3211  g_object_set_data (G_OBJECT (page->notebook_page),
3212  PLUGIN_PAGE_LABEL, page);
3213 
3214  /*
3215  * The page tab.
3216  */
3217  width = gnc_prefs_get_float(GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_WIDTH);
3218  icon = GNC_PLUGIN_PAGE_GET_CLASS(page)->tab_icon;
3219  lab_text = gnc_plugin_page_get_page_name(page);
3220  label = gtk_label_new (lab_text);
3221  g_object_set_data (G_OBJECT (page), PLUGIN_PAGE_TAB_LABEL, label);
3222 
3223  gnc_main_window_set_tab_ellipsize (label, width);
3224 
3225  gtk_widget_show (label);
3226 
3227  tab_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
3228 
3229  if (g_strcmp0 (gnc_plugin_page_get_plugin_name (page), "GncPluginPageAccountTree") == 0)
3230  gtk_widget_set_name (GTK_WIDGET(tab_hbox), "gnc-id-account-page-tab-box");
3231 
3232  gtk_box_set_homogeneous (GTK_BOX (tab_hbox), FALSE);
3233  gtk_widget_show (tab_hbox);
3234 
3235  if (icon != NULL)
3236  {
3237  image = gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_MENU);
3238  gtk_widget_show (image);
3239  gtk_box_pack_start (GTK_BOX (tab_hbox), image, FALSE, FALSE, 0);
3240  gtk_widget_set_margin_start (GTK_WIDGET(image), 5);
3241  gtk_box_pack_start (GTK_BOX (tab_hbox), label, TRUE, TRUE, 0);
3242  }
3243  else
3244  gtk_box_pack_start (GTK_BOX (tab_hbox), label, TRUE, TRUE, 0);
3245 
3247  if (text)
3248  {
3249  gtk_widget_set_tooltip_text(tab_hbox, text);
3250  }
3251 
3252  entry = gtk_entry_new();
3253  gtk_widget_hide (entry);
3254  gtk_box_pack_start (GTK_BOX (tab_hbox), entry, TRUE, TRUE, 0);
3255  g_signal_connect(G_OBJECT(entry), "activate",
3256  G_CALLBACK(gnc_main_window_tab_entry_activate), page);
3257  g_signal_connect(G_OBJECT(entry), "focus-out-event",
3258  G_CALLBACK(gnc_main_window_tab_entry_focus_out_event),
3259  page);
3260  g_signal_connect(G_OBJECT(entry), "key-press-event",
3261  G_CALLBACK(gnc_main_window_tab_entry_key_press_event),
3262  page);
3263  g_signal_connect(G_OBJECT(entry), "editing-done",
3264  G_CALLBACK(gnc_main_window_tab_entry_editing_done),
3265  page);
3266 
3267  /* Add close button - Not for immutable pages */
3268  if (!g_object_get_data (G_OBJECT (page), PLUGIN_PAGE_IMMUTABLE))
3269  {
3270  GtkWidget *close_image, *close_button;
3271  GtkRequisition requisition;
3272 
3273  close_button = gtk_button_new();
3274  gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE);
3275  close_image = gtk_image_new_from_icon_name ("window-close", GTK_ICON_SIZE_MENU);
3276  gtk_widget_show(close_image);
3277  gtk_widget_get_preferred_size (close_image, &requisition, NULL);
3278  gtk_widget_set_size_request(close_button, requisition.width + 4,
3279  requisition.height + 2);
3280  gtk_container_add(GTK_CONTAINER(close_button), close_image);
3281  if (gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_SHOW_CLOSE_BUTTON))
3282  gtk_widget_show (close_button);
3283  else
3284  gtk_widget_hide (close_button);
3285 
3286  g_signal_connect_swapped (G_OBJECT (close_button), "clicked",
3287  G_CALLBACK(gnc_main_window_close_page), page);
3288 
3289  gtk_box_pack_start (GTK_BOX (tab_hbox), close_button, FALSE, FALSE, 0);
3290  gtk_widget_set_margin_end (GTK_WIDGET(close_button), 5);
3291  g_object_set_data (G_OBJECT (page), PLUGIN_PAGE_CLOSE_BUTTON, close_button);
3292  }
3293 
3294  /*
3295  * The popup menu
3296  */
3297  label = gtk_label_new (gnc_plugin_page_get_page_name(page));
3298 
3299  /*
3300  * Now install it all in the window.
3301  */
3302  gnc_main_window_connect(window, page, tab_hbox, label);
3303 
3304  color_string = gnc_plugin_page_get_page_color(page);
3305  main_window_update_page_color (page, color_string);
3306  LEAVE("");
3307 }
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.
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.
gdouble gnc_prefs_get_float(const gchar *group, const gchar *pref_name)
Get an float value from the preferences backend.
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 4996 of file gnc-main-window.c.

4998 {
4999  ENTER("widget %p, page %p", widget, page);
5000  do_popup_menu(page, NULL);
5001  LEAVE(" ");
5002  return TRUE;
5003 }
#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 934 of file gnc-main-window.c.

935 {
936  gint i, window_count;
937  GError *error = NULL;
939  GncMainWindow *window;
940 
941  /* We use the same struct for reading and for writing, so we cast
942  away the const. */
943  data.key_file = (GKeyFile *) keyfile;
944  window_count = g_key_file_get_integer(data.key_file, STATE_FILE_TOP,
945  WINDOW_COUNT, &error);
946  if (error)
947  {
948  g_warning("error reading group %s key %s: %s",
949  STATE_FILE_TOP, WINDOW_COUNT, error->message);
950  g_error_free(error);
951  LEAVE("can't read count");
952  return;
953  }
954 
955  /* Restore all state information on the open windows. Window
956  numbers in state file are 1-based. GList indices are 0-based. */
957  gnc_set_busy_cursor (NULL, TRUE);
958  for (i = 0; i < window_count; i++)
959  {
960  data.window_num = i;
961  window = g_list_nth_data(active_windows, i);
962  gnc_main_window_restore_window(window, &data);
963  }
964  gnc_unset_busy_cursor (NULL);
965 
966  statusbar_notification_lastmodified();
967 }
#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 1116 of file gnc-main-window.c.

1117 {
1118  GncMainWindowSaveData data;
1119 
1120  /* Set up the iterator data structures */
1121  data.key_file = keyfile;
1122  data.window_num = 1;
1123  data.page_num = 1;
1124 
1125  g_key_file_set_integer(data.key_file,
1126  STATE_FILE_TOP, WINDOW_COUNT,
1127  g_list_length(active_windows));
1128  /* Dump all state information on the open windows */
1129  g_list_foreach(active_windows, (GFunc)gnc_main_window_save_window, &data);
1130 }

◆ 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 4934 of file gnc-main-window.c.

4935 {
4936  GncWindow *gncwin;
4937  gncwin = GNC_WINDOW(window);
4938  gnc_window_set_progressbar_window(gncwin);
4939 }

◆ 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 3482 of file gnc-main-window.c.

3484 {
3485  GncMainWindowPrivate *priv;
3486  MergedActionEntry *entry;
3487 
3488  g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
3489  g_return_if_fail (group_name != NULL);
3490 
3491  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3492  if (priv->merged_actions_table == NULL)
3493  return;
3494  entry = g_hash_table_lookup (priv->merged_actions_table, group_name);
3495 
3496  if (entry == NULL)
3497  return;
3498 
3499  gtk_ui_manager_remove_action_group (window->ui_merge, entry->action_group);
3500  gtk_ui_manager_remove_ui (window->ui_merge, entry->merge_id);
3501  gtk_ui_manager_ensure_update (window->ui_merge);
3502 
3503  g_hash_table_remove (priv->merged_actions_table, group_name);
3504 }
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 4796 of file gnc-main-window.c.

4797 {
4798  GtkWidget *toplevel;
4799 
4800  if (!widget)
4801  return NULL;
4802 
4803  toplevel = gtk_widget_get_toplevel (widget);
4804  if (toplevel && GTK_IS_WINDOW (toplevel))
4805  return GTK_WINDOW (toplevel);
4806  else
4807  return NULL;
4808 }

◆ 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 4811 of file gnc-main-window.c.

4812 {
4813  GList *window;
4814 
4815  GtkWindow *toplevel = gnc_ui_get_gtk_window (widget);
4816  while (toplevel && !GNC_IS_MAIN_WINDOW (toplevel))
4817  toplevel = gtk_window_get_transient_for(toplevel);
4818 
4819  if (toplevel)
4820  return toplevel;
4821 
4822  for (window = active_windows; window; window = window->next)
4823  if (gtk_window_is_active (GTK_WINDOW (window->data)))
4824  return window->data;
4825 
4826  for (window = active_windows; window; window = window->next)
4827  if (gtk_widget_get_mapped (GTK_WIDGET(window->data)))
4828  return window->data;
4829 
4830  return NULL;
4831 }
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 2397 of file gnc-main-window.c.

2399 {
2400  GncMainWindow *window;
2401  GncMainWindowPrivate *priv;
2402  GtkWidget *tab_widget;
2403  GdkRGBA tab_color;
2404  gchar *color_string = NULL;
2405  gboolean want_color = FALSE;
2406 
2407  ENTER(" ");
2408  if (color_in)
2409  color_string = g_strstrip(g_strdup(color_in));
2410 
2411  if (color_string && *color_string != '\0')
2412  want_color = TRUE;
2413 
2414  /* Update the plugin */
2415  window = GNC_MAIN_WINDOW(page->window);
2416  if (want_color)
2417  gnc_plugin_page_set_page_color(page, color_string);
2418  else
2419  gnc_plugin_page_set_page_color(page, NULL);
2420 
2421  /* Update the notebook tab */
2422  main_window_find_tab_widget (window, page, &tab_widget);
2423  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
2424 
2425  if (want_color && gdk_rgba_parse(&tab_color, color_string) && priv->show_color_tabs)
2426  {
2427  GtkCssProvider *provider = gtk_css_provider_new();
2428  GtkStyleContext *stylectxt;
2429  gchar *col_str, *widget_css;
2430 
2431  if (!GTK_IS_EVENT_BOX (tab_widget))
2432  {
2433  GtkWidget *event_box = gtk_event_box_new ();
2434  g_object_ref (tab_widget);
2435  gtk_notebook_set_tab_label (GTK_NOTEBOOK(priv->notebook),
2436  page->notebook_page, event_box);
2437  gtk_container_add (GTK_CONTAINER(event_box), tab_widget);
2438  g_object_unref (tab_widget);
2439  tab_widget = event_box;
2440  }
2441 
2442  stylectxt = gtk_widget_get_style_context (GTK_WIDGET (tab_widget));
2443  col_str = gdk_rgba_to_string (&tab_color);
2444  widget_css = g_strconcat ("*{\n background-color:", col_str, ";\n}\n", NULL);
2445 
2446  gtk_css_provider_load_from_data (provider, widget_css, -1, NULL);
2447  gtk_style_context_add_provider (stylectxt, GTK_STYLE_PROVIDER (provider),
2448  GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
2449  g_object_unref (provider);
2450  g_free (col_str);
2451  g_free (widget_css);
2452  }
2453  else
2454  {
2455  if (GTK_IS_EVENT_BOX (tab_widget))
2456  {
2457  GtkWidget *tab_hbox = gtk_bin_get_child(GTK_BIN(tab_widget));
2458  g_object_ref (tab_hbox);
2459  gtk_container_remove (GTK_CONTAINER(tab_widget), tab_hbox);
2460  gtk_notebook_set_tab_label (GTK_NOTEBOOK(priv->notebook),
2461  page->notebook_page, tab_hbox);
2462  g_object_unref (tab_hbox);
2463  }
2464  }
2465  g_free(color_string);
2466  LEAVE("done");
2467 }
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 2309 of file gnc-main-window.c.

2311 {
2312  GncMainWindow *window;
2313  GncMainWindowPrivate *priv;
2314  GtkWidget *label, *entry;
2315  gchar *name, *old_page_name, *old_page_long_name;
2316  gint lab_width;
2317 
2318  ENTER(" ");
2319 
2320  if ((name_in == NULL) || (*name_in == '\0'))
2321  {
2322  LEAVE("no string");
2323  return;
2324  }
2325  name = g_strstrip(g_strdup(name_in));
2326 
2327  /* Optimization, if the name hasn't changed, don't update X. */
2328  if (*name == '\0' || 0 == strcmp(name, gnc_plugin_page_get_page_name(page)))
2329  {
2330  g_free(name);
2331  LEAVE("empty string or name unchanged");
2332  return;
2333  }
2334 
2335  old_page_name = g_strdup( gnc_plugin_page_get_page_name(page));
2336  old_page_long_name = g_strdup( gnc_plugin_page_get_page_long_name(page));
2337 
2338  /* Update the plugin */
2339  gnc_plugin_page_set_page_name(page, name);
2340 
2341  /* Update the notebook tab */
2342  window = GNC_MAIN_WINDOW(page->window);
2343  if (!window)
2344  {
2345  g_free(old_page_name);
2346  g_free(old_page_long_name);
2347  g_free(name);
2348  LEAVE("no window widget available");
2349  return;
2350  }
2351 
2352  if (main_window_find_tab_items(window, page, &label, &entry))
2353  gtk_label_set_text(GTK_LABEL(label), name);
2354 
2355  /* Adjust the label width for new text */
2356  lab_width = gnc_prefs_get_float (GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_WIDTH);
2357  gnc_main_window_update_tab_width_one_page (page, &lab_width);
2358 
2359  /* Update Tooltip on notebook Tab */
2360  if (old_page_long_name && old_page_name
2361  && g_strrstr(old_page_long_name, old_page_name) != NULL)
2362  {
2363  gchar *new_page_long_name;
2364  gint string_position;
2365  GtkWidget *tab_widget;
2366 
2367  string_position = strlen(old_page_long_name) - strlen(old_page_name);
2368  new_page_long_name = g_strconcat(g_strndup(old_page_long_name, string_position), name, NULL);
2369 
2370  gnc_plugin_page_set_page_long_name(page, new_page_long_name);
2371 
2372  if (main_window_find_tab_widget(window, page, &tab_widget))
2373  gtk_widget_set_tooltip_text(tab_widget, new_page_long_name);
2374 
2375  g_free(new_page_long_name);
2376  }
2377 
2378  /* Update the notebook menu */
2379  if (page->notebook_page)
2380  {
2381  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
2382  label = gtk_notebook_get_menu_label (GTK_NOTEBOOK(priv->notebook),
2383  page->notebook_page);
2384  gtk_label_set_text(GTK_LABEL(label), name);
2385  }
2386 
2387  /* Force an update of the window title */
2388  gnc_main_window_update_title(window);
2389  g_free(old_page_long_name);
2390  g_free(old_page_name);
2391  g_free(name);
2392  LEAVE("done");
2393 }
const gchar * gnc_plugin_page_get_page_long_name(GncPluginPage *page)
Retrieve the long name of this page.
const gchar * gnc_plugin_page_get_page_name(GncPluginPage *page)
Retrieve the name of this page.
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.
gdouble gnc_prefs_get_float(const gchar *group, const gchar *pref_name)
Get an float value from the preferences backend.

◆ 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 2471 of file gnc-main-window.c.

2473 {
2474  GncMainWindow *window;
2475  GncMainWindowPrivate *priv;
2476  GtkWidget *tab_widget;
2477  GtkWidget *image = NULL;
2478  GList *children;
2479  gchar *image_name = NULL;
2480  const gchar *icon_name;
2481 
2482  ENTER(" ");
2483 
2484  g_return_if_fail (page && page->window);
2485 
2486  if (!GNC_IS_MAIN_WINDOW (page->window))
2487  return;
2488 
2489  window = GNC_MAIN_WINDOW(page->window);
2490 
2491  /* Get the notebook tab widget */
2492  main_window_find_tab_widget (window, page, &tab_widget);
2493  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
2494 
2495  if (!tab_widget)
2496  {
2497  LEAVE("no tab widget");
2498  return;
2499  }
2500 
2501  if (GTK_IS_EVENT_BOX(tab_widget))
2502  tab_widget = gtk_bin_get_child (GTK_BIN(tab_widget));
2503 
2504  children = gtk_container_get_children (GTK_CONTAINER(tab_widget));
2505  /* For each, walk the list of container children to get image widget */
2506  for (GList *child = children; child; child = g_list_next (child))
2507  {
2508  GtkWidget *widget = child->data;
2509  if (GTK_IS_IMAGE(widget))
2510  image = widget;
2511  }
2512  g_list_free (children);
2513 
2514  if (!image)
2515  {
2516  LEAVE("no image to replace");
2517  return;
2518  }
2519 
2520  g_object_get (image, "icon-name", &image_name, NULL);
2521 
2522  if (read_only)
2523  icon_name = "changes-prevent-symbolic";
2524  else
2525  icon_name = GNC_PLUGIN_PAGE_GET_CLASS(page)->tab_icon;
2526 
2527  if (g_strcmp0 (icon_name, image_name) == 0)
2528  {
2529  LEAVE("page icon the same, no need to replace");
2530  g_free (image_name);
2531  return;
2532  }
2533  gtk_container_remove (GTK_CONTAINER(tab_widget), image);
2534  image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
2535  gtk_widget_show (image);
2536 
2537  gtk_container_add (GTK_CONTAINER(tab_widget), image);
2538  gtk_widget_set_margin_start (GTK_WIDGET(image), 5);
2539  gtk_box_reorder_child (GTK_BOX(tab_widget), image, 0);
2540 
2541  g_free (image_name);
2542  LEAVE("done");
2543 }
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.