|
GnuCash 2.4.99
|
00001 /* 00002 * gnc-plugin_page.c -- 00003 * 00004 * Copyright (C) 2003 Jan Arne Petersen <jpetersen@uni-bonn.de> 00005 * Copyright (C) 2003,2005 David Hampton <hampton@employees.org> 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License as 00009 * published by the Free Software Foundation; either version 2 of 00010 * the License, or (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, contact: 00019 * 00020 * Free Software Foundation Voice: +1-617-542-5942 00021 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 00022 * Boston, MA 02110-1301, USA gnu@gnu.org 00023 */ 00024 00035 #include "config.h" 00036 00037 #include <gtk/gtk.h> 00038 #include "gnc-engine.h" 00039 #include "gnc-plugin.h" 00040 #include "gnc-plugin-page.h" 00041 #include "gnc-gobject-utils.h" 00042 00044 static QofLogModule log_module = GNC_MOD_GUI; 00046 static gpointer parent_class = NULL; 00047 00048 static void gnc_plugin_page_class_init (GncPluginPageClass *klass); 00049 static void gnc_plugin_page_init (GncPluginPage *plugin_page, 00050 GncPluginPageClass *klass); 00051 static void gnc_plugin_page_finalize (GObject *object); 00052 static void gnc_plugin_page_set_property (GObject *object, 00053 guint prop_id, 00054 const GValue *value, 00055 GParamSpec *pspec); 00056 static void gnc_plugin_page_get_property (GObject *object, 00057 guint prop_id, 00058 GValue *value, 00059 GParamSpec *pspec); 00060 00061 enum 00062 { 00063 INSERTED, 00064 REMOVED, 00065 SELECTED, 00066 UNSELECTED, 00067 LAST_SIGNAL 00068 }; 00069 00070 enum 00071 { 00072 PROP_0, 00073 PROP_PAGE_NAME, 00074 PROP_PAGE_COLOR, 00075 PROP_PAGE_URI, 00076 PROP_BOOK, 00077 PROP_STATUSBAR_TEXT, 00078 PROP_USE_NEW_WINDOW, 00079 PROP_UI_DESCRIPTION, 00080 PROP_UI_MERGE, 00081 PROP_ACTION_GROUP, 00082 }; 00083 00084 static guint signals[LAST_SIGNAL] = { 0 }; 00085 00086 00088 typedef struct _GncPluginPagePrivate 00089 { 00091 GtkActionGroup *action_group; 00092 GtkUIManager *ui_merge; 00093 guint merge_id; 00094 char *ui_description; 00095 00096 GList *books; 00097 00098 gboolean use_new_window; 00099 00100 gchar *page_name; 00101 gchar *page_long_name; 00102 gchar *page_color; 00103 gchar *uri; 00104 gchar *statusbar_text; 00105 } GncPluginPagePrivate; 00106 00107 #define GNC_PLUGIN_PAGE_GET_PRIVATE(o) \ 00108 (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_PLUGIN_PAGE, GncPluginPagePrivate)) 00109 00110 GType 00111 gnc_plugin_page_get_type (void) 00112 { 00113 static GType gnc_plugin_page_type = 0; 00114 00115 if (gnc_plugin_page_type == 0) 00116 { 00117 static const GTypeInfo our_info = 00118 { 00119 00120 sizeof (GncPluginPageClass), 00121 NULL, /* base_init */ 00122 NULL, /* base_finalize */ 00123 (GClassInitFunc) gnc_plugin_page_class_init, 00124 NULL, /* class_finalize */ 00125 NULL, /* class_data */ 00126 sizeof (GncPluginPage), 00127 0, /* n_preallocs */ 00128 (GInstanceInitFunc) gnc_plugin_page_init, 00129 }; 00130 00131 gnc_plugin_page_type = g_type_register_static (G_TYPE_OBJECT, 00132 "GncPluginPage", 00133 &our_info, 0); 00134 } 00135 00136 return gnc_plugin_page_type; 00137 } 00138 00139 00140 /* Create the display widget that corresponds to this plugin. This 00141 * function will be called by the main/embedded window manipulation 00142 * code to create a widget that they can display. The returned 00143 * widget should encompass all information that goes with this page, 00144 * including scroll bars, a summary bar, etc. */ 00145 GtkWidget * 00146 gnc_plugin_page_create_widget (GncPluginPage *plugin_page) 00147 { 00148 GncPluginPageClass *klass; 00149 GtkWidget *widget; 00150 00151 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page), NULL); 00152 00153 klass = GNC_PLUGIN_PAGE_GET_CLASS (plugin_page); 00154 g_return_val_if_fail (klass != NULL, NULL); 00155 g_return_val_if_fail (klass->create_widget != NULL, NULL); 00156 00157 widget = klass->create_widget (plugin_page); 00158 00159 /* 00160 * If there is a destroy function, add a ref so that the 00161 * widgets will exists when the destroy function is called. 00162 * Otherwise it will be destroyed when it is removed from the 00163 * main notebook for the window. 00164 */ 00165 if (klass->destroy_widget) 00166 g_object_ref(widget); 00167 00168 return widget; 00169 } 00170 00171 00172 /* Destroy the display widget that corresponds to this plugin. This 00173 * function will be called by the main/embedded window manipulation 00174 * code when a page is closed. */ 00175 void 00176 gnc_plugin_page_destroy_widget (GncPluginPage *plugin_page) 00177 { 00178 GncPluginPageClass *klass; 00179 00180 g_return_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page)); 00181 00182 klass = GNC_PLUGIN_PAGE_GET_CLASS (plugin_page); 00183 g_return_if_fail (klass != NULL); 00184 g_return_if_fail (klass->destroy_widget != NULL); 00185 00186 klass->destroy_widget (plugin_page); 00187 } 00188 00189 00190 /* Show/hide the summarybar associated with this page. */ 00191 void 00192 gnc_plugin_page_show_summarybar (GncPluginPage *page, 00193 gboolean visible) 00194 { 00195 g_return_if_fail (GNC_IS_PLUGIN_PAGE (page)); 00196 00197 if (!page->summarybar) 00198 return; 00199 00200 if (visible) 00201 { 00202 gtk_widget_show(page->summarybar); 00203 } 00204 else 00205 { 00206 gtk_widget_hide(page->summarybar); 00207 } 00208 } 00209 00210 00211 /* Call the plugin specific function that will save the state of a 00212 * content page to a disk. That function must save enough 00213 * information about the page that it can be recreated next time the 00214 * user starts gnucash. */ 00215 void 00216 gnc_plugin_page_save_page (GncPluginPage *page, 00217 GKeyFile *key_file, 00218 const gchar *group_name) 00219 { 00220 GncPluginPageClass *klass; 00221 00222 g_return_if_fail (GNC_IS_PLUGIN_PAGE (page)); 00223 g_return_if_fail (key_file != NULL); 00224 g_return_if_fail (group_name != NULL); 00225 00226 ENTER(" "); 00227 klass = GNC_PLUGIN_PAGE_GET_CLASS (page); 00228 g_return_if_fail (klass != NULL); 00229 g_return_if_fail (klass->save_page != NULL); 00230 00231 klass->save_page(page, key_file, group_name); 00232 LEAVE(" "); 00233 } 00234 00235 00236 /* This function looks up a specific plugin type by name, and then 00237 * calls a plugin specific function to create a new page and restore 00238 * its content to a previous state. */ 00239 GncPluginPage * 00240 gnc_plugin_page_recreate_page(GtkWidget *window, 00241 const gchar *page_type, 00242 GKeyFile *key_file, 00243 const gchar *page_group) 00244 { 00245 GncPluginPageClass *klass; 00246 GncPluginPage *page = NULL; 00247 GType type; 00248 00249 ENTER("type %s, keyfile %p, group %s", page_type, key_file, page_group); 00250 type = g_type_from_name(page_type); 00251 if (type == 0) 00252 { 00253 LEAVE("Cannot find type named %s", page_type); 00254 return NULL; 00255 } 00256 00257 klass = g_type_class_ref(type); 00258 if (klass == NULL) 00259 { 00260 const gchar *type_name = g_type_name(type); 00261 LEAVE("Cannot create class %s(%s)", page_type, type_name ? type_name : "invalid type"); 00262 return NULL; 00263 } 00264 00265 if (!klass->recreate_page) 00266 { 00267 LEAVE("Class %shas no recreate function.", page_type); 00268 g_type_class_unref(klass); 00269 return NULL; 00270 } 00271 00272 page = (klass->recreate_page)(window, key_file, page_group); 00273 g_type_class_unref(klass); 00274 LEAVE(" "); 00275 return page; 00276 } 00277 00278 00279 /* Add the actions for a content page to the specified window. */ 00280 void 00281 gnc_plugin_page_merge_actions (GncPluginPage *page, 00282 GtkUIManager *ui_merge) 00283 { 00284 GncPluginPagePrivate *priv; 00285 00286 g_return_if_fail (GNC_IS_PLUGIN_PAGE(page)); 00287 00288 priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); 00289 priv->ui_merge = ui_merge; 00290 priv->merge_id = gnc_plugin_add_actions(priv->ui_merge, 00291 priv->action_group, 00292 priv->ui_description); 00293 } 00294 00295 00296 /* Remove the actions for a content page from the specified window. */ 00297 void 00298 gnc_plugin_page_unmerge_actions (GncPluginPage *page, 00299 GtkUIManager *ui_merge) 00300 { 00301 GncPluginPagePrivate *priv; 00302 00303 priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); 00304 00305 g_return_if_fail (GNC_IS_PLUGIN_PAGE (page)); 00306 g_return_if_fail (priv->merge_id != 0); 00307 g_return_if_fail (priv->action_group != NULL); 00308 00309 gtk_ui_manager_remove_ui(ui_merge, priv->merge_id); 00310 gtk_ui_manager_remove_action_group(ui_merge, priv->action_group); 00311 00312 priv->ui_merge = NULL; 00313 priv->merge_id = 0; 00314 } 00315 00316 00317 GtkAction * 00318 gnc_plugin_page_get_action (GncPluginPage *page, const gchar *name) 00319 { 00320 GncPluginPagePrivate *priv; 00321 00322 g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), NULL); 00323 g_return_val_if_fail(name != NULL, NULL); 00324 00325 priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); 00326 if (!priv->action_group) 00327 return NULL; 00328 return gtk_action_group_get_action (priv->action_group, name); 00329 } 00330 00331 00332 /* Retrieve the textual name of a plugin. */ 00333 const gchar * 00334 gnc_plugin_page_get_plugin_name (GncPluginPage *plugin_page) 00335 { 00336 GncPluginPageClass *klass; 00337 00338 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page), NULL); 00339 00340 klass = GNC_PLUGIN_PAGE_GET_CLASS (plugin_page); 00341 g_return_val_if_fail (klass != NULL, NULL); 00342 00343 return (klass->plugin_name); 00344 } 00345 00346 00347 /* Signals */ 00348 void 00349 gnc_plugin_page_inserted (GncPluginPage *plugin_page) 00350 { 00351 g_return_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page)); 00352 00353 g_signal_emit (G_OBJECT (plugin_page), signals[INSERTED], 0); 00354 } 00355 00356 void 00357 gnc_plugin_page_removed (GncPluginPage *plugin_page) 00358 { 00359 g_return_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page)); 00360 00361 g_signal_emit (G_OBJECT (plugin_page), signals[REMOVED], 0); 00362 } 00363 00364 void 00365 gnc_plugin_page_selected (GncPluginPage *plugin_page) 00366 { 00367 g_return_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page)); 00368 00369 g_signal_emit (G_OBJECT (plugin_page), signals[SELECTED], 0); 00370 } 00371 00372 void 00373 gnc_plugin_page_unselected (GncPluginPage *plugin_page) 00374 { 00375 g_return_if_fail (GNC_IS_PLUGIN_PAGE (plugin_page)); 00376 00377 g_signal_emit (G_OBJECT (plugin_page), signals[UNSELECTED], 0); 00378 } 00379 00380 00388 static void 00389 gnc_plugin_page_class_init (GncPluginPageClass *klass) 00390 { 00391 GObjectClass *gobject_class = G_OBJECT_CLASS (klass); 00392 00393 parent_class = g_type_class_peek_parent (klass); 00394 gobject_class->finalize = gnc_plugin_page_finalize; 00395 gobject_class->set_property = gnc_plugin_page_set_property; 00396 gobject_class->get_property = gnc_plugin_page_get_property; 00397 00398 klass->tab_icon = NULL; 00399 klass->plugin_name = NULL; 00400 00401 g_type_class_add_private(klass, sizeof(GncPluginPagePrivate)); 00402 00403 g_object_class_install_property 00404 (gobject_class, 00405 PROP_PAGE_NAME, 00406 g_param_spec_string ("page-name", 00407 "Page Name", 00408 "The name of this page. This value is " 00409 "used to generate the notebook tab and " 00410 "menu items, and also the window title " 00411 "when this page is visible.", 00412 NULL, 00413 G_PARAM_READWRITE)); 00414 00415 g_object_class_install_property 00416 (gobject_class, 00417 PROP_PAGE_COLOR, 00418 g_param_spec_string ("page-color", 00419 "Page Color", 00420 "The color of this page. This value is " 00421 "used to generate the notebook tab color " 00422 "when this page is visible.", 00423 NULL, 00424 G_PARAM_READWRITE)); 00425 00426 g_object_class_install_property 00427 (gobject_class, 00428 PROP_PAGE_URI, 00429 g_param_spec_string ("page-uri", 00430 "Page URI", 00431 "The uri for this page.", 00432 NULL, 00433 G_PARAM_READWRITE)); 00434 00435 g_object_class_install_property 00436 (gobject_class, 00437 PROP_STATUSBAR_TEXT, 00438 g_param_spec_string ("statusbar-text", 00439 "Statusbar Text", 00440 "The text to be displayed in the statusbar " 00441 "at the bottom of the window when this page " 00442 "is visible.", 00443 NULL, 00444 G_PARAM_READWRITE)); 00445 00446 g_object_class_install_property 00447 (gobject_class, 00448 PROP_USE_NEW_WINDOW, 00449 g_param_spec_boolean ("use-new-window", 00450 "Use New Window", 00451 "When TRUE a new top level window will be " 00452 "created to hold this page.", 00453 FALSE, 00454 G_PARAM_READWRITE)); 00455 00456 g_object_class_install_property 00457 (gobject_class, 00458 PROP_UI_DESCRIPTION, 00459 g_param_spec_string ("ui-description", 00460 "UI Description File", 00461 "The filename containing the XML data that " 00462 "describes this pages menus and toolbars.", 00463 NULL, 00464 G_PARAM_READWRITE)); 00465 00466 g_object_class_install_property 00467 (gobject_class, 00468 PROP_UI_MERGE, 00469 g_param_spec_object ("ui-merge", 00470 "UI Merge", 00471 "A pointer to the GtkUIManager object that " 00472 "represents this pages menu hierarchy.", 00473 GTK_TYPE_UI_MANAGER, 00474 G_PARAM_READABLE)); 00475 00476 g_object_class_install_property 00477 (gobject_class, 00478 PROP_ACTION_GROUP, 00479 g_param_spec_object ("action-group", 00480 "Action Group", 00481 "A pointer to the GtkActionGroup object that " 00482 "represents this pages available menu/toolbar " 00483 "actions.", 00484 GTK_TYPE_ACTION_GROUP, 00485 G_PARAM_READABLE)); 00486 00487 00488 00489 00490 signals[INSERTED] = g_signal_new ("inserted", 00491 G_OBJECT_CLASS_TYPE (klass), 00492 G_SIGNAL_RUN_FIRST, 00493 G_STRUCT_OFFSET (GncPluginPageClass, inserted), 00494 NULL, NULL, 00495 g_cclosure_marshal_VOID__VOID, 00496 G_TYPE_NONE, 00497 0); 00498 signals[REMOVED] = g_signal_new ("removed", 00499 G_OBJECT_CLASS_TYPE (klass), 00500 G_SIGNAL_RUN_FIRST, 00501 G_STRUCT_OFFSET (GncPluginPageClass, removed), 00502 NULL, NULL, 00503 g_cclosure_marshal_VOID__VOID, 00504 G_TYPE_NONE, 00505 0); 00506 signals[SELECTED] = g_signal_new ("selected", 00507 G_OBJECT_CLASS_TYPE (klass), 00508 G_SIGNAL_RUN_FIRST, 00509 G_STRUCT_OFFSET (GncPluginPageClass, selected), 00510 NULL, NULL, 00511 g_cclosure_marshal_VOID__VOID, 00512 G_TYPE_NONE, 00513 0); 00514 signals[UNSELECTED] = g_signal_new ("unselected", 00515 G_OBJECT_CLASS_TYPE (klass), 00516 G_SIGNAL_RUN_FIRST, 00517 G_STRUCT_OFFSET (GncPluginPageClass, unselected), 00518 NULL, NULL, 00519 g_cclosure_marshal_VOID__VOID, 00520 G_TYPE_NONE, 00521 0); 00522 } 00523 00524 00533 static void 00534 gnc_plugin_page_init (GncPluginPage *page, GncPluginPageClass *klass) 00535 { 00536 GncPluginPagePrivate *priv; 00537 00538 priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); 00539 priv->page_name = NULL; 00540 priv->page_color = NULL; 00541 priv->uri = NULL; 00542 00543 page->window = NULL; 00544 page->summarybar = NULL; 00545 00546 gnc_gobject_tracking_remember(G_OBJECT(page), G_OBJECT_CLASS(klass)); 00547 } 00548 00549 00557 static void 00558 gnc_plugin_page_finalize (GObject *object) 00559 { 00560 GncPluginPagePrivate *priv; 00561 GncPluginPage *page; 00562 00563 page = GNC_PLUGIN_PAGE (object); 00564 00565 priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); 00566 if (priv->page_name) 00567 g_free(priv->page_name); 00568 if (priv->page_color) 00569 g_free(priv->page_color); 00570 if (priv->uri) 00571 g_free(priv->uri); 00572 if (priv->statusbar_text) 00573 g_free(priv->statusbar_text); 00574 00575 if (priv->books) 00576 { 00577 g_list_free(priv->books); 00578 priv->books = NULL; 00579 } 00580 00581 page->window = NULL; // Don't need to free it. 00582 00583 gnc_gobject_tracking_forget(object); 00584 G_OBJECT_CLASS (parent_class)->finalize (object); 00585 } 00586 00587 /************************************************************/ 00588 /* g_object other functions */ 00589 /************************************************************/ 00590 00591 00608 static void 00609 gnc_plugin_page_get_property (GObject *object, 00610 guint prop_id, 00611 GValue *value, 00612 GParamSpec *pspec) 00613 { 00614 GncPluginPage *page; 00615 GncPluginPagePrivate *priv; 00616 00617 g_return_if_fail(GNC_IS_PLUGIN_PAGE(object)); 00618 00619 page = GNC_PLUGIN_PAGE(object); 00620 priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); 00621 switch (prop_id) 00622 { 00623 case PROP_PAGE_NAME: 00624 g_value_set_string (value, priv->page_name); 00625 break; 00626 case PROP_PAGE_COLOR: 00627 g_value_set_string (value, priv->page_color); 00628 break; 00629 case PROP_PAGE_URI: 00630 g_value_set_string (value, priv->uri); 00631 break; 00632 case PROP_STATUSBAR_TEXT: 00633 g_value_set_string (value, priv->statusbar_text); 00634 break; 00635 case PROP_USE_NEW_WINDOW: 00636 g_value_set_boolean (value, priv->use_new_window); 00637 break; 00638 case PROP_UI_DESCRIPTION: 00639 g_value_set_string (value, priv->ui_description); 00640 break; 00641 case PROP_UI_MERGE: 00642 g_value_set_object (value, priv->ui_merge); 00643 break; 00644 case PROP_ACTION_GROUP: 00645 g_value_set_object (value, priv->action_group); 00646 break; 00647 default: 00648 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); 00649 break; 00650 } 00651 } 00652 00653 00670 static void 00671 gnc_plugin_page_set_property (GObject *object, 00672 guint prop_id, 00673 const GValue *value, 00674 GParamSpec *pspec) 00675 { 00676 GncPluginPage *page; 00677 00678 g_return_if_fail(GNC_IS_PLUGIN_PAGE(object)); 00679 00680 page = GNC_PLUGIN_PAGE(object); 00681 00682 switch (prop_id) 00683 { 00684 case PROP_PAGE_NAME: 00685 gnc_plugin_page_set_page_name(page, g_value_get_string(value)); 00686 break; 00687 case PROP_PAGE_COLOR: 00688 gnc_plugin_page_set_page_color(page, g_value_get_string(value)); 00689 break; 00690 case PROP_PAGE_URI: 00691 gnc_plugin_page_set_uri(page, g_value_get_string(value)); 00692 break; 00693 case PROP_STATUSBAR_TEXT: 00694 gnc_plugin_page_set_statusbar_text(page, g_value_get_string(value)); 00695 break; 00696 case PROP_USE_NEW_WINDOW: 00697 gnc_plugin_page_set_use_new_window(page, g_value_get_boolean(value)); 00698 break; 00699 case PROP_UI_DESCRIPTION: 00700 gnc_plugin_page_set_ui_description(page, g_value_get_string(value)); 00701 break; 00702 default: 00703 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); 00704 break; 00705 } 00706 } 00707 00708 /************************************************************/ 00709 /* */ 00710 /************************************************************/ 00711 00712 /* Add a book reference to the specified page. */ 00713 void 00714 gnc_plugin_page_add_book (GncPluginPage *page, QofBook *book) 00715 { 00716 GncPluginPagePrivate *priv; 00717 00718 g_return_if_fail (GNC_IS_PLUGIN_PAGE (page)); 00719 g_return_if_fail (book != NULL); 00720 00721 priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); 00722 priv->books = g_list_append(priv->books, book); 00723 } 00724 00725 00726 /* Query a page to see if it has a reference to a given book. */ 00727 gboolean 00728 gnc_plugin_page_has_book (GncPluginPage *page, QofBook *book) 00729 { 00730 GncPluginPagePrivate *priv; 00731 GList *item; 00732 00733 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), FALSE); 00734 g_return_val_if_fail (book != NULL, FALSE); 00735 00736 priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); 00737 for (item = priv->books; item; item = g_list_next(item)) 00738 { 00739 if (item->data == book) 00740 { 00741 return TRUE; 00742 } 00743 } 00744 return FALSE; 00745 } 00746 00747 00748 /* Query a page to see if it has a reference to any book. */ 00749 gboolean 00750 gnc_plugin_page_has_books (GncPluginPage *page) 00751 { 00752 GncPluginPagePrivate *priv; 00753 00754 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), FALSE); 00755 00756 priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); 00757 return (priv->books != NULL); 00758 } 00759 00760 00761 /* Retrieve a pointer to the GncMainWindow (GtkWindow) containing 00762 * this page. */ 00763 GtkWidget * 00764 gnc_plugin_page_get_window (GncPluginPage *page) 00765 { 00766 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), NULL); 00767 00768 return page->window; 00769 } 00770 00771 00772 /* Retrieve the name of this page. This is the string used in the 00773 * window title, and in the notebook tab and page selection menus. */ 00774 const gchar * 00775 gnc_plugin_page_get_page_name (GncPluginPage *page) 00776 { 00777 GncPluginPagePrivate *priv; 00778 00779 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), NULL); 00780 00781 priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); 00782 return priv->page_name; 00783 } 00784 00785 00786 /* Set the name of this page. This is the string used in the window 00787 * title, and in the notebook tab and page selection menus. */ 00788 void 00789 gnc_plugin_page_set_page_name (GncPluginPage *page, const gchar *name) 00790 { 00791 GncPluginPagePrivate *priv; 00792 GncPluginPageClass *klass; 00793 00794 g_return_if_fail (GNC_IS_PLUGIN_PAGE (page)); 00795 00796 priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); 00797 if (priv->page_name) 00798 g_free(priv->page_name); 00799 priv->page_name = g_strdup(name); 00800 00801 /* Perform page specific actions */ 00802 klass = GNC_PLUGIN_PAGE_GET_CLASS (page); 00803 if (klass->page_name_changed) 00804 { 00805 klass->page_name_changed(page, name); 00806 } 00807 } 00808 00809 00810 /* Retrieve the long name of this page. This is the string used in 00811 * the tooltip that is attached to the page name in the notebook 00812 * tab. */ 00813 const gchar * 00814 gnc_plugin_page_get_page_long_name (GncPluginPage *page) 00815 { 00816 GncPluginPagePrivate *priv; 00817 00818 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), NULL); 00819 00820 priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); 00821 return priv->page_long_name; 00822 } 00823 00824 00825 /* Set the long name of this page. This is the string used in the 00826 * tooltip that is attached to the page name in the notebook tab. */ 00827 void 00828 gnc_plugin_page_set_page_long_name (GncPluginPage *page, const gchar *name) 00829 { 00830 GncPluginPagePrivate *priv; 00831 00832 g_return_if_fail (GNC_IS_PLUGIN_PAGE (page)); 00833 00834 priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); 00835 if (priv->page_long_name) 00836 g_free(priv->page_long_name); 00837 priv->page_long_name = g_strdup(name); 00838 } 00839 00840 00841 /* Get the color of this page. This is the string used in the notebook tab. */ 00842 const gchar * 00843 gnc_plugin_page_get_page_color (GncPluginPage *page) 00844 { 00845 GncPluginPagePrivate *priv; 00846 00847 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), NULL); 00848 00849 priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); 00850 return priv->page_color; 00851 } 00852 00853 00854 /* Set the color of this page. This is the string used in the notebook tab. */ 00855 void 00856 gnc_plugin_page_set_page_color (GncPluginPage *page, const gchar *color) 00857 { 00858 GncPluginPagePrivate *priv; 00859 00860 g_return_if_fail (GNC_IS_PLUGIN_PAGE (page)); 00861 00862 priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); 00863 if (priv->page_color) 00864 g_free(priv->page_color); 00865 priv->page_color = g_strdup(color); 00866 } 00867 00868 00869 /* Retrieve the Uniform Resource Identifier for this page. */ 00870 const gchar * 00871 gnc_plugin_page_get_uri (GncPluginPage *page) 00872 { 00873 GncPluginPagePrivate *priv; 00874 00875 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), NULL); 00876 00877 priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); 00878 return priv->uri; 00879 } 00880 00881 00882 /* Set the Uniform Resource Identifier for this page. */ 00883 void 00884 gnc_plugin_page_set_uri (GncPluginPage *page, const gchar *name) 00885 { 00886 GncPluginPagePrivate *priv; 00887 00888 g_return_if_fail (GNC_IS_PLUGIN_PAGE (page)); 00889 00890 priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); 00891 if (priv->uri) 00892 g_free(priv->uri); 00893 priv->uri = g_strdup(name); 00894 } 00895 00896 00897 /* Retrieve the statusbar text associated with this page. */ 00898 const gchar * 00899 gnc_plugin_page_get_statusbar_text (GncPluginPage *page) 00900 { 00901 GncPluginPagePrivate *priv; 00902 00903 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), NULL); 00904 00905 priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); 00906 return priv->statusbar_text; 00907 } 00908 00909 00910 /* Set the statusbar text associated with this page. */ 00911 void 00912 gnc_plugin_page_set_statusbar_text (GncPluginPage *page, const gchar *message) 00913 { 00914 GncPluginPagePrivate *priv; 00915 00916 g_return_if_fail (GNC_IS_PLUGIN_PAGE (page)); 00917 00918 priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); 00919 if (priv->statusbar_text) 00920 g_free(priv->statusbar_text); 00921 priv->statusbar_text = g_strdup(message); 00922 } 00923 00924 00925 /* Retrieve the "use new window" setting associated with this page. */ 00926 gboolean 00927 gnc_plugin_page_get_use_new_window (GncPluginPage *page) 00928 { 00929 GncPluginPagePrivate *priv; 00930 00931 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), FALSE); 00932 00933 priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); 00934 return priv->use_new_window; 00935 } 00936 00937 00938 /* Set the "use new window" setting associated with this page. If 00939 * this setting is TRUE, the page will be installed into a new 00940 * window. Otherwise the page will be installed into an existing 00941 * window. */ 00942 void 00943 gnc_plugin_page_set_use_new_window (GncPluginPage *page, gboolean use_new) 00944 { 00945 GncPluginPagePrivate *priv; 00946 00947 g_return_if_fail (GNC_IS_PLUGIN_PAGE (page)); 00948 00949 priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); 00950 priv->use_new_window = use_new; 00951 } 00952 00953 00954 /* Retrieve the name of the XML UI file associated with this page. */ 00955 const gchar * 00956 gnc_plugin_page_get_ui_description (GncPluginPage *page) 00957 { 00958 GncPluginPagePrivate *priv; 00959 00960 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), FALSE); 00961 00962 priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); 00963 return priv->ui_description; 00964 } 00965 00966 00967 /* Set an alternate UI for the specified page. This alternate ui 00968 * may only use actions specified in the source for the page. */ 00969 void 00970 gnc_plugin_page_set_ui_description (GncPluginPage *page, 00971 const char *ui_filename) 00972 { 00973 GncPluginPagePrivate *priv; 00974 00975 g_return_if_fail(GNC_IS_PLUGIN_PAGE(page)); 00976 00977 priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); 00978 if (priv->ui_description) 00979 g_free(priv->ui_description); 00980 priv->ui_description = g_strdup(ui_filename); 00981 } 00982 00983 00984 /* Retrieve the GtkUIManager object associated with this page. */ 00985 GtkUIManager * 00986 gnc_plugin_page_get_ui_merge (GncPluginPage *page) 00987 { 00988 GncPluginPagePrivate *priv; 00989 00990 g_return_val_if_fail(GNC_IS_PLUGIN_PAGE(page), NULL); 00991 00992 priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); 00993 return priv->ui_merge; 00994 } 00995 00996 00997 /* Retrieve the GtkActionGroup object associated with this page. */ 00998 GtkActionGroup * 00999 gnc_plugin_page_get_action_group(GncPluginPage *page) 01000 { 01001 GncPluginPagePrivate *priv; 01002 01003 g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), NULL); 01004 priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); 01005 return priv->action_group; 01006 } 01007 01008 01009 /* Create the GtkActionGroup object associated with this page. */ 01010 GtkActionGroup * 01011 gnc_plugin_page_create_action_group (GncPluginPage *page, const gchar *group_name) 01012 { 01013 GncPluginPagePrivate *priv; 01014 GtkActionGroup *group; 01015 01016 priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page); 01017 group = gtk_action_group_new(group_name); 01018 gnc_gtk_action_group_set_translation_domain(group, GETTEXT_PACKAGE); 01019 priv->action_group = group; 01020 return group; 01021 } 01022 01023 gboolean 01024 gnc_plugin_page_finish_pending (GncPluginPage *page) 01025 { 01026 if (!page) 01027 return TRUE; 01028 if (!GNC_IS_PLUGIN_PAGE(page)) 01029 return TRUE; 01030 01031 if (!GNC_PLUGIN_PAGE_GET_CLASS(page)->finish_pending) 01032 return TRUE; 01033 return (GNC_PLUGIN_PAGE_GET_CLASS(page)->finish_pending)(page); 01034 } 01035
1.7.4