Hardcode ui xml in the editor

master
Yevgen Muntyan 2005-08-01 23:09:31 +00:00
parent 7986e586d8
commit 3e6c7acf9b
4 changed files with 32 additions and 32 deletions

View File

@ -452,7 +452,7 @@ static void filter_entry_activated (GtkEntry *entry,
GtkFileChooser *dialog) GtkFileChooser *dialog)
{ {
const char *text; const char *text;
Filter *filter; Filter *filter = NULL;
MooEditFileMgr *mgr; MooEditFileMgr *mgr;
mgr = g_object_get_data (G_OBJECT (dialog), "file-mgr"); mgr = g_object_get_data (G_OBJECT (dialog), "file-mgr");

View File

@ -1019,7 +1019,7 @@ gboolean moo_prefs_save (const char *file)
gboolean empty; gboolean empty;
GError *err = NULL; GError *err = NULL;
char *text; char *text;
gboolean result; gboolean result = TRUE;
g_return_val_if_fail (file != NULL, FALSE); g_return_val_if_fail (file != NULL, FALSE);
@ -1035,32 +1035,29 @@ gboolean moo_prefs_save (const char *file)
empty = FALSE; empty = FALSE;
if (empty) if (empty)
{
if (g_file_test (file, G_FILE_TEST_EXISTS))
if (moo_unlink (file))
g_critical ("%s: %s", G_STRLOC,
g_strerror (errno));
return TRUE; return TRUE;
}
text = format_xml (xml); text = format_xml (xml);
g_return_val_if_fail (text != NULL, FALSE);
if (text) result = moo_save_file_utf8 (file, text, -1, &err);
{
result = moo_save_file_utf8 (file, text, -1, &err);
if (!result) if (!result)
{ g_critical ("%s: could not save preferences to '%s'",
g_critical ("%s: could not save preferences to '%s'",
G_STRLOC, file); G_STRLOC, file);
}
if (err) if (err)
{
g_critical ("%s: %s", G_STRLOC, err->message);
g_error_free (err);
}
}
else if (moo_unlink (file))
{ {
g_critical ("%s: %s", G_STRLOC, g_critical ("%s: %s", G_STRLOC, err->message);
g_strerror (errno)); g_error_free (err);
} }
g_free (text); g_free (text);
return result; return result;
} }

View File

@ -3,13 +3,22 @@
# #
EXTRA_PROGRAMS = medit mterm markup editor termbuffer EXTRA_PROGRAMS = medit mterm markup editor termbuffer
bin_PROGRAMS =
noinst_PROGRAMS = noinst_PROGRAMS =
EXTRA_DIST = pyapp.py.in EXTRA_DIST = \
pyapp.py.in \
meditui.xml \
editor-ui.xml
BUILT_SOURCES = editor-ui.h
editor-ui.h: editor-ui.xml
sh $(srcdir)/../moo/mooutils/xml2h.sh MEDIT_UI $(srcdir)/editor-ui.xml > editor-ui.h
all-am: pyapp.py all-am: pyapp.py
if BUILD_MOOAPP if BUILD_MOOAPP
noinst_PROGRAMS += editor bin_PROGRAMS += editor
endif endif
if BUILD_MOOEDIT if BUILD_MOOEDIT
noinst_PROGRAMS += medit noinst_PROGRAMS += medit
@ -46,7 +55,9 @@ if MINGW_BUILD
editor_LDFLAGS += -mwindows editor_LDFLAGS += -mwindows
endif MINGW_BUILD endif MINGW_BUILD
editor_SOURCES = editor.c editor_SOURCES = \
editor.c \
editor-ui.h
############################################################################## ##############################################################################

View File

@ -14,14 +14,13 @@
#line 14 "@srcdir@/editor.c.in" #line 14 "@srcdir@/editor.c.in"
#include "mooapp/mooapp.h" #include "mooapp/mooapp.h"
#include "mooui/moouiobject.h" #include "mooui/moouiobject.h"
#include "editor-ui.h"
static void init_terminal (void); static void init_terminal (void);
static void init_editor (void); static void init_editor (void);
int main (int argc, char *argv[]) int main (int argc, char *argv[])
{ {
const char *file = "@srcdir@/editor-ui.xml";
MooApp *app; MooApp *app;
MooUIXML *xml; MooUIXML *xml;
MooEditor *editor; MooEditor *editor;
@ -42,16 +41,9 @@ int main (int argc, char *argv[])
"description", "MEdit is a text editor", "description", "MEdit is a text editor",
NULL)); NULL));
if (!g_file_test (file, G_FILE_TEST_EXISTS))
{
file = "editor-ui.xml";
if (!g_file_test (file, G_FILE_TEST_EXISTS))
g_error ("could not find editor-ui.xml");
}
xml = moo_app_get_ui_xml (app); xml = moo_app_get_ui_xml (app);
if (!moo_ui_xml_add_ui_from_file (xml, file, NULL)) if (!moo_ui_xml_add_ui_from_string (xml, MEDIT_UI, -1, NULL))
g_error ("%s", G_STRLOC); g_error ("%s", G_STRLOC);
moo_app_init (app); moo_app_init (app);