GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gnc-plugin-page.c
Go to the documentation of this file.
1 /*
2  * gnc-plugin_page.c --
3  *
4  * Copyright (C) 2003 Jan Arne Petersen <[email protected]>
5  * Copyright (C) 2003,2005 David Hampton <[email protected]>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation; either version 2 of
10  * the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, contact:
19  *
20  * Free Software Foundation Voice: +1-617-542-5942
21  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
22  * Boston, MA 02110-1301, USA [email protected]
23  */
24 
35 #include "config.h"
36 
37 #include <gtk/gtk.h>
38 #include "gnc-engine.h"
39 #include "gnc-plugin.h"
40 #include "gnc-plugin-page.h"
41 #include "gnc-gobject-utils.h"
42 
44 static QofLogModule log_module = GNC_MOD_GUI;
46 static gpointer parent_class = NULL;
47 
48 static void gnc_plugin_page_class_init (GncPluginPageClass *klass);
49 static void gnc_plugin_page_init (GncPluginPage *plugin_page,
50  GncPluginPageClass *klass);
51 static void gnc_plugin_page_finalize (GObject *object);
52 static void gnc_plugin_page_set_property (GObject *object,
53  guint prop_id,
54  const GValue *value,
55  GParamSpec *pspec);
56 static void gnc_plugin_page_get_property (GObject *object,
57  guint prop_id,
58  GValue *value,
59  GParamSpec *pspec);
60 
61 enum
62 {
63  INSERTED,
64  REMOVED,
65  SELECTED,
66  UNSELECTED,
67  LAST_SIGNAL
68 };
69 
70 enum
71 {
72  PROP_0,
73  PROP_PAGE_NAME,
74  PROP_PAGE_COLOR,
75  PROP_PAGE_URI,
76  PROP_BOOK,
77  PROP_STATUSBAR_TEXT,
78  PROP_USE_NEW_WINDOW,
79  PROP_UI_DESCRIPTION,
80  PROP_UI_MERGE,
81  PROP_ACTION_GROUP,
82 };
83 
84 static guint signals[LAST_SIGNAL] = { 0 };
85 
86 
88 typedef struct _GncPluginPagePrivate
89 {
91  GtkActionGroup *action_group;
92  GtkUIManager *ui_merge;
93  guint merge_id;
94  char *ui_description;
95 
96  GList *books;
97 
98  gboolean use_new_window;
99 
100  gchar *page_name;
101  gchar *page_long_name;
102  gchar *page_color;
103  gchar *uri;
104  gchar *statusbar_text;
106 
107 #define GNC_PLUGIN_PAGE_GET_PRIVATE(o) \
108  (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_PLUGIN_PAGE, GncPluginPagePrivate))
109 
110 GType
112 {
113  static GType gnc_plugin_page_type = 0;
114 
115  if (gnc_plugin_page_type == 0)
116  {
117  static const GTypeInfo our_info =
118  {
119 
120  sizeof (GncPluginPageClass),
121  NULL, /* base_init */
122  NULL, /* base_finalize */
123  (GClassInitFunc) gnc_plugin_page_class_init,
124  NULL, /* class_finalize */
125  NULL, /* class_data */
126  sizeof (GncPluginPage),
127  0, /* n_preallocs */
128  (GInstanceInitFunc) gnc_plugin_page_init,
129  };
130 
131  gnc_plugin_page_type = g_type_register_static (G_TYPE_OBJECT,
132  "GncPluginPage",
133  &our_info, 0);
134  }
135 
136  return gnc_plugin_page_type;
137 }
138 
139 
140 /* Create the display widget that corresponds to this plugin. This
141  * function will be called by the main/embedded window manipulation
142  * code to create a widget that they can display. The returned
143  * widget should encompass all information that goes with this page,
144  * including scroll bars, a summary bar, etc. */
145 GtkWidget *
147 {
148  GncPluginPageClass *klass;
149  GtkWidget *widget;
150 
151  g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page), NULL);
152 
153  klass = GNC_PLUGIN_PAGE_GET_CLASS (plugin_page);
154  g_return_val_if_fail (klass != NULL, NULL);
155  g_return_val_if_fail (klass->create_widget != NULL, NULL);
156 
157  widget = klass->create_widget (plugin_page);
158 
159  /*
160  * If there is a destroy function, add a ref so that the
161  * widgets will exists when the destroy function is called.
162  * Otherwise it will be destroyed when it is removed from the
163  * main notebook for the window.
164  */
165  if (klass->destroy_widget)
166  g_object_ref(widget);
167 
168  return widget;
169 }
170 
171 
172 /* Destroy the display widget that corresponds to this plugin. This
173  * function will be called by the main/embedded window manipulation
174  * code when a page is closed. */
175 void
177 {
178  GncPluginPageClass *klass;
179 
180  g_return_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page));
181 
182  klass = GNC_PLUGIN_PAGE_GET_CLASS (plugin_page);
183  g_return_if_fail (klass != NULL);
184  g_return_if_fail (klass->destroy_widget != NULL);
185 
186  klass->destroy_widget (plugin_page);
187 }
188 
189 
190 /* Show/hide the summarybar associated with this page. */
191 void
193  gboolean visible)
194 {
195  g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
196 
197  if (!page->summarybar)
198  return;
199 
200  if (visible)
201  {
202  gtk_widget_show(page->summarybar);
203  }
204  else
205  {
206  gtk_widget_hide(page->summarybar);
207  }
208 }
209 
210 
211 /* Call the plugin specific function that will save the state of a
212  * content page to a disk. That function must save enough
213  * information about the page that it can be recreated next time the
214  * user starts gnucash. */
215 void
217  GKeyFile *key_file,
218  const gchar *group_name)
219 {
220  GncPluginPageClass *klass;
221 
222  g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
223  g_return_if_fail (key_file != NULL);
224  g_return_if_fail (group_name != NULL);
225 
226  ENTER(" ");
227  klass = GNC_PLUGIN_PAGE_GET_CLASS (page);
228  g_return_if_fail (klass != NULL);
229  g_return_if_fail (klass->save_page != NULL);
230 
231  klass->save_page(page, key_file, group_name);
232  LEAVE(" ");
233 }
234 
235 
236 /* This function looks up a specific plugin type by name, and then
237  * calls a plugin specific function to create a new page and restore
238  * its content to a previous state. */
241  const gchar *page_type,
242  GKeyFile *key_file,
243  const gchar *page_group)
244 {
245  GncPluginPageClass *klass;
246  GncPluginPage *page = NULL;
247  GType type;
248 
249  ENTER("type %s, keyfile %p, group %s", page_type, key_file, page_group);
250  type = g_type_from_name(page_type);
251  if (type == 0)
252  {
253  LEAVE("Cannot find type named %s", page_type);
254  return NULL;
255  }
256 
257  klass = g_type_class_ref(type);
258  if (klass == NULL)
259  {
260  const gchar *type_name = g_type_name(type);
261  LEAVE("Cannot create class %s(%s)", page_type, type_name ? type_name : "invalid type");
262  return NULL;
263  }
264 
265  if (!klass->recreate_page)
266  {
267  LEAVE("Class %shas no recreate function.", page_type);
268  g_type_class_unref(klass);
269  return NULL;
270  }
271 
272  page = (klass->recreate_page)(window, key_file, page_group);
273  g_type_class_unref(klass);
274  LEAVE(" ");
275  return page;
276 }
277 
278 
279 /* Add the actions for a content page to the specified window. */
280 void
282  GtkUIManager *ui_merge)
283 {
284  GncPluginPagePrivate *priv;
285 
286  g_return_if_fail (GNC_IS_PLUGIN_PAGE(page));
287 
288  priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
289  priv->ui_merge = ui_merge;
290  priv->merge_id = gnc_plugin_add_actions(priv->ui_merge,
291  priv->action_group,
292  priv->ui_description);
293 }
294 
295 
296 /* Remove the actions for a content page from the specified window. */
297 void
299  GtkUIManager *ui_merge)
300 {
301  GncPluginPagePrivate *priv;
302 
303  priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
304 
305  g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
306  g_return_if_fail (priv->merge_id != 0);
307  g_return_if_fail (priv->action_group != NULL);
308 
309  gtk_ui_manager_remove_ui(ui_merge, priv->merge_id);
310  gtk_ui_manager_remove_action_group(ui_merge, priv->action_group);
311 
312  priv->ui_merge = NULL;
313  priv->merge_id = 0;
314 }
315 
316 
317 GtkAction *
318 gnc_plugin_page_get_action (GncPluginPage *page, const gchar *name)
319 {
320  GncPluginPagePrivate *priv;
321 
322  g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), NULL);
323  g_return_val_if_fail(name != NULL, NULL);
324 
325  priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
326  if (!priv->action_group)
327  return NULL;
328  return gtk_action_group_get_action (priv->action_group, name);
329 }
330 
331 
332 /* Retrieve the textual name of a plugin. */
333 const gchar *
335 {
336  GncPluginPageClass *klass;
337 
338  g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page), NULL);
339 
340  klass = GNC_PLUGIN_PAGE_GET_CLASS (plugin_page);
341  g_return_val_if_fail (klass != NULL, NULL);
342 
343  return (klass->plugin_name);
344 }
345 
346 
347 /* Signals */
348 void
349 gnc_plugin_page_inserted (GncPluginPage *plugin_page)
350 {
351  g_return_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page));
352 
353  g_signal_emit (G_OBJECT (plugin_page), signals[INSERTED], 0);
354 }
355 
356 void
357 gnc_plugin_page_removed (GncPluginPage *plugin_page)
358 {
359  g_return_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page));
360 
361  g_signal_emit (G_OBJECT (plugin_page), signals[REMOVED], 0);
362 }
363 
364 void
365 gnc_plugin_page_selected (GncPluginPage *plugin_page)
366 {
367  g_return_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page));
368 
369  g_signal_emit (G_OBJECT (plugin_page), signals[SELECTED], 0);
370 }
371 
372 void
373 gnc_plugin_page_unselected (GncPluginPage *plugin_page)
374 {
375  g_return_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page));
376 
377  g_signal_emit (G_OBJECT (plugin_page), signals[UNSELECTED], 0);
378 }
379 
380 
388 static void
389 gnc_plugin_page_class_init (GncPluginPageClass *klass)
390 {
391  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
392 
393  parent_class = g_type_class_peek_parent (klass);
394  gobject_class->finalize = gnc_plugin_page_finalize;
395  gobject_class->set_property = gnc_plugin_page_set_property;
396  gobject_class->get_property = gnc_plugin_page_get_property;
397 
398  klass->tab_icon = NULL;
399  klass->plugin_name = NULL;
400 
401  g_type_class_add_private(klass, sizeof(GncPluginPagePrivate));
402 
403  g_object_class_install_property
404  (gobject_class,
405  PROP_PAGE_NAME,
406  g_param_spec_string ("page-name",
407  "Page Name",
408  "The name of this page. This value is "
409  "used to generate the notebook tab and "
410  "menu items, and also the window title "
411  "when this page is visible.",
412  NULL,
413  G_PARAM_READWRITE));
414 
415  g_object_class_install_property
416  (gobject_class,
417  PROP_PAGE_COLOR,
418  g_param_spec_string ("page-color",
419  "Page Color",
420  "The color of this page. This value is "
421  "used to generate the notebook tab color "
422  "when this page is visible.",
423  NULL,
424  G_PARAM_READWRITE));
425 
426  g_object_class_install_property
427  (gobject_class,
428  PROP_PAGE_URI,
429  g_param_spec_string ("page-uri",
430  "Page URI",
431  "The uri for this page.",
432  NULL,
433  G_PARAM_READWRITE));
434 
435  g_object_class_install_property
436  (gobject_class,
437  PROP_STATUSBAR_TEXT,
438  g_param_spec_string ("statusbar-text",
439  "Statusbar Text",
440  "The text to be displayed in the statusbar "
441  "at the bottom of the window when this page "
442  "is visible.",
443  NULL,
444  G_PARAM_READWRITE));
445 
446  g_object_class_install_property
447  (gobject_class,
448  PROP_USE_NEW_WINDOW,
449  g_param_spec_boolean ("use-new-window",
450  "Use New Window",
451  "When TRUE a new top level window will be "
452  "created to hold this page.",
453  FALSE,
454  G_PARAM_READWRITE));
455 
456  g_object_class_install_property
457  (gobject_class,
458  PROP_UI_DESCRIPTION,
459  g_param_spec_string ("ui-description",
460  "UI Description File",
461  "The filename containing the XML data that "
462  "describes this pages menus and toolbars.",
463  NULL,
464  G_PARAM_READWRITE));
465 
466  g_object_class_install_property
467  (gobject_class,
468  PROP_UI_MERGE,
469  g_param_spec_object ("ui-merge",
470  "UI Merge",
471  "A pointer to the GtkUIManager object that "
472  "represents this pages menu hierarchy.",
473  GTK_TYPE_UI_MANAGER,
474  G_PARAM_READABLE));
475 
476  g_object_class_install_property
477  (gobject_class,
478  PROP_ACTION_GROUP,
479  g_param_spec_object ("action-group",
480  "Action Group",
481  "A pointer to the GtkActionGroup object that "
482  "represents this pages available menu/toolbar "
483  "actions.",
484  GTK_TYPE_ACTION_GROUP,
485  G_PARAM_READABLE));
486 
487 
488 
489 
490  signals[INSERTED] = g_signal_new ("inserted",
491  G_OBJECT_CLASS_TYPE (klass),
492  G_SIGNAL_RUN_FIRST,
493  G_STRUCT_OFFSET (GncPluginPageClass, inserted),
494  NULL, NULL,
495  g_cclosure_marshal_VOID__VOID,
496  G_TYPE_NONE,
497  0);
498  signals[REMOVED] = g_signal_new ("removed",
499  G_OBJECT_CLASS_TYPE (klass),
500  G_SIGNAL_RUN_FIRST,
501  G_STRUCT_OFFSET (GncPluginPageClass, removed),
502  NULL, NULL,
503  g_cclosure_marshal_VOID__VOID,
504  G_TYPE_NONE,
505  0);
506  signals[SELECTED] = g_signal_new ("selected",
507  G_OBJECT_CLASS_TYPE (klass),
508  G_SIGNAL_RUN_FIRST,
509  G_STRUCT_OFFSET (GncPluginPageClass, selected),
510  NULL, NULL,
511  g_cclosure_marshal_VOID__VOID,
512  G_TYPE_NONE,
513  0);
514  signals[UNSELECTED] = g_signal_new ("unselected",
515  G_OBJECT_CLASS_TYPE (klass),
516  G_SIGNAL_RUN_FIRST,
517  G_STRUCT_OFFSET (GncPluginPageClass, unselected),
518  NULL, NULL,
519  g_cclosure_marshal_VOID__VOID,
520  G_TYPE_NONE,
521  0);
522 }
523 
524 
533 static void
534 gnc_plugin_page_init (GncPluginPage *page, GncPluginPageClass *klass)
535 {
536  GncPluginPagePrivate *priv;
537 
538  priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
539  priv->page_name = NULL;
540  priv->page_color = NULL;
541  priv->uri = NULL;
542 
543  page->window = NULL;
544  page->summarybar = NULL;
545 
546  gnc_gobject_tracking_remember(G_OBJECT(page), G_OBJECT_CLASS(klass));
547 }
548 
549 
557 static void
558 gnc_plugin_page_finalize (GObject *object)
559 {
560  GncPluginPagePrivate *priv;
561  GncPluginPage *page;
562 
563  page = GNC_PLUGIN_PAGE (object);
564 
565  priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
566  if (priv->page_name)
567  g_free(priv->page_name);
568  if (priv->page_color)
569  g_free(priv->page_color);
570  if (priv->uri)
571  g_free(priv->uri);
572  if (priv->statusbar_text)
573  g_free(priv->statusbar_text);
574 
575  if (priv->books)
576  {
577  g_list_free(priv->books);
578  priv->books = NULL;
579  }
580 
581  page->window = NULL; // Don't need to free it.
582 
584  G_OBJECT_CLASS (parent_class)->finalize (object);
585 }
586 
587 /************************************************************/
588 /* g_object other functions */
589 /************************************************************/
590 
591 
608 /* Note that g_value_set_object() refs the object, as does
609  * g_object_get(). But g_object_get() only unrefs once when it disgorges
610  * the object, leaving an unbalanced ref, which leaks. So instead of
611  * using g_value_set_object(), use g_value_take_object() which doesn't
612  * ref the object when used in get_property().
613  */
614 static void
615 gnc_plugin_page_get_property (GObject *object,
616  guint prop_id,
617  GValue *value,
618  GParamSpec *pspec)
619 {
620  GncPluginPage *page;
621  GncPluginPagePrivate *priv;
622 
623  g_return_if_fail(GNC_IS_PLUGIN_PAGE(object));
624 
625  page = GNC_PLUGIN_PAGE(object);
626  priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
627  switch (prop_id)
628  {
629  case PROP_PAGE_NAME:
630  g_value_set_string (value, priv->page_name);
631  break;
632  case PROP_PAGE_COLOR:
633  g_value_set_string (value, priv->page_color);
634  break;
635  case PROP_PAGE_URI:
636  g_value_set_string (value, priv->uri);
637  break;
638  case PROP_STATUSBAR_TEXT:
639  g_value_set_string (value, priv->statusbar_text);
640  break;
641  case PROP_USE_NEW_WINDOW:
642  g_value_set_boolean (value, priv->use_new_window);
643  break;
644  case PROP_UI_DESCRIPTION:
645  g_value_set_string (value, priv->ui_description);
646  break;
647  case PROP_UI_MERGE:
648  g_value_take_object (value, priv->ui_merge);
649  break;
650  case PROP_ACTION_GROUP:
651  g_value_take_object (value, priv->action_group);
652  break;
653  default:
654  G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
655  break;
656  }
657 }
658 
659 
676 static void
677 gnc_plugin_page_set_property (GObject *object,
678  guint prop_id,
679  const GValue *value,
680  GParamSpec *pspec)
681 {
682  GncPluginPage *page;
683 
684  g_return_if_fail(GNC_IS_PLUGIN_PAGE(object));
685 
686  page = GNC_PLUGIN_PAGE(object);
687 
688  switch (prop_id)
689  {
690  case PROP_PAGE_NAME:
691  gnc_plugin_page_set_page_name(page, g_value_get_string(value));
692  break;
693  case PROP_PAGE_COLOR:
694  gnc_plugin_page_set_page_color(page, g_value_get_string(value));
695  break;
696  case PROP_PAGE_URI:
697  gnc_plugin_page_set_uri(page, g_value_get_string(value));
698  break;
699  case PROP_STATUSBAR_TEXT:
700  gnc_plugin_page_set_statusbar_text(page, g_value_get_string(value));
701  break;
702  case PROP_USE_NEW_WINDOW:
703  gnc_plugin_page_set_use_new_window(page, g_value_get_boolean(value));
704  break;
705  case PROP_UI_DESCRIPTION:
706  gnc_plugin_page_set_ui_description(page, g_value_get_string(value));
707  break;
708  default:
709  G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
710  break;
711  }
712 }
713 
714 /************************************************************/
715 /* */
716 /************************************************************/
717 
718 /* Add a book reference to the specified page. */
719 void
721 {
722  GncPluginPagePrivate *priv;
723 
724  g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
725  g_return_if_fail (book != NULL);
726 
727  priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
728  priv->books = g_list_append(priv->books, book);
729 }
730 
731 
732 /* Query a page to see if it has a reference to a given book. */
733 gboolean
735 {
736  GncPluginPagePrivate *priv;
737  GList *item;
738 
739  g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), FALSE);
740  g_return_val_if_fail (book != NULL, FALSE);
741 
742  priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
743  for (item = priv->books; item; item = g_list_next(item))
744  {
745  if (item->data == book)
746  {
747  return TRUE;
748  }
749  }
750  return FALSE;
751 }
752 
753 
754 /* Query a page to see if it has a reference to any book. */
755 gboolean
757 {
758  GncPluginPagePrivate *priv;
759 
760  g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), FALSE);
761 
762  priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
763  return (priv->books != NULL);
764 }
765 
766 
767 /* Retrieve a pointer to the GncMainWindow (GtkWindow) containing
768  * this page. */
769 GtkWidget *
771 {
772  g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), NULL);
773 
774  return page->window;
775 }
776 
777 
778 /* Retrieve the name of this page. This is the string used in the
779  * window title, and in the notebook tab and page selection menus. */
780 const gchar *
782 {
783  GncPluginPagePrivate *priv;
784 
785  g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), NULL);
786 
787  priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
788  return priv->page_name;
789 }
790 
791 
792 /* Set the name of this page. This is the string used in the window
793  * title, and in the notebook tab and page selection menus. */
794 void
795 gnc_plugin_page_set_page_name (GncPluginPage *page, const gchar *name)
796 {
797  GncPluginPagePrivate *priv;
798  GncPluginPageClass *klass;
799 
800  g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
801 
802  priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
803  if (priv->page_name)
804  g_free(priv->page_name);
805  priv->page_name = g_strdup(name);
806 
807  /* Perform page specific actions */
808  klass = GNC_PLUGIN_PAGE_GET_CLASS (page);
809  if (klass->page_name_changed)
810  {
811  klass->page_name_changed(page, name);
812  }
813 }
814 
815 
816 /* Retrieve the long name of this page. This is the string used in
817  * the tooltip that is attached to the page name in the notebook
818  * tab. */
819 const gchar *
821 {
822  GncPluginPagePrivate *priv;
823 
824  g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), NULL);
825 
826  priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
827  return priv->page_long_name;
828 }
829 
830 
831 /* Set the long name of this page. This is the string used in the
832  * tooltip that is attached to the page name in the notebook tab. */
833 void
834 gnc_plugin_page_set_page_long_name (GncPluginPage *page, const gchar *name)
835 {
836  GncPluginPagePrivate *priv;
837 
838  g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
839 
840  priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
841  if (priv->page_long_name)
842  g_free(priv->page_long_name);
843  priv->page_long_name = g_strdup(name);
844 }
845 
846 
847 /* Get the color of this page. This is the string used in the notebook tab. */
848 const gchar *
850 {
851  GncPluginPagePrivate *priv;
852 
853  g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), NULL);
854 
855  priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
856  return priv->page_color;
857 }
858 
859 
860 /* Set the color of this page. This is the string used in the notebook tab. */
861 void
862 gnc_plugin_page_set_page_color (GncPluginPage *page, const gchar *color)
863 {
864  GncPluginPagePrivate *priv;
865 
866  g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
867 
868  priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
869  if (priv->page_color)
870  g_free(priv->page_color);
871  if (color)
872  priv->page_color = g_strdup(color);
873 }
874 
875 
876 /* Retrieve the Uniform Resource Identifier for this page. */
877 const gchar *
879 {
880  GncPluginPagePrivate *priv;
881 
882  g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), NULL);
883 
884  priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
885  return priv->uri;
886 }
887 
888 
889 /* Set the Uniform Resource Identifier for this page. */
890 void
891 gnc_plugin_page_set_uri (GncPluginPage *page, const gchar *name)
892 {
893  GncPluginPagePrivate *priv;
894 
895  g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
896 
897  priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
898  if (priv->uri)
899  g_free(priv->uri);
900  priv->uri = g_strdup(name);
901 }
902 
903 
904 /* Retrieve the statusbar text associated with this page. */
905 const gchar *
907 {
908  GncPluginPagePrivate *priv;
909 
910  g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), NULL);
911 
912  priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
913  return priv->statusbar_text;
914 }
915 
916 
917 /* Set the statusbar text associated with this page. */
918 void
919 gnc_plugin_page_set_statusbar_text (GncPluginPage *page, const gchar *message)
920 {
921  GncPluginPagePrivate *priv;
922 
923  g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
924 
925  priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
926  if (priv->statusbar_text)
927  g_free(priv->statusbar_text);
928  priv->statusbar_text = g_strdup(message);
929 }
930 
931 
932 /* Retrieve the "use new window" setting associated with this page. */
933 gboolean
935 {
936  GncPluginPagePrivate *priv;
937 
938  g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), FALSE);
939 
940  priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
941  return priv->use_new_window;
942 }
943 
944 
945 /* Set the "use new window" setting associated with this page. If
946  * this setting is TRUE, the page will be installed into a new
947  * window. Otherwise the page will be installed into an existing
948  * window. */
949 void
951 {
952  GncPluginPagePrivate *priv;
953 
954  g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
955 
956  priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
957  priv->use_new_window = use_new;
958 }
959 
960 
961 /* Retrieve the name of the XML UI file associated with this page. */
962 const gchar *
964 {
965  GncPluginPagePrivate *priv;
966 
967  g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), FALSE);
968 
969  priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
970  return priv->ui_description;
971 }
972 
973 
974 /* Set an alternate UI for the specified page. This alternate ui
975  * may only use actions specified in the source for the page. */
976 void
978  const char *ui_filename)
979 {
980  GncPluginPagePrivate *priv;
981 
982  g_return_if_fail(GNC_IS_PLUGIN_PAGE(page));
983 
984  priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
985  if (priv->ui_description)
986  g_free(priv->ui_description);
987  priv->ui_description = g_strdup(ui_filename);
988 }
989 
990 
991 /* Retrieve the GtkUIManager object associated with this page. */
992 GtkUIManager *
994 {
995  GncPluginPagePrivate *priv;
996 
997  g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), NULL);
998 
999  priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
1000  return priv->ui_merge;
1001 }
1002 
1003 
1004 /* Retrieve the GtkActionGroup object associated with this page. */
1005 GtkActionGroup *
1007 {
1008  GncPluginPagePrivate *priv;
1009 
1010  g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), NULL);
1011  priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
1012  return priv->action_group;
1013 }
1014 
1015 
1016 /* Create the GtkActionGroup object associated with this page. */
1017 GtkActionGroup *
1018 gnc_plugin_page_create_action_group (GncPluginPage *page, const gchar *group_name)
1019 {
1020  GncPluginPagePrivate *priv;
1021  GtkActionGroup *group;
1022 
1023  priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
1024  group = gtk_action_group_new(group_name);
1025  gnc_gtk_action_group_set_translation_domain(group, GETTEXT_PACKAGE);
1026  priv->action_group = group;
1027  return group;
1028 }
1029 
1030 gboolean
1032 {
1033  if (!page)
1034  return TRUE;
1035  if (!GNC_IS_PLUGIN_PAGE(page))
1036  return TRUE;
1037 
1038  if (!GNC_PLUGIN_PAGE_GET_CLASS(page)->finish_pending)
1039  return TRUE;
1040  return (GNC_PLUGIN_PAGE_GET_CLASS(page)->finish_pending)(page);
1041 }
1042 
gboolean gnc_plugin_page_finish_pending(GncPluginPage *page)
GtkWidget * gnc_plugin_page_get_window(GncPluginPage *page)
gboolean gnc_plugin_page_has_books(GncPluginPage *page)
gboolean gnc_plugin_page_get_use_new_window(GncPluginPage *page)
const gchar * tab_icon
GType gnc_plugin_page_get_type(void)
void gnc_plugin_page_destroy_widget(GncPluginPage *plugin_page)
GncPluginPage *(* recreate_page)(GtkWidget *window, GKeyFile *file, const gchar *group)
void gnc_plugin_page_set_statusbar_text(GncPluginPage *page, const char *name)
void(* page_name_changed)(GncPluginPage *plugin_page, const gchar *name)
void gnc_gobject_tracking_remember(GObject *object, GObjectClass *klass)
const gchar * gnc_plugin_page_get_page_long_name(GncPluginPage *page)
void gnc_gobject_tracking_forget(GObject *object)
struct _GncPluginPagePrivate GncPluginPagePrivate
void gnc_plugin_page_set_uri(GncPluginPage *page, const char *name)
void gnc_plugin_page_set_ui_description(GncPluginPage *page, const char *ui_filename)
const gchar * gnc_plugin_page_get_page_name(GncPluginPage *page)
void gnc_plugin_page_merge_actions(GncPluginPage *page, GtkUIManager *ui_merge)
GtkWidget * window
const gchar * gnc_plugin_page_get_page_color(GncPluginPage *page)
void gnc_plugin_page_set_page_long_name(GncPluginPage *page, const char *name)
const gchar * gnc_plugin_page_get_ui_description(GncPluginPage *page)
GtkActionGroup * gnc_plugin_page_get_action_group(GncPluginPage *page)
#define ENTER(format, args...)
Definition: qoflog.h:261
GtkActionGroup * action_group
struct GncPluginPage GncPluginPage
void gnc_plugin_page_unmerge_actions(GncPluginPage *page, GtkUIManager *ui_merge)
GtkWidget * gnc_plugin_page_create_widget(GncPluginPage *plugin_page)
Gobject helper routines.
const gchar * gnc_plugin_page_get_uri(GncPluginPage *page)
void gnc_plugin_page_set_use_new_window(GncPluginPage *page, gboolean use_new)
gint gnc_plugin_add_actions(GtkUIManager *ui_merge, GtkActionGroup *action_group, const gchar *filename)
Definition: gnc-plugin.c:346
void(* destroy_widget)(GncPluginPage *plugin_page)
gboolean gnc_plugin_page_has_book(GncPluginPage *page, QofBook *book)
const gchar * plugin_name
Functions for adding plugins to a GnuCash window.
const gchar * gnc_plugin_page_get_statusbar_text(GncPluginPage *page)
void gnc_plugin_page_save_page(GncPluginPage *page, GKeyFile *key_file, const gchar *group_name)
All type declarations for the whole Gnucash engine.
GtkAction * gnc_plugin_page_get_action(GncPluginPage *page, const gchar *name)
void gnc_plugin_page_set_page_color(GncPluginPage *page, const char *color)
GtkWidget *(* create_widget)(GncPluginPage *plugin_page)
Functions for adding plugins to a GnuCash window.
#define LEAVE(format, args...)
Definition: qoflog.h:271
void(* save_page)(GncPluginPage *page, GKeyFile *file, const gchar *group)
void gnc_plugin_page_set_page_name(GncPluginPage *page, const char *name)
void gnc_plugin_page_add_book(GncPluginPage *page, QofBook *book)
GtkActionGroup * gnc_plugin_page_create_action_group(GncPluginPage *page, const gchar *group_name)
GtkUIManager * gnc_plugin_page_get_ui_merge(GncPluginPage *page)
void gnc_gtk_action_group_set_translation_domain(GtkActionGroup *action_group, const gchar *domain)
GncPluginPage * gnc_plugin_page_recreate_page(GtkWidget *window, const gchar *page_type, GKeyFile *key_file, const gchar *page_group)
void gnc_plugin_page_show_summarybar(GncPluginPage *page, gboolean visible)
GtkWidget * summarybar
const gchar * QofLogModule
Definition: qofid.h:89
const gchar * gnc_plugin_page_get_plugin_name(GncPluginPage *plugin_page)