Separated context menu xml and main UI xml; made moo_editor_apply_prefs() public

master
Yevgen Muntyan 2006-12-20 18:19:48 -06:00
parent c370937807
commit 177042a342
11 changed files with 84 additions and 33 deletions

View File

@ -159,25 +159,6 @@
</widget> <!-- Toolbar -->
<widget name="Popup">
<separator/>
<placeholder name="PopupStart"/>
<separator/>
<item action="Undo"/>
<item action="Redo"/>
<separator/>
<item action="Cut"/>
<item action="Copy"/>
<item action="Paste"/>
<separator/>
<item action="SelectAll"/>
<separator/>
<item action="BookmarksMenu"/>
<separator/>
<placeholder name="PopupEnd"/>
<separator/>
</widget> <!-- Popup -->
</object> <!-- Editor -->
</ui>

View File

@ -51,6 +51,7 @@ mooedit_noinst_headers = \
moocommand.h \
moocommanddisplay.h \
mooedit-private.h \
mooedit-ui.h \
mooeditaction-factory.h \
mooeditaction.h \
mooeditdialogs.h \
@ -153,6 +154,7 @@ BUILT_SOURCES = \
mooedittools-glade.h \
mooedit-enums.c \
mooedit-enums.h \
mooedit-ui.h \
mooprintpreview-glade.h
mooedit_enums_headers = \
@ -230,7 +232,12 @@ mooprintpreview-glade.h: $(srcdir)/glade/mooprintpreview.glade $(XML2H)
$(SHELL) $(XML2H) MOO_PRINT_PREVIEW_GLADE_XML $(srcdir)/glade/mooprintpreview.glade \
> mooprintpreview-glade.h
mooedit-ui.h: mooedit-ui.xml $(XML2H)
$(SHELL) $(XML2H) MOO_EDIT_UI_XML $(srcdir)/mooedit-ui.xml > mooedit-ui.h.tmp && \
mv mooedit-ui.h.tmp mooedit-ui.h
EXTRA_DIST = \
mooedit-ui.xml \
glade/statusbar.glade \
glade/quicksearch.glade \
glade/mootextgotoline.glade \

View File

@ -0,0 +1,22 @@
<ui>
<object name="Editor">
<widget name="Popup">
<separator/>
<placeholder name="PopupStart"/>
<separator/>
<item action="Undo"/>
<item action="Redo"/>
<separator/>
<item action="Cut"/>
<item action="Copy"/>
<item action="Paste"/>
<separator/>
<item action="SelectAll"/>
<separator/>
<item action="BookmarksMenu"/>
<separator/>
<placeholder name="PopupEnd"/>
<separator/>
</widget> <!-- Popup -->
</object> <!-- Editor -->
</ui>

View File

@ -1584,7 +1584,7 @@ _moo_edit_do_popup (MooEdit *edit,
MooUIXML *xml;
MooEditWindow *window;
xml = moo_editor_get_ui_xml (edit->priv->editor);
xml = moo_editor_get_doc_ui_xml (edit->priv->editor);
g_return_if_fail (xml != NULL);
if (!edit->priv->menu)

View File

@ -49,7 +49,6 @@ gboolean _moo_editor_save_as (MooEditor *editor,
void _moo_editor_post_message (MooEditor *editor,
GQuark domain,
const char *message);
void _moo_editor_apply_prefs (MooEditor *editor);
G_END_DECLS

View File

@ -20,6 +20,7 @@
#include "mooedit/mooedit-private.h"
#include "mooedit/moolangmgr.h"
#include "mooedit/mooeditfiltersettings.h"
#include "mooedit/mooedit-ui.h"
#include "mooutils/moomenuaction.h"
#include "mooutils/moocompat.h"
#include "mooutils/moomarshals.h"
@ -103,6 +104,7 @@ struct _MooEditorPrivate {
WindowInfo *windowless;
GSList *windows; /* WindowInfo* */
char *app_name;
MooUIXML *doc_ui_xml;
MooUIXML *ui_xml;
MooFilterMgr *filter_mgr;
MooHistoryList *history;
@ -275,9 +277,13 @@ moo_editor_init (MooEditor *editor)
{
editor->priv = G_TYPE_INSTANCE_GET_PRIVATE (editor, MOO_TYPE_EDITOR, MooEditorPrivate);
editor->priv->doc_ui_xml = moo_ui_xml_new ();
moo_ui_xml_add_ui_from_string (editor->priv->doc_ui_xml,
MOO_EDIT_UI_XML, -1);
editor->priv->lang_mgr = moo_lang_mgr_new ();
g_signal_connect_swapped (editor->priv->lang_mgr, "loaded",
G_CALLBACK (_moo_editor_apply_prefs),
G_CALLBACK (moo_editor_apply_prefs),
editor);
editor->priv->filter_mgr = moo_filter_mgr_new ();
@ -299,7 +305,7 @@ moo_editor_init (MooEditor *editor)
MOO_LANG_NONE);
_moo_edit_filter_settings_load ();
_moo_editor_apply_prefs (editor);
moo_editor_apply_prefs (editor);
}
@ -429,6 +435,7 @@ moo_editor_finalize (GObject *object)
if (editor->priv->history)
g_object_unref (editor->priv->history);
g_object_unref (editor->priv->lang_mgr);
g_object_unref (editor->priv->doc_ui_xml);
if (editor->priv->file_watch)
{
@ -679,7 +686,7 @@ moo_editor_set_app_name (MooEditor *editor,
}
MooFilterMgr*
MooFilterMgr *
moo_editor_get_filter_mgr (MooEditor *editor)
{
g_return_val_if_fail (MOO_IS_EDITOR (editor), NULL);
@ -687,7 +694,7 @@ moo_editor_get_filter_mgr (MooEditor *editor)
}
MooHistoryList*
MooHistoryList *
moo_editor_get_history (MooEditor *editor)
{
g_return_val_if_fail (MOO_IS_EDITOR (editor), NULL);
@ -695,7 +702,7 @@ moo_editor_get_history (MooEditor *editor)
}
MooUIXML*
MooUIXML *
moo_editor_get_ui_xml (MooEditor *editor)
{
g_return_val_if_fail (MOO_IS_EDITOR (editor), NULL);
@ -703,6 +710,14 @@ moo_editor_get_ui_xml (MooEditor *editor)
}
MooUIXML *
moo_editor_get_doc_ui_xml (MooEditor *editor)
{
g_return_val_if_fail (MOO_IS_EDITOR (editor), NULL);
return editor->priv->doc_ui_xml;
}
void
moo_editor_set_ui_xml (MooEditor *editor,
MooUIXML *xml)
@ -2069,7 +2084,7 @@ set_default_lang (MooEditor *editor,
void
_moo_editor_apply_prefs (MooEditor *editor)
moo_editor_apply_prefs (MooEditor *editor)
{
GSList *docs;
gboolean autosave, backups;

View File

@ -124,6 +124,7 @@ MooFilterMgr *moo_editor_get_filter_mgr (MooEditor *editor);
MooUIXML *moo_editor_get_ui_xml (MooEditor *editor);
void moo_editor_set_ui_xml (MooEditor *editor,
MooUIXML *xml);
MooUIXML *moo_editor_get_doc_ui_xml (MooEditor *editor);
MooEditor *moo_edit_window_get_editor (MooEditWindow *window);
MooEditor *moo_edit_get_editor (MooEdit *doc);
@ -141,6 +142,8 @@ gboolean moo_editor_save_copy (MooEditor *editor,
const char *encoding,
GError **error);
void moo_editor_apply_prefs (MooEditor *editor);
G_END_DECLS

View File

@ -275,7 +275,7 @@ prefs_page_apply (MooPrefsDialogPage *page)
prefs_page_apply_lang_prefs (page);
apply_filter_settings (page);
_moo_editor_apply_prefs (editor);
moo_editor_apply_prefs (editor);
}

View File

@ -134,7 +134,16 @@ tools_store_add (MooUserToolType type,
info = g_new0 (ToolInfo, 1);
info->id = g_strdup (id);
switch (type)
{
case MOO_USER_TOOL_MENU:
info->xml = moo_editor_get_ui_xml (moo_editor_instance ());
break;
case MOO_USER_TOOL_CONTEXT:
info->xml = moo_editor_get_doc_ui_xml (moo_editor_instance ());
break;
}
if (info->xml)
{
@ -352,7 +361,6 @@ load_tool (MooUserToolInfo *info)
if (info->type == MOO_USER_TOOL_CONTEXT)
{
if (info->position == MOO_USER_TOOL_POS_START)
ui_path = "Editor/Popup/PopupStart";
else

View File

@ -30,6 +30,11 @@ class Plugin(moo.edit.Plugin):
def do_init(self):
editor = moo.edit.editor_instance()
xml = editor.get_ui_xml()
if xml is None:
# standalone python module, not in medit
return False
self.ui_merge_id = xml.new_merge_id()
if have_pyconsole:

View File

@ -248,6 +248,12 @@
)
)
(define-method get_doc_ui_xml
(of-object "MooEditor")
(c-name "moo_editor_get_doc_ui_xml")
(return-type "MooUIXML*")
)
(define-method get_editor
(of-object "MooEditWindow")
(c-name "moo_edit_window_get_editor")
@ -295,3 +301,8 @@
(c-name "moo_edit_prefs_page_new")
(return-type "GtkWidget*")
)
(define-method apply_prefs
(of-object "MooEditor")
(c-name "moo_editor_apply_prefs")
)