Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

mlview-app.c

Go to the documentation of this file.
00001 /*
00002  *This file is part of MlView
00003  *
00004  *MlView is free software; you can redistribute it and/or modify it under the terms of 
00005  *the GNU General Public License as published by the Free Software Foundation; either version 2
00006  *or (at your option) any later version.
00007  *
00008  *MlView is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
00009  *without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00010  *See the GNU General Public License for more details.
00011  *
00012  *You should have received a copy of the GNU General Public License along with MlView.
00013  *see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00014  *
00015  *
00016  *Copyright 2001-2002 Dodji Seketeli.
00017  */
00018 
00019 #include <stdio.h>
00020 #include <gnome.h>
00021 #include "mlview-editor.h"
00022 #include "mlview-app.h"
00023 #include "mlview-app-context.h"
00024 #include "mlview-global-settings.h"
00025 #include "config.h"
00026 
00036 /*
00037  *The current instance of the mlview application context.
00038  *Must be set by mlview_app. For the moment, there must be one application
00039  *context per process. That should be changed in the future to enforce
00040  *reentrency.
00041  */
00042 static MlViewAppContext * gv_app_ctxt=NULL ;
00043 
00044 
00045 /*common function declarations*/
00046 
00047 /*callbacks ...*/
00048 static void 
00049 display_about_dialog() ;
00050 
00051 static void 
00052 open_cb(GtkWidget *a_widget, MlViewAppContext *a_context) ;
00053 
00054 static void 
00055 about_cb (GtkWidget *a_widget, MlViewAppContext *a_context) ;
00056 
00057 static void 
00058 paste_node_as_child_cb (GtkWidget *a_widget, MlViewAppContext *a_context) ;
00059 
00060 static void 
00061 paste_node_as_prev_sibling_cb (GtkWidget *a_widget, MlViewAppContext *a_context) ;
00062 
00063 static void 
00064 paste_node_as_next_sibling_cb (GtkWidget *a_widget, MlViewAppContext *a_context) ;
00065 
00066 static void 
00067 copy_node_cb (GtkWidget *a_widget, MlViewAppContext *a_context) ;
00068 
00069 static void 
00070 cut_node_cb (GtkWidget *a_widget, MlViewAppContext *a_context) ;
00071 
00072 static void 
00073 new_cb (GtkWidget *a_menu_item, MlViewAppContext *a_context) ;
00074 
00075 static void
00076 new_view_on_document_cb (GtkWidget *a_menu_item, MlViewAppContext *a_context) ;
00077 
00078 static void 
00079 close_cb (GtkWidget *a_menu_item, MlViewAppContext *a_context) ;
00080 
00081 static gint
00082 exit_cb (GtkWidget* a_widget,MlViewAppContext *a_context) ;
00083 
00084 static void
00085 add_child_node_cb (GtkWidget *a_menu_item,MlViewAppContext *a_context) ;
00086 
00087 static void
00088 insert_prev_sibling_node_cb (GtkWidget *a_menu_item,MlViewAppContext *a_context) ;
00089 
00090 static void
00091 insert_next_sibling_node_cb (GtkWidget *a_menu_item,MlViewAppContext *a_context) ;
00092 
00093 static void
00094 save_cb (GtkWidget *a_menu_item, MlViewAppContext *a_context) ;
00095 
00096 static void
00097 save_as_cb (GtkWidget *a_menu_item, MlViewAppContext *a_context) ;
00098 
00099 /*other functions*/
00100 static void
00101 install_menu_and_toolbar (GnomeApp *a_appwin) ;
00102 
00103 /*
00104  *Common functions functions that perform various generic tasks such as:
00105  *displaying an about dialog box for example, fetching and opening a file, ... 
00106  *
00107  */
00108 
00109 
00110 /*
00111  *Displays the about dialog.
00112  *@author Dodji Seketeli <dodji@seketeli.org> 
00113  *
00114  */
00115 static void
00116 display_about_dialog()
00117 {
00118         static GnomeAbout *about_dialog=NULL ;
00119   
00120         const gchar * authors[] = {_("Dodji Seketeli <dodji@seketeli.org>"),
00121                                    NULL} ;
00122         gchar * mlview_comments = _("A Simple xml editor for gnome.") ;
00123         about_dialog = 
00124                 GNOME_ABOUT(gnome_about_new (PACKAGE, VERSION, _("Copyright (c) 2001, 2002 Dodji Seketeli"),
00125                                              authors, mlview_comments,NULL)) ;
00126 
00127         gnome_dialog_run (GNOME_DIALOG (about_dialog)) ;
00128 }
00129 
00130 /*=========================================================
00131  *General signal handlers for the differents menuitems
00132  *========================================================*/
00133 static void
00134 open_cb (GtkWidget *a_widget, MlViewAppContext *a_context)
00135 {
00136         g_return_if_fail (a_widget!=NULL) ;
00137         g_return_if_fail (a_context != NULL) ;
00138     
00139         mlview_editor_open_local_xml_document_interactive(mlview_app_context_get_element(a_context, "MlViewEditor")) ;
00140 }
00141 
00142 static void
00143 about_cb (GtkWidget *a_widget, MlViewAppContext *a_context)
00144 {
00145         display_about_dialog ();
00146 }
00147 
00148 static void 
00149 paste_node_as_child_cb (GtkWidget *a_widget, MlViewAppContext *a_context)
00150 {
00151         MlViewEditor *editor ;
00152         editor = mlview_app_context_get_element (a_context, "MlViewEditor") ;
00153         mlview_editor_paste_node_as_child (editor) ;
00154 }
00155 
00156 static void 
00157 paste_node_as_prev_sibling_cb (GtkWidget *a_widget, MlViewAppContext *a_context)
00158 {
00159         MlViewEditor *editor ;
00160         editor = mlview_app_context_get_element (a_context, "MlViewEditor") ;
00161         mlview_editor_paste_node_as_prev_sibling (editor) ;
00162 }
00163 
00164 static void 
00165 paste_node_as_next_sibling_cb (GtkWidget *a_widget, MlViewAppContext *a_context)
00166 {
00167         MlViewEditor *editor ;
00168         editor = mlview_app_context_get_element (a_context, "MlViewEditor") ;
00169         mlview_editor_paste_node_as_next_sibling (editor) ;
00170 }
00171 
00172 static void
00173 copy_node_cb (GtkWidget *a_widget, MlViewAppContext *a_context)
00174 {
00175         MlViewEditor *editor=NULL ;
00176         
00177         g_return_if_fail (a_context) ;
00178         
00179         editor = mlview_app_context_get_element (a_context, "MlViewEditor") ;
00180         g_return_if_fail (editor != NULL) ;
00181         mlview_editor_copy_node (editor) ;
00182 }
00183 
00184 static void
00185 cut_node_cb (GtkWidget *a_widget, MlViewAppContext *a_context)
00186 {
00187         MlViewEditor *editor=NULL ;
00188         
00189         g_return_if_fail (a_context) ;
00190         
00191         editor = mlview_app_context_get_element (a_context, "MlViewEditor") ;
00192         g_return_if_fail (editor != NULL) ;
00193         mlview_editor_cut_node (editor) ;
00194 }
00195 
00196 static void
00197 new_cb (GtkWidget *a_menu_item, MlViewAppContext *a_context)
00198 {
00199         MlViewEditor *editor ;
00200         g_return_if_fail (a_context != NULL) ;
00201         g_return_if_fail (a_menu_item != NULL) ;
00202         editor = mlview_app_context_get_element (a_context, "MlViewEditor") ;
00203         mlview_editor_create_new_xml_document (editor) ;
00204 }
00205 
00206 static void
00207 new_view_on_document_cb (GtkWidget *a_menu_item, MlViewAppContext *a_context)
00208 {
00209         MlViewEditor *editor = NULL ;
00210         g_return_if_fail (a_context != NULL) ;
00211         g_return_if_fail (a_menu_item != NULL) ;
00212 
00213         editor = mlview_app_context_get_element (a_context, "MlViewEditor") ;
00214         mlview_editor_create_new_view_on_current_document_interactive (editor) ;
00215 }
00216 
00217 static void
00218 close_cb (GtkWidget *a_menu_item, MlViewAppContext *a_context)
00219 {
00220         MlViewEditor *editor = NULL ;
00221         g_return_if_fail (a_context != NULL) ;
00222         g_return_if_fail (a_menu_item != NULL) ;
00223         editor = mlview_app_context_get_element (a_context, "MlViewEditor") ;
00224         mlview_editor_close_xml_document_interactive (editor) ;
00225 }
00226 
00227 static gint
00228 exit_cb (GtkWidget* a_widget,
00229          MlViewAppContext *a_context)
00230 {
00231         GnomeApp *app = NULL ;
00232         MlViewEditor * editor = NULL ;
00233         
00234         editor = mlview_app_context_get_element (a_context, "MlViewEditor") ;
00235 
00236         if (editor)
00237                 mlview_editor_close_all_xml_documents_interactive (editor) ;
00238 
00239         app = mlview_app_context_get_element (a_context, "GnomeApp") ;
00240         gtk_widget_destroy (GTK_WIDGET(app)) ;
00241         gtk_main_quit () ;
00242         return FALSE ;
00243 }
00244 
00245 static void
00246 add_child_node_cb (GtkWidget *a_menu_item,
00247                    MlViewAppContext *a_context)
00248 {
00249         MlViewEditor *editor ;
00250         g_return_if_fail (a_context != NULL) ;
00251         g_return_if_fail (a_menu_item) ;
00252         editor = mlview_app_context_get_element (a_context, "MlViewEditor") ;
00253         mlview_editor_add_child_node_interactive (editor) ;
00254 }
00255 
00256 static void
00257 insert_prev_sibling_node_cb (GtkWidget *a_menu_item,
00258                              MlViewAppContext *a_context)
00259 {
00260         MlViewEditor *editor ;
00261         g_return_if_fail (a_context != NULL) ;
00262         g_return_if_fail (a_menu_item != NULL) ;
00263         editor = mlview_app_context_get_element (a_context, "MlViewEditor") ;
00264         mlview_editor_insert_prev_sibling_node_interactive (editor) ;
00265 }
00266 
00267 
00268 static void
00269 insert_next_sibling_node_cb (GtkWidget *a_menu_item,
00270                              MlViewAppContext *a_context)
00271 {
00272         MlViewEditor *editor = NULL ;
00273         g_return_if_fail (a_context != NULL) ;
00274         g_return_if_fail (a_menu_item != NULL) ;
00275         editor = mlview_app_context_get_element (a_context, "MlViewEditor") ;
00276         mlview_editor_insert_next_sibling_node_interactive (editor) ;
00277 }
00278 
00279 static void
00280 save_cb (GtkWidget *a_menu_item, MlViewAppContext *a_context)
00281 {
00282         MlViewEditor *editor ;
00283         g_return_if_fail (a_context != NULL) ;
00284         g_return_if_fail (a_menu_item != NULL) ;
00285 
00286         editor = mlview_app_context_get_element (a_context, "MlViewEditor") ;
00287         mlview_editor_save_xml_document (editor) ;
00288 }
00289 
00290 static void
00291 save_as_cb (GtkWidget *a_menu_item, MlViewAppContext *a_context)
00292 {
00293         MlViewEditor *editor ;
00294         g_return_if_fail (a_context != NULL) ;
00295         g_return_if_fail (a_menu_item != NULL) ;
00296 
00297         editor = mlview_app_context_get_element (a_context, "MlViewEditor") ;
00298         mlview_editor_save_xml_document_as_interactive (editor) ;
00299 }
00300 
00301 
00302 static void
00303 search_cb (GtkWidget *a_menu_item, MlViewAppContext *a_context)
00304 {
00305         MlViewEditor *editor ;
00306         g_return_if_fail (a_context != NULL) ;
00307         g_return_if_fail (a_menu_item != NULL) ;
00308         editor = mlview_app_context_get_element (a_context, "MlViewEditor") ;
00309 
00310         mlview_editor_find_xml_node_that_contains_str_interactive (editor) ;
00311 }
00312 
00313 static void
00314 associate_a_dtd_cb (GtkWidget *a_menu_item, MlViewAppContext *a_context)
00315 {
00316         MlViewEditor *editor ;
00317         g_return_if_fail(a_context != NULL) ;
00318         g_return_if_fail(a_menu_item != NULL) ;
00319 
00320         editor = mlview_app_context_get_element (a_context, "MlViewEditor") ;
00321 
00322         mlview_editor_associate_dtd_interactive(editor) ;
00323 }
00324 
00325 static void
00326 validate_document_cb (GtkWidget *a_menu_item, MlViewAppContext *a_context)
00327 {
00328         MlViewEditor *editor ;
00329         g_return_if_fail (a_context != NULL) ;
00330         g_return_if_fail (a_menu_item != NULL) ;
00331 
00332         editor = mlview_app_context_get_element (a_context, "MlViewEditor") ;
00333         mlview_editor_validate (editor) ;
00334 }
00335 
00336 static void
00337 expand_tree_to_depth_cb (GtkWidget *a_menu_item, MlViewAppContext *a_context)
00338 {
00339         MlViewEditor *editor ;
00340         g_return_if_fail (a_context != NULL) ;
00341         g_return_if_fail (a_menu_item != NULL) ;
00342 
00343         editor = mlview_app_context_get_element (a_context, "MlViewEditor") ;
00344         mlview_editor_expand_tree_to_depth_interactive (editor) ;
00345 }
00346 
00347 static void
00348 edit_settings_cb (GtkWidget *a_menu_item, MlViewAppContext *a_context)
00349 {
00350         MlViewEditor *editor = NULL ;
00351 
00352         g_return_if_fail (a_context != NULL) ;
00353         g_return_if_fail (a_menu_item != NULL) ;
00354 
00355         editor = mlview_app_context_get_element (a_context, "MlViewEditor") ;
00356 
00357         mlview_editor_edit_settings_interactive (editor) ;
00358 }
00359 
00360 static void
00361 change_view_name_cb (GtkWidget *a_menu_item, MlViewAppContext *a_context)
00362 {
00363         MlViewEditor *editor = NULL ;
00364         
00365         g_return_if_fail (a_context != NULL) ;
00366         g_return_if_fail (a_menu_item != NULL) ;
00367 
00368         editor = mlview_app_context_get_element (a_context, "MlViewEditor") ;
00369         mlview_editor_set_current_view_name_interactive (editor) ;
00370 }
00371 
00372 
00373 /*===============================================================
00374  *The applications menus definitions.
00375  *FIXME: Manage to comply with the gnome application menu rules.
00376  *===============================================================*/
00377 
00378 /*the menuitems of the /file menu*/
00379 static GnomeUIInfo g_menu_files_tree[] =
00380 {
00381         GNOMEUIINFO_MENU_OPEN_ITEM (open_cb, NULL),
00382 
00383         GNOMEUIINFO_MENU_CLOSE_ITEM (close_cb, NULL),
00384 
00385         GNOMEUIINFO_MENU_NEW_ITEM (N_("New xml document"),
00386                                    N_("Creates new xml document"),
00387                                    new_cb, NULL),
00388         
00389         GNOMEUIINFO_MENU_NEW_ITEM (N_("New view on xml document"),
00390                                    N_("Creates a new view on current xml document"),
00391                                    new_view_on_document_cb, NULL),
00392 
00393         GNOMEUIINFO_SEPARATOR,
00394 
00395         GNOMEUIINFO_MENU_SAVE_ITEM (save_cb, NULL),
00396 
00397         GNOMEUIINFO_MENU_SAVE_AS_ITEM (save_as_cb, NULL),
00398 
00399         GNOMEUIINFO_ITEM (N_("Change view name"),
00400                           N_("Rename the current view"),
00401                           change_view_name_cb, NULL),
00402 
00403         GNOMEUIINFO_SEPARATOR,
00404 
00405         GNOMEUIINFO_MENU_EXIT_ITEM (exit_cb, NULL),
00406 
00407         GNOMEUIINFO_END
00408 };
00409 
00410 /*The menuitems of the /edit menu */
00411 static GnomeUIInfo g_menu_edit_tree [] =
00412 {
00413         GNOMEUIINFO_ITEM (N_("Add child node"),
00414                           N_("Adds a child node to the currently selected xml node"),
00415                           add_child_node_cb,NULL),
00416         GNOMEUIINFO_ITEM (N_("Insert previous node"),
00417                           N_("Inserts a sibling node just before the current selected node"),
00418                           insert_prev_sibling_node_cb,NULL),
00419         GNOMEUIINFO_ITEM (N_("Insert next node"),
00420                           N_("Inserts a sibling node just after the current selected node"),
00421                           insert_next_sibling_node_cb,NULL),
00422         GNOMEUIINFO_SEPARATOR,
00423         GNOMEUIINFO_ITEM (N_("Copy node"),
00424                           N_("Copies the current selected node and it children"),
00425                           copy_node_cb,NULL) ,
00426         GNOMEUIINFO_ITEM (N_("Cut node"),
00427                           N_("Cuts the current selected node and it children"),
00428                           cut_node_cb,NULL) ,
00429         GNOMEUIINFO_SEPARATOR,
00430         GNOMEUIINFO_ITEM (N_("Paste node as child"),
00431                           N_("Pastes the last copied node as a child of the currently selected node"),
00432                           paste_node_as_child_cb,NULL) ,
00433         GNOMEUIINFO_ITEM (N_("Paste node as prev"),
00434                           N_("Pastes the last copied node as the previous sibling of the currently selected node"),
00435                           paste_node_as_prev_sibling_cb,NULL) ,
00436         GNOMEUIINFO_ITEM (N_("Paste node as next"),
00437                           N_("Pastes the last copied node as the next sibling of the currently selected node"),
00438                           paste_node_as_next_sibling_cb,NULL) ,
00439         GNOMEUIINFO_SEPARATOR,
00440         GNOMEUIINFO_ITEM(N_("Settings"),
00441                          N_("Edits Gnome MlView Settings"),
00442                          edit_settings_cb,NULL) ,
00443         GNOMEUIINFO_END
00444 };
00445 
00446 /*The */
00447 static GnomeUIInfo g_menu_actions_tree[] = 
00448 {
00449         GNOMEUIINFO_ITEM (N_("Associate a Dtd"),N_("Associates a Dtd to the current xml document"), associate_a_dtd_cb, NULL),
00450         GNOMEUIINFO_ITEM (N_("Validate document"),N_("Validates the document against it current Dtd"), validate_document_cb, NULL),
00451         GNOMEUIINFO_SEPARATOR,
00452         GNOMEUIINFO_ITEM (N_("Expand current node"),N_("Expands the current selected node to an absolute depth"), expand_tree_to_depth_cb, NULL),
00453         GNOMEUIINFO_END
00454 } ;
00455 
00456 /*The menuitems of the /help menu*/
00457 static GnomeUIInfo g_menu_help_tree[] =
00458 {
00459         GNOMEUIINFO_MENU_ABOUT_ITEM(about_cb,NULL),
00460         GNOMEUIINFO_END
00461 };
00462 
00463 /*The menuitems of the /search menu*/
00464 static GnomeUIInfo g_menu_search_tree[] =
00465 {
00466         GNOMEUIINFO_ITEM (N_("Find an xml node"), N_("Finds an xml node that matches some criteria"), search_cb, NULL),
00467         GNOMEUIINFO_END
00468 };
00469 
00470 
00471 /*The application menubar*/
00472 static GnomeUIInfo g_app_menu_bar[] = 
00473 {
00474         GNOMEUIINFO_MENU_FILE_TREE(g_menu_files_tree),
00475         GNOMEUIINFO_MENU_EDIT_TREE(g_menu_edit_tree),
00476         GNOMEUIINFO_SUBTREE(N_("_Search"), g_menu_search_tree),
00477         GNOMEUIINFO_SUBTREE(N_("Actions"), g_menu_actions_tree),
00478         GNOMEUIINFO_MENU_HELP_TREE(g_menu_help_tree),
00479         GNOMEUIINFO_END
00480 };
00481 
00482 /*the application toolbar*/
00483 static GnomeUIInfo g_toolbar[] = 
00484 {
00485         GNOMEUIINFO_ITEM_STOCK (N_("Open"), N_("open an existing file"), open_cb, GNOME_STOCK_PIXMAP_OPEN),
00486         GNOMEUIINFO_ITEM_STOCK (N_("New"), N_("creates a new xml document"), new_cb, GNOME_STOCK_PIXMAP_NEW),
00487         GNOMEUIINFO_ITEM_STOCK (N_("Close"),N_("closes the currently open file"), close_cb, GNOME_STOCK_PIXMAP_CLOSE),
00488         GNOMEUIINFO_SEPARATOR,
00489         GNOMEUIINFO_ITEM_STOCK (N_("Save"),N_("save this file"), save_cb, GNOME_STOCK_PIXMAP_SAVE),
00490         GNOMEUIINFO_ITEM_STOCK (N_("Save as"),N_("save this file with a new name"), save_as_cb, GNOME_STOCK_PIXMAP_SAVE_AS),
00491         GNOMEUIINFO_SEPARATOR,
00492         GNOMEUIINFO_ITEM_STOCK (N_("Exit"), N_("Exits MlView application"), exit_cb, GNOME_STOCK_PIXMAP_QUIT),
00493         GNOMEUIINFO_END
00494 };
00495 
00496 /*
00497  *FIXME: define a general popup menu that contains some edit menu stuffs, some search stuffs and also som mdi stuffs.
00498  */
00499 
00500 /*be carefull. The fields of this array are modified in install_menu_and_toolbar() so if you add a field, update the function !!!*/
00501 static GnomeUIInfo g_edition_toolbar[] =
00502 {
00503         GNOMEUIINFO_ITEM_DATA(N_("Add child"), N_("Add a child node to the current selected node"),add_child_node_cb,NULL,NULL),
00504         GNOMEUIINFO_SEPARATOR,
00505         GNOMEUIINFO_ITEM_DATA(N_("Insert prev"),N_("Inserts a sibling node just before the current selected node"),insert_prev_sibling_node_cb,NULL,NULL),
00506         GNOMEUIINFO_SEPARATOR,
00507         GNOMEUIINFO_ITEM_DATA(N_("Insert next"),N_("Inserts a sibling node just after the current selected node"),insert_next_sibling_node_cb,NULL,NULL),
00508         GNOMEUIINFO_SEPARATOR,
00509         GNOMEUIINFO_ITEM_DATA(N_("Copy"),N_("Copies the current selected node and it children"),copy_node_cb,NULL,NULL) ,
00510         GNOMEUIINFO_SEPARATOR,
00511         GNOMEUIINFO_ITEM_DATA(N_("Cut"),N_("Cuts the current selected node and it children"),cut_node_cb,NULL,NULL) ,
00512         GNOMEUIINFO_SEPARATOR,
00513         GNOMEUIINFO_ITEM_DATA(N_("Paste child"),N_("Pastes the last copied node as a child of the currently selected node"),paste_node_as_child_cb,NULL,NULL) ,
00514         GNOMEUIINFO_SEPARATOR,
00515         GNOMEUIINFO_ITEM_DATA(N_("Paste prev"),N_("Pastes the last copied node as the previous sibling node of the currently selected node"),paste_node_as_prev_sibling_cb,NULL,NULL) ,
00516         GNOMEUIINFO_SEPARATOR,
00517         GNOMEUIINFO_ITEM_DATA(N_("Paste next"),N_("Pastes the last copied node as the next sibling node of the currently selected node"),paste_node_as_next_sibling_cb,NULL,NULL) ,     
00518         GNOMEUIINFO_END
00519 };
00520 
00521 /*
00522  *install a main menu and a main toolbar to the
00523  *main application root window.
00524  *@param a_appwin the main application root win. 
00525  *
00526  */
00527 static void
00528 install_menu_and_toolbar(GnomeApp *a_appwin)
00529 {
00530         GtkToolbar * tb=NULL ;
00531         if(!a_appwin)
00532                 return ;        
00533         gnome_app_create_menus_with_data (a_appwin,g_app_menu_bar,gv_app_ctxt) ;
00534 
00535         tb = GTK_TOOLBAR (gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL,
00536                                            GTK_TOOLBAR_BOTH)) ;
00537         gtk_toolbar_set_space_size (tb,0) ;
00538 
00539         gnome_app_create_toolbar_with_data (a_appwin,g_toolbar,gv_app_ctxt);
00540 
00541         g_edition_toolbar[0].user_data = gv_app_ctxt ;
00542         g_edition_toolbar[2].user_data = gv_app_ctxt ;
00543         g_edition_toolbar[4].user_data = gv_app_ctxt ;
00544         g_edition_toolbar[6].user_data = gv_app_ctxt ;
00545         g_edition_toolbar[8].user_data = gv_app_ctxt ;
00546         g_edition_toolbar[10].user_data = gv_app_ctxt ;
00547         g_edition_toolbar[12].user_data = gv_app_ctxt ;
00548         g_edition_toolbar[14].user_data = gv_app_ctxt ;
00549 
00550         gnome_app_fill_toolbar(tb, g_edition_toolbar,
00551                                gtk_accel_group_get_default()) ;
00552 
00553         gnome_app_add_toolbar(a_appwin,tb,"edition",
00554                               GNOME_DOCK_ITEM_BEH_NORMAL,
00555                               GNOME_DOCK_TOP,
00556                               2,0,0) ;
00557 }
00558 
00559 
00566 void
00567 mlview_app_build_set_global_settings (MlViewAppContext * a_app_context)
00568 {
00569         g_return_if_fail (a_app_context != NULL) ;
00570         g_return_if_fail (MLVIEW_IS_APP_CONTEXT (a_app_context)) ;
00571 
00572         mlview_app_context_set_settings_value (a_app_context, MLVIEW_STG_K_ICON_PATH,
00573                                                MLVIEW_STG_V_ICON_PATH) ;
00574 
00575         mlview_app_context_set_settings_value (a_app_context, MLVIEW_STG_K_OPEN_ELEMENT_NODE_XPM,
00576                                                MLVIEW_STG_V_OPEN_ELEMENT_NODE_XPM) ;
00577 
00578         mlview_app_context_set_settings_value (a_app_context, MLVIEW_STG_K_CLOSE_ELEMENT_NODE_XPM,
00579                                                MLVIEW_STG_V_CLOSE_ELEMENT_NODE_XPM) ;
00580 
00581         mlview_app_context_set_settings_value (a_app_context,MLVIEW_STG_K_TEXT_NODE_XPM ,
00582                                                MLVIEW_STG_V_TEXT_NODE_XPM) ;
00583 
00584         mlview_app_context_set_settings_value (a_app_context,MLVIEW_STG_K_PIXMAPS_DIR,
00585                                                MLVIEW_STG_V_PIXMAPS_DIR) ;
00586         
00587 }
00588 
00589 
00595 void 
00596 mlview_app_set_icon (GnomeApp * a_app) 
00597 {
00598         MlViewAppContext * app_context = NULL ;
00599                 
00600         g_return_if_fail (a_app != NULL) ;
00601         g_return_if_fail (GNOME_IS_APP (a_app)) ;
00602         g_return_if_fail (GTK_WIDGET (a_app)->window != NULL) ;
00603 
00604         app_context = gtk_object_get_data (GTK_OBJECT (a_app), "mlview-app-context") ;
00605         
00606         g_return_if_fail (app_context != NULL) ;
00607         g_return_if_fail (MLVIEW_IS_APP_CONTEXT (app_context)) ;
00608 
00609         mlview_app_context_set_window_icon (app_context, GTK_WIDGET (a_app)) ;
00610 }
00611 
00612 
00613 
00619 GnomeApp*
00620 mlview_app_new ( gchar * a_appname )
00621 {
00622         GnomeApp *mlview_application=NULL;
00623         GtkWidget *editor=NULL,*appbar=NULL;
00624 
00625         mlview_application = GNOME_APP (gnome_app_new (a_appname, a_appname)) ;
00626                 
00627         /*creates the application context*/
00628         gv_app_ctxt = MLVIEW_APP_CONTEXT (mlview_app_context_get_instance()) ;
00629         gtk_object_set_data (GTK_OBJECT (mlview_application), "mlview-app-context", gv_app_ctxt) ;
00630 
00631         /*add the gnome app to the app context*/
00632         mlview_app_context_set_element (gv_app_ctxt, "GnomeApp",
00633                                         mlview_application) ;
00634 
00635         mlview_app_build_set_global_settings (gv_app_ctxt) ;
00636                 
00637 
00638         /*create the main vbox of the root window.*/
00639         editor = mlview_editor_new ("mlview:empty", gv_app_ctxt) ;
00640         gnome_app_set_contents (GNOME_APP (mlview_application),
00641                                 editor) ;
00642         
00643         /*add the mlview editor widget to the app context*/
00644         mlview_app_context_set_element (gv_app_ctxt, "MlViewEditor", editor) ;
00645         mlview_editor_set_app_context (MLVIEW_EDITOR (editor), gv_app_ctxt) ;
00646 
00647         /*create the app status bar, add it to the gnome app and store the pointer into the app context*/
00648         appbar = gnome_appbar_new (TRUE,TRUE,GNOME_PREFERENCES_NEVER) ;
00649         gnome_app_set_statusbar (mlview_application, appbar) ;
00650         mlview_app_context_set_element (gv_app_ctxt, "GnomeAppBar" ,appbar) ;
00651 
00652         /*Install the menu and toolbar*/
00653         install_menu_and_toolbar (mlview_application) ;
00654 
00655         gtk_widget_show (editor) ;
00656 
00657         /*FIXME: the message printing is just for test purpose*/
00658         mlview_app_context_sbar_set_default_message (gv_app_ctxt, "MlView is ready") ;
00659 
00660         /*Make sure we exit the glib main loop when the user clicks the
00661          *window close button.(Thanks to Peter Bray" <peter_darren_bray@yahoo.com>)
00662          */
00663         gtk_signal_connect (GTK_OBJECT (mlview_application),
00664                            "delete_event",
00665                            GTK_SIGNAL_FUNC (gtk_exit),
00666                            NULL) ;
00667         gtk_signal_connect (GTK_OBJECT (mlview_application),
00668                            "destroy",
00669                            GTK_SIGNAL_FUNC (gtk_exit),
00670                            NULL) ;
00671         return mlview_application ;
00672 }
00673 
00674 
00683 MlViewEditor *
00684 mlview_app_get_editor (GnomeApp * a_app)
00685 {
00686         GnomeApp * app_candidate = NULL ;
00687         MlViewEditor * result = NULL ;
00688 
00689         g_return_val_if_fail (a_app != NULL, NULL) ;
00690         g_return_val_if_fail (GNOME_IS_APP (a_app), NULL) ;
00691 
00692         app_candidate = mlview_app_context_get_element (gv_app_ctxt, "GnomeApp") ;
00693 
00694         if ( app_candidate ) {
00695                 result = mlview_app_context_get_element (gv_app_ctxt, "MlViewEditor") ;
00696         }
00697 
00698         return result ; 
00699 }

Generated on Sat Jul 6 09:57:31 2002 for Gnome-MlView by doxygen1.2.16