36 #include "gnc-gui-query.h" 41 #include "dialog-utils.h" 54 static QofLogModule log_module = GNC_MOD_GUI;
58 static void gnc_embedded_window_constructed (GObject *
object);
59 static void gnc_embedded_window_finalize (GObject *
object);
60 static void gnc_embedded_window_dispose (GObject *
object);
62 static void gnc_window_embedded_window_init (GncWindowInterface *iface);
64 static void gnc_embedded_window_setup_window (GncEmbeddedWindow *window);
106 G_IMPLEMENT_INTERFACE(GNC_TYPE_WINDOW,
107 gnc_window_embedded_window_init))
111 static guint embedded_window_signals[LAST_SIGNAL] = { 0 };
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);
122 ENTER(
"window %p, page %p", window, page);
124 page->
window = GTK_WIDGET(window);
127 gtk_box_pack_end(GTK_BOX(window), page->
notebook_page, TRUE, TRUE, 2);
128 gnc_plugin_page_inserted (page);
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);
142 ENTER(
"window %p, page %p", window, page);
146 LEAVE(
"no displayed widget");
150 gtk_container_remove (GTK_CONTAINER(window), GTK_WIDGET(page->
notebook_page));
152 gnc_plugin_page_removed (page);
155 g_object_unref(page);
175 gnc_embedded_window_class_init (GncEmbeddedWindowClass *klass)
177 GObjectClass *object_class;
178 ENTER(
"klass %p", klass);
179 object_class = G_OBJECT_CLASS (klass);
181 object_class->constructed = gnc_embedded_window_constructed;
182 object_class->finalize = gnc_embedded_window_finalize;
183 object_class->dispose = gnc_embedded_window_dispose;
195 embedded_window_signals[PAGE_CHANGED] =
196 g_signal_new (
"page_changed",
197 G_OBJECT_CLASS_TYPE (object_class),
201 g_cclosure_marshal_VOID__OBJECT,
216 gnc_embedded_window_init (GncEmbeddedWindow *window)
218 ENTER(
"window %p", window);
220 gtk_orientable_set_orientation (GTK_ORIENTABLE(window), GTK_ORIENTATION_VERTICAL);
223 gtk_widget_set_name (GTK_WIDGET(window),
"gnc-id-embedded-window");
225 gnc_embedded_window_setup_window (window);
237 gnc_embedded_window_constructed (GObject *obj)
241 G_OBJECT_CLASS (gnc_embedded_window_parent_class)->constructed (obj);
248 gnc_embedded_window_finalize (GObject *
object)
250 g_return_if_fail (
object != NULL);
251 g_return_if_fail (GNC_IS_EMBEDDED_WINDOW (
object));
253 ENTER(
"object %p",
object);
255 G_OBJECT_CLASS (gnc_embedded_window_parent_class)->finalize (
object);
265 gnc_embedded_window_dispose (GObject *
object)
267 GncEmbeddedWindow *window;
269 g_return_if_fail (
object != NULL);
270 g_return_if_fail (GNC_IS_EMBEDDED_WINDOW (
object));
272 ENTER(
"object %p",
object);
273 window = GNC_EMBEDDED_WINDOW (
object);
277 DEBUG(
"unreffing page %p (count currently %d)", window->page,
278 G_OBJECT(window->page)->ref_count);
279 g_object_unref(window->page);
283 G_OBJECT_CLASS (gnc_embedded_window_parent_class)->dispose (
object);
292 gnc_embedded_window_setup_window (GncEmbeddedWindow *window)
294 ENTER(
"window %p", window);
297 gtk_widget_show (GTK_WIDGET(window));
299 window->menu_dock = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
300 gtk_box_set_homogeneous (GTK_BOX (window->menu_dock), FALSE);
301 gtk_widget_show (window->menu_dock);
302 gtk_box_pack_start (GTK_BOX (window), window->menu_dock, FALSE, TRUE, 0);
304 window->statusbar = gtk_statusbar_new ();
305 gtk_widget_show (window->statusbar);
306 gtk_box_pack_end (GTK_BOX (window), window->statusbar, FALSE, TRUE, 0);
308 window->simple_action_group = NULL;
316 GActionEntry *action_entries,
317 gint n_action_entries,
318 const gchar *ui_filename,
319 GtkWidget *enclosing_win,
320 gboolean add_accelerators,
323 GncEmbeddedWindow *window;
325 GError *error = NULL;
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);
332 window = g_object_new (GNC_TYPE_EMBEDDED_WINDOW, NULL);
334 builder = gtk_builder_new ();
335 gtk_builder_set_translation_domain (builder, PROJECT_NAME);
337 ui_fullname = g_strconcat (GNUCASH_RESOURCE_PREFIX
"/", ui_filename, NULL);
339 gtk_builder_add_from_resource (builder, ui_fullname, &error);
343 g_critical (
"Failed to load, Error %s", error->message);
344 g_error_free (error);
348 window->menubar_model = (GMenuModel *)gtk_builder_get_object (builder,
"embeddedwin-menu");
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));
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));
359 g_object_unref (builder);
361 window->simple_action_group = g_simple_action_group_new ();
363 g_action_map_add_action_entries (G_ACTION_MAP(window->simple_action_group),
368 gtk_widget_insert_action_group (GTK_WIDGET(window),
"embeddedwin",
369 G_ACTION_GROUP(window->simple_action_group));
371 window->parent_window = enclosing_win;
374 window->accel_group = gtk_accel_group_new ();
375 gtk_window_add_accel_group (GTK_WINDOW(enclosing_win), window->accel_group);
378 g_free (ui_fullname);
379 LEAVE(
"window %p", window);
390 gnc_embedded_window_get_gtk_window (GncWindow *window_in)
392 GncEmbeddedWindow *window;
394 g_return_val_if_fail (GNC_IS_EMBEDDED_WINDOW (window_in), NULL);
396 window = GNC_EMBEDDED_WINDOW(window_in);
397 return GTK_WINDOW(window->parent_window);
407 gnc_embedded_window_get_statusbar (GncWindow *window_in)
409 GncEmbeddedWindow *window;
411 g_return_val_if_fail (GNC_IS_EMBEDDED_WINDOW (window_in), NULL);
413 window = GNC_EMBEDDED_WINDOW(window_in);
414 return window->statusbar;
424 gnc_embedded_window_get_menubar (GncWindow *window)
426 g_return_val_if_fail (GNC_IS_EMBEDDED_WINDOW(window), NULL);
428 return GNC_EMBEDDED_WINDOW (window)->menubar;
437 gnc_embedded_window_get_toolbar (GncWindow *window)
439 g_return_val_if_fail (GNC_IS_EMBEDDED_WINDOW(window), NULL);
441 return GNC_EMBEDDED_WINDOW (window)->toolbar;
450 gnc_embedded_window_get_menubar_model (GncWindow *window)
452 g_return_val_if_fail (GNC_IS_EMBEDDED_WINDOW(window), NULL);
454 return GNC_EMBEDDED_WINDOW (window)->menubar_model;
462 static GtkAccelGroup *
463 gnc_embedded_window_get_accel_group (GncWindow *window)
465 g_return_val_if_fail (GNC_IS_EMBEDDED_WINDOW(window), NULL);
467 return GNC_EMBEDDED_WINDOW (window)->accel_group;
475 gnc_window_embedded_window_init (GncWindowInterface *iface)
477 iface->get_gtk_window = gnc_embedded_window_get_gtk_window;
478 iface->get_statusbar = gnc_embedded_window_get_statusbar;
479 iface->get_menubar = gnc_embedded_window_get_menubar;
480 iface->get_toolbar = gnc_embedded_window_get_toolbar;
481 iface->get_menubar_model = gnc_embedded_window_get_menubar_model;
482 iface->get_accel_group = gnc_embedded_window_get_accel_group;
GtkWidget * menubar
The menubar.
void gnc_plugin_page_destroy_widget(GncPluginPage *plugin_page)
Destroy the display widget that corresponds to this plugin.
The instance data structure for a content plugin.
GtkAccelGroup * accel_group
The accelerator group of all actions provided by the embedded window.
void gnc_embedded_window_close_page(GncEmbeddedWindow *window, GncPluginPage *page)
Remove a data plugin page from a window.
void gnc_gobject_tracking_forget(GObject *object)
Tell gnucash to remember this object in the database.
#define DEBUG(format, args...)
Print a debugging message.
Functions that are supported by all types of windows.
void gnc_embedded_window_open_page(GncEmbeddedWindow *window, GncPluginPage *page)
Display a data plugin page in a window.
Plugin management functions for the GnuCash UI.
GtkWidget * window
The window that contains the display widget for this plugin.
GtkWidget * toolbar
The toolbar.
The instance data structure for an embedded window object.
GncPluginPage * page
The currently selected page.
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.
#define ENTER(format, args...)
Print a function entry debugging message.
G_DEFINE_TYPE_WITH_CODE(GncMainWindow, gnc_main_window, GTK_TYPE_APPLICATION_WINDOW, G_IMPLEMENT_INTERFACE(GNC_TYPE_WINDOW, gnc_window_main_window_init)) static guint main_window_signals[LAST_SIGNAL]
A holding place for all the signals generated by the main window code.
void gnc_gobject_tracking_remember(GObject *object)
Tell gnucash to remember this object in the database.
GtkWidget * statusbar
A pointer to the status bar at the bottom edge of the window.
Gnome specific utility functions.
All type declarations for the whole Gnucash engine.
void gnc_add_accelerator_keys_for_menu(GtkWidget *menu, GMenuModel *model, GtkAccelGroup *accel_group)
Add accelerator keys for menu item widgets.
GncPluginPage * gnc_embedded_window_get_page(GncEmbeddedWindow *window)
Retrieve the plugin that is embedded in the specified window.
GtkWidget * menu_dock
The dock (vbox) at the top of the window containing the menubar and toolbar.
GtkWidget * parent_window
The parent of this embedded "window".
GMenuModel * menubar_model
The menubar_model.
GSimpleActionGroup * simple_action_group
The group of all actions provided by the embedded window itself.
Functions that are supported by all types of windows.
Functions for adding plugins to a GnuCash window.
#define LEAVE(format, args...)
Print a function exit debugging message.
File path resolution utility functions.
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.
GtkBox vbox
The parent object for an embedded window.