Embedded Window Functions
[Windows]


Files

file  gnc-embedded-window.h
 Functions that are supported by all types of windows.

Data Structures

struct  GncEmbeddedWindow
struct  GncEmbeddedWindowClass

Defines

#define GNC_TYPE_EMBEDDED_WINDOW   (gnc_embedded_window_get_type ())
#define GNC_EMBEDDED_WINDOW(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_EMBEDDED_WINDOW, GncEmbeddedWindow))
#define GNC_EMBEDDED_WINDOW_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_EMBEDDED_WINDOW, GncEmbeddedWindowClass))
#define GNC_IS_EMBEDDED_WINDOW(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_EMBEDDED_WINDOW))
#define GNC_IS_EMBEDDED_WINDOW_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_EMBEDDED_WINDOW))
#define GNC_EMBEDDED_WINDOW_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_EMBEDDED_WINDOW, GncEmbeddedWindowClass))

Functions

GType gnc_embedded_window_get_type (void)
GncEmbeddedWindowgnc_embedded_window_new (const gchar *action_group_name, GtkActionEntry *action_entries, gint n_action_entries, const gchar *ui_filename, GtkWidget *enclosing_win, gboolean add_accelerators, gpointer user_data)
void gnc_embedded_window_open_page (GncEmbeddedWindow *window, GncPluginPage *page)
void gnc_embedded_window_close_page (GncEmbeddedWindow *window, GncPluginPage *page)
GncPluginPagegnc_embedded_window_get_page (GncEmbeddedWindow *window)


Function Documentation

void gnc_embedded_window_close_page ( GncEmbeddedWindow window,
GncPluginPage page 
)

Remove a data plugin page from a window.

Parameters:
page The page of data to be removed.

Definition at line 157 of file gnc-embedded-window.c.

00159 {
00160   GncEmbeddedWindowPrivate *priv;
00161 
00162   g_return_if_fail (GNC_IS_EMBEDDED_WINDOW (window));
00163   g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
00164   priv = GNC_EMBEDDED_WINDOW_GET_PRIVATE(window);
00165   g_return_if_fail (priv->page == page);
00166 
00167   ENTER("window %p, page %p", window, page);
00168 
00169   if (!page->notebook_page) {
00170     LEAVE("no displayed widget");
00171     return;
00172   }
00173 
00174   gtk_container_remove (GTK_CONTAINER(window), GTK_WIDGET(page->notebook_page));
00175   priv->page = NULL;
00176   gnc_plugin_page_removed (page);
00177 
00178   gnc_plugin_page_unmerge_actions (page, window->ui_merge);
00179   gtk_ui_manager_ensure_update (window->ui_merge);
00180 
00181   gnc_plugin_page_destroy_widget (page);
00182   g_object_unref(page);
00183   LEAVE(" ");
00184 }

GncPluginPage* gnc_embedded_window_get_page ( GncEmbeddedWindow window  ) 

Retrieve the plugin that is embedded in the specified window.

Parameters:
window The window whose plugin is desired.
Returns:
A pointer to a GncPluginPage.

Definition at line 189 of file gnc-embedded-window.c.

00190 {
00191   GncEmbeddedWindowPrivate *priv;
00192 
00193   priv = GNC_EMBEDDED_WINDOW_GET_PRIVATE(window);
00194   return priv->page;
00195 }

GType gnc_embedded_window_get_type ( void   ) 

Get the type of a gnc embedded window.

Returns:
A GType.

Definition at line 95 of file gnc-embedded-window.c.

00096 {
00097   static GType gnc_embedded_window_type = 0;
00098 
00099   if (gnc_embedded_window_type == 0) {
00100     static const GTypeInfo our_info = {
00101       sizeof (GncEmbeddedWindowClass),
00102       NULL,
00103       NULL,
00104       (GClassInitFunc) gnc_embedded_window_class_init,
00105       NULL,
00106       NULL,
00107       sizeof (GncEmbeddedWindow),
00108       0,
00109       (GInstanceInitFunc) gnc_embedded_window_init
00110     };
00111 
00112     static const GInterfaceInfo plugin_info = {
00113       (GInterfaceInitFunc) gnc_window_embedded_window_init,
00114       NULL,
00115       NULL
00116     };
00117 
00118     gnc_embedded_window_type = g_type_register_static (GTK_TYPE_VBOX,
00119                                                        "GncEmbeddedWindow",
00120                                                        &our_info, 0);
00121     g_type_add_interface_static (gnc_embedded_window_type,
00122                                  GNC_TYPE_WINDOW,
00123                                  &plugin_info);
00124   }
00125 
00126   return gnc_embedded_window_type;
00127 }

GncEmbeddedWindow* gnc_embedded_window_new ( const gchar *  action_group_name,
GtkActionEntry *  action_entries,
gint  n_action_entries,
const gchar *  ui_filename,
GtkWidget *  enclosing_win,
gboolean  add_accelerators,
gpointer  user_data 
)

Create a new gnc embedded window plugin.

Definition at line 346 of file gnc-embedded-window.c.

00353 {
00354   GncEmbeddedWindowPrivate *priv;
00355   GncEmbeddedWindow *window;
00356   gchar *ui_fullname;
00357   GError *error = NULL;
00358   guint merge_id;
00359 
00360   ENTER("group %s, first %p, num %d, ui file %s, parent %p, add accelerators %d, user data %p",
00361         action_group_name, action_entries, n_action_entries, ui_filename,
00362         enclosing_win, add_accelerators, user_data);
00363   window = g_object_new (GNC_TYPE_EMBEDDED_WINDOW, NULL);
00364   priv = GNC_EMBEDDED_WINDOW_GET_PRIVATE(window);
00365 
00366   /* Determine the full pathname of the ui file */
00367   ui_fullname = gnc_gnome_locate_ui_file(ui_filename);
00368 
00369   priv->parent_window = enclosing_win;
00370 
00371   /* Create menu and toolbar information */
00372   priv->action_group = gtk_action_group_new (action_group_name);
00373   gnc_gtk_action_group_set_translation_domain(priv->action_group, GETTEXT_PACKAGE);
00374   gtk_action_group_add_actions (priv->action_group, action_entries,
00375                                 n_action_entries, user_data);
00376   gtk_ui_manager_insert_action_group (window->ui_merge, priv->action_group, 0);
00377   merge_id = gtk_ui_manager_add_ui_from_file (window->ui_merge, ui_fullname,
00378                                               &error);
00379 
00380   /* Error checking */
00381   g_assert(merge_id || error);
00382   if (error) {
00383     g_critical("Failed to load ui file.\n  Filename %s\n  Error %s",
00384                ui_fullname, error->message);
00385     g_error_free(error);
00386     g_free(ui_fullname); 
00387     LEAVE("window %p", window);
00388     return window;
00389   }
00390 
00391   /* Add accelerators (if wanted) */
00392   if (add_accelerators)
00393     gtk_window_add_accel_group (GTK_WINDOW(enclosing_win),
00394                                 gtk_ui_manager_get_accel_group(window->ui_merge));
00395 
00396   gtk_ui_manager_ensure_update (window->ui_merge);
00397   g_free(ui_fullname);
00398   LEAVE("window %p", window);
00399   return window;
00400 }

void gnc_embedded_window_open_page ( GncEmbeddedWindow window,
GncPluginPage page 
)

Display a data plugin page in a window.

Parameters:
window The window to display a new page in.
page The new page of data to be displayed.

Definition at line 132 of file gnc-embedded-window.c.

00134 {
00135   GncEmbeddedWindowPrivate *priv;
00136 
00137   g_return_if_fail (GNC_IS_EMBEDDED_WINDOW (window));
00138   g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
00139   priv = GNC_EMBEDDED_WINDOW_GET_PRIVATE(window);
00140   g_return_if_fail (priv->page == NULL);
00141 
00142   ENTER("window %p, page %p", window, page);
00143   priv->page = page;
00144   page->window = GTK_WIDGET(window);
00145   page->notebook_page = gnc_plugin_page_create_widget (page);
00146 
00147   gtk_box_pack_end(GTK_BOX(window), page->notebook_page, TRUE, TRUE, 2);
00148   gnc_plugin_page_inserted (page);
00149 
00150   gnc_plugin_page_merge_actions (page, window->ui_merge);
00151   LEAVE(" ");
00152 }


Generated on Mon Sep 8 05:04:39 2008 for GnuCash by  doxygen 1.5.2