Started sessions stuff
parent
1ca2c83ba3
commit
5ce865ccd0
|
@ -17,6 +17,7 @@ mooedit_include_headers = \
|
|||
$(mooedit)/mooeditconfig.h \
|
||||
$(mooedit)/mooeditor.h \
|
||||
$(mooedit)/mooeditprefs.h \
|
||||
$(mooedit)/mooeditsession.h \
|
||||
$(mooedit)/mooeditwindow.h \
|
||||
$(mooedit)/mooindenter.h \
|
||||
$(mooedit)/moolang.h \
|
||||
|
@ -42,6 +43,7 @@ mooedit_noinst_headers = \
|
|||
$(mooedit)/mooeditfileops.h \
|
||||
$(mooedit)/mooeditprefs-glade.h \
|
||||
$(mooedit)/mooeditsavemultiple-glade.h \
|
||||
$(mooedit)/mooeditsession-private.h \
|
||||
$(mooedit)/moofold.h \
|
||||
$(mooedit)/moohighlighter.h \
|
||||
$(mooedit)/moolang-aux.h \
|
||||
|
@ -78,6 +80,7 @@ mooedit_sources = \
|
|||
$(mooedit)/mooeditor.c \
|
||||
$(mooedit)/mooeditprefs.c \
|
||||
$(mooedit)/mooeditprefspage.c \
|
||||
$(mooedit)/mooeditsession.c \
|
||||
$(mooedit)/mooeditwindow.c \
|
||||
$(mooedit)/moofold.c \
|
||||
$(mooedit)/moohighlighter.c \
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#ifndef __MOO_EDITOR_H__
|
||||
#define __MOO_EDITOR_H__
|
||||
|
||||
#include <mooedit/mooeditwindow.h>
|
||||
#include <mooedit/mooeditsession.h>
|
||||
#include <mooedit/moolangmgr.h>
|
||||
#include <mooutils/moouixml.h>
|
||||
#include <mooutils/moohistorylist.h>
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* mooeditsession-private.h
|
||||
*
|
||||
* Copyright (C) 2004-2006 by Yevgen Muntyan <muntyan@math.tamu.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* See COPYING file that comes with this distribution.
|
||||
*/
|
||||
|
||||
#ifndef MOOEDIT_COMPILATION
|
||||
#error "This file may not be used directly"
|
||||
#endif
|
||||
|
||||
#ifndef __MOO_EDIT_SESSION_PRIVATE_H__
|
||||
#define __MOO_EDIT_SESSION_PRIVATE_H__
|
||||
|
||||
#include "mooedit/mooeditor.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
MooEditSession *_moo_edit_session_new (void);
|
||||
void _moo_edit_session_add_window (MooEditWindow *window);
|
||||
gboolean _moo_edit_session_load (MooEditSession *session,
|
||||
MooEditor *editor,
|
||||
MooEditWindow *window);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MOO_EDIT_SESSION_PRIVATE_H__ */
|
|
@ -0,0 +1,177 @@
|
|||
/*
|
||||
* mooeditsession.c
|
||||
*
|
||||
* Copyright (C) 2004-2006 by Yevgen Muntyan <muntyan@math.tamu.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* See COPYING file that comes with this distribution.
|
||||
*/
|
||||
|
||||
#define MOOEDIT_COMPILATION
|
||||
#include "mooedit/mooeditsession-private.h"
|
||||
|
||||
|
||||
typedef struct _SWindow SWindow;
|
||||
typedef struct _SDoc SDoc;
|
||||
|
||||
struct _SWindow {
|
||||
GSList *docs;
|
||||
SDoc *active;
|
||||
};
|
||||
|
||||
struct _SDoc {
|
||||
char *filename;
|
||||
char *encoding;
|
||||
};
|
||||
|
||||
struct _MooEditSession {
|
||||
GSList *windows; /* MooEditSessionWindow* */
|
||||
};
|
||||
|
||||
|
||||
static SWindow *session_window_new (void);
|
||||
static SWindow *session_window_copy (SWindow *win);
|
||||
static void session_window_free (SWindow *win);
|
||||
static SDoc *session_doc_new (const char *filename,
|
||||
const char *encoding);
|
||||
static SDoc *session_doc_copy (SDoc *doc);
|
||||
static void session_doc_free (SDoc *doc);
|
||||
|
||||
|
||||
GType
|
||||
moo_edit_session_get_type (void)
|
||||
{
|
||||
static GType type;
|
||||
|
||||
if (G_UNLIKELY (!type))
|
||||
type = g_boxed_type_register_static ("MooEditSession",
|
||||
(GBoxedCopyFunc) moo_edit_session_copy,
|
||||
(GBoxedFreeFunc) moo_edit_session_free);
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
MooEditSession *
|
||||
_moo_edit_session_new (void)
|
||||
{
|
||||
return g_new0 (MooEditSession, 1);
|
||||
}
|
||||
|
||||
|
||||
MooEditSession *
|
||||
moo_edit_session_copy (MooEditSession *session)
|
||||
{
|
||||
MooEditSession *copy;
|
||||
GSList *l;
|
||||
|
||||
g_return_val_if_fail (session != NULL, NULL);
|
||||
|
||||
copy = _moo_edit_session_new ();
|
||||
|
||||
for (l = session->windows; l != NULL; l = l->next)
|
||||
copy->windows = g_slist_prepend (copy->windows,
|
||||
session_window_copy (l->data));
|
||||
copy->windows = g_slist_reverse (copy->windows);
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
moo_edit_session_free (MooEditSession *session)
|
||||
{
|
||||
if (session)
|
||||
{
|
||||
g_slist_foreach (session->windows, (GFunc) session_window_free, NULL);
|
||||
g_slist_free (session->windows);
|
||||
g_free (session);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static SWindow *
|
||||
session_window_new (void)
|
||||
{
|
||||
return g_new0 (SWindow, 1);
|
||||
}
|
||||
|
||||
|
||||
static SWindow *
|
||||
session_window_copy (SWindow *win)
|
||||
{
|
||||
SWindow *copy;
|
||||
GSList *l;
|
||||
|
||||
g_return_val_if_fail (win != NULL, NULL);
|
||||
|
||||
copy = session_window_new ();
|
||||
|
||||
for (l = win->docs; l != NULL; l = l->next)
|
||||
{
|
||||
SDoc *doc_copy = session_doc_copy (l->data);
|
||||
copy->docs = g_slist_prepend (copy->docs, doc_copy);
|
||||
if (l->data == win->active)
|
||||
copy->active = doc_copy;
|
||||
}
|
||||
|
||||
copy->docs = g_slist_reverse (copy->docs);
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
session_window_free (SWindow *win)
|
||||
{
|
||||
if (win)
|
||||
{
|
||||
g_slist_foreach (win->docs, (GFunc) session_doc_free, NULL);
|
||||
g_slist_free (win->docs);
|
||||
g_free (win);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static SDoc *
|
||||
session_doc_new (const char *filename,
|
||||
const char *encoding)
|
||||
{
|
||||
SDoc *doc;
|
||||
|
||||
g_return_val_if_fail (filename != NULL, NULL);
|
||||
|
||||
doc = g_new0 (SDoc, 1);
|
||||
doc->filename = g_strdup (filename);
|
||||
doc->encoding = g_strdup (encoding);
|
||||
|
||||
return doc;
|
||||
}
|
||||
|
||||
|
||||
static SDoc *
|
||||
session_doc_copy (SDoc *doc)
|
||||
{
|
||||
g_return_val_if_fail (doc != NULL, NULL);
|
||||
return session_doc_new (doc->filename, doc->encoding);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
session_doc_free (SDoc *doc)
|
||||
{
|
||||
if (doc)
|
||||
{
|
||||
g_free (doc->filename);
|
||||
g_free (doc->encoding);
|
||||
g_free (doc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MooEditSession *moo_edit_session_parse_markup (const char *markup);
|
||||
char *moo_edit_session_get_markup (MooEditSession *session);
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* mooeditsession.h
|
||||
*
|
||||
* Copyright (C) 2004-2006 by Yevgen Muntyan <muntyan@math.tamu.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* See COPYING file that comes with this distribution.
|
||||
*/
|
||||
|
||||
#ifndef __MOO_EDIT_SESSION_H__
|
||||
#define __MOO_EDIT_SESSION_H__
|
||||
|
||||
#include <mooedit/mooeditwindow.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
#define MOO_TYPE_EDIT_SESSION (moo_edit_session_get_type ())
|
||||
|
||||
typedef struct _MooEditSession MooEditSession;
|
||||
|
||||
|
||||
GType moo_edit_session_get_type (void) G_GNUC_CONST;
|
||||
|
||||
MooEditSession *moo_edit_session_copy (MooEditSession *session);
|
||||
void moo_edit_session_free (MooEditSession *session);
|
||||
|
||||
MooEditSession *moo_edit_session_parse_markup (const char *markup);
|
||||
char *moo_edit_session_get_markup (MooEditSession *session);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MOO_EDIT_SESSION_H__ */
|
Loading…
Reference in New Issue