GnuCash 2.3.0
Data Structures | Files | Defines | Typedefs | Enumerations | Functions
Main Window functions.
Windows

Data Structures

struct  GncMainWindowPrivate
struct  MergedActionEntry
struct  GncMainWindowSaveData
struct  menu_update
struct  _ActionStatus
struct  GncMainWindow
struct  GncMainWindowClass
struct  GncMainWindowActionData

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.


Defines

#define PLUGIN_PAGE_LABEL   "plugin-page"
#define PLUGIN_PAGE_CLOSE_BUTTON   "close-button"
#define PLUGIN_PAGE_TAB_LABEL   "label"
#define KEY_SHOW_CLOSE_BUTTON   "tab_close_buttons"
#define KEY_TAB_NEXT_RECENT   "tab_next_recent"
#define KEY_TAB_POSITION   "tab_position"
#define KEY_TAB_WIDTH   "tab_width"
#define GNC_MAIN_WINDOW_NAME   "GncMainWindow"
#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 (void)
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)
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)

Define 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 85 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 76 of file gnc-main-window.c.

{
    PAGE_ADDED,
    PAGE_CHANGED,
    LAST_SIGNAL
};

Function Documentation

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

{
    g_return_if_fail (GTK_IS_ACTION_GROUP (action_group));

    gtk_action_group_set_translate_func (action_group,
                                         (GtkTranslateFunc)dgettext_swapped,
                                         g_strdup (domain),
                                         g_free);
}
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 2905 of file gnc-main-window.c.

{
    GtkActionGroup *force;

    g_return_if_fail (GNC_IS_MAIN_WINDOW (window));

    /* Unfortunately gtk_ui_manager_ensure_update doesn't work
     * here.  Force a full update by adding and removing an empty
     * action group.
     */
    force = gtk_action_group_new("force_update");
    gtk_ui_manager_insert_action_group (window->ui_merge, force, 0);
    gtk_ui_manager_ensure_update (window->ui_merge);
    gtk_ui_manager_remove_action_group (window->ui_merge, force);
    g_object_unref(force);
}
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 4375 of file gnc-main-window.c.

{
    GList *tmp;
    GtkAction *action;

    for (tmp = active_windows; tmp; tmp = g_list_next(tmp))
    {
        action = gnc_main_window_find_action (tmp->data, action_name);
        gtk_action_set_sensitive (action, sensitive);
    }
}
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 1057 of file gnc-main-window.c.

{
    const GList *windows, *item;

    windows = gnc_gobject_tracking_get_list(GNC_MAIN_WINDOW_NAME);
    for (item = windows; item; item = g_list_next(item))
    {
        if (!gnc_main_window_finish_pending(item->data))
        {
            return FALSE;
        }
    }
    return TRUE;
}
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 4322 of file gnc-main-window.c.

{
    g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), FALSE);

    ENTER("widget %p, event %p, page %p", whatever, event, page);
    /* Ignore double-clicks and triple-clicks */
    if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
    {
        do_popup_menu(page, event);
        LEAVE("menu shown");
        return TRUE;
    }

    LEAVE("other click");
    return FALSE;
}
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 2720 of file gnc-main-window.c.

{
    GncMainWindow *window;
    GncMainWindowPrivate *priv;

    if (!page || !page->notebook_page)
        return;

    if (!gnc_plugin_page_finish_pending(page))
        return;

    if (!GNC_IS_MAIN_WINDOW (page->window))
        return;

    window = GNC_MAIN_WINDOW (page->window);
    if (!window)
    {
        g_warning("Page is not in a window.");
        return;
    }

    gnc_main_window_disconnect(window, page);
    gnc_plugin_page_destroy_widget (page);
    g_object_unref(page);

    /* If this isn't the last window, go ahead and destroy the window. */
    priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
    if (priv->installed_pages == NULL)
    {
        if (g_list_length(active_windows) > 1)
        {
            gtk_widget_destroy(GTK_WIDGET(window));
        }
    }
}
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 2529 of file gnc-main-window.c.

{
    GncMainWindow *window;
    GncMainWindowPrivate *priv;
    GtkNotebook *notebook;
    gint page_num;

    window = GNC_MAIN_WINDOW (page->window);
    priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
    notebook = GTK_NOTEBOOK (priv->notebook);
    page_num = gtk_notebook_page_num(notebook, page->notebook_page);
    gtk_notebook_set_current_page (notebook, page_num);
    gtk_window_present(GTK_WINDOW(window));
}
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 2924 of file gnc-main-window.c.

{
    GtkAction *action = NULL;
    const GList *groups, *tmp;

    groups = gtk_ui_manager_get_action_groups(window->ui_merge);
    for (tmp = groups; tmp; tmp = g_list_next(tmp))
    {
        action = gtk_action_group_get_action(GTK_ACTION_GROUP(tmp->data), name);
        if (action)
            break;
    }
    return action;
}
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 1037 of file gnc-main-window.c.

{
    GncMainWindowPrivate *priv;
    GList *item;

    g_return_val_if_fail(GNC_IS_MAIN_WINDOW(window), TRUE);

    priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
    for (item = priv->installed_pages; item; item = g_list_next(item))
    {
        if (!gnc_plugin_page_finish_pending(item->data))
        {
            return FALSE;
        }
    }
    return TRUE;
}
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 2945 of file gnc-main-window.c.

{
    GncMainWindowPrivate *priv;
    MergedActionEntry *entry;

    g_return_val_if_fail (GNC_IS_MAIN_WINDOW (window), NULL);
    g_return_val_if_fail (group_name != NULL, NULL);

    priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
    if (priv->merged_actions_table == NULL)
        return NULL;
    entry = g_hash_table_lookup (priv->merged_actions_table, group_name);

    if (entry == NULL)
        return NULL;

    return entry->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 2765 of file gnc-main-window.c.

{
    GncMainWindowPrivate *priv;

    priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
    return priv->current_page;
}
GType gnc_main_window_get_type ( void  )

Get the type of a gnc main window.

Returns:
A GType.

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

{
    static GType gnc_main_window_type = 0;

    if (gnc_main_window_type == 0)
    {
        static const GTypeInfo our_info =
        {
            sizeof (GncMainWindowClass),
            NULL,
            NULL,
            (GClassInitFunc) gnc_main_window_class_init,
            NULL,
            NULL,
            sizeof (GncMainWindow),
            0,
            (GInstanceInitFunc) gnc_main_window_init
        };

        static const GInterfaceInfo plugin_info =
        {
            (GInterfaceInitFunc) gnc_window_main_window_init,
            NULL,
            NULL
        };

        gnc_main_window_type = g_type_register_static (GTK_TYPE_WINDOW,
                               GNC_MAIN_WINDOW_NAME,
                               &our_info, 0);
        g_type_add_interface_static (gnc_main_window_type,
                                     GNC_TYPE_WINDOW,
                                     &plugin_info);
    }

    return gnc_main_window_type;
}
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 4388 of file gnc-main-window.c.

{
    g_assert(window);
    return window->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 2780 of file gnc-main-window.c.

{
    GncMainWindowPrivate *priv;
    MergedActionEntry *entry;

    g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
    g_return_if_fail (group_name != NULL);
    g_return_if_fail (GTK_IS_ACTION_GROUP(group));
    g_return_if_fail (merge_id > 0);

    priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
    entry = g_new0 (MergedActionEntry, 1);
    entry->action_group = group;
    entry->merge_id = merge_id;
    gtk_ui_manager_ensure_update (window->ui_merge);
    g_hash_table_insert (priv->merged_actions_table, g_strdup (group_name), entry);
}
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 2809 of file gnc-main-window.c.

{
    GncMainWindowPrivate *priv;
    GncMainWindowActionData *data;
    MergedActionEntry *entry;
    GError *error = NULL;
    gchar *pathname;

    g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
    g_return_if_fail (group_name != NULL);
    g_return_if_fail (actions != NULL);
    g_return_if_fail (n_actions > 0);
    g_return_if_fail (filename != NULL);

    pathname = gnc_gnome_locate_ui_file (filename);
    if (pathname == NULL)
        return;

    data = g_new0 (GncMainWindowActionData, 1);
    data->window = window;
    data->data = user_data;

    priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
    entry = g_new0 (MergedActionEntry, 1);
    entry->action_group = gtk_action_group_new (group_name);
    gnc_gtk_action_group_set_translation_domain (entry->action_group, GETTEXT_PACKAGE);
    gtk_action_group_add_actions (entry->action_group, actions, n_actions, data);
    if (toggle_actions != NULL && n_toggle_actions > 0)
    {
        gtk_action_group_add_toggle_actions (entry->action_group,
                                             toggle_actions, n_toggle_actions,
                                             data);
    }
    gtk_ui_manager_insert_action_group (window->ui_merge, entry->action_group, 0);
    entry->merge_id = gtk_ui_manager_add_ui_from_file (window->ui_merge, pathname, &error);
    g_assert(entry->merge_id || error);
    if (entry->merge_id)
    {
        gtk_ui_manager_ensure_update (window->ui_merge);
        g_hash_table_insert (priv->merged_actions_table, g_strdup (group_name), entry);
    }
    else
    {
        g_critical("Failed to load ui file.\n  Filename %s\n  Error %s",
                   filename, error->message);
        g_error_free(error);
        g_free(entry);
    }
    g_free(pathname);
}
GncMainWindow * gnc_main_window_new ( void  )

Create a new gnc main window plugin.

Returns:
A pointer to the new object.

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

{
    GncMainWindow *window;
    GtkWidget *old_window;

    window = g_object_new (GNC_TYPE_MAIN_WINDOW, NULL);
    gtk_window_set_default_size(GTK_WINDOW(window), 800, 600);

    old_window = gnc_ui_get_toplevel();
    if (old_window)
    {
        gint width, height;
        gtk_window_get_size (GTK_WINDOW (old_window), &width, &height);
        gtk_window_resize (GTK_WINDOW (window), width, height);
        if ((gdk_window_get_state((GTK_WIDGET(old_window))->window)
                & GDK_WINDOW_STATE_MAXIMIZED) != 0)
        {
            gtk_window_maximize (GTK_WINDOW (window));
        }
    }
    active_windows = g_list_append (active_windows, window);
    gnc_main_window_update_title(window);
#ifdef MAC_INTEGRATION
    gnc_quartz_set_menu(window);
#else
    gnc_main_window_update_all_menu_items();
#endif
    gnc_engine_add_commit_error_callback( gnc_main_window_engine_commit_error_callback, window );

    return window;
}
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 2553 of file gnc-main-window.c.

{
    GncMainWindowPrivate *priv;
    GtkWidget *tab_hbox;
    GtkWidget *label, *entry, *event_box;
    const gchar *icon, *text, *color_string;
    GtkWidget *image;
    GList *tmp;
    gint width;
    GdkColor tab_color;

    ENTER("window %p, page %p", window, page);

    if (window)
        g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
    g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
    g_return_if_fail (gnc_plugin_page_has_books(page));

    if (gnc_main_window_page_exists(page))
    {
        gnc_main_window_display_page(page);
        return;
    }

    /* Does the page want to be in a new window? */
    if (gnc_plugin_page_get_use_new_window(page))
    {
        /* See if there's a blank window. If so, use that. */
        for (tmp = active_windows; tmp; tmp = g_list_next(tmp))
        {
            window = GNC_MAIN_WINDOW(tmp->data);
            priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
            if (priv->installed_pages == NULL)
            {
                break;
            }
        }
        if (tmp == NULL)
            window = gnc_main_window_new ();
        gtk_widget_show(GTK_WIDGET(window));
    }
    else if ((window == NULL) && active_windows)
    {
        window = active_windows->data;
    }

    page->window = GTK_WIDGET(window);
    page->notebook_page = gnc_plugin_page_create_widget (page);
    g_object_set_data (G_OBJECT (page->notebook_page),
                       PLUGIN_PAGE_LABEL, page);

    /*
     * The page tab.
     */
    width = gnc_gconf_get_float(GCONF_GENERAL, KEY_TAB_WIDTH, NULL);
    icon = GNC_PLUGIN_PAGE_GET_CLASS(page)->tab_icon;
    label = gtk_label_new (gnc_plugin_page_get_page_name(page));
    if (width != 0)
    {
        gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_MIDDLE);
        gtk_label_set_max_width_chars(GTK_LABEL(label), width);
    }
    gtk_widget_show (label);

    tab_hbox = gtk_hbox_new (FALSE, 6);
    gtk_widget_show (tab_hbox);

    if (icon != NULL)
    {
        image = gtk_image_new_from_stock (icon, GTK_ICON_SIZE_MENU);
        gtk_widget_show (image);
        gtk_box_pack_start (GTK_BOX (tab_hbox), image, FALSE, FALSE, 0);
        gtk_box_pack_start (GTK_BOX (tab_hbox), label, TRUE, TRUE, 0);
    }
    else
        gtk_box_pack_start (GTK_BOX (tab_hbox), label, TRUE, TRUE, 0);

    event_box = gtk_event_box_new();
    /* Note: this doesn't work properly on Windows with gtk+2.18.x (last
     * with 2.18.7). Setting the eventbox visible with that version results
     * in the tab's text being invisible. See bug #610675 for more on this.
     */
    gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box), TRUE);
    gtk_widget_show(event_box);
    gtk_container_add(GTK_CONTAINER(event_box), tab_hbox);
    color_string = gnc_plugin_page_get_page_color(page);
    if (color_string == NULL) color_string = "";
    if (gdk_color_parse(color_string, &tab_color))
    {
        gtk_widget_modify_bg(event_box, GTK_STATE_NORMAL, &tab_color);
        gtk_widget_modify_bg(event_box, GTK_STATE_ACTIVE, &tab_color);
    }
    else
    {
        gtk_widget_modify_bg(event_box, GTK_STATE_NORMAL, NULL);
        gtk_widget_modify_bg(event_box, GTK_STATE_ACTIVE, NULL);
    }

    text = gnc_plugin_page_get_page_long_name(page);
    if (text)
    {
        gtk_widget_set_tooltip_text(event_box, text);
    }

    entry = gtk_entry_new();
    gtk_widget_hide (entry);
    gtk_box_pack_start (GTK_BOX (tab_hbox), entry, TRUE, TRUE, 0);
    g_signal_connect(G_OBJECT(entry), "activate",
                     G_CALLBACK(gnc_main_window_tab_entry_activate), page);
    g_signal_connect(G_OBJECT(entry), "focus-out-event",
                     G_CALLBACK(gnc_main_window_tab_entry_focus_out_event),
                     page);
    g_signal_connect(G_OBJECT(entry), "key-press-event",
                     G_CALLBACK(gnc_main_window_tab_entry_key_press_event),
                     page);
    g_signal_connect(G_OBJECT(entry), "editing-done",
                     G_CALLBACK(gnc_main_window_tab_entry_editing_done),
                     page);

    /* Add close button - Not for immutable pages */
    if (!g_object_get_data (G_OBJECT (page), PLUGIN_PAGE_IMMUTABLE))
    {
        GtkWidget *close_image, *close_button;
        GtkRequisition requisition;

        close_button = gtk_button_new();
        gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE);
        close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
        gtk_widget_show(close_image);
        gtk_widget_size_request(close_image, &requisition);
        gtk_widget_set_size_request(close_button, requisition.width + 4,
                                    requisition.height + 2);
        gtk_button_set_alignment(GTK_BUTTON(close_button), 0.5, 0.5);
        gtk_container_add(GTK_CONTAINER(close_button), close_image);
        if (gnc_gconf_get_bool(GCONF_GENERAL, KEY_SHOW_CLOSE_BUTTON, NULL))
            gtk_widget_show (close_button);
        else
            gtk_widget_hide (close_button);

        g_signal_connect_swapped (G_OBJECT (close_button), "clicked",
                                  G_CALLBACK(gnc_main_window_close_page), page);

        gtk_box_pack_start (GTK_BOX (tab_hbox), close_button, FALSE, FALSE, 0);

        g_object_set_data (G_OBJECT (page), PLUGIN_PAGE_CLOSE_BUTTON, close_button);
    }

    /*
     * The popup menu
     */
    label = gtk_label_new (gnc_plugin_page_get_page_name(page));

    /*
     * Now install it all in the window.
     */
    gnc_main_window_connect(window, page, event_box, label);
    LEAVE("");
}
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 851 of file gnc-main-window.c.

{
    gint i, window_count;
    GError *error = NULL;
    GncMainWindowSaveData data;
    GncMainWindow *window;

    /* We use the same struct for reading and for writing, so we cast
       away the const. */
    data.key_file = (GKeyFile *) keyfile;
    window_count = g_key_file_get_integer(data.key_file, STATE_FILE_TOP,
                                          WINDOW_COUNT, &error);
    if (error)
    {
        g_warning("error reading group %s key %s: %s",
                  STATE_FILE_TOP, WINDOW_COUNT, error->message);
        g_error_free(error);
        LEAVE("can't read count");
        return;
    }

    /* Restore all state information on the open windows.  Window
       numbers in state file are 1-based. GList indices are 0-based. */
    gnc_set_busy_cursor (NULL, TRUE);
    for (i = 0; i < window_count; i++)
    {
        data.window_num = i;
        window = g_list_nth_data(active_windows, i);
        gnc_main_window_restore_window(window, &data);
    }
    gnc_unset_busy_cursor (NULL);
}
void gnc_main_window_restore_default_state ( void  )

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

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

{
    GtkAction *action;
    GncMainWindow *window;

    /* The default state should be to have an Account Tree page open
     * in the window. */
    DEBUG("no saved state file");
    window = g_list_nth_data(active_windows, 0);
    action = gnc_main_window_find_action(window, "ViewAccountTreeAction");
    gtk_action_activate(action);
}
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 1019 of file gnc-main-window.c.

{
    GncMainWindowSaveData data;

    /* Set up the iterator data structures */
    data.key_file = keyfile;
    data.window_num = 1;
    data.page_num = 1;

    g_key_file_set_integer(data.key_file,
                           STATE_FILE_TOP, WINDOW_COUNT,
                           g_list_length(active_windows));
    /* Dump all state information on the open windows */
    g_list_foreach(active_windows, (GFunc)gnc_main_window_save_window, &data);
}
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 4233 of file gnc-main-window.c.

{
    GncWindow *gncwin;
    gncwin = GNC_WINDOW(window);
    gnc_window_set_progressbar_window(gncwin);
}
void gnc_main_window_show_all_windows ( void  )

Shows all main windows.

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

{
    GList *window_iter;
#ifdef MAC_INTEGRATION
    GtkOSXApplication *theApp = g_object_new(GTK_TYPE_OSX_APPLICATION, NULL);
#endif
    for (window_iter = active_windows; window_iter != NULL; window_iter = window_iter->next)
    {
        gtk_widget_show(GTK_WIDGET(window_iter->data));
#ifdef MAC_INTEGRATION
        gnc_quartz_set_menu(window_iter->data);
#endif
    }
#ifdef MAC_INTEGRATION
    g_signal_connect(theApp, "NSApplicationWillTerminate",
                     G_CALLBACK(gnc_quartz_shutdown), NULL);
    gtk_osxapplication_ready(theApp);
#endif
}
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 2874 of file gnc-main-window.c.

{
    GncMainWindowPrivate *priv;
    MergedActionEntry *entry;

    g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
    g_return_if_fail (group_name != NULL);

    priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
    if (priv->merged_actions_table == NULL)
        return;
    entry = g_hash_table_lookup (priv->merged_actions_table, group_name);

    if (entry == NULL)
        return;

    gtk_ui_manager_remove_action_group (window->ui_merge, entry->action_group);
    gtk_ui_manager_remove_ui (window->ui_merge, entry->merge_id);
    gtk_ui_manager_ensure_update (window->ui_merge);

    g_hash_table_remove (priv->merged_actions_table, group_name);
}
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 4121 of file gnc-main-window.c.

{
    GList *window;

    for (window = active_windows; window; window = window->next)
        if (gtk_window_is_active (GTK_WINDOW (window->data)))
            return window->data;

    return NULL;
}
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 1984 of file gnc-main-window.c.

{
    GncMainWindow *window;
    GncMainWindowPrivate *priv;
    GtkWidget *event_box;
    GdkColor tab_color;
    gchar *color_string;


    ENTER(" ");

    if ((color_in == NULL) || (*color_in == '\0'))
    {
        LEAVE("no string");
        return;
    }
    color_string = g_strstrip(g_strdup(color_in));

    /* Optimization, if the color hasn't changed, don't update. */
    if (*color_string == '\0' || 0 == safe_strcmp(color_string, gnc_plugin_page_get_page_color(page)))
    {
        g_free(color_string);
        LEAVE("empty string or color unchanged");
        return;
    }

    /* Update the plugin */
    window = GNC_MAIN_WINDOW(page->window);
    priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
    gnc_plugin_page_set_page_color(page, color_string);

    /* Update the notebook tab */
    main_window_find_tab_event(window, page, &event_box);

    if (gdk_color_parse(color_string, &tab_color))
    {
        gtk_widget_modify_bg(event_box, GTK_STATE_NORMAL, &tab_color);
        gtk_widget_modify_bg(event_box, GTK_STATE_ACTIVE, &tab_color);
    }
    else
    {
        gtk_widget_modify_bg(event_box, GTK_STATE_NORMAL, NULL);
        gtk_widget_modify_bg(event_box, GTK_STATE_ACTIVE, NULL);
    }
    g_free(color_string);
    LEAVE("done");
}
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 1902 of file gnc-main-window.c.

{
    GncMainWindow *window;
    GncMainWindowPrivate *priv;
    GtkWidget *label, *entry, *event_box;
    gchar *name, *old_page_name, *old_page_long_name;

    ENTER(" ");

    if ((name_in == NULL) || (*name_in == '\0'))
    {
        LEAVE("no string");
        return;
    }
    name = g_strstrip(g_strdup(name_in));

    /* Optimization, if the name hasn't changed, don't update X. */
    if (*name == '\0' || 0 == strcmp(name, gnc_plugin_page_get_page_name(page)))
    {
        g_free(name);
        LEAVE("empty string or name unchanged");
        return;
    }

    old_page_name = g_strdup( gnc_plugin_page_get_page_name(page));
    old_page_long_name = g_strdup( gnc_plugin_page_get_page_long_name(page));

    /* Update the plugin */
    gnc_plugin_page_set_page_name(page, name);

    /* Update the notebook tab */
    window = GNC_MAIN_WINDOW(page->window);
    if (!window)
    {
        g_free(old_page_name);
        g_free(old_page_long_name);
        g_free(name);
        LEAVE("no window widget available");
        return;
    }

    if (main_window_find_tab_items(window, page, &label, &entry))
        gtk_label_set_text(GTK_LABEL(label), name);

    /* Update Tooltip on notebook Tab */
    if (old_page_long_name && old_page_name
            && g_strrstr(old_page_long_name, old_page_name) != NULL)
    {
        gchar *new_page_long_name;
        gint string_position;

        string_position = strlen(old_page_long_name) - strlen(old_page_name);
        new_page_long_name = g_strconcat(g_strndup(old_page_long_name, string_position), name, NULL);

        gnc_plugin_page_set_page_long_name(page, new_page_long_name);

        if (main_window_find_tab_event(window, page, &event_box))
            gtk_widget_set_tooltip_text(event_box, new_page_long_name);

        g_free(new_page_long_name);
    }

    /* Update the notebook menu */
    if (page->notebook_page)
    {
        priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
        label = gtk_notebook_get_menu_label (GTK_NOTEBOOK(priv->notebook),
                                             page->notebook_page);
        gtk_label_set_text(GTK_LABEL(label), name);
    }

    /* Force an update of the window title */
    gnc_main_window_update_title(window);
    g_free(old_page_long_name);
    g_free(old_page_name);
    g_free(name);
    LEAVE("done");
}
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines