GnuCash  5.6-150-g038405b370+
Files | Macros | Functions
Embedded Window Functions

Files

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

Macros

#define GNC_TYPE_EMBEDDED_WINDOW   (gnc_embedded_window_get_type ())
 

Functions

GncEmbeddedWindow * gnc_embedded_window_new (const gchar *action_group_name, GActionEntry *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. More...
 
void gnc_embedded_window_open_page (GncEmbeddedWindow *window, GncPluginPage *page)
 Display a data plugin page in a window. More...
 
void gnc_embedded_window_close_page (GncEmbeddedWindow *window, GncPluginPage *page)
 Remove a data plugin page from a window. More...
 
GncPluginPagegnc_embedded_window_get_page (GncEmbeddedWindow *window)
 Retrieve the plugin that is embedded in the specified window. More...
 

Detailed Description

Function Documentation

◆ gnc_embedded_window_close_page()

void gnc_embedded_window_close_page ( GncEmbeddedWindow *  window,
GncPluginPage page 
)

Remove a data plugin page from a window.

Parameters
windowThe window whose plugin is to be removed.
pageThe page of data to be removed.

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

137 {
138  g_return_if_fail (GNC_IS_EMBEDDED_WINDOW (window));
139  g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
140  g_return_if_fail (window->page == page);
141 
142  ENTER("window %p, page %p", window, page);
143 
144  if (!page->notebook_page)
145  {
146  LEAVE("no displayed widget");
147  return;
148  }
149 
150  gtk_container_remove (GTK_CONTAINER(window), GTK_WIDGET(page->notebook_page));
151  window->page = NULL;
152  gnc_plugin_page_removed (page);
153 
155  g_object_unref(page);
156  LEAVE(" ");
157 }
void gnc_plugin_page_destroy_widget(GncPluginPage *plugin_page)
Destroy the display widget that corresponds to this plugin.
#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
GtkWidget * notebook_page
The display widget for this plugin.

◆ gnc_embedded_window_get_page()

GncPluginPage* gnc_embedded_window_get_page ( GncEmbeddedWindow *  window)

Retrieve the plugin that is embedded in the specified window.

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

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

163 {
164  return window->page;
165 }

◆ gnc_embedded_window_new()

GncEmbeddedWindow* gnc_embedded_window_new ( const gchar *  action_group_name,
GActionEntry *  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.

Returns
A pointer to the new object.

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

322 {
323  GncEmbeddedWindow *window;
324  gchar *ui_fullname;
325  GError *error = NULL;
326  GtkBuilder *builder;
327 
328  ENTER("group %s, first %p, num %d, ui file %s, parent %p, add accelerators %d, user data %p",
329  action_group_name, action_entries, n_action_entries, ui_filename,
330  enclosing_win, add_accelerators, user_data);
331 
332  window = g_object_new (GNC_TYPE_EMBEDDED_WINDOW, NULL);
333 
334  builder = gtk_builder_new ();
335  gtk_builder_set_translation_domain (builder, PROJECT_NAME);
336 
337  ui_fullname = g_strconcat (GNUCASH_RESOURCE_PREFIX "/", ui_filename, NULL);
338 
339  gtk_builder_add_from_resource (builder, ui_fullname, &error);
340 
341  if (error)
342  {
343  g_critical ("Failed to load, Error %s", error->message);
344  g_error_free (error);
345  return NULL;
346  }
347 
348  window->menubar_model = (GMenuModel *)gtk_builder_get_object (builder, "embeddedwin-menu");
349 
350  window->menubar = gtk_menu_bar_new_from_model (window->menubar_model);
351  gtk_container_add (GTK_CONTAINER(window->menu_dock), window->menubar);
352  gtk_widget_show (GTK_WIDGET(window->menubar));
353 
354  window->toolbar = (GtkWidget *)gtk_builder_get_object (builder, "embeddedwin-toolbar");
355  g_object_set (window->toolbar, "toolbar-style", GTK_TOOLBAR_BOTH, NULL);
356  gtk_container_add (GTK_CONTAINER(window->menu_dock), GTK_WIDGET(window->toolbar));
357  gtk_widget_show (GTK_WIDGET(window->toolbar));
358 
359  g_object_unref (builder);
360 
361  window->simple_action_group = g_simple_action_group_new ();
362 
363  g_action_map_add_action_entries (G_ACTION_MAP(window->simple_action_group),
364  action_entries,
365  n_action_entries,
366  user_data);
367 
368  gtk_widget_insert_action_group (GTK_WIDGET(window), "embeddedwin",
369  G_ACTION_GROUP(window->simple_action_group));
370 
371  window->parent_window = enclosing_win;
372 
373  // need to add the accelerator keys
374  window->accel_group = gtk_accel_group_new ();
375  gtk_window_add_accel_group (GTK_WINDOW(enclosing_win), window->accel_group);
376  gnc_add_accelerator_keys_for_menu (GTK_WIDGET(window->menubar), window->menubar_model, window->accel_group);
377 
378  g_free (ui_fullname);
379  LEAVE("window %p", window);
380  return window;
381 }
#define ENTER(format, args...)
Print a function entry debugging message.
Definition: qoflog.h:272
void gnc_add_accelerator_keys_for_menu(GtkWidget *menu, GMenuModel *model, GtkAccelGroup *accel_group)
Add accelerator keys for menu item widgets.
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282

◆ gnc_embedded_window_open_page()

void gnc_embedded_window_open_page ( GncEmbeddedWindow *  window,
GncPluginPage page 
)

Display a data plugin page in a window.

Parameters
windowThe window to display a new page in.
pageThe new page of data to be displayed.

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

117 {
118  g_return_if_fail (GNC_IS_EMBEDDED_WINDOW (window));
119  g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
120  g_return_if_fail (window->page == NULL);
121 
122  ENTER("window %p, page %p", window, page);
123  window->page = page;
124  page->window = GTK_WIDGET(window);
126 
127  gtk_box_pack_end(GTK_BOX(window), page->notebook_page, TRUE, TRUE, 2);
128  gnc_plugin_page_inserted (page);
129  LEAVE(" ");
130 }
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
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition: qoflog.h:282
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.