GnuCash  4.12-68-g5dc52459a1+
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  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

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

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Names of signals generated by the main window.

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

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

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

4286 {
4287  QofBook *book = gnc_get_current_book ();
4288  gboolean use_split_action_for_num_before =
4290  gboolean use_book_currency_before =
4292  gint use_read_only_threshold_before =
4294  gboolean use_split_action_for_num_after;
4295  gboolean use_book_currency_after;
4296  gint use_read_only_threshold_after;
4297  gboolean return_val = FALSE;
4298  GList *results = NULL, *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 (NULL),
4306  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  use_book_currency_after = gnc_book_use_book_currency (book);
4321 
4322  // mark cached value as invalid so we get new value
4323  book->cached_num_days_autoreadonly_isvalid = FALSE;
4324  use_read_only_threshold_after = qof_book_get_num_days_autoreadonly (book);
4325 
4326  if (use_split_action_for_num_before != use_split_action_for_num_after)
4327  {
4329  use_split_action_for_num_after);
4330  return_val = TRUE;
4331  }
4332  if (use_book_currency_before != use_book_currency_after)
4333  {
4334  gnc_book_option_book_currency_selected_cb (use_book_currency_after);
4335  return_val = TRUE;
4336  }
4337  if (use_read_only_threshold_before != use_read_only_threshold_after)
4338  return_val = TRUE;
4339 
4340  qof_book_commit_edit (book);
4341  return return_val;
4342 }
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:1094
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:1311

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

4422 {
4423  QofBook *book = gnc_get_current_book ();
4424  GNCOptionDB *options;
4425  GNCOptionWin *optionwin;
4426 
4427  options = gnc_option_db_new_for_type (QOF_ID_BOOK);
4428  qof_book_load_options (book, gnc_option_db_load, options);
4429  gnc_option_db_clean (options);
4430 
4431  /* Only allow one Book Options dialog if called from file->properties
4432  menu */
4433  if (gnc_forall_gui_components(DIALOG_BOOK_OPTIONS_CM_CLASS,
4434  show_handler, NULL))
4435  {
4436  return NULL;
4437  }
4438  optionwin = gnc_options_dialog_new_modal (
4439  modal,
4440  (title ? title : _( "Book Options")),
4441  DIALOG_BOOK_OPTIONS_CM_CLASS, parent);
4442  gnc_options_dialog_build_contents (optionwin, options);
4443 
4445 
4446  gnc_options_dialog_set_apply_cb (optionwin,
4447  gnc_book_options_dialog_apply_cb,
4448  (gpointer)options);
4449  gnc_options_dialog_set_close_cb (optionwin,
4450  gnc_book_options_dialog_close_cb,
4451  (gpointer)options);
4452  if (modal)
4454  return gnc_options_dialog_widget (optionwin);
4455 }
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:1305
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 244 of file gnc-main-window.c.

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

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

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

5246 {
5247  GList *tmp;
5248  GtkAction *action;
5249 
5250  for (tmp = active_windows; tmp; tmp = g_list_next(tmp))
5251  {
5252  action = gnc_main_window_find_action (tmp->data, action_name);
5253  gtk_action_set_sensitive (action, sensitive);
5254  }
5255 }
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 1184 of file gnc-main-window.c.

1185 {
1186  const GList *windows, *item;
1187 
1188  windows = gnc_gobject_tracking_get_list(GNC_MAIN_WINDOW_NAME);
1189  for (item = windows; item; item = g_list_next(item))
1190  {
1191  if (!gnc_main_window_finish_pending(item->data))
1192  {
1193  return FALSE;
1194  }
1195  }
1196  if (gnc_gui_refresh_suspended ())
1197  {
1198  gnc_warning_dialog (NULL, "%s", "An operation is still running, wait for it to complete before quitting.");
1199  return FALSE;
1200  }
1201  return TRUE;
1202 }
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 5224 of file gnc-main-window.c.

5227 {
5228  g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), FALSE);
5229 
5230  ENTER("widget %p, event %p, page %p", whatever, event, page);
5231  /* Ignore double-clicks and triple-clicks */
5232  if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
5233  {
5234  do_popup_menu(page, event);
5235  LEAVE("menu shown");
5236  return TRUE;
5237  }
5238 
5239  LEAVE("other click");
5240  return FALSE;
5241 }
#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 3388 of file gnc-main-window.c.

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

3212 {
3213  GncMainWindow *window;
3214  GncMainWindowPrivate *priv;
3215  GtkNotebook *notebook;
3216  gint page_num;
3217 
3218  window = GNC_MAIN_WINDOW (page->window);
3219  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3220  notebook = GTK_NOTEBOOK (priv->notebook);
3221  page_num = gtk_notebook_page_num(notebook, page->notebook_page);
3222  gtk_notebook_set_current_page (notebook, page_num);
3223  gtk_window_present(GTK_WINDOW(window));
3224 }
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 3604 of file gnc-main-window.c.

3605 {
3606  GtkAction *action = NULL;
3607  const GList *groups, *tmp;
3608 
3609  groups = gtk_ui_manager_get_action_groups(window->ui_merge);
3610  for (tmp = groups; tmp; tmp = g_list_next(tmp))
3611  {
3612  action = gtk_action_group_get_action(GTK_ACTION_GROUP(tmp->data), name);
3613  if (action)
3614  break;
3615  }
3616  return action;
3617 }

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

1165 {
1166  GncMainWindowPrivate *priv;
1167  GList *item;
1168 
1169  g_return_val_if_fail(GNC_IS_MAIN_WINDOW(window), TRUE);
1170 
1171  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
1172  for (item = priv->installed_pages; item; item = g_list_next(item))
1173  {
1174  if (!gnc_plugin_page_finish_pending(item->data))
1175  {
1176  return FALSE;
1177  }
1178  }
1179  return TRUE;
1180 }
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 3625 of file gnc-main-window.c.

3627 {
3628  GncMainWindowPrivate *priv;
3629  MergedActionEntry *entry;
3630 
3631  g_return_val_if_fail (GNC_IS_MAIN_WINDOW (window), NULL);
3632  g_return_val_if_fail (group_name != NULL, NULL);
3633 
3634  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3635  if (priv->merged_actions_table == NULL)
3636  return NULL;
3637  entry = g_hash_table_lookup (priv->merged_actions_table, group_name);
3638 
3639  if (entry == NULL)
3640  return NULL;
3641 
3642  return entry->action_group;
3643 }
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 3445 of file gnc-main-window.c.

3446 {
3447  GncMainWindowPrivate *priv;
3448 
3449  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3450  return priv->current_page;
3451 }
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 5257 of file gnc-main-window.c.

5258 {
5259  g_assert(window);
5260  return window->ui_merge;
5261 }

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

569 {
570  GncMainWindowPrivate *priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
571  return priv->restoring_pages;
572 }
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 3460 of file gnc-main-window.c.

3464 {
3465  GncMainWindowPrivate *priv;
3466  MergedActionEntry *entry;
3467 
3468  g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
3469  g_return_if_fail (group_name != NULL);
3470  g_return_if_fail (GTK_IS_ACTION_GROUP(group));
3471  g_return_if_fail (merge_id > 0);
3472 
3473  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3474  entry = g_new0 (MergedActionEntry, 1);
3475  entry->action_group = group;
3476  entry->merge_id = merge_id;
3477  gtk_ui_manager_ensure_update (window->ui_merge);
3478  g_hash_table_insert (priv->merged_actions_table, g_strdup (group_name), entry);
3479 }
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 3489 of file gnc-main-window.c.

3497 {
3498  GncMainWindowPrivate *priv;
3500  MergedActionEntry *entry;
3501  GError *error = NULL;
3502  gchar *pathname;
3503 
3504  g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
3505  g_return_if_fail (group_name != NULL);
3506  g_return_if_fail (actions != NULL);
3507  g_return_if_fail (n_actions > 0);
3508  g_return_if_fail (filename != NULL);
3509 
3510  pathname = gnc_filepath_locate_ui_file (filename);
3511  if (pathname == NULL)
3512  return;
3513 
3514  data = g_new0 (GncMainWindowActionData, 1);
3515  data->window = window;
3516  data->data = user_data;
3517 
3518  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3519  entry = g_new0 (MergedActionEntry, 1);
3520  entry->action_group = gtk_action_group_new (group_name);
3521  gtk_action_group_set_translation_domain (entry->action_group, PROJECT_NAME);
3522  gtk_action_group_add_actions (entry->action_group, actions, n_actions, data);
3523  if (toggle_actions != NULL && n_toggle_actions > 0)
3524  {
3525  gtk_action_group_add_toggle_actions (entry->action_group,
3526  toggle_actions, n_toggle_actions,
3527  data);
3528  }
3529  gtk_ui_manager_insert_action_group (window->ui_merge, entry->action_group, 0);
3530  entry->merge_id = gtk_ui_manager_add_ui_from_file (window->ui_merge, pathname, &error);
3531  g_assert(entry->merge_id || error);
3532  if (entry->merge_id)
3533  {
3534  gtk_ui_manager_ensure_update (window->ui_merge);
3535  g_hash_table_insert (priv->merged_actions_table, g_strdup (group_name), entry);
3536  }
3537  else
3538  {
3539  g_critical("Failed to load ui file.\n Filename %s\n Error %s",
3540  filename, error->message);
3541  g_error_free(error);
3542  g_free(entry);
3543  }
3544  g_free(pathname);
3545 }
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 3006 of file gnc-main-window.c.

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

3237 {
3238  GncMainWindowPrivate *priv;
3239  GtkWidget *tab_hbox;
3240  GtkWidget *label, *entry;
3241  const gchar *icon, *text, *color_string, *lab_text;
3242  GtkWidget *image;
3243  GList *tmp;
3244  TabWidth *tw;
3245 
3246  ENTER("window %p, page %p", window, page);
3247  if (window)
3248  g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
3249  g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
3250  g_return_if_fail (gnc_plugin_page_has_books(page));
3251 
3252  if (gnc_main_window_page_exists(page))
3253  {
3255  return;
3256  }
3257 
3258  /* Does the page want to be in a new window? */
3260  {
3261  /* See if there's a blank window. If so, use that. */
3262  for (tmp = active_windows; tmp; tmp = g_list_next(tmp))
3263  {
3264  window = GNC_MAIN_WINDOW(tmp->data);
3265  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3266  if (priv->installed_pages == NULL)
3267  {
3268  break;
3269  }
3270  }
3271  if (tmp == NULL)
3272  window = gnc_main_window_new ();
3273  gtk_widget_show(GTK_WIDGET(window));
3274  }
3275  else if ((window == NULL) && active_windows)
3276  {
3277  window = active_windows->data;
3278  }
3279 
3280  page->window = GTK_WIDGET(window);
3282  g_object_set_data (G_OBJECT (page->notebook_page),
3283  PLUGIN_PAGE_LABEL, page);
3284 
3285  /*
3286  * The page tab.
3287  */
3288  icon = GNC_PLUGIN_PAGE_GET_CLASS(page)->tab_icon;
3289  lab_text = gnc_plugin_page_get_page_name(page);
3290  label = gtk_label_new (lab_text);
3291  g_object_set_data (G_OBJECT (page), PLUGIN_PAGE_TAB_LABEL, label);
3292 
3293  tw = populate_tab_width_struct ();
3294  gnc_main_window_update_tab_width_one_page (page, tw);
3295  g_free (tw);
3296 
3297  gtk_widget_show (label);
3298 
3299  tab_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
3300 
3301  if (g_strcmp0 (gnc_plugin_page_get_plugin_name (page), "GncPluginPageAccountTree") == 0)
3302  gtk_widget_set_name (GTK_WIDGET(tab_hbox), "gnc-id-account-page-tab-box");
3303 
3304  gtk_box_set_homogeneous (GTK_BOX (tab_hbox), FALSE);
3305  gtk_widget_show (tab_hbox);
3306 
3307  if (icon != NULL)
3308  {
3309  image = gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_MENU);
3310  gtk_widget_show (image);
3311  gtk_box_pack_start (GTK_BOX (tab_hbox), image, FALSE, FALSE, 0);
3312  gtk_widget_set_margin_start (GTK_WIDGET(image), 5);
3313  gtk_box_pack_start (GTK_BOX (tab_hbox), label, TRUE, TRUE, 0);
3314  }
3315  else
3316  gtk_box_pack_start (GTK_BOX (tab_hbox), label, TRUE, TRUE, 0);
3317 
3319  if (text)
3320  {
3321  gtk_widget_set_tooltip_text(tab_hbox, text);
3322  }
3323 
3324  entry = gtk_entry_new();
3325  gtk_widget_hide (entry);
3326  gtk_box_pack_start (GTK_BOX (tab_hbox), entry, TRUE, TRUE, 0);
3327  g_signal_connect(G_OBJECT(entry), "activate",
3328  G_CALLBACK(gnc_main_window_tab_entry_activate), page);
3329  g_signal_connect(G_OBJECT(entry), "focus-out-event",
3330  G_CALLBACK(gnc_main_window_tab_entry_focus_out_event),
3331  page);
3332  g_signal_connect(G_OBJECT(entry), "key-press-event",
3333  G_CALLBACK(gnc_main_window_tab_entry_key_press_event),
3334  page);
3335  g_signal_connect(G_OBJECT(entry), "editing-done",
3336  G_CALLBACK(gnc_main_window_tab_entry_editing_done),
3337  page);
3338 
3339  /* Add close button - Not for immutable pages */
3340  if (!g_object_get_data (G_OBJECT (page), PLUGIN_PAGE_IMMUTABLE))
3341  {
3342  GtkWidget *close_image, *close_button;
3343  GtkRequisition requisition;
3344 
3345  close_button = gtk_button_new();
3346  gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE);
3347  close_image = gtk_image_new_from_icon_name ("window-close", GTK_ICON_SIZE_MENU);
3348  gtk_widget_show(close_image);
3349  gtk_widget_get_preferred_size (close_image, &requisition, NULL);
3350  gtk_widget_set_size_request(close_button, requisition.width + 4,
3351  requisition.height + 2);
3352  gtk_container_add(GTK_CONTAINER(close_button), close_image);
3353  if (gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_SHOW_CLOSE_BUTTON))
3354  gtk_widget_show (close_button);
3355  else
3356  gtk_widget_hide (close_button);
3357 
3358  g_signal_connect_swapped (G_OBJECT (close_button), "clicked",
3359  G_CALLBACK(gnc_main_window_close_page), page);
3360 
3361  gtk_box_pack_start (GTK_BOX (tab_hbox), close_button, FALSE, FALSE, 0);
3362  gtk_widget_set_margin_end (GTK_WIDGET(close_button), 5);
3363  g_object_set_data (G_OBJECT (page), PLUGIN_PAGE_CLOSE_BUTTON, close_button);
3364  }
3365 
3366  /*
3367  * The popup menu
3368  */
3369  label = gtk_label_new (gnc_plugin_page_get_page_name(page));
3370 
3371  /*
3372  * Now install it all in the window.
3373  */
3374  gnc_main_window_connect(window, page, tab_hbox, label);
3375 
3376  color_string = gnc_plugin_page_get_page_color(page);
3377  main_window_update_page_color (page, color_string);
3378  LEAVE("");
3379 }
gboolean gnc_plugin_page_has_books(GncPluginPage *page)
Query a page to see if it has a reference to any book.
gboolean gnc_plugin_page_get_use_new_window(GncPluginPage *page)
Retrieve the "use new window" setting associated with this page.
const gchar * gnc_plugin_page_get_page_long_name(GncPluginPage *page)
Retrieve the long name of this page.
This data structure allows the passing of the tab width and whether the tab layout is on the left or ...
const gchar * gnc_plugin_page_get_page_name(GncPluginPage *page)
Retrieve the name of this page.
GtkWidget * window
The window that contains the display widget for this plugin.
const gchar * gnc_plugin_page_get_page_color(GncPluginPage *page)
Retrieve the color of this page.
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
void gnc_main_window_display_page(GncPluginPage *page)
Bring the window containing the specified page to the top of the window stack, then switch the notebo...
void main_window_update_page_color(GncPluginPage *page, const gchar *color_in)
Update the color on the page tabs in the main window.
The instance private data structure for an embedded window object.
#define PLUGIN_PAGE_LABEL
This label is used to provide a mapping from a visible page widget back to the corresponding GncPlugi...
GncMainWindow * gnc_main_window_new(void)
Create a new gnc main window plugin.
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.
void gnc_main_window_close_page(GncPluginPage *page)
Remove a data plugin page from a window and display the previous page.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282
GList * installed_pages
A list of all pages that are installed in this window.
GtkWidget * notebook_page
The display widget for this plugin.
GtkWidget * gnc_plugin_page_create_widget(GncPluginPage *plugin_page)
Create the display widget that corresponds to this plugin.
const gchar * gnc_plugin_page_get_plugin_name(GncPluginPage *plugin_page)
Retrieve the textual name of a plugin.

◆ gnc_main_window_popup_menu_cb()

gboolean gnc_main_window_popup_menu_cb ( GtkWidget *  widget,
GncPluginPage page 
)

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

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

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

5211 {
5212  ENTER("widget %p, page %p", widget, page);
5213  do_popup_menu(page, NULL);
5214  LEAVE(" ");
5215  return TRUE;
5216 }
#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 964 of file gnc-main-window.c.

965 {
966  gint i, window_count;
967  GError *error = NULL;
969  GncMainWindow *window;
970 
971  /* We use the same struct for reading and for writing, so we cast
972  away the const. */
973  data.key_file = (GKeyFile *) keyfile;
974  window_count = g_key_file_get_integer(data.key_file, STATE_FILE_TOP,
975  WINDOW_COUNT, &error);
976  if (error)
977  {
978  g_warning("error reading group %s key %s: %s",
979  STATE_FILE_TOP, WINDOW_COUNT, error->message);
980  g_error_free(error);
981  LEAVE("can't read count");
982  return;
983  }
984 
985  /* Restore all state information on the open windows. Window
986  numbers in state file are 1-based. GList indices are 0-based. */
987  gnc_set_busy_cursor (NULL, TRUE);
988  for (i = 0; i < window_count; i++)
989  {
990  data.window_num = i;
991  window = g_list_nth_data(active_windows, i);
992  gnc_main_window_restore_window(window, &data);
993  }
994  gnc_unset_busy_cursor (NULL);
995 
996  statusbar_notification_lastmodified();
997 }
#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 1146 of file gnc-main-window.c.

1147 {
1148  GncMainWindowSaveData data;
1149 
1150  /* Set up the iterator data structures */
1151  data.key_file = keyfile;
1152  data.window_num = 1;
1153  data.page_num = 1;
1154 
1155  g_key_file_set_integer(data.key_file,
1156  STATE_FILE_TOP, WINDOW_COUNT,
1157  g_list_length(active_windows));
1158  /* Dump all state information on the open windows */
1159  g_list_foreach(active_windows, (GFunc)gnc_main_window_save_window, &data);
1160 }

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

5148 {
5149  GncWindow *gncwin;
5150  gncwin = GNC_WINDOW(window);
5151  gnc_window_set_progressbar_window(gncwin);
5152 }

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

3556 {
3557  GncMainWindowPrivate *priv;
3558  MergedActionEntry *entry;
3559 
3560  g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
3561  g_return_if_fail (group_name != NULL);
3562 
3563  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3564  if (priv->merged_actions_table == NULL)
3565  return;
3566  entry = g_hash_table_lookup (priv->merged_actions_table, group_name);
3567 
3568  if (entry == NULL)
3569  return;
3570 
3571  gtk_ui_manager_remove_action_group (window->ui_merge, entry->action_group);
3572  gtk_ui_manager_remove_ui (window->ui_merge, entry->merge_id);
3573  gtk_ui_manager_ensure_update (window->ui_merge);
3574 
3575  g_hash_table_remove (priv->merged_actions_table, group_name);
3576 }
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 5009 of file gnc-main-window.c.

5010 {
5011  GtkWidget *toplevel;
5012 
5013  if (!widget)
5014  return NULL;
5015 
5016  toplevel = gtk_widget_get_toplevel (widget);
5017  if (toplevel && GTK_IS_WINDOW (toplevel))
5018  return GTK_WINDOW (toplevel);
5019  else
5020  return NULL;
5021 }

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

5025 {
5026  GList *window;
5027 
5028  GtkWindow *toplevel = gnc_ui_get_gtk_window (widget);
5029  while (toplevel && !GNC_IS_MAIN_WINDOW (toplevel))
5030  toplevel = gtk_window_get_transient_for(toplevel);
5031 
5032  if (toplevel)
5033  return toplevel;
5034 
5035  for (window = active_windows; window; window = window->next)
5036  if (gtk_window_is_active (GTK_WINDOW (window->data)))
5037  return window->data;
5038 
5039  for (window = active_windows; window; window = window->next)
5040  if (gtk_widget_get_mapped (GTK_WIDGET(window->data)))
5041  return window->data;
5042 
5043  return NULL;
5044 }
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 2468 of file gnc-main-window.c.

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

2381 {
2382  GncMainWindow *window;
2383  GncMainWindowPrivate *priv;
2384  GtkWidget *label, *entry;
2385  gchar *name, *old_page_name, *old_page_long_name;
2386  TabWidth *tw;
2387 
2388  ENTER(" ");
2389 
2390  if ((name_in == NULL) || (*name_in == '\0'))
2391  {
2392  LEAVE("no string");
2393  return;
2394  }
2395  name = g_strstrip(g_strdup(name_in));
2396 
2397  /* Optimization, if the name hasn't changed, don't update X. */
2398  if (*name == '\0' || 0 == strcmp(name, gnc_plugin_page_get_page_name(page)))
2399  {
2400  g_free(name);
2401  LEAVE("empty string or name unchanged");
2402  return;
2403  }
2404 
2405  old_page_name = g_strdup( gnc_plugin_page_get_page_name(page));
2406  old_page_long_name = g_strdup( gnc_plugin_page_get_page_long_name(page));
2407 
2408  /* Update the plugin */
2409  gnc_plugin_page_set_page_name(page, name);
2410 
2411  /* Update the notebook tab */
2412  window = GNC_MAIN_WINDOW(page->window);
2413  if (!window)
2414  {
2415  g_free(old_page_name);
2416  g_free(old_page_long_name);
2417  g_free(name);
2418  LEAVE("no window widget available");
2419  return;
2420  }
2421 
2422  if (main_window_find_tab_items(window, page, &label, &entry))
2423  gtk_label_set_text(GTK_LABEL(label), name);
2424 
2425  /* Adjust the label width for new text */
2426  tw = populate_tab_width_struct ();
2427  gnc_main_window_update_tab_width_one_page (page, tw);
2428  g_free (tw);
2429 
2430  /* Update Tooltip on notebook Tab */
2431  if (old_page_long_name && old_page_name
2432  && g_strrstr(old_page_long_name, old_page_name) != NULL)
2433  {
2434  gchar *new_page_long_name;
2435  gint string_position;
2436  GtkWidget *tab_widget;
2437 
2438  string_position = strlen(old_page_long_name) - strlen(old_page_name);
2439  new_page_long_name = g_strconcat(g_strndup(old_page_long_name, string_position), name, NULL);
2440 
2441  gnc_plugin_page_set_page_long_name(page, new_page_long_name);
2442 
2443  if (main_window_find_tab_widget(window, page, &tab_widget))
2444  gtk_widget_set_tooltip_text(tab_widget, new_page_long_name);
2445 
2446  g_free(new_page_long_name);
2447  }
2448 
2449  /* Update the notebook menu */
2450  if (page->notebook_page)
2451  {
2452  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
2453  label = gtk_notebook_get_menu_label (GTK_NOTEBOOK(priv->notebook),
2454  page->notebook_page);
2455  gtk_label_set_text(GTK_LABEL(label), name);
2456  }
2457 
2458  /* Force an update of the window title */
2459  gnc_main_window_update_title(window);
2460  g_free(old_page_long_name);
2461  g_free(old_page_name);
2462  g_free(name);
2463  LEAVE("done");
2464 }
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 2542 of file gnc-main-window.c.

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