GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Files | Data Structures | Macros | Typedefs | Enumerations | Functions
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
 
struct  MergedActionEntry
 
struct  GncMainWindowSaveData
 
struct  menu_update
 
struct  _ActionStatus
 
struct  GncMainWindow
 
struct  GncMainWindowClass
 
struct  GncMainWindowActionData
 

Macros

#define PLUGIN_PAGE_LABEL   "plugin-page"
 
#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_MAIN_WINDOW_NAME   "GncMainWindow"
 
#define MSG_AUTO_SAVE   _("Changes will be saved automatically in %u seconds")
 
#define GNC_MAIN_WINDOW_GET_PRIVATE(o)   (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_MAIN_WINDOW, GncMainWindowPrivate))
 
#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 struct GncMainWindowPrivate GncMainWindowPrivate
 
typedef struct _ActionStatus ActionStatus
 
typedef struct GncMainWindow GncMainWindow
 
typedef void(* GncMainWindowFunc )(GncMainWindow *window, GncPluginPage *page)
 
typedef void(* GncMainWindowPageFunc )(GncPluginPage *page, gpointer user_data)
 

Enumerations

enum  { PAGE_ADDED, PAGE_CHANGED, LAST_SIGNAL }
 

Functions

void gnc_main_window_foreach_page (GncMainWindowPageFunc fn, gpointer user_data)
 
void gnc_main_window_restore_all_windows (const GKeyFile *keyfile)
 
void gnc_main_window_restore_default_state (GncMainWindow *window)
 
void gnc_main_window_save_all_windows (GKeyFile *keyfile)
 
gboolean gnc_main_window_finish_pending (GncMainWindow *window)
 
gboolean gnc_main_window_all_finish_pending (void)
 
void main_window_update_page_name (GncPluginPage *page, const gchar *name_in)
 
void main_window_update_page_color (GncPluginPage *page, const gchar *color_in)
 
GType gnc_main_window_get_type (void)
 
GncMainWindowgnc_main_window_new (void)
 
void gnc_main_window_display_page (GncPluginPage *page)
 
void gnc_main_window_open_page (GncMainWindow *window, GncPluginPage *page)
 
void gnc_main_window_close_page (GncPluginPage *page)
 
GncPluginPagegnc_main_window_get_current_page (GncMainWindow *window)
 
void gnc_main_window_manual_merge_actions (GncMainWindow *window, const gchar *group_name, GtkActionGroup *group, guint merge_id)
 
void gnc_main_window_merge_actions (GncMainWindow *window, const gchar *group_name, GtkActionEntry *actions, guint n_actions, GtkToggleActionEntry *toggle_actions, guint n_toggle_actions, const gchar *filename, gpointer user_data)
 
void gnc_main_window_unmerge_actions (GncMainWindow *window, const gchar *group_name)
 
void gnc_main_window_actions_updated (GncMainWindow *window)
 
GtkAction * gnc_main_window_find_action (GncMainWindow *window, const gchar *name)
 
GtkActionGroup * gnc_main_window_get_action_group (GncMainWindow *window, const gchar *group_name)
 
GtkWidget * gnc_book_options_dialog_cb (gboolean modal, gchar *title)
 
void gnc_main_window_show_all_windows (void)
 
GtkWidget * gnc_ui_get_toplevel (void)
 
void gnc_main_window_set_progressbar_window (GncMainWindow *window)
 
gboolean gnc_main_window_button_press_cb (GtkWidget *whatever, GdkEventButton *event, GncPluginPage *page)
 
void gnc_gtk_action_group_set_translation_domain (GtkActionGroup *action_group, const gchar *domain)
 
void gnc_main_window_all_action_set_sensitive (const gchar *action_name, gboolean sensitive)
 
GtkUIManager * gnc_main_window_get_uimanager (GncMainWindow *window)
 

Detailed Description

Macro Definition Documentation

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

Typedef Documentation

typedef struct GncMainWindow GncMainWindow

The instance data structure for a main window object.

The instance private data structure for an embedded window object.

Enumeration Type Documentation

anonymous enum

Names of signals generated by the main window.

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

82 {
83  PAGE_ADDED,
84  PAGE_CHANGED,
85  LAST_SIGNAL
86 };

Function Documentation

GtkWidget * gnc_book_options_dialog_cb ( gboolean  modal,
gchar *  title 
)

Opens the Book Options dialog.

Parameters
modalTrue to open in modal mode, false otherwise.
titleTitle of the dialog; "Book Options" if NULL.
Returns
A pointer to the GtkWidget for the dialog that can be used when started in modal mode.

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

3982 {
3983  QofBook *book = gnc_get_current_book ();
3984  GNCOptionDB *options;
3985  GNCOptionWin *optionwin;
3986 
3987  options = gnc_option_db_new_for_type (QOF_ID_BOOK);
3988  qof_book_load_options (book, gnc_option_db_load_from_kvp, options);
3989  gnc_option_db_clean (options);
3990 
3991  optionwin = gnc_options_dialog_new_modal (modal,
3992  (title ? title : _( "Book Options")));
3993  gnc_options_dialog_build_contents (optionwin, options);
3994 
3996 
3997  gnc_options_dialog_set_apply_cb (optionwin,
3998  gnc_book_options_dialog_apply_cb,
3999  (gpointer)options);
4000  gnc_options_dialog_set_close_cb (optionwin,
4001  gnc_book_options_dialog_close_cb,
4002  (gpointer)options);
4003  if (modal)
4005  return gnc_options_dialog_widget (optionwin);
4006 }
void gnc_options_dialog_set_book_options_help_cb(GNCOptionWin *win)
void gnc_options_dialog_set_new_book_option_values(GNCOptionDB *odb)
void gnc_gtk_action_group_set_translation_domain ( GtkActionGroup *  action_group,
const gchar *  domain 
)

gnc_gtk_action_group_set_translation_domain:

Parameters
action_groupa #GtkActionGroup
domainthe translation domain to use for dgettext() calls

Sets the translation domain and uses dgettext() for translating the label and tooltip of #GtkActionEntrys added by gtk_action_group_add_actions().

This is copied from gtk's gtk_action_group_set_translation_domain() into GnuCash in order to fix problems when empty msgids were passed through gettext().

See http://bugzilla.gnome.org/show_bug.cgi?id=326200 . If that bug is fixed in the gtk that we can rely open, then gnc_gtk_action_group_set_translation_domain can be replaced by gtk_action_group_set_translation_domain again.

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

4709 {
4710  g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));
4711 
4712  gtk_action_group_set_translate_func (action_group,
4713  (GtkTranslateFunc)dgettext_swapped,
4714  g_strdup (domain),
4715  g_free);
4716 }
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 3205 of file gnc-main-window.c.

3206 {
3207  GtkActionGroup *force;
3208 
3209  g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
3210 
3211  /* Unfortunately gtk_ui_manager_ensure_update doesn't work
3212  * here. Force a full update by adding and removing an empty
3213  * action group.
3214  */
3215  force = gtk_action_group_new("force_update");
3216  gtk_ui_manager_insert_action_group (window->ui_merge, force, 0);
3217  gtk_ui_manager_ensure_update (window->ui_merge);
3218  gtk_ui_manager_remove_action_group (window->ui_merge, force);
3219  g_object_unref(force);
3220 }
GtkUIManager * ui_merge
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 4720 of file gnc-main-window.c.

4722 {
4723  GList *tmp;
4724  GtkAction *action;
4725 
4726  for (tmp = active_windows; tmp; tmp = g_list_next(tmp))
4727  {
4728  action = gnc_main_window_find_action (tmp->data, action_name);
4729  gtk_action_set_sensitive (action, sensitive);
4730  }
4731 }
GtkAction * gnc_main_window_find_action(GncMainWindow *window, const gchar *name)
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 1112 of file gnc-main-window.c.

1113 {
1114  const GList *windows, *item;
1115 
1116  windows = gnc_gobject_tracking_get_list(GNC_MAIN_WINDOW_NAME);
1117  for (item = windows; item; item = g_list_next(item))
1118  {
1119  if (!gnc_main_window_finish_pending(item->data))
1120  {
1121  return FALSE;
1122  }
1123  }
1124  return TRUE;
1125 }
const GList * gnc_gobject_tracking_get_list(const gchar *name)
gboolean gnc_main_window_finish_pending(GncMainWindow *window)
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 4667 of file gnc-main-window.c.

4670 {
4671  g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), FALSE);
4672 
4673  ENTER("widget %p, event %p, page %p", whatever, event, page);
4674  /* Ignore double-clicks and triple-clicks */
4675  if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
4676  {
4677  do_popup_menu(page, event);
4678  LEAVE("menu shown");
4679  return TRUE;
4680  }
4681 
4682  LEAVE("other click");
4683  return FALSE;
4684 }
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
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 3020 of file gnc-main-window.c.

3021 {
3022  GncMainWindow *window;
3023  GncMainWindowPrivate *priv;
3024 
3025  if (!page || !page->notebook_page)
3026  return;
3027 
3028  if (!gnc_plugin_page_finish_pending(page))
3029  return;
3030 
3031  if (!GNC_IS_MAIN_WINDOW (page->window))
3032  return;
3033 
3034  window = GNC_MAIN_WINDOW (page->window);
3035  if (!window)
3036  {
3037  g_warning("Page is not in a window.");
3038  return;
3039  }
3040 
3041  gnc_main_window_disconnect(window, page);
3043  g_object_unref(page);
3044 
3045  /* If this isn't the last window, go ahead and destroy the window. */
3046  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3047  if (priv->installed_pages == NULL)
3048  {
3049  if (g_list_length(active_windows) > 1)
3050  {
3051  gtk_widget_destroy(GTK_WIDGET(window));
3052  }
3053  }
3054 }
gboolean gnc_plugin_page_finish_pending(GncPluginPage *page)
void gnc_plugin_page_destroy_widget(GncPluginPage *plugin_page)
GtkWidget * window
GtkWidget * notebook_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 2847 of file gnc-main-window.c.

2848 {
2849  GncMainWindow *window;
2850  GncMainWindowPrivate *priv;
2851  GtkNotebook *notebook;
2852  gint page_num;
2853 
2854  window = GNC_MAIN_WINDOW (page->window);
2855  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
2856  notebook = GTK_NOTEBOOK (priv->notebook);
2857  page_num = gtk_notebook_page_num(notebook, page->notebook_page);
2858  gtk_notebook_set_current_page (notebook, page_num);
2859  gtk_window_present(GTK_WINDOW(window));
2860 }
GtkWidget * window
GtkWidget * notebook_page
GtkAction * gnc_main_window_find_action ( GncMainWindow window,
const gchar *  name 
)

Find action in main window.

Parameters
windowWhe 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 3224 of file gnc-main-window.c.

3225 {
3226  GtkAction *action = NULL;
3227  const GList *groups, *tmp;
3228 
3229  groups = gtk_ui_manager_get_action_groups(window->ui_merge);
3230  for (tmp = groups; tmp; tmp = g_list_next(tmp))
3231  {
3232  action = gtk_action_group_get_action(GTK_ACTION_GROUP(tmp->data), name);
3233  if (action)
3234  break;
3235  }
3236  return action;
3237 }
GtkUIManager * ui_merge
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
windowWhe 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 1092 of file gnc-main-window.c.

1093 {
1094  GncMainWindowPrivate *priv;
1095  GList *item;
1096 
1097  g_return_val_if_fail(GNC_IS_MAIN_WINDOW(window), TRUE);
1098 
1099  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
1100  for (item = priv->installed_pages; item; item = g_list_next(item))
1101  {
1102  if (!gnc_plugin_page_finish_pending(item->data))
1103  {
1104  return FALSE;
1105  }
1106  }
1107  return TRUE;
1108 }
gboolean gnc_plugin_page_finish_pending(GncPluginPage *page)
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 3245 of file gnc-main-window.c.

3247 {
3248  GncMainWindowPrivate *priv;
3249  MergedActionEntry *entry;
3250 
3251  g_return_val_if_fail (GNC_IS_MAIN_WINDOW (window), NULL);
3252  g_return_val_if_fail (group_name != NULL, NULL);
3253 
3254  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3255  if (priv->merged_actions_table == NULL)
3256  return NULL;
3257  entry = g_hash_table_lookup (priv->merged_actions_table, group_name);
3258 
3259  if (entry == NULL)
3260  return NULL;
3261 
3262  return entry->action_group;
3263 }
GHashTable * merged_actions_table
GtkActionGroup * action_group
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 3065 of file gnc-main-window.c.

3066 {
3067  GncMainWindowPrivate *priv;
3068 
3069  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3070  return priv->current_page;
3071 }
GncPluginPage * current_page
GType gnc_main_window_get_type ( void  )

Get the type of a gnc main window.

Returns
A GType.

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

2420 {
2421  static GType gnc_main_window_type = 0;
2422 
2423  if (gnc_main_window_type == 0)
2424  {
2425  static const GTypeInfo our_info =
2426  {
2427  sizeof (GncMainWindowClass),
2428  NULL,
2429  NULL,
2430  (GClassInitFunc) gnc_main_window_class_init,
2431  NULL,
2432  NULL,
2433  sizeof (GncMainWindow),
2434  0,
2435  (GInstanceInitFunc) gnc_main_window_init
2436  };
2437 
2438  static const GInterfaceInfo plugin_info =
2439  {
2440  (GInterfaceInitFunc) gnc_window_main_window_init,
2441  NULL,
2442  NULL
2443  };
2444 
2445  gnc_main_window_type = g_type_register_static (GTK_TYPE_WINDOW,
2446  GNC_MAIN_WINDOW_NAME,
2447  &our_info, 0);
2448  g_type_add_interface_static (gnc_main_window_type,
2449  GNC_TYPE_WINDOW,
2450  &plugin_info);
2451  }
2452 
2453  return gnc_main_window_type;
2454 }
struct GncMainWindow GncMainWindow
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 4733 of file gnc-main-window.c.

4734 {
4735  g_assert(window);
4736  return window->ui_merge;
4737 }
GtkUIManager * ui_merge
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 3080 of file gnc-main-window.c.

3084 {
3085  GncMainWindowPrivate *priv;
3086  MergedActionEntry *entry;
3087 
3088  g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
3089  g_return_if_fail (group_name != NULL);
3090  g_return_if_fail (GTK_IS_ACTION_GROUP(group));
3091  g_return_if_fail (merge_id > 0);
3092 
3093  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3094  entry = g_new0 (MergedActionEntry, 1);
3095  entry->action_group = group;
3096  entry->merge_id = merge_id;
3097  gtk_ui_manager_ensure_update (window->ui_merge);
3098  g_hash_table_insert (priv->merged_actions_table, g_strdup (group_name), entry);
3099 }
GtkUIManager * ui_merge
GHashTable * merged_actions_table
GtkActionGroup * action_group
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 3109 of file gnc-main-window.c.

3117 {
3118  GncMainWindowPrivate *priv;
3120  MergedActionEntry *entry;
3121  GError *error = NULL;
3122  gchar *pathname;
3123 
3124  g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
3125  g_return_if_fail (group_name != NULL);
3126  g_return_if_fail (actions != NULL);
3127  g_return_if_fail (n_actions > 0);
3128  g_return_if_fail (filename != NULL);
3129 
3130  pathname = gnc_filepath_locate_ui_file (filename);
3131  if (pathname == NULL)
3132  return;
3133 
3134  data = g_new0 (GncMainWindowActionData, 1);
3135  data->window = window;
3136  data->data = user_data;
3137 
3138  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3139  entry = g_new0 (MergedActionEntry, 1);
3140  entry->action_group = gtk_action_group_new (group_name);
3142  gtk_action_group_add_actions (entry->action_group, actions, n_actions, data);
3143  if (toggle_actions != NULL && n_toggle_actions > 0)
3144  {
3145  gtk_action_group_add_toggle_actions (entry->action_group,
3146  toggle_actions, n_toggle_actions,
3147  data);
3148  }
3149  gtk_ui_manager_insert_action_group (window->ui_merge, entry->action_group, 0);
3150  entry->merge_id = gtk_ui_manager_add_ui_from_file (window->ui_merge, pathname, &error);
3151  g_assert(entry->merge_id || error);
3152  if (entry->merge_id)
3153  {
3154  gtk_ui_manager_ensure_update (window->ui_merge);
3155  g_hash_table_insert (priv->merged_actions_table, g_strdup (group_name), entry);
3156  }
3157  else
3158  {
3159  g_critical("Failed to load ui file.\n Filename %s\n Error %s",
3160  filename, error->message);
3161  g_error_free(error);
3162  g_free(entry);
3163  }
3164  g_free(pathname);
3165 }
gchar * gnc_filepath_locate_ui_file(const gchar *name)
GtkUIManager * ui_merge
GHashTable * merged_actions_table
GtkActionGroup * action_group
void gnc_gtk_action_group_set_translation_domain(GtkActionGroup *action_group, const gchar *domain)
GncMainWindow * gnc_main_window_new ( void  )

Create a new gnc main window plugin.

Returns
A pointer to the new object.

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

2659 {
2660  GncMainWindow *window;
2661  GtkWidget *old_window;
2662 
2663  window = g_object_new (GNC_TYPE_MAIN_WINDOW, NULL);
2664  gtk_window_set_default_size(GTK_WINDOW(window), 800, 600);
2665 
2666  old_window = gnc_ui_get_toplevel();
2667  if (old_window)
2668  {
2669  gint width, height;
2670  gtk_window_get_size (GTK_WINDOW (old_window), &width, &height);
2671  gtk_window_resize (GTK_WINDOW (window), width, height);
2672  if ((gdk_window_get_state((GTK_WIDGET(old_window))->window)
2673  & GDK_WINDOW_STATE_MAXIMIZED) != 0)
2674  {
2675  gtk_window_maximize (GTK_WINDOW (window));
2676  }
2677  }
2678  active_windows = g_list_append (active_windows, window);
2679  gnc_main_window_update_title(window);
2680 #ifdef MAC_INTEGRATION
2681  gnc_quartz_set_menu(window);
2682 #else
2683  gnc_main_window_update_all_menu_items();
2684 #endif
2685  gnc_engine_add_commit_error_callback( gnc_main_window_engine_commit_error_callback, window );
2686 
2687  return window;
2688 }
void gnc_engine_add_commit_error_callback(EngineCommitErrorCallback cb, gpointer data)
Definition: gnc-engine.c:197
GtkWidget * gnc_ui_get_toplevel(void)
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 2871 of file gnc-main-window.c.

2873 {
2874  GncMainWindowPrivate *priv;
2875  GtkWidget *tab_hbox;
2876  GtkWidget *label, *entry;
2877  const gchar *icon, *text, *color_string;
2878  GtkWidget *image;
2879  GList *tmp;
2880  gint width;
2881  GdkColor tab_color;
2882 
2883  ENTER("window %p, page %p", window, page);
2884  if (window)
2885  g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
2886  g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
2887  g_return_if_fail (gnc_plugin_page_has_books(page));
2888 
2889  if (gnc_main_window_page_exists(page))
2890  {
2892  return;
2893  }
2894 
2895  /* Does the page want to be in a new window? */
2897  {
2898  /* See if there's a blank window. If so, use that. */
2899  for (tmp = active_windows; tmp; tmp = g_list_next(tmp))
2900  {
2901  window = GNC_MAIN_WINDOW(tmp->data);
2902  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
2903  if (priv->installed_pages == NULL)
2904  {
2905  break;
2906  }
2907  }
2908  if (tmp == NULL)
2909  window = gnc_main_window_new ();
2910  gtk_widget_show(GTK_WIDGET(window));
2911  }
2912  else if ((window == NULL) && active_windows)
2913  {
2914  window = active_windows->data;
2915  }
2916 
2917  page->window = GTK_WIDGET(window);
2918  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
2920  g_object_set_data (G_OBJECT (page->notebook_page),
2921  PLUGIN_PAGE_LABEL, page);
2922 
2923  /*
2924  * The page tab.
2925  */
2926  width = gnc_prefs_get_float(GNC_PREFS_GROUP_GENERAL, GNC_PREF_TAB_WIDTH);
2927  icon = GNC_PLUGIN_PAGE_GET_CLASS(page)->tab_icon;
2928  label = gtk_label_new (gnc_plugin_page_get_page_name(page));
2929  if (width != 0)
2930  {
2931  gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_MIDDLE);
2932  gtk_label_set_max_width_chars(GTK_LABEL(label), width);
2933  }
2934  gtk_widget_show (label);
2935 
2936  tab_hbox = gtk_hbox_new (FALSE, 6);
2937  gtk_widget_show (tab_hbox);
2938 
2939  if (icon != NULL)
2940  {
2941  image = gtk_image_new_from_stock (icon, GTK_ICON_SIZE_MENU);
2942  gtk_widget_show (image);
2943  gtk_box_pack_start (GTK_BOX (tab_hbox), image, FALSE, FALSE, 0);
2944  gtk_box_pack_start (GTK_BOX (tab_hbox), label, TRUE, TRUE, 0);
2945  }
2946  else
2947  gtk_box_pack_start (GTK_BOX (tab_hbox), label, TRUE, TRUE, 0);
2948 
2950  if (text)
2951  {
2952  gtk_widget_set_tooltip_text(tab_hbox, text);
2953  }
2954 
2955  entry = gtk_entry_new();
2956  gtk_widget_hide (entry);
2957  gtk_box_pack_start (GTK_BOX (tab_hbox), entry, TRUE, TRUE, 0);
2958  g_signal_connect(G_OBJECT(entry), "activate",
2959  G_CALLBACK(gnc_main_window_tab_entry_activate), page);
2960  g_signal_connect(G_OBJECT(entry), "focus-out-event",
2961  G_CALLBACK(gnc_main_window_tab_entry_focus_out_event),
2962  page);
2963  g_signal_connect(G_OBJECT(entry), "key-press-event",
2964  G_CALLBACK(gnc_main_window_tab_entry_key_press_event),
2965  page);
2966  g_signal_connect(G_OBJECT(entry), "editing-done",
2967  G_CALLBACK(gnc_main_window_tab_entry_editing_done),
2968  page);
2969 
2970  /* Add close button - Not for immutable pages */
2971  if (!g_object_get_data (G_OBJECT (page), PLUGIN_PAGE_IMMUTABLE))
2972  {
2973  GtkWidget *close_image, *close_button;
2974  GtkRequisition requisition;
2975 
2976  close_button = gtk_button_new();
2977  gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE);
2978  close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
2979  gtk_widget_show(close_image);
2980  gtk_widget_size_request(close_image, &requisition);
2981  gtk_widget_set_size_request(close_button, requisition.width + 4,
2982  requisition.height + 2);
2983  gtk_button_set_alignment(GTK_BUTTON(close_button), 0.5, 0.5);
2984  gtk_container_add(GTK_CONTAINER(close_button), close_image);
2985  if (gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, GNC_PREF_SHOW_CLOSE_BUTTON))
2986  gtk_widget_show (close_button);
2987  else
2988  gtk_widget_hide (close_button);
2989 
2990  g_signal_connect_swapped (G_OBJECT (close_button), "clicked",
2991  G_CALLBACK(gnc_main_window_close_page), page);
2992 
2993  gtk_box_pack_start (GTK_BOX (tab_hbox), close_button, FALSE, FALSE, 0);
2994 
2995  g_object_set_data (G_OBJECT (page), PLUGIN_PAGE_CLOSE_BUTTON, close_button);
2996  }
2997 
2998  /*
2999  * The popup menu
3000  */
3001  label = gtk_label_new (gnc_plugin_page_get_page_name(page));
3002 
3003  /*
3004  * Now install it all in the window.
3005  */
3006  gnc_main_window_connect(window, page, tab_hbox, label);
3007 
3008  color_string = gnc_plugin_page_get_page_color(page);
3009  main_window_update_page_color (page, color_string);
3010  LEAVE("");
3011 }
gboolean gnc_plugin_page_has_books(GncPluginPage *page)
gboolean gnc_plugin_page_get_use_new_window(GncPluginPage *page)
const gchar * gnc_plugin_page_get_page_long_name(GncPluginPage *page)
const gchar * gnc_plugin_page_get_page_name(GncPluginPage *page)
GtkWidget * window
const gchar * gnc_plugin_page_get_page_color(GncPluginPage *page)
#define ENTER(format, args...)
Definition: qoflog.h:261
void gnc_main_window_display_page(GncPluginPage *page)
GtkWidget * gnc_plugin_page_create_widget(GncPluginPage *plugin_page)
void main_window_update_page_color(GncPluginPage *page, const gchar *color_in)
#define PLUGIN_PAGE_LABEL
GncMainWindow * gnc_main_window_new(void)
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Definition: gnc-prefs.c:196
void gnc_main_window_close_page(GncPluginPage *page)
#define LEAVE(format, args...)
Definition: qoflog.h:271
GtkWidget * notebook_page
gdouble gnc_prefs_get_float(const gchar *group, const gchar *pref_name)
Definition: gnc-prefs.c:227
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 904 of file gnc-main-window.c.

905 {
906  gint i, window_count;
907  GError *error = NULL;
909  GncMainWindow *window;
910 
911  /* We use the same struct for reading and for writing, so we cast
912  away the const. */
913  data.key_file = (GKeyFile *) keyfile;
914  window_count = g_key_file_get_integer(data.key_file, STATE_FILE_TOP,
915  WINDOW_COUNT, &error);
916  if (error)
917  {
918  g_warning("error reading group %s key %s: %s",
919  STATE_FILE_TOP, WINDOW_COUNT, error->message);
920  g_error_free(error);
921  LEAVE("can't read count");
922  return;
923  }
924 
925  /* Restore all state information on the open windows. Window
926  numbers in state file are 1-based. GList indices are 0-based. */
927  gnc_set_busy_cursor (NULL, TRUE);
928  for (i = 0; i < window_count; i++)
929  {
930  data.window_num = i;
931  window = g_list_nth_data(active_windows, i);
932  gnc_main_window_restore_window(window, &data);
933  }
934  gnc_unset_busy_cursor (NULL);
935 
936  statusbar_notification_lastmodified();
937 }
#define LEAVE(format, args...)
Definition: qoflog.h:271
void gnc_main_window_restore_default_state ( GncMainWindow window)

Restore the persistent state of one window to a sane default.

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

941 {
942  GtkAction *action;
943 
944  /* The default state should be to have an Account Tree page open
945  * in the window. */
946  DEBUG("no saved state file");
947  if (!window)
948  window = g_list_nth_data(active_windows, 0);
949  action = gnc_main_window_find_action(window, "ViewAccountTreeAction");
950  gtk_action_activate(action);
951 }
#define DEBUG(format, args...)
Definition: qoflog.h:255
GtkAction * gnc_main_window_find_action(GncMainWindow *window, const gchar *name)
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 1074 of file gnc-main-window.c.

1075 {
1076  GncMainWindowSaveData data;
1077 
1078  /* Set up the iterator data structures */
1079  data.key_file = keyfile;
1080  data.window_num = 1;
1081  data.page_num = 1;
1082 
1083  g_key_file_set_integer(data.key_file,
1084  STATE_FILE_TOP, WINDOW_COUNT,
1085  g_list_length(active_windows));
1086  /* Dump all state information on the open windows */
1087  g_list_foreach(active_windows, (GFunc)gnc_main_window_save_window, &data);
1088 }
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 4578 of file gnc-main-window.c.

4579 {
4580  GncWindow *gncwin;
4581  gncwin = GNC_WINDOW(window);
4582  gnc_window_set_progressbar_window(gncwin);
4583 }
void gnc_main_window_show_all_windows ( void  )

Shows all main windows.

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

4444 {
4445  GList *window_iter;
4446 #ifdef MAC_INTEGRATION
4447  GtkosxApplication *theApp = g_object_new(GTKOSX_TYPE_APPLICATION, NULL);
4448 #endif
4449  for (window_iter = active_windows; window_iter != NULL; window_iter = window_iter->next)
4450  {
4451  gtk_widget_show(GTK_WIDGET(window_iter->data));
4452  }
4453 #ifdef MAC_INTEGRATION
4454  g_signal_connect(theApp, "NSApplicationWillTerminate",
4455  G_CALLBACK(gnc_quartz_shutdown), NULL);
4456  gtkosx_application_ready(theApp);
4457  g_object_unref (theApp);
4458 #endif
4459 }
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 3174 of file gnc-main-window.c.

3176 {
3177  GncMainWindowPrivate *priv;
3178  MergedActionEntry *entry;
3179 
3180  g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
3181  g_return_if_fail (group_name != NULL);
3182 
3183  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
3184  if (priv->merged_actions_table == NULL)
3185  return;
3186  entry = g_hash_table_lookup (priv->merged_actions_table, group_name);
3187 
3188  if (entry == NULL)
3189  return;
3190 
3191  gtk_ui_manager_remove_action_group (window->ui_merge, entry->action_group);
3192  gtk_ui_manager_remove_ui (window->ui_merge, entry->merge_id);
3193  gtk_ui_manager_ensure_update (window->ui_merge);
3194 
3195  g_hash_table_remove (priv->merged_actions_table, group_name);
3196 }
GtkUIManager * ui_merge
GHashTable * merged_actions_table
GtkActionGroup * action_group
GtkWidget* gnc_ui_get_toplevel ( void  )

Get a pointer to the first active top level window or NULL if there is none.

Returns
A pointer to a GtkWindow object.

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

4467 {
4468  GList *window;
4469 
4470  for (window = active_windows; window; window = window->next)
4471  if (gtk_window_is_active (GTK_WINDOW (window->data)))
4472  return window->data;
4473 
4474  return NULL;
4475 }
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 2278 of file gnc-main-window.c.

2280 {
2281  GncMainWindow *window;
2282  GncMainWindowPrivate *priv;
2283  GtkWidget *tab_widget;
2284  GdkColor tab_color;
2285  gchar *color_string = NULL;
2286  gboolean want_color = FALSE;
2287 
2288  ENTER(" ");
2289  if (color_in)
2290  color_string = g_strstrip(g_strdup(color_in));
2291 
2292  if (color_string && *color_string != '\0')
2293  want_color = TRUE;
2294 
2295  /* Update the plugin */
2296  window = GNC_MAIN_WINDOW(page->window);
2297  if (want_color)
2298  gnc_plugin_page_set_page_color(page, color_string);
2299  else
2300  gnc_plugin_page_set_page_color(page, NULL);
2301 
2302  /* Update the notebook tab */
2303  main_window_find_tab_widget (window, page, &tab_widget);
2304  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
2305 
2306  if (want_color && gdk_color_parse(color_string, &tab_color) && priv->show_color_tabs)
2307  {
2308  if (!GTK_IS_EVENT_BOX (tab_widget))
2309  {
2310  GtkWidget *event_box = gtk_event_box_new ();
2311  g_object_ref (tab_widget);
2312  gtk_notebook_set_tab_label (GTK_NOTEBOOK(priv->notebook),
2313  page->notebook_page, event_box);
2314  gtk_container_add (GTK_CONTAINER(event_box), tab_widget);
2315  g_object_unref (tab_widget);
2316  tab_widget = event_box;
2317  }
2318  gtk_widget_modify_bg(tab_widget, GTK_STATE_NORMAL, &tab_color);
2319  gtk_widget_modify_bg(tab_widget, GTK_STATE_ACTIVE, &tab_color);
2320  }
2321  else
2322  {
2323  if (GTK_IS_EVENT_BOX (tab_widget))
2324  {
2325  GtkWidget *tab_hbox = gtk_bin_get_child(GTK_BIN(tab_widget));
2326  g_object_ref (tab_hbox);
2327  gtk_container_remove (GTK_CONTAINER(tab_widget), tab_hbox);
2328  gtk_notebook_set_tab_label (GTK_NOTEBOOK(priv->notebook),
2329  page->notebook_page, tab_hbox);
2330  g_object_unref (tab_hbox);
2331  }
2332  }
2333  g_free(color_string);
2334  LEAVE("done");
2335 }
GtkWidget * window
#define ENTER(format, args...)
Definition: qoflog.h:261
void gnc_plugin_page_set_page_color(GncPluginPage *page, const char *color)
#define LEAVE(format, args...)
Definition: qoflog.h:271
GtkWidget * notebook_page
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 2195 of file gnc-main-window.c.

2197 {
2198  GncMainWindow *window;
2199  GncMainWindowPrivate *priv;
2200  GtkWidget *label, *entry;
2201  gchar *name, *old_page_name, *old_page_long_name;
2202 
2203  ENTER(" ");
2204 
2205  if ((name_in == NULL) || (*name_in == '\0'))
2206  {
2207  LEAVE("no string");
2208  return;
2209  }
2210  name = g_strstrip(g_strdup(name_in));
2211 
2212  /* Optimization, if the name hasn't changed, don't update X. */
2213  if (*name == '\0' || 0 == strcmp(name, gnc_plugin_page_get_page_name(page)))
2214  {
2215  g_free(name);
2216  LEAVE("empty string or name unchanged");
2217  return;
2218  }
2219 
2220  old_page_name = g_strdup( gnc_plugin_page_get_page_name(page));
2221  old_page_long_name = g_strdup( gnc_plugin_page_get_page_long_name(page));
2222 
2223  /* Update the plugin */
2224  gnc_plugin_page_set_page_name(page, name);
2225 
2226  /* Update the notebook tab */
2227  window = GNC_MAIN_WINDOW(page->window);
2228  if (!window)
2229  {
2230  g_free(old_page_name);
2231  g_free(old_page_long_name);
2232  g_free(name);
2233  LEAVE("no window widget available");
2234  return;
2235  }
2236 
2237  if (main_window_find_tab_items(window, page, &label, &entry))
2238  gtk_label_set_text(GTK_LABEL(label), name);
2239 
2240  /* Update Tooltip on notebook Tab */
2241  if (old_page_long_name && old_page_name
2242  && g_strrstr(old_page_long_name, old_page_name) != NULL)
2243  {
2244  gchar *new_page_long_name;
2245  gint string_position;
2246  GtkWidget *tab_widget;
2247 
2248  string_position = strlen(old_page_long_name) - strlen(old_page_name);
2249  new_page_long_name = g_strconcat(g_strndup(old_page_long_name, string_position), name, NULL);
2250 
2251  gnc_plugin_page_set_page_long_name(page, new_page_long_name);
2252 
2253  if (main_window_find_tab_widget(window, page, &tab_widget))
2254  gtk_widget_set_tooltip_text(tab_widget, new_page_long_name);
2255 
2256  g_free(new_page_long_name);
2257  }
2258 
2259  /* Update the notebook menu */
2260  if (page->notebook_page)
2261  {
2262  priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
2263  label = gtk_notebook_get_menu_label (GTK_NOTEBOOK(priv->notebook),
2264  page->notebook_page);
2265  gtk_label_set_text(GTK_LABEL(label), name);
2266  }
2267 
2268  /* Force an update of the window title */
2269  gnc_main_window_update_title(window);
2270  g_free(old_page_long_name);
2271  g_free(old_page_name);
2272  g_free(name);
2273  LEAVE("done");
2274 }
const gchar * gnc_plugin_page_get_page_long_name(GncPluginPage *page)
const gchar * gnc_plugin_page_get_page_name(GncPluginPage *page)
GtkWidget * window
void gnc_plugin_page_set_page_long_name(GncPluginPage *page, const char *name)
#define ENTER(format, args...)
Definition: qoflog.h:261
#define LEAVE(format, args...)
Definition: qoflog.h:271
void gnc_plugin_page_set_page_name(GncPluginPage *page, const char *name)
GtkWidget * notebook_page