36 #include "gnc-gui-query.h"
47 static GObjectClass *parent_class = NULL;
53 static void gnc_embedded_window_finalize (GObject *
object);
54 static void gnc_embedded_window_dispose (GObject *
object);
56 static void gnc_window_embedded_window_init (
GncWindowIface *iface);
89 #define GNC_EMBEDDED_WINDOW_GET_PRIVATE(o) \
90 (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_EMBEDDED_WINDOW, GncEmbeddedWindowPrivate))
98 static GType gnc_embedded_window_type = 0;
100 if (gnc_embedded_window_type == 0)
102 static const GTypeInfo our_info =
107 (GClassInitFunc) gnc_embedded_window_class_init,
112 (GInstanceInitFunc) gnc_embedded_window_init
115 static const GInterfaceInfo plugin_info =
117 (GInterfaceInitFunc) gnc_window_embedded_window_init,
122 gnc_embedded_window_type = g_type_register_static (GTK_TYPE_VBOX,
125 g_type_add_interface_static (gnc_embedded_window_type,
130 return gnc_embedded_window_type;
141 g_return_if_fail (GNC_IS_EMBEDDED_WINDOW (window));
142 g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
143 priv = GNC_EMBEDDED_WINDOW_GET_PRIVATE(window);
144 g_return_if_fail (priv->
page == NULL);
146 ENTER(
"window %p, page %p", window, page);
148 page->
window = GTK_WIDGET(window);
151 gtk_box_pack_end(GTK_BOX(window), page->
notebook_page, TRUE, TRUE, 2);
152 gnc_plugin_page_inserted (page);
166 g_return_if_fail (GNC_IS_EMBEDDED_WINDOW (window));
167 g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
168 priv = GNC_EMBEDDED_WINDOW_GET_PRIVATE(window);
169 g_return_if_fail (priv->
page == page);
171 ENTER(
"window %p, page %p", window, page);
175 LEAVE(
"no displayed widget");
179 gtk_container_remove (GTK_CONTAINER(window), GTK_WIDGET(page->
notebook_page));
181 gnc_plugin_page_removed (page);
184 gtk_ui_manager_ensure_update (window->
ui_merge);
187 g_object_unref(page);
198 priv = GNC_EMBEDDED_WINDOW_GET_PRIVATE(window);
212 GObjectClass *object_class;
213 ENTER(
"klass %p", klass);
214 object_class = G_OBJECT_CLASS (klass);
216 parent_class = g_type_class_peek_parent (klass);
218 object_class->finalize = gnc_embedded_window_finalize;
219 object_class->dispose = gnc_embedded_window_dispose;
238 ENTER(
"window %p", window);
240 gnc_embedded_window_setup_window (window);
243 G_OBJECT_CLASS(klass));
252 gnc_embedded_window_finalize (GObject *
object)
254 g_return_if_fail (
object != NULL);
255 g_return_if_fail (GNC_IS_EMBEDDED_WINDOW (
object));
257 ENTER(
"object %p",
object);
259 G_OBJECT_CLASS (parent_class)->finalize (
object);
269 gnc_embedded_window_dispose (GObject *
object)
274 g_return_if_fail (
object != NULL);
275 g_return_if_fail (GNC_IS_EMBEDDED_WINDOW (
object));
277 ENTER(
"object %p",
object);
278 window = GNC_EMBEDDED_WINDOW (
object);
279 priv = GNC_EMBEDDED_WINDOW_GET_PRIVATE(window);
282 DEBUG(
"unreffing page %p (count currently %d)", priv->
page,
283 G_OBJECT(priv->
page)->ref_count);
284 g_object_unref(priv->
page);
288 G_OBJECT_CLASS (parent_class)->dispose (
object);
294 gnc_embedded_window_add_widget (GtkUIManager *merge,
300 ENTER(
"merge %p, new widget %p, window %p", merge, widget, window);
301 priv = GNC_EMBEDDED_WINDOW_GET_PRIVATE(window);
302 if (GTK_IS_TOOLBAR (widget))
304 priv->toolbar = widget;
307 gtk_box_pack_start (GTK_BOX (priv->
menu_dock), widget, FALSE, FALSE, 0);
308 gtk_widget_show (widget);
321 ENTER(
"window %p", window);
322 priv = GNC_EMBEDDED_WINDOW_GET_PRIVATE(window);
325 gtk_widget_show (GTK_WIDGET(window));
327 priv->
menu_dock = gtk_vbox_new (FALSE, 0);
329 gtk_box_pack_start (GTK_BOX (window), priv->
menu_dock, FALSE, TRUE, 0);
332 gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR(priv->
statusbar), FALSE);
334 gtk_box_pack_end (GTK_BOX (window), priv->
statusbar, FALSE, TRUE, 0);
336 window->
ui_merge = gtk_ui_manager_new ();
337 g_signal_connect (G_OBJECT (window->
ui_merge),
"add_widget",
338 G_CALLBACK (gnc_embedded_window_add_widget), window);
348 GtkActionEntry *action_entries,
349 gint n_action_entries,
350 const gchar *ui_filename,
351 GtkWidget *enclosing_win,
352 gboolean add_accelerators,
358 GError *error = NULL;
361 ENTER(
"group %s, first %p, num %d, ui file %s, parent %p, add accelerators %d, user data %p",
362 action_group_name, action_entries, n_action_entries, ui_filename,
363 enclosing_win, add_accelerators, user_data);
364 window = g_object_new (GNC_TYPE_EMBEDDED_WINDOW, NULL);
365 priv = GNC_EMBEDDED_WINDOW_GET_PRIVATE(window);
369 g_return_val_if_fail (ui_fullname != NULL, NULL);
374 priv->
action_group = gtk_action_group_new (action_group_name);
376 gtk_action_group_add_actions (priv->
action_group, action_entries,
377 n_action_entries, user_data);
379 merge_id = gtk_ui_manager_add_ui_from_file (window->
ui_merge, ui_fullname,
383 g_assert(merge_id || error);
386 g_critical(
"Failed to load ui file.\n Filename %s\n Error %s",
387 ui_fullname, error->message);
390 LEAVE(
"window %p", window);
395 if (add_accelerators)
396 gtk_window_add_accel_group (GTK_WINDOW(enclosing_win),
397 gtk_ui_manager_get_accel_group(window->
ui_merge));
399 gtk_ui_manager_ensure_update (window->
ui_merge);
401 LEAVE(
"window %p", window);
412 gnc_embedded_window_get_gtk_window (GncWindow *window_in)
417 g_return_val_if_fail (GNC_IS_EMBEDDED_WINDOW (window_in), NULL);
419 window = GNC_EMBEDDED_WINDOW(window_in);
420 priv = GNC_EMBEDDED_WINDOW_GET_PRIVATE(window);
431 gnc_embedded_window_get_statusbar (GncWindow *window_in)
436 g_return_val_if_fail (GNC_IS_EMBEDDED_WINDOW (window_in), NULL);
438 window = GNC_EMBEDDED_WINDOW(window_in);
439 priv = GNC_EMBEDDED_WINDOW_GET_PRIVATE(window);
451 iface->get_gtk_window = gnc_embedded_window_get_gtk_window;
452 iface->get_statusbar = gnc_embedded_window_get_statusbar;
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)
void gnc_plugin_page_destroy_widget(GncPluginPage *plugin_page)
void gnc_gobject_tracking_remember(GObject *object, GObjectClass *klass)
void gnc_embedded_window_close_page(GncEmbeddedWindow *window, GncPluginPage *page)
void gnc_gobject_tracking_forget(GObject *object)
#define DEBUG(format, args...)
Functions that are supported by all types of windows.
void gnc_embedded_window_open_page(GncEmbeddedWindow *window, GncPluginPage *page)
void gnc_plugin_page_merge_actions(GncPluginPage *page, GtkUIManager *ui_merge)
Plugin management functions for the GnuCash UI.
gchar * gnc_filepath_locate_ui_file(const gchar *name)
#define ENTER(format, args...)
void gnc_plugin_page_unmerge_actions(GncPluginPage *page, GtkUIManager *ui_merge)
GtkWidget * gnc_plugin_page_create_widget(GncPluginPage *plugin_page)
Gnome specific utility functions.
All type declarations for the whole Gnucash engine.
GtkActionGroup * action_group
GncPluginPage * gnc_embedded_window_get_page(GncEmbeddedWindow *window)
Functions that are supported by all types of windows.
Functions for adding plugins to a GnuCash window.
GType gnc_embedded_window_get_type(void)
#define LEAVE(format, args...)
File path resolution utility functions.
void gnc_gtk_action_group_set_translation_domain(GtkActionGroup *action_group, const gchar *domain)
GtkWidget * parent_window
GtkWidget * notebook_page
const gchar * QofLogModule