~sarahstrong/ubuntu/lucid/gedit/mypatch

« back to all changes in this revision

Viewing changes to src/gedit.c

  • Committer: Bazaar Package Importer
  • Author(s): Joe Drew
  • Date: 2002-01-13 02:13:27 UTC
  • Revision ID: james.westby@ubuntu.com-20020113021327-dukaa4n50oykvrjg
Tags: upstream-0.9.6
ImportĀ upstreamĀ versionĀ 0.9.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 
2
/*
 
3
 * gedit
 
4
 *
 
5
 * Copyright (C) 1998, 1999, 2000 Alex Roberts, Evan Lawrence, Jason Leach, Jose Celorio
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation; either version 2 of the License, or
 
10
 * (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, write to the Free Software
 
19
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 
20
 */
 
21
 
 
22
#include <config.h>
 
23
#include <gnome.h>
 
24
#include <glade/glade.h>
 
25
 
 
26
#include <libgnomevfs/gnome-vfs.h>
 
27
 
 
28
#include "commands.h"
 
29
#include "document.h"
 
30
#include "prefs.h"
 
31
#include "file.h"
 
32
#include "menus.h"
 
33
#include "plugin.h"
 
34
#include "recent.h"
 
35
#include "utils.h"
 
36
#include "window.h"
 
37
 
 
38
#ifdef HAVE_LIBGNORBA
 
39
#include <libgnorba/gnorba.h>
 
40
#endif
 
41
 
 
42
#include <libgnomeui/gnome-window-icon.h>
 
43
 
 
44
static const struct poptOption options[] =
 
45
{
 
46
        { "debug-window", '\0', 0, &debug_window, 0,
 
47
          N_("Show window debugging messages."), NULL },
 
48
 
 
49
        { "debug-commands", '\0', 0, &debug_commands, 0,
 
50
          N_("Show commands debugging messages."), NULL },
 
51
 
 
52
        { "debug-document", '\0', 0, &debug_document, 0,
 
53
          N_("Show document debugging messages."), NULL },
 
54
 
 
55
        { "debug-file", '\0', 0, &debug_file, 0,
 
56
          N_("Show file debugging messages."), NULL },
 
57
 
 
58
        { "debug-plugins", '\0', 0, &debug_plugins, 0,
 
59
          N_("Show plugin debugging messages."), NULL },
 
60
 
 
61
        { "debug-prefs", '\0', 0, &debug_prefs, 0,
 
62
          N_("Show prefs debugging messages."), NULL },
 
63
 
 
64
        { "debug-print", '\0', 0, &debug_print, 0,
 
65
          N_("Show printing debugging messages."), NULL },
 
66
 
 
67
        { "debug-search", '\0', 0, &debug_search, 0,
 
68
          N_("Show search debugging messages."), NULL },
 
69
 
 
70
        { "debug-undo", '\0', 0, &debug_undo, 0,
 
71
          N_("Show undo debugging messages."), NULL },
 
72
 
 
73
        { "debug-view", '\0', 0, &debug_view, 0,
 
74
          N_("Show view debugging messages."), NULL },
 
75
 
 
76
        { "debug-recent", '\0', 0, &debug_recent, 0,
 
77
          N_("Show recent debugging messages."), NULL },
 
78
 
 
79
        { "debug", '\0', 0, &debug, 0,
 
80
          N_("Turn on all debugging messages."), NULL },
 
81
 
 
82
        {NULL, '\0', 0, NULL, 0}
 
83
};
 
84
 
 
85
 
 
86
gint debug = 0;
 
87
gint debug_view = 0;
 
88
gint debug_undo = 0;
 
89
gint debug_search = 0;
 
90
gint debug_prefs = 0;
 
91
gint debug_print = 0;
 
92
gint debug_plugins = 0;
 
93
gint debug_file = 0;
 
94
gint debug_document = 0;
 
95
gint debug_commands = 0;
 
96
gint debug_recent = 0;
 
97
gint debug_window = 0;
 
98
 
 
99
#ifdef HAVE_LIBGNORBA
 
100
 
 
101
CORBA_ORB global_orb;
 
102
PortableServer_POA root_poa;
 
103
PortableServer_POAManager root_poa_manager;
 
104
CORBA_Environment *global_ev;
 
105
CORBA_Object name_service;
 
106
 
 
107
void
 
108
corba_exception (CORBA_Environment* ev)
 
109
{
 
110
        switch (ev->_major)
 
111
        {
 
112
        case CORBA_SYSTEM_EXCEPTION:
 
113
                g_log ("gedit CORBA", G_LOG_LEVEL_DEBUG,
 
114
                       "CORBA system exception %s.\n",
 
115
                       CORBA_exception_id (ev));
 
116
                break;
 
117
        case CORBA_USER_EXCEPTION:
 
118
                g_log ("gedit CORBA", G_LOG_LEVEL_DEBUG,
 
119
                       "CORBA user exception: %s.\n",
 
120
                       CORBA_exception_id (ev));
 
121
                break;
 
122
        default:
 
123
                break;
 
124
        }
 
125
}
 
126
 
 
127
#endif /* HAVE_LIBGNORBA */
 
128
 
 
129
int
 
130
main (int argc, char **argv)
 
131
{
 
132
        char **args;
 
133
        poptContext ctx;
 
134
        int i;
 
135
        
 
136
        GList *file_list = NULL;
 
137
 
 
138
        /* Initialize i18n */
 
139
        bindtextdomain(PACKAGE, GNOMELOCALEDIR);
 
140
        textdomain(PACKAGE);
 
141
 
 
142
#ifdef HAVE_LIBGNORBA
 
143
        global_ev = g_new0 (CORBA_Environment, 1);
 
144
        CORBA_exception_init (global_ev);
 
145
        global_orb = gnome_CORBA_init ("gedit", VERSION, &argc, argv,
 
146
                                       options, 0, &ctx, global_ev);
 
147
        corba_exception (global_ev);
 
148
        root_poa = CORBA_ORB_resolve_initial_references
 
149
                (global_orb, "RootPOA", global_ev);
 
150
        corba_exception (global_ev);
 
151
        root_poa_manager = PortableServer_POA__get_the_POAManager
 
152
                (root_poa, global_ev);
 
153
        corba_exception (global_ev);
 
154
        PortableServer_POAManager_activate (root_poa_manager, global_ev);
 
155
        corba_exception (global_ev);
 
156
        name_service = gnome_name_service_get ();
 
157
#else
 
158
        gnome_init_with_popt_table ("gedit", VERSION, argc, argv, options, 0, &ctx);
 
159
#endif /* HAVE_LIBGNORBA */
 
160
 
 
161
        args = (char**) poptGetArgs(ctx);
 
162
 
 
163
        if (!g_file_exists (GNOME_ICONDIR "/gedit-icon.png"))
 
164
            g_warning ("Could not find %s", GNOME_ICONDIR "/gedit-icon.png");
 
165
        gnome_window_icon_set_default_from_file (GNOME_ICONDIR "/gedit-icon.png");
 
166
        
 
167
        for (i = 0; args && args[i]; i++)
 
168
                file_list = g_list_append (file_list, args[i]);
 
169
        
 
170
        poptFreeContext (ctx);
 
171
 
 
172
        if (!gnome_vfs_init ()) {
 
173
                g_error (_("Cannot initialize gnome-vfs."));
 
174
                return 1;
 
175
        }
 
176
 
 
177
        glade_gnome_init ();
 
178
        gedit_prefs_load_settings ();
 
179
        gedit_plugins_init ();
 
180
        gedit_mdi_init ();
 
181
        gedit_close_all_flag_clear ();
 
182
 
 
183
        gtk_init_add ((GtkFunction)gedit_document_load, (gpointer)file_list);
 
184
 
 
185
        gtk_main();
 
186
 
 
187
        return 0;
 
188
}