svn merge -r 696:705 svn+ssh://svn.berlios.de/svnroot/repos/ggap/moo/branches/style-scheme
This commit is contained in:
parent
012ec552a4
commit
a412b92d08
36
moo.kdevelop
36
moo.kdevelop
@ -24,7 +24,7 @@
|
||||
</ignoreparts>
|
||||
<projectdirectory>.</projectdirectory>
|
||||
<absoluteprojectpath>false</absoluteprojectpath>
|
||||
<description/>
|
||||
<description></description>
|
||||
<secondaryLanguages>
|
||||
<language>C</language>
|
||||
</secondaryLanguages>
|
||||
@ -46,7 +46,7 @@
|
||||
</run>
|
||||
<configurations>
|
||||
<debug>
|
||||
<configargs>--enable-debug=full --enable-all-gcc-warnings=fatal --disable-moo-module </configargs>
|
||||
<configargs>--enable-debug=full --enable-all-gcc-warnings=fatal --disable-moo-module --without-python --without-mooterm</configargs>
|
||||
<builddir>build/debug</builddir>
|
||||
<ccompiler>kdevgccoptions</ccompiler>
|
||||
<cxxcompiler>kdevgppoptions</cxxcompiler>
|
||||
@ -54,13 +54,13 @@
|
||||
<cflags>-O0 -g3 -pg</cflags>
|
||||
<cxxflags>-O0 -g3 -pg</cxxflags>
|
||||
<envvars/>
|
||||
<topsourcedir/>
|
||||
<cppflags/>
|
||||
<ldflags/>
|
||||
<ccompilerbinary/>
|
||||
<cxxcompilerbinary/>
|
||||
<f77compilerbinary/>
|
||||
<f77flags/>
|
||||
<topsourcedir></topsourcedir>
|
||||
<cppflags></cppflags>
|
||||
<ldflags></ldflags>
|
||||
<ccompilerbinary></ccompilerbinary>
|
||||
<cxxcompilerbinary></cxxcompilerbinary>
|
||||
<f77compilerbinary></f77compilerbinary>
|
||||
<f77flags></f77flags>
|
||||
</debug>
|
||||
<gtk-cvs>
|
||||
<configargs>--enable-debug=full --enable-all-gcc-warnings=fatal --enable-developer-mode --disable-moo-module --without-python --without-mooterm --without-mooapp</configargs>
|
||||
@ -200,10 +200,10 @@
|
||||
<general>
|
||||
<dbgshell>libtool</dbgshell>
|
||||
<programargs>--g-fatal-warnings</programargs>
|
||||
<gdbpath/>
|
||||
<configGdbScript/>
|
||||
<runShellScript/>
|
||||
<runGdbScript/>
|
||||
<gdbpath></gdbpath>
|
||||
<configGdbScript></configGdbScript>
|
||||
<runShellScript></runShellScript>
|
||||
<runGdbScript></runGdbScript>
|
||||
<breakonloadinglibs>true</breakonloadinglibs>
|
||||
<separatetty>false</separatetty>
|
||||
<floatingtoolbar>true</floatingtoolbar>
|
||||
@ -268,16 +268,16 @@
|
||||
</kdevdoctreeview>
|
||||
<kdevfilecreate>
|
||||
<filetypes>
|
||||
<type icon="source" ext="g" create="template" name="GAP source" >
|
||||
<type icon="source" ext="g" name="GAP source" create="template" >
|
||||
<descr>A new empty GAP source file</descr>
|
||||
</type>
|
||||
<type icon="source_cpp" ext="cpp" create="template" name="C++ Source" >
|
||||
<type icon="source_cpp" ext="cpp" name="C++ Source" create="template" >
|
||||
<descr>A new empty C++ file.</descr>
|
||||
</type>
|
||||
<type icon="source_h" ext="h" create="template" name="C/C++ Header" >
|
||||
<type icon="source_h" ext="h" name="C/C++ Header" create="template" >
|
||||
<descr>A new empty header file for C/C++.</descr>
|
||||
</type>
|
||||
<type icon="source_c" ext="c" create="template" name="C Source" >
|
||||
<type icon="source_c" ext="c" name="C Source" create="template" >
|
||||
<descr>A new empty C file.</descr>
|
||||
</type>
|
||||
</filetypes>
|
||||
@ -304,7 +304,7 @@
|
||||
</codecompletion>
|
||||
<references/>
|
||||
<creategettersetter>
|
||||
<prefixGet/>
|
||||
<prefixGet></prefixGet>
|
||||
<prefixSet>set</prefixSet>
|
||||
<prefixVariable>m_,_</prefixVariable>
|
||||
<parameterName>theValue</parameterName>
|
||||
|
@ -766,7 +766,7 @@ static gboolean moo_app_init_real (MooApp *app)
|
||||
{
|
||||
G_GNUC_UNUSED const char *app_dir;
|
||||
const char *rc_file;
|
||||
MooLangTable *lang_table;
|
||||
MooLangMgr *lang_mgr;
|
||||
MooUIXML *ui_xml;
|
||||
GError *error = NULL;
|
||||
|
||||
@ -831,13 +831,13 @@ static gboolean moo_app_init_real (MooApp *app)
|
||||
moo_editor_set_app_name (app->priv->editor,
|
||||
app->priv->info->short_name);
|
||||
|
||||
lang_table = moo_editor_get_lang_table (app->priv->editor);
|
||||
moo_lang_table_add_dir (lang_table, lang_dir);
|
||||
lang_mgr = moo_editor_get_lang_mgr (app->priv->editor);
|
||||
moo_lang_mgr_add_dir (lang_mgr, lang_dir);
|
||||
|
||||
if (user_lang_dir)
|
||||
moo_lang_table_add_dir (lang_table, user_lang_dir);
|
||||
moo_lang_mgr_add_dir (lang_mgr, user_lang_dir);
|
||||
|
||||
moo_lang_table_read_dirs (lang_table);
|
||||
moo_lang_mgr_read_dirs (lang_mgr);
|
||||
|
||||
g_signal_connect_swapped (app->priv->editor,
|
||||
"all-windows-closed",
|
||||
|
@ -54,8 +54,8 @@ GtkWidget *_moo_app_create_prefs_dialog (MooApp *app)
|
||||
#endif
|
||||
|
||||
#ifdef MOO_BUILD_EDIT
|
||||
moo_prefs_dialog_append_page (dialog, moo_edit_prefs_page_new (moo_app_get_editor (app)));
|
||||
// moo_prefs_dialog_append_page (dialog, moo_edit_colors_prefs_page_new (moo_app_get_editor (app)));
|
||||
// moo_prefs_dialog_append_page (dialog, moo_edit_prefs_page_new (moo_app_get_editor (app)));
|
||||
moo_prefs_dialog_append_page (dialog, moo_edit_colors_prefs_page_new (moo_app_get_editor (app)));
|
||||
_moo_plugin_attach_prefs (GTK_WIDGET (dialog));
|
||||
#endif
|
||||
|
||||
|
@ -24,77 +24,70 @@ mooeditinclude_HEADERS = \
|
||||
mooeditwindow.h \
|
||||
mooindenter.h \
|
||||
moolang.h \
|
||||
moolangmgr.h \
|
||||
moolineview.h \
|
||||
mooplugin.h \
|
||||
mooplugin-macro.h \
|
||||
mooplugin.h \
|
||||
mootextbuffer.h \
|
||||
mootextiter.h \
|
||||
mootextstyle.h \
|
||||
mootextstylescheme.h \
|
||||
mootextview.h
|
||||
|
||||
noinst_HEADERS = \
|
||||
gtksourceiter.h \
|
||||
mooedit-private.h \
|
||||
mooeditcolorsprefs-glade.h \
|
||||
mooeditdialogs.h \
|
||||
mooeditfileops.h \
|
||||
mooeditfind-glade.h \
|
||||
mooeditgotoline-glade.h \
|
||||
mooeditprefs-glade.h \
|
||||
moohighlighter.h \
|
||||
moolang-aux.h \
|
||||
moolang-parser.h \
|
||||
moolang-rules.h \
|
||||
moolang-strings.h \
|
||||
moolinebuffer.h \
|
||||
moopluginprefs-glade.h \
|
||||
mootextbtree.h \
|
||||
mootextview-private.h
|
||||
|
||||
|
||||
if !MOO_OS_MINGW
|
||||
unix_sources = \
|
||||
moocmdview.c \
|
||||
moocmdview.h
|
||||
unix_sources = moocmdview.c
|
||||
mooeditinclude_HEADERS += moocmdview.h
|
||||
endif
|
||||
|
||||
libmooedit_la_SOURCES = \
|
||||
$(unix_sources) \
|
||||
$(mooeditinclude_HEADERS) \
|
||||
$(noinst_HEADERS) \
|
||||
gtksourceiter.c \
|
||||
gtksourceiter.h \
|
||||
mooedit.c \
|
||||
mooedit-private.h \
|
||||
mooeditdialogs.c \
|
||||
mooeditdialogs.h \
|
||||
mooeditfileops.c \
|
||||
mooeditfileops.h \
|
||||
mooeditfind.c \
|
||||
mooeditinput.c \
|
||||
mooeditor.c \
|
||||
mooeditprefs.c \
|
||||
mooeditprefs.h \
|
||||
mooeditprefspage.c \
|
||||
mooeditsearch.c \
|
||||
mooeditsearch.h \
|
||||
mooeditwindow.c \
|
||||
mooeditwindow.h \
|
||||
moohighlighter.c \
|
||||
moohighlighter.h \
|
||||
mooindenter.c \
|
||||
mooindenter.h \
|
||||
moolang.c \
|
||||
moolang.h \
|
||||
moolangmgr.c \
|
||||
moolang-parser.c \
|
||||
moolang-parser.h \
|
||||
moolang-rules.c \
|
||||
moolang-rules.h \
|
||||
moolang-aux.h \
|
||||
moolang-strings.h \
|
||||
moolinebuffer.c \
|
||||
moolinebuffer.h \
|
||||
moolineview.c \
|
||||
moolineview.h \
|
||||
mooplugin.c \
|
||||
mooplugin.h \
|
||||
mooplugin-macro.h \
|
||||
mootextbtree.c \
|
||||
mootextbtree.h \
|
||||
mootextbuffer.c \
|
||||
mootextbuffer.h \
|
||||
mootextiter.h \
|
||||
mootextstyle.c \
|
||||
mootextstyle.h \
|
||||
mootextview.c \
|
||||
mootextview.h \
|
||||
mootextview-private.h \
|
||||
mooeditgotoline-glade.h \
|
||||
mooeditfind-glade.h \
|
||||
moopluginprefs-glade.h \
|
||||
mooeditprefs-glade.h \
|
||||
mooeditcolorsprefs-glade.h
|
||||
mootextstylescheme.c \
|
||||
mootextview.c
|
||||
|
||||
libmooedit_la_LIBADD = \
|
||||
plugins/libplugins.la
|
||||
|
@ -24,92 +24,136 @@
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkNotebook" id="notebook">
|
||||
<widget class="GtkHBox" id="hbox2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="show_tabs">True</property>
|
||||
<property name="show_border">True</property>
|
||||
<property name="tab_pos">GTK_POS_TOP</property>
|
||||
<property name="scrollable">False</property>
|
||||
<property name="enable_popup">False</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox2">
|
||||
<widget class="GtkNotebook" id="notebook">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="show_tabs">True</property>
|
||||
<property name="show_border">True</property>
|
||||
<property name="tab_pos">GTK_POS_TOP</property>
|
||||
<property name="scrollable">False</property>
|
||||
<property name="enable_popup">False</property>
|
||||
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="tab_expand">False</property>
|
||||
<property name="tab_fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Colors</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="type">tab</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkFrame" id="frame1">
|
||||
<property name="visible">True</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<property name="label_yalign">0.5</property>
|
||||
<property name="shadow_type">GTK_SHADOW_NONE</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkAlignment" id="alignment1">
|
||||
<widget class="GtkAlignment" id="alignment3">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xscale">1</property>
|
||||
<property name="yscale">1</property>
|
||||
<property name="top_padding">0</property>
|
||||
<property name="bottom_padding">0</property>
|
||||
<property name="top_padding">6</property>
|
||||
<property name="bottom_padding">6</property>
|
||||
<property name="left_padding">12</property>
|
||||
<property name="right_padding">0</property>
|
||||
<property name="right_padding">12</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkFontSelection" id="fontselection1">
|
||||
<widget class="GtkTable" id="table1">
|
||||
<property name="visible">True</property>
|
||||
<property name="preview_text" translatable="yes">abcdefghijk ABCDEFGHIJK</property>
|
||||
<property name="n_rows">3</property>
|
||||
<property name="n_columns">2</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="row_spacing">0</property>
|
||||
<property name="column_spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label6">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Font:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="right_attach">1</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="bottom_attach">1</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label7">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Color scheme:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="right_attach">1</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkComboBox" id="scheme_combo">
|
||||
<property name="visible">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="y_options">fill</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkFontButton" id="font_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="show_style">True</property>
|
||||
<property name="show_size">True</property>
|
||||
<property name="use_font">False</property>
|
||||
<property name="use_size">False</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="bottom_attach">1</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="tab_expand">False</property>
|
||||
<property name="tab_fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label5">
|
||||
<widget class="GtkLabel" id="label8">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes"><b>frame1</b></property>
|
||||
<property name="label" translatable="yes">Font and Scheme</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
@ -119,133 +163,476 @@
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="type">label_item</property>
|
||||
<property name="type">tab</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="tab_expand">False</property>
|
||||
<property name="tab_fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label2">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Font</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="type">tab</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox3">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkScrolledWindow" id="scrolledwindow1">
|
||||
<widget class="GtkVBox" id="vbox2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="shadow_type">GTK_SHADOW_IN</property>
|
||||
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkTreeView" id="default_treeview">
|
||||
<widget class="GtkTable" id="table2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="headers_visible">True</property>
|
||||
<property name="rules_hint">False</property>
|
||||
<property name="reorderable">False</property>
|
||||
<property name="enable_search">False</property>
|
||||
<property name="n_rows">6</property>
|
||||
<property name="n_columns">2</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="row_spacing">0</property>
|
||||
<property name="column_spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label9">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Text color:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="right_attach">1</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="bottom_attach">1</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkColorButton" id="foreground">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="use_alpha">False</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="bottom_attach">1</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label10">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Text background:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="right_attach">1</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkColorButton" id="background">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="use_alpha">False</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label11">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Selected text:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="right_attach">1</property>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkColorButton" id="selected_foreground">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="use_alpha">False</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label12">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Selection:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="right_attach">1</property>
|
||||
<property name="top_attach">3</property>
|
||||
<property name="bottom_attach">4</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkColorButton" id="selected_background">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="use_alpha">False</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">3</property>
|
||||
<property name="bottom_attach">4</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label13">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Current line:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="right_attach">1</property>
|
||||
<property name="top_attach">4</property>
|
||||
<property name="bottom_attach">5</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkColorButton" id="current_line">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="use_alpha">False</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">4</property>
|
||||
<property name="bottom_attach">5</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="tab_expand">False</property>
|
||||
<property name="tab_fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Colors</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="type">tab</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox4">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkScrolledWindow" id="scrolledwindow1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="shadow_type">GTK_SHADOW_IN</property>
|
||||
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkTreeView" id="default_treeview">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="headers_visible">True</property>
|
||||
<property name="rules_hint">False</property>
|
||||
<property name="reorderable">False</property>
|
||||
<property name="enable_search">False</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="tab_expand">False</property>
|
||||
<property name="tab_fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label3">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Default styles</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="type">tab</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox8">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox3">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkScrolledWindow" id="scrolledwindow4">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="shadow_type">GTK_SHADOW_IN</property>
|
||||
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkTreeView" id="lang_treeview">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="headers_visible">True</property>
|
||||
<property name="rules_hint">False</property>
|
||||
<property name="reorderable">False</property>
|
||||
<property name="enable_search">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="tab_expand">False</property>
|
||||
<property name="tab_fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label4">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Highlighting styles</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="type">tab</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="tab_expand">False</property>
|
||||
<property name="tab_fill">True</property>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox9">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label3">
|
||||
<widget class="GtkAlignment" id="alignment6">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Default text styles</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="xscale">0.15000000596</property>
|
||||
<property name="yscale">1</property>
|
||||
<property name="top_padding">0</property>
|
||||
<property name="bottom_padding">0</property>
|
||||
<property name="left_padding">0</property>
|
||||
<property name="right_padding">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkComboBox" id="syntax_combo">
|
||||
<property name="visible">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="type">tab</property>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox4">
|
||||
<widget class="GtkScrolledWindow" id="scrolledwindow5">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
|
||||
<property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
|
||||
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
||||
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<placeholder/>
|
||||
<widget class="GtkTextView" id="sample_view">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
<property name="overwrite">False</property>
|
||||
<property name="accepts_tab">True</property>
|
||||
<property name="justification">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap_mode">GTK_WRAP_WORD</property>
|
||||
<property name="cursor_visible">True</property>
|
||||
<property name="pixels_above_lines">0</property>
|
||||
<property name="pixels_below_lines">0</property>
|
||||
<property name="pixels_inside_wrap">0</property>
|
||||
<property name="left_margin">0</property>
|
||||
<property name="right_margin">0</property>
|
||||
<property name="indent">0</property>
|
||||
<property name="text" translatable="yes">Choose language in the menu above.</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="tab_expand">False</property>
|
||||
<property name="tab_fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label4">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Highlighting text styles</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="type">tab</property>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -520,7 +520,7 @@ moo_edit_set_lang (MooEdit *edit,
|
||||
MooLang *lang)
|
||||
{
|
||||
g_return_if_fail (MOO_IS_EDIT (edit));
|
||||
moo_text_buffer_set_lang (get_moo_buffer (edit), lang);
|
||||
moo_text_view_set_lang (MOO_TEXT_VIEW (edit), lang);
|
||||
}
|
||||
|
||||
|
||||
@ -698,8 +698,8 @@ _moo_edit_choose_lang (MooEdit *edit)
|
||||
|
||||
if (edit->priv->filename)
|
||||
{
|
||||
MooLangTable *table = moo_editor_get_lang_table (edit->priv->editor);
|
||||
lang = moo_lang_table_get_lang_for_file (table, edit->priv->filename);
|
||||
MooLangMgr *mgr = moo_editor_get_lang_mgr (edit->priv->editor);
|
||||
lang = moo_lang_mgr_get_lang_for_file (mgr, edit->priv->filename);
|
||||
}
|
||||
|
||||
moo_edit_set_lang (edit, lang);
|
||||
|
@ -94,7 +94,7 @@ struct _MooEditorPrivate {
|
||||
MooUIXML *ui_xml;
|
||||
MooFilterMgr *filter_mgr;
|
||||
MooHistoryList *history;
|
||||
MooLangTable *lang_table;
|
||||
MooLangMgr *lang_mgr;
|
||||
MooFileWatch *file_watch;
|
||||
gboolean open_single;
|
||||
gboolean allow_empty_window;
|
||||
@ -185,7 +185,7 @@ static void moo_editor_init (MooEditor *editor)
|
||||
{
|
||||
editor->priv = g_new0 (MooEditorPrivate, 1);
|
||||
|
||||
editor->priv->lang_table = moo_lang_table_new ();
|
||||
editor->priv->lang_mgr = moo_lang_mgr_new ();
|
||||
editor->priv->filter_mgr = moo_filter_mgr_new ();
|
||||
|
||||
editor->priv->history = moo_history_list_new ("Editor");
|
||||
@ -274,7 +274,7 @@ static void moo_editor_finalize (GObject *object)
|
||||
g_object_unref (editor->priv->filter_mgr);
|
||||
if (editor->priv->history)
|
||||
g_object_unref (editor->priv->history);
|
||||
g_object_unref (editor->priv->lang_table);
|
||||
g_object_unref (editor->priv->lang_mgr);
|
||||
|
||||
if (editor->priv->file_watch)
|
||||
{
|
||||
@ -1360,9 +1360,9 @@ moo_editor_get_doc (MooEditor *editor,
|
||||
}
|
||||
|
||||
|
||||
MooLangTable*
|
||||
moo_editor_get_lang_table (MooEditor *editor)
|
||||
MooLangMgr*
|
||||
moo_editor_get_lang_mgr (MooEditor *editor)
|
||||
{
|
||||
g_return_val_if_fail (MOO_IS_EDITOR (editor), NULL);
|
||||
return editor->priv->lang_table;
|
||||
return editor->priv->lang_mgr;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
#define __MOO_EDITOR_H__
|
||||
|
||||
#include <mooedit/mooeditwindow.h>
|
||||
#include <mooedit/moolangmgr.h>
|
||||
#include <mooutils/moouixml.h>
|
||||
#include <mooutils/moohistorylist.h>
|
||||
#include <mooutils/moofiltermgr.h>
|
||||
@ -97,7 +98,7 @@ void moo_editor_set_ui_xml (MooEditor *editor,
|
||||
|
||||
MooEditor *moo_edit_window_get_editor (MooEditWindow *window);
|
||||
|
||||
MooLangTable *moo_editor_get_lang_table (MooEditor *editor);
|
||||
MooLangMgr *moo_editor_get_lang_mgr (MooEditor *editor);
|
||||
|
||||
|
||||
#ifdef MOOEDIT_COMPILATION
|
||||
|
@ -15,46 +15,819 @@
|
||||
#define MOOEDIT_COMPILATION
|
||||
#include "mooedit/mooedit-private.h"
|
||||
#include "mooedit/mooeditprefs.h"
|
||||
#include "mooedit/mooeditprefs-glade.h"
|
||||
// #include "mooedit/mooeditprefs-glade.h"
|
||||
#include "mooedit/mooeditcolorsprefs-glade.h"
|
||||
#include "mooutils/mooprefsdialog.h"
|
||||
#include "mooutils/moocompat.h"
|
||||
#include "mooutils/moostock.h"
|
||||
#include "mooutils/mooglade.h"
|
||||
#include "mooutils/moocellrenderercolor.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
GtkWidget*
|
||||
moo_edit_prefs_page_new (MooEditor *editor)
|
||||
{
|
||||
GtkWidget *page;
|
||||
static void color_page_init (MooPrefsDialogPage *page);
|
||||
static void color_page_apply (MooPrefsDialogPage *page);
|
||||
|
||||
g_return_val_if_fail (MOO_IS_EDITOR (editor), NULL);
|
||||
static void scheme_combo_init (GtkWidget *combo,
|
||||
MooEditor *editor);
|
||||
static void scheme_combo_data_func (GtkCellLayout *layout,
|
||||
GtkCellRenderer *cell,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter);
|
||||
static void scheme_combo_set_scheme (GtkComboBox *combo,
|
||||
MooTextStyleScheme *scheme);
|
||||
static void scheme_combo_changed (GtkComboBox *combo,
|
||||
MooPrefsDialogPage *page);
|
||||
|
||||
_moo_edit_set_default_settings ();
|
||||
static void syntax_combo_init (GtkWidget *combo,
|
||||
MooEditor *editor);
|
||||
static void syntax_combo_data_func (GtkCellLayout *layout,
|
||||
GtkCellRenderer *cell,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter);
|
||||
static void syntax_combo_set_lang (GtkComboBox *combo,
|
||||
MooLang *lang);
|
||||
static void syntax_combo_changed (GtkComboBox *combo,
|
||||
MooPrefsDialogPage *page);
|
||||
|
||||
page = moo_prefs_dialog_page_new_from_xml ("Editor",
|
||||
GTK_STOCK_EDIT,
|
||||
MOO_EDIT_PREFS_GLADE_UI,
|
||||
-1,
|
||||
"page",
|
||||
MOO_EDIT_PREFS_PREFIX);
|
||||
return page;
|
||||
}
|
||||
static MooLangMgr *page_get_mgr (MooPrefsDialogPage *page);
|
||||
static MooEditor *page_get_editor (MooPrefsDialogPage *page);
|
||||
static void page_set_scheme (MooPrefsDialogPage *page,
|
||||
MooTextStyleScheme *scheme);
|
||||
static void page_set_lang (MooPrefsDialogPage *page,
|
||||
MooLang *lang);
|
||||
static GtkWidget *page_get_preview (MooPrefsDialogPage *page);
|
||||
static void preview_set_lang (GtkWidget *preview,
|
||||
MooLang *lang);
|
||||
static MooTextStyleScheme *page_get_scheme (MooPrefsDialogPage *page);
|
||||
static MooLang *page_get_lang (MooPrefsDialogPage *page);
|
||||
|
||||
|
||||
static void default_treeview_init (GtkTreeView *treeview,
|
||||
MooPrefsDialogPage *page);
|
||||
static void default_treeview_set_scheme (GtkTreeView *treeview,
|
||||
MooTextStyleScheme *scheme);
|
||||
|
||||
static void lang_treeview_init (GtkTreeView *treeview,
|
||||
MooPrefsDialogPage *page);
|
||||
|
||||
static void treeview_apply_scheme (GtkWidget *widget,
|
||||
MooTextStyleScheme *scheme);
|
||||
|
||||
|
||||
GtkWidget*
|
||||
moo_edit_colors_prefs_page_new (MooEditor *editor)
|
||||
{
|
||||
GtkWidget *page;
|
||||
MooPrefsDialogPage *page;
|
||||
GtkWidget *scheme_combo, *syntax_combo;
|
||||
GtkTreeView *default_treeview;//, *lang_treeview;
|
||||
MooGladeXML *xml;
|
||||
|
||||
g_return_val_if_fail (MOO_IS_EDITOR (editor), NULL);
|
||||
|
||||
page = moo_prefs_dialog_page_new_from_xml ("Editor Colors",
|
||||
GTK_STOCK_EDIT,
|
||||
MOO_EDIT_COLORS_PREFS_GLADE_UI,
|
||||
-1,
|
||||
"page",
|
||||
MOO_EDIT_PREFS_PREFIX);
|
||||
return page;
|
||||
xml = moo_glade_xml_new_empty ();
|
||||
moo_glade_xml_map_id (xml, "page", MOO_TYPE_PREFS_DIALOG_PAGE);
|
||||
moo_glade_xml_map_id (xml, "sample_view", MOO_TYPE_TEXT_VIEW);
|
||||
moo_glade_xml_parse_memory (xml, MOO_EDIT_COLORS_PREFS_GLADE_UI, -1, "page");
|
||||
|
||||
page = moo_glade_xml_get_widget (xml, "page");
|
||||
page->xml = xml;
|
||||
|
||||
g_object_set (page,
|
||||
"label", "Font and Colors",
|
||||
"icon-stock-id", GTK_STOCK_EDIT,
|
||||
NULL);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (page), "moo-editor",
|
||||
g_object_ref (editor), g_object_unref);
|
||||
g_object_set_data_full (G_OBJECT (page), "moo-lang-mgr",
|
||||
g_object_ref (moo_editor_get_lang_mgr (editor)),
|
||||
g_object_unref);
|
||||
|
||||
g_signal_connect (page, "init", G_CALLBACK (color_page_init), NULL);
|
||||
// g_signal_connect (page, "apply", G_CALLBACK (color_page_apply), NULL);
|
||||
|
||||
scheme_combo = moo_glade_xml_get_widget (xml, "scheme_combo");
|
||||
scheme_combo_init (scheme_combo, editor);
|
||||
g_signal_connect (scheme_combo, "changed",
|
||||
G_CALLBACK (scheme_combo_changed), page);
|
||||
|
||||
syntax_combo = moo_glade_xml_get_widget (xml, "syntax_combo");
|
||||
syntax_combo_init (syntax_combo, editor);
|
||||
g_signal_connect (syntax_combo, "changed",
|
||||
G_CALLBACK (syntax_combo_changed), page);
|
||||
|
||||
default_treeview = moo_glade_xml_get_widget (xml, "default_treeview");
|
||||
default_treeview_init (default_treeview, page);
|
||||
|
||||
// lang_treeview = moo_glade_xml_get_widget (xml, "lang_treeview");
|
||||
// lang_treeview_init (lang_treeview, page, editor);
|
||||
|
||||
return GTK_WIDGET (page);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
scheme_combo_init (GtkWidget *combo,
|
||||
MooEditor *editor)
|
||||
{
|
||||
GtkListStore *store;
|
||||
MooLangMgr *mgr;
|
||||
GSList *list, *l;
|
||||
GtkCellRenderer *cell;
|
||||
|
||||
mgr = moo_editor_get_lang_mgr (editor);
|
||||
list = moo_lang_mgr_list_schemes (mgr);
|
||||
g_return_if_fail (list != NULL);
|
||||
|
||||
store = gtk_list_store_new (1, MOO_TYPE_TEXT_STYLE_SCHEME);
|
||||
|
||||
for (l = list; l != NULL; l = l->next)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter, 0, l->data, -1);
|
||||
}
|
||||
|
||||
gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (store));
|
||||
|
||||
cell = gtk_cell_renderer_text_new ();
|
||||
gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo));
|
||||
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE);
|
||||
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo), cell,
|
||||
(GtkCellLayoutDataFunc) scheme_combo_data_func,
|
||||
NULL, NULL);
|
||||
|
||||
g_object_unref (store);
|
||||
g_slist_free (list);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
scheme_combo_data_func (G_GNUC_UNUSED GtkCellLayout *layout,
|
||||
GtkCellRenderer *cell,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter)
|
||||
{
|
||||
MooTextStyleScheme *scheme = NULL;
|
||||
gtk_tree_model_get (model, iter, 0, &scheme, -1);
|
||||
g_return_if_fail (scheme != NULL);
|
||||
g_object_set (cell, "text", scheme->name, NULL);
|
||||
g_object_unref (scheme);
|
||||
}
|
||||
|
||||
|
||||
static GtkWidget*
|
||||
page_get_preview (MooPrefsDialogPage *page)
|
||||
{
|
||||
return moo_glade_xml_get_widget (page->xml, "sample_view");
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
color_page_init (MooPrefsDialogPage *page)
|
||||
{
|
||||
MooEditor *editor;
|
||||
MooLangMgr *mgr;
|
||||
MooTextStyleScheme *scheme;
|
||||
GtkComboBox *scheme_combo, *syntax_combo;
|
||||
|
||||
editor = page_get_editor (page);
|
||||
mgr = moo_editor_get_lang_mgr (editor);
|
||||
scheme = moo_lang_mgr_get_active_scheme (mgr);
|
||||
g_return_if_fail (scheme != NULL);
|
||||
|
||||
scheme_combo = moo_glade_xml_get_widget (page->xml, "scheme_combo");
|
||||
scheme_combo_set_scheme (scheme_combo, scheme);
|
||||
|
||||
syntax_combo = moo_glade_xml_get_widget (page->xml, "syntax_combo");
|
||||
syntax_combo_set_lang (syntax_combo, NULL);
|
||||
}
|
||||
|
||||
|
||||
static MooEditor*
|
||||
page_get_editor (MooPrefsDialogPage *page)
|
||||
{
|
||||
return g_object_get_data (G_OBJECT (page), "moo-editor");
|
||||
}
|
||||
|
||||
|
||||
static MooLangMgr*
|
||||
page_get_mgr (MooPrefsDialogPage *page)
|
||||
{
|
||||
return g_object_get_data (G_OBJECT (page), "moo-lang-mgr");
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
scheme_combo_set_scheme (GtkComboBox *combo,
|
||||
MooTextStyleScheme *scheme)
|
||||
{
|
||||
GtkTreeModel *model = gtk_combo_box_get_model (combo);
|
||||
gboolean found = FALSE;
|
||||
GtkTreeIter iter;
|
||||
|
||||
gtk_tree_model_get_iter_first (model, &iter);
|
||||
do {
|
||||
MooTextStyleScheme *s;
|
||||
gtk_tree_model_get (model, &iter, 0, &s, -1);
|
||||
g_object_unref (s);
|
||||
if (scheme == s)
|
||||
{
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (gtk_tree_model_iter_next (model, &iter));
|
||||
|
||||
g_return_if_fail (found);
|
||||
|
||||
gtk_combo_box_set_active_iter (combo, &iter);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
scheme_combo_changed (GtkComboBox *combo,
|
||||
MooPrefsDialogPage *page)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
MooTextStyleScheme *scheme = NULL;
|
||||
|
||||
if (!gtk_combo_box_get_active_iter (combo, &iter))
|
||||
g_return_if_reached ();
|
||||
|
||||
model = gtk_combo_box_get_model (combo);
|
||||
gtk_tree_model_get (model, &iter, 0, &scheme, -1);
|
||||
g_return_if_fail (scheme != NULL);
|
||||
|
||||
page_set_scheme (page, scheme);
|
||||
g_object_unref (scheme);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
page_set_scheme (MooPrefsDialogPage *page,
|
||||
MooTextStyleScheme *scheme)
|
||||
{
|
||||
GtkColorButton *fg, *bg, *sel_fg, *sel_bg, *cur_line;
|
||||
GdkColor color;
|
||||
GdkScreen *screen;
|
||||
|
||||
g_return_if_fail (scheme != NULL);
|
||||
|
||||
g_object_set_data (G_OBJECT (page), "moo-text-style-scheme", scheme);
|
||||
|
||||
if (gtk_widget_has_screen (GTK_WIDGET (page)))
|
||||
screen = gtk_widget_get_screen (GTK_WIDGET (page));
|
||||
else
|
||||
screen = gdk_screen_get_default ();
|
||||
|
||||
fg = moo_glade_xml_get_widget (page->xml, "foreground");
|
||||
bg = moo_glade_xml_get_widget (page->xml, "background");
|
||||
sel_fg = moo_glade_xml_get_widget (page->xml, "selected_foreground");
|
||||
sel_bg = moo_glade_xml_get_widget (page->xml, "selected_background");
|
||||
cur_line = moo_glade_xml_get_widget (page->xml, "current_line");
|
||||
|
||||
_moo_text_style_scheme_get_color (scheme, MOO_TEXT_COLOR_FG, &color, screen);
|
||||
gtk_color_button_set_color (fg, &color);
|
||||
_moo_text_style_scheme_get_color (scheme, MOO_TEXT_COLOR_BG, &color, screen);
|
||||
gtk_color_button_set_color (bg, &color);
|
||||
_moo_text_style_scheme_get_color (scheme, MOO_TEXT_COLOR_SEL_FG, &color, screen);
|
||||
gtk_color_button_set_color (sel_fg, &color);
|
||||
_moo_text_style_scheme_get_color (scheme, MOO_TEXT_COLOR_SEL_BG, &color, screen);
|
||||
gtk_color_button_set_color (sel_bg, &color);
|
||||
_moo_text_style_scheme_get_color (scheme, MOO_TEXT_COLOR_CUR_LINE, &color, screen);
|
||||
gtk_color_button_set_color (cur_line, &color);
|
||||
|
||||
moo_text_view_apply_scheme (MOO_TEXT_VIEW (page_get_preview (page)), scheme);
|
||||
default_treeview_set_scheme (moo_glade_xml_get_widget (page->xml, "default_treeview"), scheme);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
cmp_langs (MooLang *lang1,
|
||||
MooLang *lang2)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (!lang1 || !lang2)
|
||||
return lang1 < lang2 ? -1 : (lang1 > lang2 ? 1 : 0);
|
||||
|
||||
result = strcmp (lang1->section, lang2->section);
|
||||
if (!result)
|
||||
result = strcmp (lang1->name, lang2->name);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
syntax_combo_init (GtkWidget *combo,
|
||||
MooEditor *editor)
|
||||
{
|
||||
GtkListStore *store;
|
||||
MooLangMgr *mgr;
|
||||
GSList *list, *l;
|
||||
GtkCellRenderer *cell;
|
||||
|
||||
mgr = moo_editor_get_lang_mgr (editor);
|
||||
|
||||
list = moo_lang_mgr_get_available_langs (mgr);
|
||||
list = g_slist_prepend (list, NULL);
|
||||
list = g_slist_sort (list, (GCompareFunc) cmp_langs);
|
||||
|
||||
store = gtk_list_store_new (1, MOO_TYPE_LANG);
|
||||
|
||||
for (l = list; l != NULL; l = l->next)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter, 0, l->data, -1);
|
||||
}
|
||||
|
||||
gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (store));
|
||||
|
||||
cell = gtk_cell_renderer_text_new ();
|
||||
gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo));
|
||||
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE);
|
||||
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo), cell,
|
||||
(GtkCellLayoutDataFunc) syntax_combo_data_func,
|
||||
NULL, NULL);
|
||||
|
||||
g_object_unref (store);
|
||||
g_slist_free (list);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
syntax_combo_data_func (G_GNUC_UNUSED GtkCellLayout *layout,
|
||||
GtkCellRenderer *cell,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter)
|
||||
{
|
||||
MooLang *lang = NULL;
|
||||
|
||||
gtk_tree_model_get (model, iter, 0, &lang, -1);
|
||||
|
||||
if (lang)
|
||||
{
|
||||
char *text = g_strdup_printf ("%s/%s", lang->section, lang->name);
|
||||
g_object_set (cell, "text", text, NULL);
|
||||
g_free (text);
|
||||
moo_lang_unref (lang);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_object_set (cell, "text", "None", NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
syntax_combo_changed (GtkComboBox *combo,
|
||||
MooPrefsDialogPage *page)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
MooLang *lang = NULL;
|
||||
|
||||
if (!gtk_combo_box_get_active_iter (combo, &iter))
|
||||
g_return_if_reached ();
|
||||
|
||||
model = gtk_combo_box_get_model (combo);
|
||||
gtk_tree_model_get (model, &iter, 0, &lang, -1);
|
||||
|
||||
page_set_lang (page, lang);
|
||||
|
||||
if (lang)
|
||||
moo_lang_unref (lang);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
syntax_combo_set_lang (GtkComboBox *combo,
|
||||
MooLang *lang)
|
||||
{
|
||||
GtkTreeModel *model = gtk_combo_box_get_model (combo);
|
||||
gboolean found = FALSE;
|
||||
GtkTreeIter iter;
|
||||
|
||||
gtk_tree_model_get_iter_first (model, &iter);
|
||||
|
||||
do {
|
||||
MooLang *l;
|
||||
|
||||
gtk_tree_model_get (model, &iter, 0, &l, -1);
|
||||
|
||||
if (l)
|
||||
moo_lang_unref (l);
|
||||
|
||||
if (lang == l)
|
||||
{
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (gtk_tree_model_iter_next (model, &iter));
|
||||
|
||||
g_return_if_fail (found);
|
||||
|
||||
gtk_combo_box_set_active_iter (combo, &iter);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
preview_set_lang (GtkWidget *preview,
|
||||
MooLang *lang)
|
||||
{
|
||||
if (lang && lang->sample)
|
||||
{
|
||||
GtkTextBuffer *buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (preview));
|
||||
gtk_text_buffer_set_text (buf, lang->sample, -1);
|
||||
}
|
||||
|
||||
moo_text_view_set_lang (MOO_TEXT_VIEW (preview), lang);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
page_set_lang (MooPrefsDialogPage *page,
|
||||
MooLang *lang)
|
||||
{
|
||||
g_object_set_data (G_OBJECT (page), "moo-lang", lang);
|
||||
preview_set_lang (page_get_preview (page), lang);
|
||||
}
|
||||
|
||||
|
||||
static MooTextStyleScheme*
|
||||
page_get_scheme (MooPrefsDialogPage *page)
|
||||
{
|
||||
return g_object_get_data (G_OBJECT (page), "moo-text-style-scheme");
|
||||
}
|
||||
|
||||
|
||||
static MooLang*
|
||||
page_get_lang (MooPrefsDialogPage *page)
|
||||
{
|
||||
return g_object_get_data (G_OBJECT (page), "moo-lang");
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************/
|
||||
/* Default styles list
|
||||
*/
|
||||
|
||||
static void default_treeview_style_func (GtkTreeViewColumn *column,
|
||||
GtkCellRenderer *cell,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
MooPrefsDialogPage *page);
|
||||
static void default_treeview_toggle_func (GtkTreeViewColumn *column,
|
||||
GtkCellRenderer *cell,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
MooPrefsDialogPage *page);
|
||||
static void default_treeview_color_func (GtkTreeViewColumn *column,
|
||||
GtkCellRenderer *cell,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
MooPrefsDialogPage *page);
|
||||
|
||||
|
||||
static void
|
||||
default_treeview_create_toggle (GtkTreeView *treeview,
|
||||
MooPrefsDialogPage *page,
|
||||
MooTextStyleMask mask,
|
||||
const char *title)
|
||||
{
|
||||
GtkCellRenderer *cell;
|
||||
GtkTreeViewColumn *column;
|
||||
GtkWidget *label;
|
||||
|
||||
cell = gtk_cell_renderer_toggle_new ();
|
||||
g_object_set (cell, "activatable", TRUE, NULL);
|
||||
g_object_set_data (G_OBJECT (cell), "moo-text-style-mask", GUINT_TO_POINTER (mask));
|
||||
|
||||
column = gtk_tree_view_column_new ();
|
||||
gtk_tree_view_column_pack_start (column, cell, FALSE);
|
||||
gtk_tree_view_column_set_cell_data_func (column, cell,
|
||||
(GtkTreeCellDataFunc) default_treeview_toggle_func,
|
||||
page, NULL);
|
||||
gtk_tree_view_column_set_expand (column, FALSE);
|
||||
gtk_tree_view_append_column (treeview, column);
|
||||
|
||||
label = gtk_label_new (title);
|
||||
gtk_widget_show (label);
|
||||
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
|
||||
gtk_tree_view_column_set_widget (column, label);
|
||||
}
|
||||
|
||||
static void
|
||||
default_treeview_create_color (GtkTreeView *treeview,
|
||||
MooPrefsDialogPage *page,
|
||||
MooTextStyleMask mask,
|
||||
const char *title)
|
||||
{
|
||||
GtkCellRenderer *cell;
|
||||
GtkTreeViewColumn *column;
|
||||
|
||||
cell = moo_cell_renderer_color_new ();
|
||||
g_object_set (cell, "activatable", TRUE, NULL);
|
||||
g_object_set_data (G_OBJECT (cell), "moo-text-style-mask", GUINT_TO_POINTER (mask));
|
||||
|
||||
column = gtk_tree_view_column_new ();
|
||||
gtk_tree_view_column_set_title (column, title);
|
||||
gtk_tree_view_column_pack_start (column, cell, TRUE);
|
||||
gtk_tree_view_column_set_cell_data_func (column, cell,
|
||||
(GtkTreeCellDataFunc) default_treeview_color_func,
|
||||
page, NULL);
|
||||
gtk_tree_view_column_set_expand (column, FALSE);
|
||||
gtk_tree_view_append_column (treeview, column);
|
||||
}
|
||||
|
||||
static void
|
||||
default_treeview_init (GtkTreeView *treeview,
|
||||
MooPrefsDialogPage *page)
|
||||
{
|
||||
GtkCellRenderer *cell;
|
||||
GtkListStore *store;
|
||||
GtkTreeViewColumn *column;
|
||||
|
||||
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (treeview),
|
||||
GTK_SELECTION_NONE);
|
||||
|
||||
store = gtk_list_store_new (1, G_TYPE_STRING);
|
||||
gtk_tree_view_set_model (treeview, GTK_TREE_MODEL (store));
|
||||
g_object_unref (store);
|
||||
|
||||
cell = gtk_cell_renderer_text_new ();
|
||||
gtk_tree_view_insert_column_with_data_func (treeview, -1, "Style", cell,
|
||||
(GtkTreeCellDataFunc) default_treeview_style_func, page, NULL);
|
||||
column = gtk_tree_view_get_column (treeview, 0);
|
||||
|
||||
default_treeview_create_color (treeview, page, MOO_TEXT_STYLE_FOREGROUND, "Foreground");
|
||||
default_treeview_create_color (treeview, page, MOO_TEXT_STYLE_BACKGROUND, "Background");
|
||||
|
||||
default_treeview_create_toggle (treeview, page, MOO_TEXT_STYLE_BOLD, "<b>B</b>");
|
||||
default_treeview_create_toggle (treeview, page, MOO_TEXT_STYLE_ITALIC, "<i>I</i>");
|
||||
default_treeview_create_toggle (treeview, page, MOO_TEXT_STYLE_UNDERLINE, "<u>U</u>");
|
||||
default_treeview_create_toggle (treeview, page, MOO_TEXT_STYLE_STRIKETHROUGH, "<s>S</s>");
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
text_cell_set_props_from_style (GtkCellRenderer *cell,
|
||||
MooTextStyle *style)
|
||||
{
|
||||
g_return_if_fail (style != NULL);
|
||||
|
||||
if ((style->mask & MOO_TEXT_STYLE_BOLD) && style->bold)
|
||||
g_object_set (cell, "weight", PANGO_WEIGHT_BOLD, NULL);
|
||||
else
|
||||
g_object_set (cell, "weight-set", FALSE, NULL);
|
||||
|
||||
if ((style->mask & MOO_TEXT_STYLE_ITALIC) && style->italic)
|
||||
g_object_set (cell, "style", PANGO_STYLE_ITALIC, NULL);
|
||||
else
|
||||
g_object_set (cell, "style-set", FALSE, NULL);
|
||||
|
||||
if ((style->mask & MOO_TEXT_STYLE_UNDERLINE) && style->underline)
|
||||
g_object_set (cell, "underline", PANGO_UNDERLINE_SINGLE, NULL);
|
||||
else
|
||||
g_object_set (cell, "underline", PANGO_UNDERLINE_NONE, NULL);
|
||||
|
||||
if ((style->mask & MOO_TEXT_STYLE_STRIKETHROUGH) && style->strikethrough)
|
||||
g_object_set (cell, "strikethrough", TRUE, NULL);
|
||||
else
|
||||
g_object_set (cell, "strikethrough", FALSE, NULL);
|
||||
|
||||
if (style->mask & MOO_TEXT_STYLE_FOREGROUND)
|
||||
g_object_set (cell, "foreground-gdk", &style->foreground, NULL);
|
||||
else
|
||||
g_object_set (cell, "foreground-set", FALSE, NULL);
|
||||
|
||||
if (style->mask & MOO_TEXT_STYLE_BACKGROUND)
|
||||
g_object_set (cell, "background-gdk", &style->background, NULL);
|
||||
else
|
||||
g_object_set (cell, "background-set", FALSE, NULL);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
default_treeview_style_func (G_GNUC_UNUSED GtkTreeViewColumn *column,
|
||||
GtkCellRenderer *cell,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
G_GNUC_UNUSED MooPrefsDialogPage *page)
|
||||
{
|
||||
char *style_name;
|
||||
MooTextStyle *style;
|
||||
|
||||
gtk_tree_model_get (model, iter, 0, &style_name, -1);
|
||||
g_return_if_fail (style_name != NULL);
|
||||
|
||||
style = moo_lang_mgr_get_style (page_get_mgr (page),
|
||||
NULL, style_name,
|
||||
page_get_scheme (page));
|
||||
g_return_if_fail (style != NULL);
|
||||
|
||||
text_cell_set_props_from_style (cell, style);
|
||||
g_object_set (cell, "text", style_name, NULL);
|
||||
|
||||
moo_text_style_free (style);
|
||||
g_free (style_name);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
default_treeview_toggle_func (G_GNUC_UNUSED GtkTreeViewColumn *column,
|
||||
GtkCellRenderer *cell,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
MooPrefsDialogPage *page)
|
||||
{
|
||||
char *style_name;
|
||||
MooTextStyle *style;
|
||||
MooTextStyleMask mask;
|
||||
gboolean active = FALSE;
|
||||
|
||||
gtk_tree_model_get (model, iter, 0, &style_name, -1);
|
||||
g_return_if_fail (style_name != NULL);
|
||||
|
||||
style = moo_lang_mgr_get_style (page_get_mgr (page),
|
||||
NULL, style_name,
|
||||
page_get_scheme (page));
|
||||
g_return_if_fail (style != NULL);
|
||||
|
||||
mask = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (cell), "moo-text-style-mask"));
|
||||
|
||||
/* XXX */
|
||||
if (mask & style->mask)
|
||||
{
|
||||
switch (mask)
|
||||
{
|
||||
case MOO_TEXT_STYLE_BOLD:
|
||||
active = style->bold ? TRUE : FALSE;
|
||||
break;
|
||||
case MOO_TEXT_STYLE_ITALIC:
|
||||
active = style->italic ? TRUE : FALSE;
|
||||
break;
|
||||
case MOO_TEXT_STYLE_UNDERLINE:
|
||||
active = style->underline ? TRUE : FALSE;
|
||||
break;
|
||||
case MOO_TEXT_STYLE_STRIKETHROUGH:
|
||||
active = style->strikethrough ? TRUE : FALSE;
|
||||
break;
|
||||
default:
|
||||
g_return_if_reached ();
|
||||
}
|
||||
}
|
||||
|
||||
g_object_set (cell, "active", active, NULL);
|
||||
moo_text_style_free (style);
|
||||
g_free (style_name);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
default_treeview_color_func (G_GNUC_UNUSED GtkTreeViewColumn *column,
|
||||
GtkCellRenderer *cell,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
MooPrefsDialogPage *page)
|
||||
{
|
||||
char *style_name;
|
||||
MooTextStyle *style;
|
||||
MooTextStyleScheme *scheme;
|
||||
MooTextStyleMask mask;
|
||||
GdkScreen *screen;
|
||||
|
||||
if (!gtk_widget_has_screen (GTK_WIDGET (page)))
|
||||
return;
|
||||
|
||||
screen = gtk_widget_get_screen (GTK_WIDGET (page));
|
||||
|
||||
gtk_tree_model_get (model, iter, 0, &style_name, -1);
|
||||
g_return_if_fail (style_name != NULL);
|
||||
|
||||
scheme = page_get_scheme (page);
|
||||
style = moo_lang_mgr_get_style (page_get_mgr (page),
|
||||
NULL, style_name,
|
||||
scheme);
|
||||
g_return_if_fail (style != NULL);
|
||||
|
||||
mask = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (cell), "moo-text-style-mask"));
|
||||
|
||||
switch (mask)
|
||||
{
|
||||
case MOO_TEXT_STYLE_FOREGROUND:
|
||||
if (style->mask & MOO_TEXT_STYLE_FOREGROUND)
|
||||
g_object_set (cell, "color", &style->foreground, NULL);
|
||||
else
|
||||
g_object_set (cell, "color-set", FALSE, NULL);
|
||||
break;
|
||||
case MOO_TEXT_STYLE_BACKGROUND:
|
||||
if (style->mask & MOO_TEXT_STYLE_BACKGROUND)
|
||||
g_object_set (cell, "color", &style->background, NULL);
|
||||
else
|
||||
g_object_set (cell, "color-set", FALSE, NULL);
|
||||
break;
|
||||
default:
|
||||
g_return_if_reached ();
|
||||
}
|
||||
|
||||
moo_text_style_free (style);
|
||||
g_free (style_name);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
default_treeview_set_scheme (GtkTreeView *treeview,
|
||||
MooTextStyleScheme *scheme)
|
||||
{
|
||||
GtkListStore *store;
|
||||
GtkTreeModel *model;
|
||||
GSList *styles, *l;
|
||||
GtkTreeIter iter;
|
||||
|
||||
treeview_apply_scheme (GTK_WIDGET (treeview), scheme);
|
||||
|
||||
model = gtk_tree_view_get_model (treeview);
|
||||
store = GTK_LIST_STORE (model);
|
||||
gtk_list_store_clear (store);
|
||||
|
||||
styles = moo_text_style_scheme_list_default (scheme);
|
||||
|
||||
for (l = styles; l != NULL; l = l->next)
|
||||
{
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter, 0, l->data, -1);
|
||||
}
|
||||
|
||||
g_slist_foreach (styles, (GFunc) g_free, NULL);
|
||||
g_slist_free (styles);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
treeview_apply_scheme (GtkWidget *widget,
|
||||
MooTextStyleScheme *scheme)
|
||||
{
|
||||
GdkColor color;
|
||||
GdkColor *color_ptr;
|
||||
|
||||
g_return_if_fail (scheme != NULL);
|
||||
|
||||
gtk_widget_ensure_style (widget);
|
||||
|
||||
color_ptr = NULL;
|
||||
if (scheme->text_colors[MOO_TEXT_COLOR_FG])
|
||||
{
|
||||
if (gdk_color_parse (scheme->text_colors[MOO_TEXT_COLOR_FG], &color))
|
||||
color_ptr = &color;
|
||||
else
|
||||
g_warning ("%s: could not parse color '%s'", G_STRLOC,
|
||||
scheme->text_colors[MOO_TEXT_COLOR_FG]);
|
||||
}
|
||||
gtk_widget_modify_text (widget, GTK_STATE_NORMAL, color_ptr);
|
||||
gtk_widget_modify_text (widget, GTK_STATE_ACTIVE, color_ptr);
|
||||
gtk_widget_modify_text (widget, GTK_STATE_PRELIGHT, color_ptr);
|
||||
gtk_widget_modify_text (widget, GTK_STATE_INSENSITIVE, color_ptr);
|
||||
|
||||
color_ptr = NULL;
|
||||
if (scheme->text_colors[MOO_TEXT_COLOR_BG])
|
||||
{
|
||||
if (gdk_color_parse (scheme->text_colors[MOO_TEXT_COLOR_BG], &color))
|
||||
color_ptr = &color;
|
||||
else
|
||||
g_warning ("%s: could not parse color '%s'", G_STRLOC,
|
||||
scheme->text_colors[MOO_TEXT_COLOR_BG]);
|
||||
}
|
||||
gtk_widget_modify_base (widget, GTK_STATE_NORMAL, color_ptr);
|
||||
gtk_widget_modify_base (widget, GTK_STATE_ACTIVE, color_ptr);
|
||||
gtk_widget_modify_base (widget, GTK_STATE_PRELIGHT, color_ptr);
|
||||
gtk_widget_modify_base (widget, GTK_STATE_INSENSITIVE, color_ptr);
|
||||
|
||||
color_ptr = NULL;
|
||||
if (scheme->text_colors[MOO_TEXT_COLOR_SEL_FG])
|
||||
{
|
||||
if (gdk_color_parse (scheme->text_colors[MOO_TEXT_COLOR_SEL_FG], &color))
|
||||
color_ptr = &color;
|
||||
else
|
||||
g_warning ("%s: could not parse color '%s'", G_STRLOC,
|
||||
scheme->text_colors[MOO_TEXT_COLOR_SEL_FG]);
|
||||
}
|
||||
gtk_widget_modify_text (widget, GTK_STATE_SELECTED, color_ptr);
|
||||
|
||||
color_ptr = NULL;
|
||||
if (scheme->text_colors[MOO_TEXT_COLOR_SEL_BG])
|
||||
{
|
||||
if (gdk_color_parse (scheme->text_colors[MOO_TEXT_COLOR_SEL_BG], &color))
|
||||
color_ptr = &color;
|
||||
else
|
||||
g_warning ("%s: could not parse color '%s'", G_STRLOC,
|
||||
scheme->text_colors[MOO_TEXT_COLOR_SEL_BG]);
|
||||
}
|
||||
gtk_widget_modify_base (widget, GTK_STATE_SELECTED, color_ptr);
|
||||
}
|
||||
|
@ -695,14 +695,14 @@ static void
|
||||
apply_styles (MooEditWindow *window,
|
||||
MooEdit *edit)
|
||||
{
|
||||
MooLangTable *table;
|
||||
MooLangMgr *mgr;
|
||||
MooTextStyleScheme *scheme;
|
||||
|
||||
table = moo_editor_get_lang_table (window->priv->editor);
|
||||
scheme = moo_lang_table_get_active_scheme (table);
|
||||
mgr = moo_editor_get_lang_mgr (window->priv->editor);
|
||||
scheme = moo_lang_mgr_get_active_scheme (mgr);
|
||||
g_return_if_fail (scheme != NULL);
|
||||
|
||||
_moo_text_style_scheme_apply (scheme, edit);
|
||||
moo_text_view_apply_scheme (MOO_TEXT_VIEW (edit), scheme);
|
||||
}
|
||||
|
||||
|
||||
@ -1637,18 +1637,18 @@ static void
|
||||
lang_item_activated (MooEditWindow *window,
|
||||
const char *lang_name)
|
||||
{
|
||||
MooLangTable *table;
|
||||
MooLangMgr *mgr;
|
||||
MooLang *lang = NULL;
|
||||
MooEdit *doc = ACTIVE_DOC (window);
|
||||
|
||||
g_return_if_fail (doc != NULL);
|
||||
g_return_if_fail (MOO_IS_EDIT_WINDOW (window));
|
||||
|
||||
table = moo_editor_get_lang_table (window->priv->editor);
|
||||
mgr = moo_editor_get_lang_mgr (window->priv->editor);
|
||||
|
||||
if (lang_name)
|
||||
{
|
||||
lang = moo_lang_table_get_lang (table, lang_name);
|
||||
lang = moo_lang_mgr_get_lang (mgr, lang_name);
|
||||
g_return_if_fail (lang != NULL);
|
||||
}
|
||||
|
||||
@ -1661,16 +1661,16 @@ create_lang_action (MooEditWindow *window)
|
||||
{
|
||||
MooAction *action;
|
||||
MooMenuMgr *menu_mgr;
|
||||
MooLangTable *table;
|
||||
MooLangMgr *lang_mgr;
|
||||
GSList *langs, *sections, *l;
|
||||
|
||||
table = moo_editor_get_lang_table (window->priv->editor);
|
||||
lang_mgr = moo_editor_get_lang_mgr (window->priv->editor);
|
||||
|
||||
/* TODO display names, etc. */
|
||||
sections = moo_lang_table_get_sections (table);
|
||||
sections = moo_lang_mgr_get_sections (lang_mgr);
|
||||
sections = g_slist_sort (sections, (GCompareFunc) strcmp);
|
||||
|
||||
langs = moo_lang_table_get_available_langs (table);
|
||||
langs = moo_lang_mgr_get_available_langs (lang_mgr);
|
||||
langs = g_slist_sort (langs, (GCompareFunc) cmp_langs);
|
||||
|
||||
action = moo_menu_action_new (LANG_ACTION_ID);
|
||||
|
@ -277,7 +277,7 @@ create_tag (MooHighlighter *hl,
|
||||
_moo_lang_set_tag_style (rule ? rule->context->lang : ctx_node->ctx->lang,
|
||||
tag,
|
||||
rule ? rule->context : ctx_node->ctx,
|
||||
rule);
|
||||
rule, NULL);
|
||||
ctx_node->child_tags = g_slist_prepend (ctx_node->child_tags, tag);
|
||||
|
||||
return tag;
|
||||
@ -750,3 +750,35 @@ moo_highlighter_apply_tags (MooHighlighter *hl,
|
||||
LINE_SET_TAGS_APPLIED (line);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
tag_set_scheme (G_GNUC_UNUSED gpointer whatever,
|
||||
MooSyntaxTag *tag,
|
||||
MooTextStyleScheme *scheme)
|
||||
{
|
||||
if (tag)
|
||||
{
|
||||
_moo_lang_erase_tag_style (GTK_TEXT_TAG (tag));
|
||||
_moo_lang_set_tag_style (tag->rule ? tag->rule->context->lang : tag->ctx_node->ctx->lang,
|
||||
GTK_TEXT_TAG (tag),
|
||||
tag->rule ? tag->rule->context : tag->ctx_node->ctx,
|
||||
tag->rule, scheme);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ctx_node_set_scheme (CtxNode *node,
|
||||
MooTextStyleScheme *scheme)
|
||||
{
|
||||
g_hash_table_foreach (node->match_tags, (GHFunc) tag_set_scheme, scheme);
|
||||
tag_set_scheme (NULL, MOO_SYNTAX_TAG (node->context_tag), scheme);
|
||||
}
|
||||
|
||||
void
|
||||
moo_highlighter_apply_scheme (MooHighlighter *hl,
|
||||
MooTextStyleScheme *scheme)
|
||||
{
|
||||
g_return_if_fail (hl != NULL && scheme != NULL);
|
||||
g_slist_foreach (hl->nodes, (GFunc) ctx_node_set_scheme, scheme);
|
||||
}
|
||||
|
@ -87,6 +87,8 @@ void moo_highlighter_apply_tags (MooHighlighter *highlight,
|
||||
int first_line,
|
||||
int last_line);
|
||||
|
||||
void moo_highlighter_apply_scheme (MooHighlighter *highlight,
|
||||
MooTextStyleScheme *scheme);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
@ -15,6 +15,7 @@
|
||||
#define MOOEDIT_COMPILATION
|
||||
#include "mooedit/moolang-parser.h"
|
||||
#include "mooedit/moolang-strings.h"
|
||||
#include "mooedit/moolangmgr.h"
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <string.h>
|
||||
@ -162,6 +163,7 @@ inline static void STRING_FREE (xmlChar *s)
|
||||
#define IS_DEFAULT_STYLE_NODE(node_) (IS_ELEMENT_NODE(node_) && NODE_NAME_IS_(node_, DEFAULT_STYLE_ELM))
|
||||
#define IS_BRACKET_MATCH_NODE(node_) (IS_ELEMENT_NODE(node_) && NODE_NAME_IS_(node_, BRACKET_MATCH_ELM))
|
||||
#define IS_BRACKET_MISMATCH_NODE(node_) (IS_ELEMENT_NODE(node_) && NODE_NAME_IS_(node_, BRACKET_MISMATCH_ELM))
|
||||
#define IS_SAMPLE_CODE_NODE(node_) (IS_ELEMENT_NODE(node_) && NODE_NAME_IS_(node_, SAMPLE_CODE_ELM))
|
||||
|
||||
|
||||
#if VERBOSE
|
||||
@ -449,6 +451,21 @@ lang_xml_parse (xmlNode *node)
|
||||
if (!xml->general)
|
||||
goto error;
|
||||
}
|
||||
else if (IS_SAMPLE_CODE_NODE (child))
|
||||
{
|
||||
xmlChar *content;
|
||||
|
||||
if (xml->sample)
|
||||
{
|
||||
g_warning ("%s: duplicated '" SAMPLE_CODE_ELM "' element", G_STRLOC);
|
||||
goto error;
|
||||
}
|
||||
|
||||
content = xmlNodeGetContent (child);
|
||||
xml->sample = STRDUP (content);
|
||||
|
||||
STRING_FREE (content);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("%s: unknown tag '%s'", G_STRLOC, child->name);
|
||||
@ -499,6 +516,7 @@ moo_lang_xml_free (LangXML *xml)
|
||||
g_free (xml->mimetypes);
|
||||
g_free (xml->extensions);
|
||||
g_free (xml->author);
|
||||
g_free (xml->sample);
|
||||
general_xml_free (xml->general);
|
||||
syntax_xml_free (xml->syntax);
|
||||
style_list_xml_free (xml->style_list);
|
||||
@ -1480,9 +1498,9 @@ moo_rule_new_from_xml (RuleXML *xml,
|
||||
break;
|
||||
case MOO_CONTEXT_SWITCH:
|
||||
if (xml->end_switch_info.ref.lang)
|
||||
switch_to = moo_lang_table_get_context (lang->table,
|
||||
xml->end_switch_info.ref.lang,
|
||||
xml->end_switch_info.ref.name);
|
||||
switch_to = moo_lang_mgr_get_context (lang->mgr,
|
||||
xml->end_switch_info.ref.lang,
|
||||
xml->end_switch_info.ref.name);
|
||||
else
|
||||
switch_to = moo_lang_get_context (lang, xml->end_switch_info.ref.name);
|
||||
|
||||
@ -1884,7 +1902,7 @@ rule_include_xml_create_rule (RuleIncludeXML *xml,
|
||||
MooContext *ctx;
|
||||
|
||||
if (xml->from_lang)
|
||||
ctx = moo_lang_table_get_context (lang->table, xml->from_lang, xml->from_context);
|
||||
ctx = moo_lang_mgr_get_context (lang->mgr, xml->from_lang, xml->from_context);
|
||||
else
|
||||
ctx = moo_lang_get_context (lang, xml->from_context);
|
||||
|
||||
@ -2059,10 +2077,11 @@ error:
|
||||
|
||||
|
||||
static MooTextStyleScheme*
|
||||
style_scheme_xml_parse (xmlNode *node)
|
||||
style_scheme_xml_parse (xmlNode *node,
|
||||
char **base_scheme)
|
||||
{
|
||||
MooTextStyleScheme *scheme;
|
||||
xmlChar *name = NULL, *foreground = NULL, *background = NULL;
|
||||
xmlChar *name = NULL, *foreground = NULL, *background = NULL, *base = NULL;
|
||||
xmlChar *selected_foreground = NULL, *selected_background = NULL, *current_line = NULL;
|
||||
|
||||
g_return_val_if_fail (IS_SCHEME_NODE (node), NULL);
|
||||
@ -2073,6 +2092,7 @@ style_scheme_xml_parse (xmlNode *node)
|
||||
selected_foreground = GET_PROP (node, SCHEME_SEL_FOREGROUND_PROP);
|
||||
selected_background = GET_PROP (node, SCHEME_SEL_BACKGROUND_PROP);
|
||||
current_line = GET_PROP (node, SCHEME_CURRENT_LINE_PROP);
|
||||
base = GET_PROP (node, SCHEME_BASE_SCHEME_PROP);
|
||||
|
||||
if (!name || !name[0])
|
||||
{
|
||||
@ -2080,13 +2100,13 @@ style_scheme_xml_parse (xmlNode *node)
|
||||
goto error;
|
||||
}
|
||||
|
||||
scheme = moo_text_style_scheme_new_empty (name);
|
||||
scheme = moo_text_style_scheme_new_empty (name, NULL);
|
||||
|
||||
scheme->foreground = STRDUP (foreground);
|
||||
scheme->background = STRDUP (background);
|
||||
scheme->selected_foreground = STRDUP (selected_foreground);
|
||||
scheme->selected_background = STRDUP (selected_background);
|
||||
scheme->current_line = STRDUP (current_line);
|
||||
scheme->text_colors[MOO_TEXT_COLOR_FG] = STRDUP (foreground);
|
||||
scheme->text_colors[MOO_TEXT_COLOR_BG] = STRDUP (background);
|
||||
scheme->text_colors[MOO_TEXT_COLOR_SEL_FG] = STRDUP (selected_foreground);
|
||||
scheme->text_colors[MOO_TEXT_COLOR_SEL_BG] = STRDUP (selected_background);
|
||||
scheme->text_colors[MOO_TEXT_COLOR_CUR_LINE] = STRDUP (current_line);
|
||||
|
||||
ELM_FOREACH (node, child)
|
||||
{
|
||||
@ -2153,12 +2173,16 @@ style_scheme_xml_parse (xmlNode *node)
|
||||
}
|
||||
ELM_FOREACH_END;
|
||||
|
||||
if (base_scheme)
|
||||
*base_scheme = STRDUP (base);
|
||||
|
||||
STRING_FREE (name);
|
||||
STRING_FREE (foreground);
|
||||
STRING_FREE (background);
|
||||
STRING_FREE (selected_foreground);
|
||||
STRING_FREE (selected_background);
|
||||
STRING_FREE (current_line);
|
||||
STRING_FREE (base);
|
||||
return scheme;
|
||||
|
||||
error:
|
||||
@ -2168,13 +2192,15 @@ error:
|
||||
STRING_FREE (selected_foreground);
|
||||
STRING_FREE (selected_background);
|
||||
STRING_FREE (current_line);
|
||||
moo_text_style_scheme_unref (scheme);
|
||||
STRING_FREE (base);
|
||||
g_object_unref (scheme);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
MooTextStyleScheme*
|
||||
moo_text_style_scheme_parse_file (const char *file)
|
||||
moo_text_style_scheme_parse_file (const char *file,
|
||||
char **base_scheme)
|
||||
{
|
||||
xmlDoc *doc;
|
||||
xmlNode *root;
|
||||
@ -2187,7 +2213,7 @@ moo_text_style_scheme_parse_file (const char *file)
|
||||
g_return_val_if_fail (doc != NULL, NULL);
|
||||
|
||||
root = xmlDocGetRootElement (doc);
|
||||
scheme = style_scheme_xml_parse (root);
|
||||
scheme = style_scheme_xml_parse (root, base_scheme);
|
||||
|
||||
xmlFreeDoc (doc);
|
||||
xmlCleanupParser ();
|
||||
@ -2198,7 +2224,8 @@ moo_text_style_scheme_parse_file (const char *file)
|
||||
|
||||
MooTextStyleScheme*
|
||||
moo_text_style_scheme_parse_memory (const char *buffer,
|
||||
int size)
|
||||
int size,
|
||||
char **base_scheme)
|
||||
{
|
||||
xmlDoc *doc;
|
||||
xmlNode *root;
|
||||
@ -2214,7 +2241,7 @@ moo_text_style_scheme_parse_memory (const char *buffer,
|
||||
g_return_val_if_fail (doc != NULL, NULL);
|
||||
|
||||
root = xmlDocGetRootElement (doc);
|
||||
scheme = style_scheme_xml_parse (root);
|
||||
scheme = style_scheme_xml_parse (root, base_scheme);
|
||||
|
||||
xmlFreeDoc (doc);
|
||||
xmlCleanupParser ();
|
||||
|
@ -61,6 +61,7 @@ struct _LangXML {
|
||||
char *mimetypes;
|
||||
char *extensions;
|
||||
char *author;
|
||||
char *sample;
|
||||
guint hidden : 1;
|
||||
GeneralXML *general;
|
||||
SyntaxXML *syntax;
|
||||
@ -185,9 +186,11 @@ LangXML *moo_lang_parse_memory (const char *buffer,
|
||||
int size);
|
||||
void moo_lang_xml_free (LangXML *xml);
|
||||
|
||||
MooTextStyleScheme *moo_text_style_scheme_parse_file (const char *file);
|
||||
MooTextStyleScheme *moo_text_style_scheme_parse_file (const char *file,
|
||||
char **base_scheme);
|
||||
MooTextStyleScheme *moo_text_style_scheme_parse_memory (const char *buffer,
|
||||
int size);
|
||||
int size,
|
||||
char **base_scheme);
|
||||
|
||||
MooRule *moo_rule_new_from_xml (RuleXML *xml,
|
||||
LangXML *lang_xml,
|
||||
|
@ -41,7 +41,7 @@
|
||||
#define DEFAULT_STYLE_ELM "default-style"
|
||||
#define SCHEME_NAME_PROP "name"
|
||||
#define DEFAULT_SCHEME_PROP "default-scheme"
|
||||
#define SCHEME_USE_SCHEME_PROP "use-scheme"
|
||||
#define SCHEME_BASE_SCHEME_PROP "base"
|
||||
#define SCHEME_FOREGROUND_PROP "foreground"
|
||||
#define SCHEME_BACKGROUND_PROP "background"
|
||||
#define SCHEME_SEL_FOREGROUND_PROP "selected-foreground"
|
||||
@ -62,6 +62,7 @@
|
||||
#define COMMENTS_ELM "comments"
|
||||
#define SINGLE_LINE_ELM "single-line"
|
||||
#define MULTI_LINE_ELM "multi-line"
|
||||
#define SAMPLE_CODE_ELM "sample-code"
|
||||
|
||||
#define LANG_NAME_PROP "name"
|
||||
#define LANG_VERSION_PROP "version"
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -16,7 +16,7 @@
|
||||
#define __MOO_LANG_H__
|
||||
|
||||
#include <gtk/gtktexttag.h>
|
||||
#include <mooedit/mootextstyle.h>
|
||||
#include <mooedit/mootextstylescheme.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@ -25,18 +25,9 @@ G_BEGIN_DECLS
|
||||
#define MOO_STYLES_PREFS_PREFIX MOO_EDIT_PREFS_PREFIX "/styles"
|
||||
|
||||
#define MOO_TYPE_LANG (moo_lang_get_type ())
|
||||
#define MOO_TYPE_LANG_TABLE (moo_lang_table_get_type ())
|
||||
|
||||
#define MOO_LANG_TABLE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), MOO_TYPE_LANG_TABLE, MooLangTable))
|
||||
#define MOO_LANG_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MOO_TYPE_LANG_TABLE, MooLangTableClass))
|
||||
#define MOO_IS_LANG_TABLE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), MOO_TYPE_LANG_TABLE))
|
||||
#define MOO_IS_LANG_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MOO_TYPE_LANG_TABLE))
|
||||
#define MOO_LANG_TABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOO_TYPE_LANG_TABLE, MooLangTableClass))
|
||||
|
||||
|
||||
typedef struct _MooLang MooLang;
|
||||
typedef struct _MooLangTable MooLangTable;
|
||||
typedef struct _MooLangTableClass MooLangTableClass;
|
||||
typedef struct _MooContext MooContext;
|
||||
typedef struct _MooContextArray MooContextArray;
|
||||
typedef struct _MooCtxSwitch MooCtxSwitch;
|
||||
@ -44,14 +35,14 @@ typedef struct _MooRule MooRule;
|
||||
typedef struct _MooRuleArray MooRuleArray;
|
||||
|
||||
struct _MooLang {
|
||||
MooLangTable *table;
|
||||
struct _MooLangMgr *mgr;
|
||||
|
||||
GHashTable *context_names; /* char* -> MooContext* */
|
||||
MooContextArray *contexts;
|
||||
|
||||
GHashTable *style_names; /* char* -> MooStyle* */
|
||||
MooTextStyleArray *styles;
|
||||
GHashTable *style_cache; /* char* -> MooStyle* */
|
||||
GHashTable *style_cache;
|
||||
|
||||
char *name; /* not NULL */
|
||||
char *section; /* not NULL; "Others" by default */
|
||||
@ -65,33 +56,12 @@ struct _MooLang {
|
||||
char *multi_line_comment_start;
|
||||
char *multi_line_comment_end;
|
||||
|
||||
char *sample;
|
||||
|
||||
guint hidden : 1;
|
||||
};
|
||||
|
||||
|
||||
struct _MooLangTable {
|
||||
GObject base;
|
||||
|
||||
GSList *lang_dirs;
|
||||
GSList *langs;
|
||||
GHashTable *lang_names;
|
||||
GHashTable *schemes;
|
||||
MooTextStyleScheme *active_scheme;
|
||||
guint dirs_read : 1;
|
||||
};
|
||||
|
||||
struct _MooLangTableClass
|
||||
{
|
||||
GObjectClass base_class;
|
||||
|
||||
void (*lang_added) (MooLangTable *table,
|
||||
const char *lang_name);
|
||||
void (*lang_removed) (MooLangTable *table,
|
||||
const char *lang_name);
|
||||
};
|
||||
|
||||
|
||||
|
||||
typedef enum {
|
||||
MOO_CONTEXT_STAY = 0,
|
||||
MOO_CONTEXT_POP,
|
||||
@ -201,7 +171,6 @@ struct _MooRule
|
||||
|
||||
|
||||
GType moo_lang_get_type (void) G_GNUC_CONST;
|
||||
GType moo_lang_table_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
@ -221,7 +190,7 @@ void moo_context_set_line_end_switch (MooContext *ctx,
|
||||
/* MooLang
|
||||
*/
|
||||
|
||||
MooLang *moo_lang_new (MooLangTable *table,
|
||||
MooLang *moo_lang_new (struct _MooLangMgr *mgr,
|
||||
const char *name,
|
||||
const char *section,
|
||||
const char *version,
|
||||
@ -244,51 +213,22 @@ void moo_lang_add_style (MooLang *lang,
|
||||
const MooTextStyle *style);
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* MooLangTable
|
||||
*/
|
||||
|
||||
MooLangTable *moo_lang_table_new (void);
|
||||
|
||||
GSList *moo_lang_table_get_available_langs (MooLangTable *table);
|
||||
GSList *moo_lang_table_get_sections (MooLangTable *table);
|
||||
|
||||
MooLang *moo_lang_table_get_lang_for_file (MooLangTable *table,
|
||||
const char *filename);
|
||||
MooLang *moo_lang_table_get_lang_for_filename (MooLangTable *table,
|
||||
const char *filename);
|
||||
MooLang *moo_lang_table_get_lang_for_mime_type (MooLangTable *table,
|
||||
const char *mime_type);
|
||||
MooLang *moo_lang_table_get_lang (MooLangTable *table,
|
||||
const char *name);
|
||||
MooContext *moo_lang_table_get_context (MooLangTable *table,
|
||||
const char *lang_name,
|
||||
const char *ctx_name);
|
||||
|
||||
void moo_lang_table_add_dir (MooLangTable *table,
|
||||
const char *dir);
|
||||
void moo_lang_table_read_dirs (MooLangTable *table);
|
||||
|
||||
MooTextStyle *moo_lang_table_get_style (MooLangTable *table,
|
||||
const char *lang_name, /* default style if NULL */
|
||||
const char *style_name);
|
||||
void moo_lang_table_set_style (MooLangTable *table,
|
||||
const char *lang_name, /* default style if NULL */
|
||||
const char *style_name,
|
||||
const MooTextStyle *style);
|
||||
MooTextStyleScheme *moo_lang_table_get_active_scheme (MooLangTable *table);
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Auxiliary private methods
|
||||
*/
|
||||
|
||||
void _moo_lang_free (MooLang *lang);
|
||||
|
||||
void _moo_lang_scheme_changed (MooLang *lang);
|
||||
void _moo_lang_set_tag_style (MooLang *lang,
|
||||
GtkTextTag *tag,
|
||||
MooContext *ctx,
|
||||
MooRule *rule);
|
||||
MooRule *rule,
|
||||
MooTextStyleScheme *scheme);
|
||||
void _moo_style_set_tag_style (const MooTextStyle *style,
|
||||
GtkTextTag *tag);
|
||||
void _moo_lang_erase_tag_style (GtkTextTag *tag);
|
||||
|
||||
/* implemented in moohighlighter.c */
|
||||
MooContext *_moo_text_iter_get_context (const GtkTextIter *iter);
|
||||
|
||||
|
1027
moo/mooedit/moolangmgr.c
Normal file
1027
moo/mooedit/moolangmgr.c
Normal file
File diff suppressed because it is too large
Load Diff
96
moo/mooedit/moolangmgr.h
Normal file
96
moo/mooedit/moolangmgr.h
Normal file
@ -0,0 +1,96 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4; coding: utf-8 -*-
|
||||
*
|
||||
* moolangmgr.h
|
||||
*
|
||||
* Copyright (C) 2004-2005 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_LANG_MGR_H__
|
||||
#define __MOO_LANG_MGR_H__
|
||||
|
||||
#include <mooedit/moolang.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
#define MOO_LANG_DIR_BASENAME "syntax"
|
||||
#define MOO_STYLES_PREFS_PREFIX MOO_EDIT_PREFS_PREFIX "/styles"
|
||||
|
||||
#define MOO_TYPE_LANG_MGR (moo_lang_mgr_get_type ())
|
||||
#define MOO_LANG_MGR(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), MOO_TYPE_LANG_MGR, MooLangMgr))
|
||||
#define MOO_LANG_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MOO_TYPE_LANG_MGR, MooLangMgrClass))
|
||||
#define MOO_IS_LANG_MGR(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), MOO_TYPE_LANG_MGR))
|
||||
#define MOO_IS_LANG_MGR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MOO_TYPE_LANG_MGR))
|
||||
#define MOO_LANG_MGR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOO_TYPE_LANG_MGR, MooLangMgrClass))
|
||||
|
||||
|
||||
typedef struct _MooLangMgr MooLangMgr;
|
||||
typedef struct _MooLangMgrClass MooLangMgrClass;
|
||||
|
||||
struct _MooLangMgr {
|
||||
GObject base;
|
||||
|
||||
GSList *lang_dirs;
|
||||
GSList *langs;
|
||||
GHashTable *lang_names;
|
||||
GHashTable *schemes;
|
||||
MooTextStyleScheme *active_scheme;
|
||||
guint dirs_read : 1;
|
||||
};
|
||||
|
||||
struct _MooLangMgrClass
|
||||
{
|
||||
GObjectClass base_class;
|
||||
|
||||
void (*lang_added) (MooLangMgr *mgr,
|
||||
const char *lang_name);
|
||||
void (*lang_removed) (MooLangMgr *mgr,
|
||||
const char *lang_name);
|
||||
};
|
||||
|
||||
|
||||
GType moo_lang_mgr_get_type (void) G_GNUC_CONST;
|
||||
|
||||
MooLangMgr *moo_lang_mgr_new (void);
|
||||
|
||||
GSList *moo_lang_mgr_get_available_langs (MooLangMgr *mgr);
|
||||
GSList *moo_lang_mgr_get_sections (MooLangMgr *mgr);
|
||||
|
||||
MooLang *moo_lang_mgr_get_lang_for_file (MooLangMgr *mgr,
|
||||
const char *filename);
|
||||
MooLang *moo_lang_mgr_get_lang_for_filename (MooLangMgr *mgr,
|
||||
const char *filename);
|
||||
MooLang *moo_lang_mgr_get_lang_for_mime_type (MooLangMgr *mgr,
|
||||
const char *mime_type);
|
||||
MooLang *moo_lang_mgr_get_lang (MooLangMgr *mgr,
|
||||
const char *name);
|
||||
MooContext *moo_lang_mgr_get_context (MooLangMgr *mgr,
|
||||
const char *lang_name,
|
||||
const char *ctx_name);
|
||||
|
||||
GSList *moo_lang_mgr_list_schemes (MooLangMgr *mgr);
|
||||
|
||||
void moo_lang_mgr_add_dir (MooLangMgr *mgr,
|
||||
const char *dir);
|
||||
void moo_lang_mgr_read_dirs (MooLangMgr *mgr);
|
||||
|
||||
MooTextStyle *moo_lang_mgr_get_style (MooLangMgr *mgr,
|
||||
const char *lang_name, /* default style if NULL */
|
||||
const char *style_name,
|
||||
MooTextStyleScheme *scheme);
|
||||
MooTextStyleScheme *moo_lang_mgr_get_active_scheme (MooLangMgr *mgr);
|
||||
|
||||
void _moo_lang_mgr_add_lang (MooLangMgr *mgr,
|
||||
MooLang *lang);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MOO_LANG_MGR_H__ */
|
@ -538,6 +538,19 @@ _moo_text_buffer_apply_syntax_tag (MooTextBuffer *buffer,
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
moo_text_buffer_apply_scheme (MooTextBuffer *buffer,
|
||||
MooTextStyleScheme *scheme)
|
||||
{
|
||||
g_return_if_fail (scheme != NULL);
|
||||
g_return_if_fail (MOO_IS_TEXT_BUFFER (buffer));
|
||||
|
||||
moo_text_buffer_set_bracket_match_style (buffer, scheme->bracket_match);
|
||||
moo_text_buffer_set_bracket_mismatch_style (buffer, scheme->bracket_mismatch);
|
||||
moo_highlighter_apply_scheme (buffer->priv->hl, scheme);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Matching brackets
|
||||
*/
|
||||
|
@ -73,6 +73,8 @@ void moo_text_buffer_set_check_brackets (MooTextBuffer *buf
|
||||
gboolean moo_text_buffer_has_text (MooTextBuffer *buffer);
|
||||
gboolean moo_text_buffer_has_selection (MooTextBuffer *buffer);
|
||||
|
||||
void moo_text_buffer_apply_scheme (MooTextBuffer *buffer,
|
||||
MooTextStyleScheme *scheme);
|
||||
|
||||
void _moo_text_buffer_ensure_highlight (MooTextBuffer *buffer,
|
||||
int first_line,
|
||||
|
@ -187,393 +187,3 @@ moo_text_style_mask_get_type (void)
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
/* Style schemes
|
||||
*/
|
||||
|
||||
static void fill_in_default_scheme (MooTextStyleScheme *scheme);
|
||||
|
||||
|
||||
GType
|
||||
moo_text_style_scheme_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
if (!type)
|
||||
type = g_boxed_type_register_static ("MooTextStyleScheme",
|
||||
(GBoxedCopyFunc) moo_text_style_scheme_ref,
|
||||
(GBoxedFreeFunc) moo_text_style_scheme_unref);
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
MooTextStyleScheme*
|
||||
moo_text_style_scheme_new_empty (const char *name)
|
||||
{
|
||||
MooTextStyleScheme *scheme;
|
||||
|
||||
g_return_val_if_fail (name && name[0], NULL);
|
||||
|
||||
scheme = g_new0 (MooTextStyleScheme, 1);
|
||||
|
||||
scheme->name = g_strdup (name);
|
||||
scheme->styles = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
g_free,
|
||||
(GDestroyNotify) moo_text_style_free);
|
||||
scheme->ref_count = 1;
|
||||
scheme->use_theme_colors = TRUE;
|
||||
|
||||
return scheme;
|
||||
}
|
||||
|
||||
|
||||
MooTextStyleScheme*
|
||||
moo_text_style_scheme_new_default (void)
|
||||
{
|
||||
MooTextStyleScheme *scheme;
|
||||
scheme = moo_text_style_scheme_new_empty (SCHEME_DEFAULT);
|
||||
fill_in_default_scheme (scheme);
|
||||
return scheme;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
copy_style (const char *style_name,
|
||||
const MooTextStyle *style,
|
||||
GHashTable *dest)
|
||||
{
|
||||
g_hash_table_insert (dest, g_strdup (style_name),
|
||||
moo_text_style_copy (style));
|
||||
}
|
||||
|
||||
MooTextStyleScheme*
|
||||
moo_text_style_scheme_copy (MooTextStyleScheme *scheme)
|
||||
{
|
||||
MooTextStyleScheme *copy;
|
||||
|
||||
g_return_val_if_fail (scheme != NULL, NULL);
|
||||
|
||||
copy = moo_text_style_scheme_new_empty (scheme->name);
|
||||
|
||||
copy->foreground = g_strdup (scheme->foreground);
|
||||
copy->background = g_strdup (scheme->background);
|
||||
copy->selected_foreground = g_strdup (scheme->selected_foreground);
|
||||
copy->selected_background = g_strdup (scheme->selected_background);
|
||||
copy->current_line = g_strdup (scheme->current_line);
|
||||
copy->use_theme_colors = scheme->use_theme_colors;
|
||||
copy->bracket_match = moo_text_style_copy (scheme->bracket_match);
|
||||
copy->bracket_mismatch = moo_text_style_copy (scheme->bracket_mismatch);
|
||||
|
||||
g_hash_table_foreach (scheme->styles, (GHFunc) copy_style, scheme->styles);
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
moo_text_style_scheme_compose (MooTextStyleScheme *scheme,
|
||||
const char *language_name,
|
||||
const char *style_name,
|
||||
const MooTextStyle *style)
|
||||
{
|
||||
const char *key;
|
||||
char *freeme = NULL;
|
||||
MooTextStyle *old_style;
|
||||
|
||||
g_return_if_fail (scheme != NULL);
|
||||
g_return_if_fail (style_name != NULL && style != NULL);
|
||||
|
||||
if (language_name)
|
||||
{
|
||||
freeme = g_strdup_printf ("%s::%s", language_name, style_name);
|
||||
key = freeme;
|
||||
}
|
||||
else
|
||||
{
|
||||
key = style_name;
|
||||
}
|
||||
|
||||
old_style = g_hash_table_lookup (scheme->styles, key);
|
||||
|
||||
if (old_style)
|
||||
moo_text_style_compose (old_style, style);
|
||||
else
|
||||
g_hash_table_insert (scheme->styles, g_strdup (key),
|
||||
moo_text_style_copy (style));
|
||||
|
||||
g_free (freeme);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
moo_text_style_scheme_set (MooTextStyleScheme *scheme,
|
||||
const char *language_name,
|
||||
const char *style_name,
|
||||
const MooTextStyle *style)
|
||||
{
|
||||
const char *key;
|
||||
char *freeme = NULL;
|
||||
|
||||
g_return_if_fail (scheme != NULL);
|
||||
g_return_if_fail (style_name != NULL && style != NULL);
|
||||
|
||||
if (language_name)
|
||||
{
|
||||
freeme = g_strdup_printf ("%s::%s", language_name, style_name);
|
||||
key = freeme;
|
||||
}
|
||||
else
|
||||
{
|
||||
key = style_name;
|
||||
}
|
||||
|
||||
g_hash_table_insert (scheme->styles, g_strdup (key),
|
||||
moo_text_style_copy (style));
|
||||
|
||||
g_free (freeme);
|
||||
}
|
||||
|
||||
|
||||
const MooTextStyle*
|
||||
moo_text_style_scheme_get (MooTextStyleScheme *scheme,
|
||||
const char *language_name,
|
||||
const char *style_name)
|
||||
{
|
||||
const MooTextStyle *style;
|
||||
const char *key;
|
||||
char *freeme = NULL;
|
||||
|
||||
g_return_val_if_fail (scheme != NULL, NULL);
|
||||
g_return_val_if_fail (style_name != NULL, NULL);
|
||||
|
||||
if (language_name)
|
||||
{
|
||||
freeme = g_strdup_printf ("%s::%s", language_name, style_name);
|
||||
key = freeme;
|
||||
}
|
||||
else
|
||||
{
|
||||
key = style_name;
|
||||
}
|
||||
|
||||
style = g_hash_table_lookup (scheme->styles, key);
|
||||
|
||||
g_free (freeme);
|
||||
return style;
|
||||
}
|
||||
|
||||
|
||||
MooTextStyleScheme*
|
||||
moo_text_style_scheme_ref (MooTextStyleScheme *scheme)
|
||||
{
|
||||
g_return_val_if_fail (scheme != NULL, NULL);
|
||||
scheme->ref_count++;
|
||||
return scheme;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
moo_text_style_scheme_unref (MooTextStyleScheme *scheme)
|
||||
{
|
||||
if (scheme && !(--scheme->ref_count))
|
||||
{
|
||||
g_free (scheme->name);
|
||||
g_free (scheme->foreground);
|
||||
g_free (scheme->background);
|
||||
g_free (scheme->selected_foreground);
|
||||
g_free (scheme->selected_background);
|
||||
g_free (scheme->current_line);
|
||||
g_hash_table_destroy (scheme->styles);
|
||||
moo_text_style_free (scheme->bracket_match);
|
||||
moo_text_style_free (scheme->bracket_mismatch);
|
||||
g_free (scheme);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static MooTextStyle*
|
||||
new_style (const char *fg,
|
||||
const char *bg,
|
||||
gboolean italic,
|
||||
gboolean bold,
|
||||
gboolean underline,
|
||||
gboolean strikethrough,
|
||||
MooTextStyleMask mask)
|
||||
{
|
||||
GdkColor foreground, background;
|
||||
|
||||
if (mask & MOO_TEXT_STYLE_FOREGROUND)
|
||||
{
|
||||
if (!gdk_color_parse (fg, &foreground))
|
||||
{
|
||||
g_warning ("could not parse color %s", fg);
|
||||
mask = mask & ~MOO_TEXT_STYLE_FOREGROUND;
|
||||
}
|
||||
}
|
||||
|
||||
if (mask & MOO_TEXT_STYLE_BACKGROUND)
|
||||
{
|
||||
if (!gdk_color_parse (bg, &background))
|
||||
{
|
||||
g_warning ("could not parse color %s", bg);
|
||||
mask = mask & ~MOO_TEXT_STYLE_BACKGROUND;
|
||||
}
|
||||
}
|
||||
|
||||
return moo_text_style_new (NULL, &foreground, &background,
|
||||
bold, italic, underline, strikethrough,
|
||||
mask, FALSE);
|
||||
}
|
||||
|
||||
|
||||
#define INSERT(name_,fg_,bg_,italic_,bold_,underline_,strikethrough_,mask_) \
|
||||
g_hash_table_insert (scheme->styles, g_strdup (name_), \
|
||||
new_style (fg_, bg_, italic_, bold_, \
|
||||
underline_, strikethrough_, mask_))
|
||||
|
||||
static void
|
||||
fill_in_default_scheme (MooTextStyleScheme *scheme)
|
||||
{
|
||||
scheme->current_line = g_strdup ("#EEF6FF");
|
||||
scheme->bracket_match = new_style (NULL, "#FFFF99", FALSE,
|
||||
FALSE, FALSE, FALSE,
|
||||
MOO_TEXT_STYLE_BACKGROUND);
|
||||
|
||||
INSERT (DEF_STYLE_NORMAL,
|
||||
NULL, NULL, FALSE, FALSE, FALSE, FALSE, 0);
|
||||
|
||||
INSERT (DEF_STYLE_PREPROCESSOR,
|
||||
"#008000", NULL, FALSE, FALSE, FALSE, FALSE,
|
||||
MOO_TEXT_STYLE_FOREGROUND);
|
||||
|
||||
INSERT (DEF_STYLE_STRING,
|
||||
"#DD0000", NULL, FALSE, FALSE, FALSE, FALSE,
|
||||
MOO_TEXT_STYLE_FOREGROUND);
|
||||
|
||||
INSERT (DEF_STYLE_COMMENT,
|
||||
"#808080", NULL, TRUE, FALSE, FALSE, FALSE,
|
||||
MOO_TEXT_STYLE_FOREGROUND | MOO_TEXT_STYLE_ITALIC);
|
||||
|
||||
INSERT (DEF_STYLE_BASE_N,
|
||||
"#008080", NULL, FALSE, FALSE, FALSE, FALSE,
|
||||
MOO_TEXT_STYLE_FOREGROUND);
|
||||
|
||||
INSERT (DEF_STYLE_KEYWORD,
|
||||
NULL, NULL, FALSE, TRUE, FALSE, FALSE,
|
||||
MOO_TEXT_STYLE_BOLD);
|
||||
|
||||
INSERT (DEF_STYLE_DATA_TYPE,
|
||||
"#800000", NULL, FALSE, FALSE, FALSE, FALSE,
|
||||
MOO_TEXT_STYLE_FOREGROUND);
|
||||
|
||||
INSERT (DEF_STYLE_DECIMAL,
|
||||
"#0000FF", NULL, FALSE, FALSE, FALSE, FALSE,
|
||||
MOO_TEXT_STYLE_FOREGROUND);
|
||||
|
||||
INSERT (DEF_STYLE_FLOAT,
|
||||
"#800080", NULL, FALSE, FALSE, FALSE, FALSE,
|
||||
MOO_TEXT_STYLE_FOREGROUND);
|
||||
|
||||
INSERT (DEF_STYLE_CHAR,
|
||||
"#FF00FF", NULL, FALSE, FALSE, FALSE, FALSE,
|
||||
MOO_TEXT_STYLE_FOREGROUND);
|
||||
|
||||
INSERT (DEF_STYLE_ALERT,
|
||||
"#FFFFFF", "#FFCCCC", FALSE, TRUE, FALSE, FALSE,
|
||||
MOO_TEXT_STYLE_FOREGROUND | MOO_TEXT_STYLE_BACKGROUND |
|
||||
MOO_TEXT_STYLE_BOLD | MOO_TEXT_STYLE_ITALIC);
|
||||
|
||||
INSERT (DEF_STYLE_FUNCTION,
|
||||
"#000080", NULL, FALSE, FALSE, FALSE, FALSE,
|
||||
MOO_TEXT_STYLE_FOREGROUND);
|
||||
|
||||
INSERT (DEF_STYLE_ERROR,
|
||||
"#FF0000", NULL, FALSE, FALSE, TRUE, FALSE,
|
||||
MOO_TEXT_STYLE_FOREGROUND | MOO_TEXT_STYLE_UNDERLINE);
|
||||
|
||||
INSERT (DEF_STYLE_OTHERS,
|
||||
"#008000", NULL, FALSE, FALSE, FALSE, FALSE,
|
||||
MOO_TEXT_STYLE_FOREGROUND);
|
||||
}
|
||||
#undef INSERT
|
||||
|
||||
|
||||
void
|
||||
_moo_text_style_scheme_apply (MooTextStyleScheme *scheme,
|
||||
gpointer view)
|
||||
{
|
||||
GdkColor color;
|
||||
GdkColor *color_ptr;
|
||||
MooTextBuffer *buffer;
|
||||
|
||||
g_return_if_fail (scheme != NULL);
|
||||
g_return_if_fail (MOO_IS_TEXT_VIEW (view));
|
||||
|
||||
buffer = MOO_TEXT_BUFFER (gtk_text_view_get_buffer (view));
|
||||
|
||||
gtk_widget_ensure_style (view);
|
||||
|
||||
color_ptr = NULL;
|
||||
if (scheme->foreground)
|
||||
{
|
||||
if (gdk_color_parse (scheme->foreground, &color))
|
||||
color_ptr = &color;
|
||||
else
|
||||
g_warning ("%s: could not parse color '%s'", G_STRLOC, scheme->foreground);
|
||||
}
|
||||
gtk_widget_modify_text (view, GTK_STATE_NORMAL, color_ptr);
|
||||
gtk_widget_modify_text (view, GTK_STATE_ACTIVE, color_ptr);
|
||||
gtk_widget_modify_text (view, GTK_STATE_PRELIGHT, color_ptr);
|
||||
gtk_widget_modify_text (view, GTK_STATE_INSENSITIVE, color_ptr);
|
||||
moo_text_view_set_cursor_color (view, color_ptr);
|
||||
|
||||
color_ptr = NULL;
|
||||
if (scheme->background)
|
||||
{
|
||||
if (gdk_color_parse (scheme->background, &color))
|
||||
color_ptr = &color;
|
||||
else
|
||||
g_warning ("%s: could not parse color '%s'", G_STRLOC, scheme->background);
|
||||
}
|
||||
gtk_widget_modify_base (view, GTK_STATE_NORMAL, color_ptr);
|
||||
gtk_widget_modify_base (view, GTK_STATE_ACTIVE, color_ptr);
|
||||
gtk_widget_modify_base (view, GTK_STATE_PRELIGHT, color_ptr);
|
||||
gtk_widget_modify_base (view, GTK_STATE_INSENSITIVE, color_ptr);
|
||||
|
||||
color_ptr = NULL;
|
||||
if (scheme->selected_foreground)
|
||||
{
|
||||
if (gdk_color_parse (scheme->selected_foreground, &color))
|
||||
color_ptr = &color;
|
||||
else
|
||||
g_warning ("%s: could not parse color '%s'", G_STRLOC, scheme->selected_foreground);
|
||||
}
|
||||
gtk_widget_modify_text (view, GTK_STATE_SELECTED, color_ptr);
|
||||
|
||||
color_ptr = NULL;
|
||||
if (scheme->selected_background)
|
||||
{
|
||||
if (gdk_color_parse (scheme->selected_background, &color))
|
||||
color_ptr = &color;
|
||||
else
|
||||
g_warning ("%s: could not parse color '%s'", G_STRLOC, scheme->selected_background);
|
||||
}
|
||||
gtk_widget_modify_base (view, GTK_STATE_SELECTED, color_ptr);
|
||||
|
||||
color_ptr = NULL;
|
||||
if (scheme->current_line)
|
||||
{
|
||||
if (gdk_color_parse (scheme->current_line, &color))
|
||||
color_ptr = &color;
|
||||
else
|
||||
g_warning ("%s: could not parse color '%s'", G_STRLOC, scheme->current_line);
|
||||
}
|
||||
moo_text_view_set_current_line_color (view, color_ptr);
|
||||
moo_text_view_set_highlight_current_line (view, color_ptr != NULL);
|
||||
|
||||
moo_text_buffer_set_bracket_match_style (buffer, scheme->bracket_match);
|
||||
moo_text_buffer_set_bracket_mismatch_style (buffer, scheme->bracket_mismatch);
|
||||
}
|
||||
|
@ -21,11 +21,9 @@ G_BEGIN_DECLS
|
||||
|
||||
#define MOO_TYPE_TEXT_STYLE (moo_text_style_get_type ())
|
||||
#define MOO_TYPE_TEXT_STYLE_MASK (moo_text_style_mask_get_type ())
|
||||
#define MOO_TYPE_TEXT_STYLE_SCHEME (moo_text_style_scheme_get_type ())
|
||||
|
||||
typedef struct _MooTextStyle MooTextStyle;
|
||||
typedef struct _MooTextStyleArray MooTextStyleArray;
|
||||
typedef struct _MooTextStyleScheme MooTextStyleScheme;
|
||||
|
||||
typedef enum {
|
||||
MOO_TEXT_STYLE_FOREGROUND = 1 << 0,
|
||||
@ -53,24 +51,9 @@ struct _MooTextStyleArray {
|
||||
guint len;
|
||||
};
|
||||
|
||||
struct _MooTextStyleScheme {
|
||||
char *name;
|
||||
char *foreground;
|
||||
char *background;
|
||||
char *selected_foreground;
|
||||
char *selected_background;
|
||||
char *current_line;
|
||||
MooTextStyle *bracket_match;
|
||||
MooTextStyle *bracket_mismatch;
|
||||
GHashTable *styles; /* char* -> MooTextStyle* */
|
||||
guint ref_count;
|
||||
guint use_theme_colors : 1;
|
||||
};
|
||||
|
||||
|
||||
GType moo_text_style_get_type (void) G_GNUC_CONST;
|
||||
GType moo_text_style_mask_get_type (void) G_GNUC_CONST;
|
||||
GType moo_text_style_scheme_get_type (void) G_GNUC_CONST;
|
||||
|
||||
MooTextStyle *moo_text_style_new (const char *default_style,
|
||||
const GdkColor *foreground,
|
||||
@ -88,27 +71,6 @@ void moo_text_style_compose (MooTextStyle *dest,
|
||||
const MooTextStyle *src);
|
||||
void moo_text_style_free (MooTextStyle *style);
|
||||
|
||||
MooTextStyleScheme *moo_text_style_scheme_new_empty (const char *name);
|
||||
MooTextStyleScheme *moo_text_style_scheme_new_default (void);
|
||||
MooTextStyleScheme *moo_text_style_scheme_copy (MooTextStyleScheme *scheme);
|
||||
MooTextStyleScheme *moo_text_style_scheme_ref (MooTextStyleScheme *scheme);
|
||||
void moo_text_style_scheme_unref (MooTextStyleScheme *scheme);
|
||||
|
||||
void moo_text_style_scheme_compose (MooTextStyleScheme *scheme,
|
||||
const char *language_name,
|
||||
const char *style_name,
|
||||
const MooTextStyle *style);
|
||||
void moo_text_style_scheme_set (MooTextStyleScheme *scheme,
|
||||
const char *language_name,
|
||||
const char *style_name,
|
||||
const MooTextStyle *style);
|
||||
const MooTextStyle *moo_text_style_scheme_get (MooTextStyleScheme *scheme,
|
||||
const char *language_name,
|
||||
const char *style_name);
|
||||
|
||||
void _moo_text_style_scheme_apply (MooTextStyleScheme *scheme,
|
||||
gpointer view);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
424
moo/mooedit/mootextstylescheme.c
Normal file
424
moo/mooedit/mootextstylescheme.c
Normal file
@ -0,0 +1,424 @@
|
||||
/*
|
||||
* mootextstylescheme.c
|
||||
*
|
||||
* Copyright (C) 2004-2005 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/mootextstylescheme.h"
|
||||
#include "mooedit/moolang-strings.h"
|
||||
#include "mooedit/mootextview.h"
|
||||
#include "mooedit/mootextbuffer.h"
|
||||
#include "mooutils/moomarshals.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
static void moo_text_style_scheme_finalize (GObject *object);
|
||||
static void fill_in_default_scheme (MooTextStyleScheme *scheme);
|
||||
|
||||
|
||||
/* MOO_TYPE_TEXT_STYLE_SCHEME */
|
||||
G_DEFINE_TYPE (MooTextStyleScheme, moo_text_style_scheme, G_TYPE_OBJECT)
|
||||
|
||||
enum {
|
||||
CHANGED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static guint signals[LAST_SIGNAL];
|
||||
|
||||
static void
|
||||
moo_text_style_scheme_class_init (MooTextStyleSchemeClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
gobject_class->finalize = moo_text_style_scheme_finalize;
|
||||
|
||||
signals[CHANGED] =
|
||||
g_signal_new ("changed",
|
||||
G_OBJECT_CLASS_TYPE (klass),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (MooTextStyleSchemeClass, changed),
|
||||
NULL, NULL,
|
||||
_moo_marshal_VOID__VOID,
|
||||
G_TYPE_NONE,0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
moo_text_style_scheme_init (MooTextStyleScheme *scheme)
|
||||
{
|
||||
scheme->base_scheme = NULL;
|
||||
scheme->name = NULL;
|
||||
memset (scheme->text_colors, 0, MOO_TEXT_NUM_COLORS * sizeof(char*));
|
||||
scheme->bracket_match = NULL;
|
||||
scheme->bracket_mismatch = NULL;
|
||||
scheme->styles = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
g_free,
|
||||
(GDestroyNotify) moo_text_style_free);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
moo_text_style_scheme_finalize (GObject *object)
|
||||
{
|
||||
guint i;
|
||||
MooTextStyleScheme *scheme = MOO_TEXT_STYLE_SCHEME (object);
|
||||
|
||||
if (scheme->base_scheme)
|
||||
g_object_unref (scheme->base_scheme);
|
||||
|
||||
g_free (scheme->name);
|
||||
|
||||
for (i = 0; i < MOO_TEXT_NUM_COLORS; ++i)
|
||||
g_free (scheme->text_colors[i]);
|
||||
|
||||
g_hash_table_destroy (scheme->styles);
|
||||
moo_text_style_free (scheme->bracket_match);
|
||||
moo_text_style_free (scheme->bracket_mismatch);
|
||||
|
||||
G_OBJECT_CLASS(moo_text_style_scheme_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
|
||||
MooTextStyleScheme*
|
||||
moo_text_style_scheme_new_empty (const char *name,
|
||||
MooTextStyleScheme *base)
|
||||
{
|
||||
MooTextStyleScheme *scheme;
|
||||
|
||||
g_return_val_if_fail (name && name[0], NULL);
|
||||
|
||||
scheme = g_object_new (MOO_TYPE_TEXT_STYLE_SCHEME, NULL);
|
||||
|
||||
scheme->base_scheme = base ? g_object_ref (base) : NULL;
|
||||
scheme->name = g_strdup (name);
|
||||
|
||||
return scheme;
|
||||
}
|
||||
|
||||
|
||||
MooTextStyleScheme*
|
||||
moo_text_style_scheme_new_default (void)
|
||||
{
|
||||
MooTextStyleScheme *scheme;
|
||||
scheme = moo_text_style_scheme_new_empty (SCHEME_DEFAULT, NULL);
|
||||
fill_in_default_scheme (scheme);
|
||||
return scheme;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
copy_style (const char *style_name,
|
||||
const MooTextStyle *style,
|
||||
GHashTable *dest)
|
||||
{
|
||||
g_hash_table_insert (dest, g_strdup (style_name),
|
||||
moo_text_style_copy (style));
|
||||
}
|
||||
|
||||
MooTextStyleScheme*
|
||||
moo_text_style_scheme_copy (MooTextStyleScheme *scheme)
|
||||
{
|
||||
MooTextStyleScheme *copy;
|
||||
guint i;
|
||||
|
||||
g_return_val_if_fail (scheme != NULL, NULL);
|
||||
|
||||
copy = moo_text_style_scheme_new_empty (scheme->name, scheme->base_scheme);
|
||||
|
||||
for (i = 0; i < MOO_TEXT_NUM_COLORS; ++i)
|
||||
copy->text_colors[i] = g_strdup (scheme->text_colors[i]);
|
||||
|
||||
copy->bracket_match = moo_text_style_copy (scheme->bracket_match);
|
||||
copy->bracket_mismatch = moo_text_style_copy (scheme->bracket_mismatch);
|
||||
|
||||
g_hash_table_foreach (scheme->styles, (GHFunc) copy_style, scheme->styles);
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
moo_text_style_scheme_compose (MooTextStyleScheme *scheme,
|
||||
const char *language_name,
|
||||
const char *style_name,
|
||||
const MooTextStyle *style)
|
||||
{
|
||||
const char *key;
|
||||
char *freeme = NULL;
|
||||
MooTextStyle *old_style;
|
||||
|
||||
g_return_if_fail (scheme != NULL);
|
||||
g_return_if_fail (style_name != NULL && style != NULL);
|
||||
|
||||
if (language_name)
|
||||
{
|
||||
freeme = g_strdup_printf ("%s::%s", language_name, style_name);
|
||||
key = freeme;
|
||||
}
|
||||
else
|
||||
{
|
||||
key = style_name;
|
||||
}
|
||||
|
||||
old_style = g_hash_table_lookup (scheme->styles, key);
|
||||
|
||||
if (old_style)
|
||||
moo_text_style_compose (old_style, style);
|
||||
else
|
||||
g_hash_table_insert (scheme->styles, g_strdup (key),
|
||||
moo_text_style_copy (style));
|
||||
|
||||
g_free (freeme);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
moo_text_style_scheme_set (MooTextStyleScheme *scheme,
|
||||
const char *language_name,
|
||||
const char *style_name,
|
||||
const MooTextStyle *style)
|
||||
{
|
||||
const char *key;
|
||||
char *freeme = NULL;
|
||||
|
||||
g_return_if_fail (scheme != NULL);
|
||||
g_return_if_fail (style_name != NULL && style != NULL);
|
||||
|
||||
if (language_name)
|
||||
{
|
||||
freeme = g_strdup_printf ("%s::%s", language_name, style_name);
|
||||
key = freeme;
|
||||
}
|
||||
else
|
||||
{
|
||||
key = style_name;
|
||||
}
|
||||
|
||||
g_hash_table_insert (scheme->styles, g_strdup (key),
|
||||
moo_text_style_copy (style));
|
||||
|
||||
g_free (freeme);
|
||||
}
|
||||
|
||||
|
||||
const MooTextStyle*
|
||||
moo_text_style_scheme_get (MooTextStyleScheme *scheme,
|
||||
const char *language_name,
|
||||
const char *style_name)
|
||||
{
|
||||
const MooTextStyle *style;
|
||||
const char *key;
|
||||
char *freeme = NULL;
|
||||
|
||||
g_return_val_if_fail (scheme != NULL, NULL);
|
||||
g_return_val_if_fail (style_name != NULL, NULL);
|
||||
|
||||
if (language_name)
|
||||
{
|
||||
freeme = g_strdup_printf ("%s::%s", language_name, style_name);
|
||||
key = freeme;
|
||||
}
|
||||
else
|
||||
{
|
||||
key = style_name;
|
||||
}
|
||||
|
||||
style = g_hash_table_lookup (scheme->styles, key);
|
||||
|
||||
g_free (freeme);
|
||||
return style;
|
||||
}
|
||||
|
||||
|
||||
static MooTextStyle*
|
||||
new_style (const char *fg,
|
||||
const char *bg,
|
||||
gboolean italic,
|
||||
gboolean bold,
|
||||
gboolean underline,
|
||||
gboolean strikethrough,
|
||||
MooTextStyleMask mask)
|
||||
{
|
||||
GdkColor foreground, background;
|
||||
|
||||
if (mask & MOO_TEXT_STYLE_FOREGROUND)
|
||||
{
|
||||
if (!gdk_color_parse (fg, &foreground))
|
||||
{
|
||||
g_warning ("could not parse color %s", fg);
|
||||
mask = mask & ~MOO_TEXT_STYLE_FOREGROUND;
|
||||
}
|
||||
}
|
||||
|
||||
if (mask & MOO_TEXT_STYLE_BACKGROUND)
|
||||
{
|
||||
if (!gdk_color_parse (bg, &background))
|
||||
{
|
||||
g_warning ("could not parse color %s", bg);
|
||||
mask = mask & ~MOO_TEXT_STYLE_BACKGROUND;
|
||||
}
|
||||
}
|
||||
|
||||
return moo_text_style_new (NULL, &foreground, &background,
|
||||
bold, italic, underline, strikethrough,
|
||||
mask, FALSE);
|
||||
}
|
||||
|
||||
|
||||
#define INSERT(name_,fg_,bg_,italic_,bold_,underline_,strikethrough_,mask_) \
|
||||
g_hash_table_insert (scheme->styles, g_strdup (name_), \
|
||||
new_style (fg_, bg_, italic_, bold_, \
|
||||
underline_, strikethrough_, mask_))
|
||||
|
||||
static void
|
||||
fill_in_default_scheme (MooTextStyleScheme *scheme)
|
||||
{
|
||||
scheme->text_colors[MOO_TEXT_COLOR_CUR_LINE] = g_strdup ("#EEF6FF");
|
||||
scheme->bracket_match = new_style (NULL, "#FFFF99", FALSE,
|
||||
FALSE, FALSE, FALSE,
|
||||
MOO_TEXT_STYLE_BACKGROUND);
|
||||
|
||||
INSERT (DEF_STYLE_NORMAL,
|
||||
NULL, NULL, FALSE, FALSE, FALSE, FALSE, 0);
|
||||
|
||||
INSERT (DEF_STYLE_PREPROCESSOR,
|
||||
"#008000", NULL, FALSE, FALSE, FALSE, FALSE,
|
||||
MOO_TEXT_STYLE_FOREGROUND);
|
||||
|
||||
INSERT (DEF_STYLE_STRING,
|
||||
"#DD0000", NULL, FALSE, FALSE, FALSE, FALSE,
|
||||
MOO_TEXT_STYLE_FOREGROUND);
|
||||
|
||||
INSERT (DEF_STYLE_COMMENT,
|
||||
"#808080", NULL, TRUE, FALSE, FALSE, FALSE,
|
||||
MOO_TEXT_STYLE_FOREGROUND | MOO_TEXT_STYLE_ITALIC);
|
||||
|
||||
INSERT (DEF_STYLE_BASE_N,
|
||||
"#008080", NULL, FALSE, FALSE, FALSE, FALSE,
|
||||
MOO_TEXT_STYLE_FOREGROUND);
|
||||
|
||||
INSERT (DEF_STYLE_KEYWORD,
|
||||
NULL, NULL, FALSE, TRUE, FALSE, FALSE,
|
||||
MOO_TEXT_STYLE_BOLD);
|
||||
|
||||
INSERT (DEF_STYLE_DATA_TYPE,
|
||||
"#800000", NULL, FALSE, FALSE, FALSE, FALSE,
|
||||
MOO_TEXT_STYLE_FOREGROUND);
|
||||
|
||||
INSERT (DEF_STYLE_DECIMAL,
|
||||
"#0000FF", NULL, FALSE, FALSE, FALSE, FALSE,
|
||||
MOO_TEXT_STYLE_FOREGROUND);
|
||||
|
||||
INSERT (DEF_STYLE_FLOAT,
|
||||
"#800080", NULL, FALSE, FALSE, FALSE, FALSE,
|
||||
MOO_TEXT_STYLE_FOREGROUND);
|
||||
|
||||
INSERT (DEF_STYLE_CHAR,
|
||||
"#FF00FF", NULL, FALSE, FALSE, FALSE, FALSE,
|
||||
MOO_TEXT_STYLE_FOREGROUND);
|
||||
|
||||
INSERT (DEF_STYLE_ALERT,
|
||||
"#FFFFFF", "#FFCCCC", FALSE, TRUE, FALSE, FALSE,
|
||||
MOO_TEXT_STYLE_FOREGROUND | MOO_TEXT_STYLE_BACKGROUND |
|
||||
MOO_TEXT_STYLE_BOLD | MOO_TEXT_STYLE_ITALIC);
|
||||
|
||||
INSERT (DEF_STYLE_FUNCTION,
|
||||
"#000080", NULL, FALSE, FALSE, FALSE, FALSE,
|
||||
MOO_TEXT_STYLE_FOREGROUND);
|
||||
|
||||
INSERT (DEF_STYLE_ERROR,
|
||||
"#FF0000", NULL, FALSE, FALSE, TRUE, FALSE,
|
||||
MOO_TEXT_STYLE_FOREGROUND | MOO_TEXT_STYLE_UNDERLINE);
|
||||
|
||||
INSERT (DEF_STYLE_OTHERS,
|
||||
"#008000", NULL, FALSE, FALSE, FALSE, FALSE,
|
||||
MOO_TEXT_STYLE_FOREGROUND);
|
||||
}
|
||||
#undef INSERT
|
||||
|
||||
|
||||
void
|
||||
_moo_text_style_scheme_get_color (MooTextStyleScheme *scheme,
|
||||
MooTextColor color,
|
||||
GdkColor *dest,
|
||||
GdkScreen *screen)
|
||||
{
|
||||
GtkSettings *settings;
|
||||
GtkStyle *style;
|
||||
|
||||
g_return_if_fail (scheme != NULL);
|
||||
g_return_if_fail (dest != NULL);
|
||||
g_return_if_fail (GDK_IS_SCREEN (screen));
|
||||
g_return_if_fail (color < MOO_TEXT_NUM_COLORS);
|
||||
|
||||
if (scheme->text_colors[color])
|
||||
{
|
||||
if (gdk_color_parse (scheme->text_colors[color], dest))
|
||||
return;
|
||||
else
|
||||
g_warning ("%s: could not parse color '%s'", G_STRLOC,
|
||||
scheme->text_colors[color]);
|
||||
}
|
||||
|
||||
settings = gtk_settings_get_for_screen (screen);
|
||||
|
||||
style = gtk_rc_get_style_by_paths (settings, NULL, NULL, MOO_TYPE_TEXT_VIEW);
|
||||
|
||||
if (!style)
|
||||
style = gtk_style_new ();
|
||||
else
|
||||
g_object_ref (style);
|
||||
|
||||
switch (color)
|
||||
{
|
||||
case MOO_TEXT_COLOR_FG:
|
||||
*dest = style->text[GTK_STATE_NORMAL];
|
||||
break;
|
||||
|
||||
case MOO_TEXT_COLOR_BG:
|
||||
case MOO_TEXT_COLOR_CUR_LINE:
|
||||
*dest = style->base[GTK_STATE_NORMAL];
|
||||
break;
|
||||
|
||||
case MOO_TEXT_COLOR_SEL_FG:
|
||||
*dest = style->text[GTK_STATE_SELECTED];
|
||||
break;
|
||||
|
||||
case MOO_TEXT_COLOR_SEL_BG:
|
||||
*dest = style->base[GTK_STATE_SELECTED];
|
||||
break;
|
||||
|
||||
case MOO_TEXT_NUM_COLORS:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
g_object_unref (style);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
prepend_default_style (const char *style_name,
|
||||
G_GNUC_UNUSED gpointer whatever,
|
||||
GSList **list)
|
||||
{
|
||||
if (!strstr (style_name, "::"))
|
||||
*list = g_slist_prepend (*list, g_strdup (style_name));
|
||||
}
|
||||
|
||||
GSList*
|
||||
moo_text_style_scheme_list_default (MooTextStyleScheme *scheme)
|
||||
{
|
||||
GSList *list = NULL;
|
||||
g_return_val_if_fail (MOO_IS_TEXT_STYLE_SCHEME (scheme), NULL);
|
||||
g_hash_table_foreach (scheme->styles, (GHFunc) prepend_default_style, &list);
|
||||
return g_slist_reverse (list);
|
||||
}
|
92
moo/mooedit/mootextstylescheme.h
Normal file
92
moo/mooedit/mootextstylescheme.h
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* mootextstylescheme.h
|
||||
*
|
||||
* Copyright (C) 2004-2005 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_TEXT_STYLE_SCHEME_H__
|
||||
#define __MOO_TEXT_STYLE_SCHEME_H__
|
||||
|
||||
#include <mooedit/mootextstyle.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
#define MOO_TYPE_TEXT_STYLE_SCHEME (moo_text_style_scheme_get_type ())
|
||||
#define MOO_TEXT_STYLE_SCHEME(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), MOO_TYPE_TEXT_STYLE_SCHEME, MooTextStyleScheme))
|
||||
#define MOO_TEXT_STYLE_SCHEME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MOO_TYPE_TEXT_STYLE_SCHEME, MooTextStyleSchemeClass))
|
||||
#define MOO_IS_TEXT_STYLE_SCHEME(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), MOO_TYPE_TEXT_STYLE_SCHEME))
|
||||
#define MOO_IS_TEXT_STYLE_SCHEME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MOO_TYPE_TEXT_STYLE_SCHEME))
|
||||
#define MOO_TEXT_STYLE_SCHEME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOO_TYPE_TEXT_STYLE_SCHEME, MooTextStyleSchemeClass))
|
||||
|
||||
typedef struct _MooTextStyleScheme MooTextStyleScheme;
|
||||
typedef struct _MooTextStyleSchemeClass MooTextStyleSchemeClass;
|
||||
|
||||
typedef enum {
|
||||
MOO_TEXT_COLOR_FG = 0,
|
||||
MOO_TEXT_COLOR_BG,
|
||||
MOO_TEXT_COLOR_SEL_FG,
|
||||
MOO_TEXT_COLOR_SEL_BG,
|
||||
MOO_TEXT_COLOR_CUR_LINE,
|
||||
MOO_TEXT_NUM_COLORS
|
||||
} MooTextColor;
|
||||
|
||||
|
||||
struct _MooTextStyleScheme
|
||||
{
|
||||
GObject parent;
|
||||
|
||||
MooTextStyleScheme *base_scheme;
|
||||
char *name;
|
||||
char *text_colors[MOO_TEXT_NUM_COLORS];
|
||||
MooTextStyle *bracket_match;
|
||||
MooTextStyle *bracket_mismatch;
|
||||
GHashTable *styles; /* char* -> MooTextStyle* */
|
||||
};
|
||||
|
||||
struct _MooTextStyleSchemeClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
void (*changed) (MooTextStyleScheme *scheme);
|
||||
};
|
||||
|
||||
|
||||
GType moo_text_style_scheme_get_type (void) G_GNUC_CONST;
|
||||
|
||||
MooTextStyleScheme *moo_text_style_scheme_new_empty (const char *name,
|
||||
MooTextStyleScheme *base);
|
||||
MooTextStyleScheme *moo_text_style_scheme_new_default (void);
|
||||
|
||||
MooTextStyleScheme *moo_text_style_scheme_copy (MooTextStyleScheme *scheme);
|
||||
|
||||
GSList *moo_text_style_scheme_list_default (MooTextStyleScheme *scheme);
|
||||
|
||||
void moo_text_style_scheme_compose (MooTextStyleScheme *scheme,
|
||||
const char *language_name,
|
||||
const char *style_name,
|
||||
const MooTextStyle *style);
|
||||
void moo_text_style_scheme_set (MooTextStyleScheme *scheme,
|
||||
const char *language_name,
|
||||
const char *style_name,
|
||||
const MooTextStyle *style);
|
||||
const MooTextStyle *moo_text_style_scheme_get (MooTextStyleScheme *scheme,
|
||||
const char *language_name,
|
||||
const char *style_name);
|
||||
|
||||
void _moo_text_style_scheme_get_color (MooTextStyleScheme *scheme,
|
||||
MooTextColor color,
|
||||
GdkColor *dest,
|
||||
GdkScreen *screen);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MOO_TEXT_STYLE_SCHEME_H__ */
|
@ -1168,8 +1168,9 @@ moo_text_view_expose (GtkWidget *widget,
|
||||
GtkTextIter start, end;
|
||||
int first_line, last_line;
|
||||
|
||||
if (view->priv->highlight_current_line && event->window == text_window)
|
||||
moo_text_view_draw_current_line (text_view, event);
|
||||
if (view->priv->highlight_current_line &&
|
||||
event->window == text_window && view->priv->current_line_gc)
|
||||
moo_text_view_draw_current_line (text_view, event);
|
||||
|
||||
if (event->window == text_window)
|
||||
{
|
||||
@ -1268,3 +1269,95 @@ moo_text_view_set_cursor_color (MooTextView *view,
|
||||
|
||||
g_free (rc_string);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
moo_text_view_set_lang (MooTextView *view,
|
||||
MooLang *lang)
|
||||
{
|
||||
g_return_if_fail (MOO_IS_TEXT_VIEW (view));
|
||||
moo_text_buffer_set_lang (get_moo_buffer (view), lang);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
moo_text_view_apply_scheme (MooTextView *view,
|
||||
MooTextStyleScheme *scheme)
|
||||
{
|
||||
GdkColor color;
|
||||
GdkColor *color_ptr;
|
||||
MooTextBuffer *buffer;
|
||||
GtkWidget *widget;
|
||||
|
||||
g_return_if_fail (scheme != NULL);
|
||||
g_return_if_fail (MOO_IS_TEXT_VIEW (view));
|
||||
|
||||
widget = GTK_WIDGET (view);
|
||||
buffer = get_moo_buffer (view);
|
||||
gtk_widget_ensure_style (widget);
|
||||
|
||||
color_ptr = NULL;
|
||||
if (scheme->text_colors[MOO_TEXT_COLOR_FG])
|
||||
{
|
||||
if (gdk_color_parse (scheme->text_colors[MOO_TEXT_COLOR_FG], &color))
|
||||
color_ptr = &color;
|
||||
else
|
||||
g_warning ("%s: could not parse color '%s'", G_STRLOC,
|
||||
scheme->text_colors[MOO_TEXT_COLOR_FG]);
|
||||
}
|
||||
gtk_widget_modify_text (widget, GTK_STATE_NORMAL, color_ptr);
|
||||
gtk_widget_modify_text (widget, GTK_STATE_ACTIVE, color_ptr);
|
||||
gtk_widget_modify_text (widget, GTK_STATE_PRELIGHT, color_ptr);
|
||||
gtk_widget_modify_text (widget, GTK_STATE_INSENSITIVE, color_ptr);
|
||||
moo_text_view_set_cursor_color (view, color_ptr);
|
||||
|
||||
color_ptr = NULL;
|
||||
if (scheme->text_colors[MOO_TEXT_COLOR_BG])
|
||||
{
|
||||
if (gdk_color_parse (scheme->text_colors[MOO_TEXT_COLOR_BG], &color))
|
||||
color_ptr = &color;
|
||||
else
|
||||
g_warning ("%s: could not parse color '%s'", G_STRLOC,
|
||||
scheme->text_colors[MOO_TEXT_COLOR_BG]);
|
||||
}
|
||||
gtk_widget_modify_base (widget, GTK_STATE_NORMAL, color_ptr);
|
||||
gtk_widget_modify_base (widget, GTK_STATE_ACTIVE, color_ptr);
|
||||
gtk_widget_modify_base (widget, GTK_STATE_PRELIGHT, color_ptr);
|
||||
gtk_widget_modify_base (widget, GTK_STATE_INSENSITIVE, color_ptr);
|
||||
|
||||
color_ptr = NULL;
|
||||
if (scheme->text_colors[MOO_TEXT_COLOR_SEL_FG])
|
||||
{
|
||||
if (gdk_color_parse (scheme->text_colors[MOO_TEXT_COLOR_SEL_FG], &color))
|
||||
color_ptr = &color;
|
||||
else
|
||||
g_warning ("%s: could not parse color '%s'", G_STRLOC,
|
||||
scheme->text_colors[MOO_TEXT_COLOR_SEL_FG]);
|
||||
}
|
||||
gtk_widget_modify_text (widget, GTK_STATE_SELECTED, color_ptr);
|
||||
|
||||
color_ptr = NULL;
|
||||
if (scheme->text_colors[MOO_TEXT_COLOR_SEL_BG])
|
||||
{
|
||||
if (gdk_color_parse (scheme->text_colors[MOO_TEXT_COLOR_SEL_BG], &color))
|
||||
color_ptr = &color;
|
||||
else
|
||||
g_warning ("%s: could not parse color '%s'", G_STRLOC,
|
||||
scheme->text_colors[MOO_TEXT_COLOR_SEL_BG]);
|
||||
}
|
||||
gtk_widget_modify_base (widget, GTK_STATE_SELECTED, color_ptr);
|
||||
|
||||
color_ptr = NULL;
|
||||
if (scheme->text_colors[MOO_TEXT_COLOR_CUR_LINE])
|
||||
{
|
||||
if (gdk_color_parse (scheme->text_colors[MOO_TEXT_COLOR_CUR_LINE], &color))
|
||||
color_ptr = &color;
|
||||
else
|
||||
g_warning ("%s: could not parse color '%s'", G_STRLOC,
|
||||
scheme->text_colors[MOO_TEXT_COLOR_CUR_LINE]);
|
||||
}
|
||||
moo_text_view_set_current_line_color (view, color_ptr);
|
||||
moo_text_view_set_highlight_current_line (view, color_ptr != NULL);
|
||||
|
||||
moo_text_buffer_apply_scheme (buffer, scheme);
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include <gtk/gtktextview.h>
|
||||
#include <mooedit/mooindenter.h>
|
||||
#include <mooedit/moolang.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@ -83,55 +84,60 @@ GType moo_text_selection_type_get_type (void) G_GNUC_CONST;
|
||||
|
||||
MooTextView *moo_text_view_new (void);
|
||||
|
||||
void moo_text_view_select_all (MooTextView *view);
|
||||
void moo_text_view_select_all (MooTextView *view);
|
||||
|
||||
gboolean moo_text_view_is_empty (MooTextView *view);
|
||||
gboolean moo_text_view_is_empty (MooTextView *view);
|
||||
|
||||
char *moo_text_view_get_selection (MooTextView *view);
|
||||
char *moo_text_view_get_text (MooTextView *view);
|
||||
gboolean moo_text_view_has_selection (MooTextView *view);
|
||||
gboolean moo_text_view_has_text (MooTextView *view);
|
||||
char *moo_text_view_get_selection (MooTextView *view);
|
||||
char *moo_text_view_get_text (MooTextView *view);
|
||||
gboolean moo_text_view_has_selection (MooTextView *view);
|
||||
gboolean moo_text_view_has_text (MooTextView *view);
|
||||
|
||||
void moo_text_view_delete_selection (MooTextView *view);
|
||||
void moo_text_view_delete_selection (MooTextView *view);
|
||||
|
||||
gboolean moo_text_view_can_redo (MooTextView *view);
|
||||
gboolean moo_text_view_can_undo (MooTextView *view);
|
||||
void moo_text_view_redo (MooTextView *view);
|
||||
void moo_text_view_undo (MooTextView *view);
|
||||
void moo_text_view_start_not_undoable_action(MooTextView *view);
|
||||
void moo_text_view_end_not_undoable_action (MooTextView *view);
|
||||
gboolean moo_text_view_can_redo (MooTextView *view);
|
||||
gboolean moo_text_view_can_undo (MooTextView *view);
|
||||
void moo_text_view_redo (MooTextView *view);
|
||||
void moo_text_view_undo (MooTextView *view);
|
||||
void moo_text_view_start_not_undoable_action(MooTextView *view);
|
||||
void moo_text_view_end_not_undoable_action (MooTextView *view);
|
||||
|
||||
void moo_text_view_find_interactive (MooTextView *view);
|
||||
void moo_text_view_replace_interactive (MooTextView *view);
|
||||
void moo_text_view_find_next_interactive (MooTextView *view);
|
||||
void moo_text_view_find_prev_interactive (MooTextView *view);
|
||||
void moo_text_view_goto_line (MooTextView *view,
|
||||
int line);
|
||||
void moo_text_view_find_interactive (MooTextView *view);
|
||||
void moo_text_view_replace_interactive (MooTextView *view);
|
||||
void moo_text_view_find_next_interactive (MooTextView *view);
|
||||
void moo_text_view_find_prev_interactive (MooTextView *view);
|
||||
void moo_text_view_goto_line (MooTextView *view,
|
||||
int line);
|
||||
|
||||
void moo_text_view_set_font_from_string (MooTextView *view,
|
||||
const char *font);
|
||||
void moo_text_view_set_font_from_string (MooTextView *view,
|
||||
const char *font);
|
||||
|
||||
MooIndenter *moo_text_view_get_indenter (MooTextView *view);
|
||||
void moo_text_view_set_indenter (MooTextView *view,
|
||||
MooIndenter *indenter);
|
||||
MooIndenter *moo_text_view_get_indenter (MooTextView *view);
|
||||
void moo_text_view_set_indenter (MooTextView *view,
|
||||
MooIndenter *indenter);
|
||||
|
||||
void moo_text_view_move_cursor (MooTextView *view,
|
||||
int line,
|
||||
int character,
|
||||
gboolean in_idle);
|
||||
void moo_text_view_move_cursor (MooTextView *view,
|
||||
int line,
|
||||
int character,
|
||||
gboolean in_idle);
|
||||
|
||||
void moo_text_view_set_highlight_current_line
|
||||
(MooTextView *view,
|
||||
gboolean highlight);
|
||||
void moo_text_view_set_current_line_color (MooTextView *view,
|
||||
const GdkColor *color);
|
||||
void moo_text_view_set_cursor_color (MooTextView *view,
|
||||
const GdkColor *color);
|
||||
void moo_text_view_set_show_tabs (MooTextView *view,
|
||||
gboolean show);
|
||||
(MooTextView *view,
|
||||
gboolean highlight);
|
||||
void moo_text_view_set_current_line_color (MooTextView *view,
|
||||
const GdkColor *color);
|
||||
void moo_text_view_set_cursor_color (MooTextView *view,
|
||||
const GdkColor *color);
|
||||
void moo_text_view_set_show_tabs (MooTextView *view,
|
||||
gboolean show);
|
||||
void moo_text_view_apply_scheme (MooTextView *view,
|
||||
MooTextStyleScheme *scheme);
|
||||
|
||||
GtkTextTag *moo_text_view_lookup_tag (MooTextView *view,
|
||||
const char *name);
|
||||
GtkTextTag *moo_text_view_lookup_tag (MooTextView *view,
|
||||
const char *name);
|
||||
|
||||
void moo_text_view_set_lang (MooTextView *view,
|
||||
MooLang *lang);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
@ -165,4 +165,17 @@
|
||||
<multi-line start="/*" end="*/"/>
|
||||
</comments>
|
||||
</general>
|
||||
|
||||
<sample-code>/* This is a comment
|
||||
* TODO: do something
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
printf ("Hello world!");
|
||||
return 0;
|
||||
}
|
||||
</sample-code>
|
||||
</language>
|
||||
|
@ -9161,4 +9161,18 @@
|
||||
<single-line start="#"/>
|
||||
</comments>
|
||||
</general>
|
||||
|
||||
<sample-code>## This is a comment
|
||||
## TODO: do something
|
||||
|
||||
InstallGlobalFunction("func",
|
||||
func(arg)
|
||||
local i;
|
||||
|
||||
for i in [1..100] do
|
||||
Print("Hello world!");
|
||||
od;
|
||||
end);
|
||||
</sample-code>
|
||||
|
||||
</language>
|
||||
|
@ -8,7 +8,7 @@
|
||||
<!-- rule_type -->
|
||||
<!ENTITY % rule_type "String|Regex|Char|TwoChars|Range|Keyword">
|
||||
|
||||
<!ELEMENT language (syntax, styles?, general?)>
|
||||
<!ELEMENT language (syntax, styles?, general?, sample-code?)>
|
||||
<!ATTLIST language
|
||||
name CDATA #REQUIRED
|
||||
hidden (%boolean;) #IMPLIED
|
||||
@ -150,3 +150,7 @@
|
||||
underline (%boolean;) #IMPLIED
|
||||
strikethrough (%boolean;) #IMPLIED
|
||||
>
|
||||
|
||||
|
||||
<!-- Sample code -->
|
||||
<!ELEMENT sample-code (#PCDATA)>
|
||||
|
@ -39,6 +39,7 @@ utilsinclude_HEADERS = \
|
||||
eggregex.h \
|
||||
mooaccelbutton.h \
|
||||
moobigpaned.h \
|
||||
moocellrenderercolor.h \
|
||||
mooclosure.h \
|
||||
moocombo.h \
|
||||
mooentry.h \
|
||||
@ -76,6 +77,7 @@ libmooutils_la_SOURCES = \
|
||||
mooaccelbutton.c \
|
||||
mooaccelbutton-glade.h \
|
||||
moobigpaned.c \
|
||||
moocellrenderercolor.c \
|
||||
mooclosure.c \
|
||||
moocombo.c \
|
||||
moocompat.c \
|
||||
|
326
moo/mooutils/moocellrenderercolor.c
Normal file
326
moo/mooutils/moocellrenderercolor.c
Normal file
@ -0,0 +1,326 @@
|
||||
/*
|
||||
* moocellrenderercolor.c
|
||||
*
|
||||
* Copyright (C) 2004-2005 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.
|
||||
*/
|
||||
|
||||
#include "mooutils/moocellrenderercolor.h"
|
||||
#include "mooutils/moomarshals.h"
|
||||
#include <gtk/gtkcolorseldialog.h>
|
||||
|
||||
#define CELL_MIN_WIDTH 20
|
||||
#define CELL_MIN_HEIGHT 12
|
||||
#define CELL_BORDER_WIDTH 1
|
||||
|
||||
|
||||
static void moo_cell_renderer_color_get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void moo_cell_renderer_color_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void moo_cell_renderer_color_get_size (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *rectangle,
|
||||
gint *x_offset,
|
||||
gint *y_offset,
|
||||
gint *width,
|
||||
gint *height);
|
||||
static void moo_cell_renderer_color_render (GtkCellRenderer *cell,
|
||||
GdkDrawable *window,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GdkRectangle *expose_area,
|
||||
GtkCellRendererState flags);
|
||||
static gboolean moo_cell_renderer_color_activate (GtkCellRenderer *cell,
|
||||
GdkEvent *event,
|
||||
GtkWidget *widget,
|
||||
const gchar *path,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GtkCellRendererState flags);
|
||||
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_COLOR,
|
||||
PROP_COLOR_SET,
|
||||
PROP_ACTIVATABLE
|
||||
};
|
||||
|
||||
enum {
|
||||
COLOR_SET,
|
||||
NUM_SIGNALS
|
||||
};
|
||||
|
||||
static guint signals[NUM_SIGNALS];
|
||||
|
||||
G_DEFINE_TYPE (MooCellRendererColor, moo_cell_renderer_color, GTK_TYPE_CELL_RENDERER)
|
||||
|
||||
|
||||
static void
|
||||
moo_cell_renderer_color_class_init (MooCellRendererColorClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (klass);
|
||||
|
||||
object_class->get_property = moo_cell_renderer_color_get_property;
|
||||
object_class->set_property = moo_cell_renderer_color_set_property;
|
||||
|
||||
cell_class->get_size = moo_cell_renderer_color_get_size;
|
||||
cell_class->render = moo_cell_renderer_color_render;
|
||||
cell_class->activate = moo_cell_renderer_color_activate;
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_COLOR,
|
||||
g_param_spec_boxed ("color",
|
||||
"color",
|
||||
"color",
|
||||
GDK_TYPE_COLOR,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_ACTIVATABLE,
|
||||
g_param_spec_boolean ("activatable",
|
||||
"activatable",
|
||||
"activatable",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_COLOR_SET,
|
||||
g_param_spec_boolean ("color-set",
|
||||
"color-set",
|
||||
"color-set",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
signals[COLOR_SET] =
|
||||
g_signal_new ("color-set",
|
||||
G_OBJECT_CLASS_TYPE (klass),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (MooCellRendererColorClass, color_set),
|
||||
NULL, NULL,
|
||||
_moo_marshal_VOID__BOXED,
|
||||
G_TYPE_NONE, 1,
|
||||
GDK_TYPE_COLOR);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
moo_cell_renderer_color_init (MooCellRendererColor *cell)
|
||||
{
|
||||
cell->color_set = FALSE;
|
||||
cell->activatable = FALSE;
|
||||
GTK_CELL_RENDERER(cell)->mode = GTK_CELL_RENDERER_MODE_ACTIVATABLE;
|
||||
GTK_CELL_RENDERER(cell)->xpad = 2;
|
||||
GTK_CELL_RENDERER(cell)->ypad = 2;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
moo_cell_renderer_color_get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
MooCellRendererColor *cell = MOO_CELL_RENDERER_COLOR (object);
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
case PROP_COLOR:
|
||||
g_value_set_boxed (value, &cell->color);
|
||||
break;
|
||||
|
||||
case PROP_COLOR_SET:
|
||||
g_value_set_boolean (value, cell->color_set ? TRUE : FALSE);
|
||||
break;
|
||||
|
||||
case PROP_ACTIVATABLE:
|
||||
g_value_set_boolean (value, cell->activatable ? TRUE : FALSE);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
moo_cell_renderer_color_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GdkColor *color;
|
||||
MooCellRendererColor *cell = MOO_CELL_RENDERER_COLOR (object);
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
case PROP_COLOR:
|
||||
color = g_value_get_boxed (value);
|
||||
if (color)
|
||||
{
|
||||
cell->color = *color;
|
||||
cell->color_set = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
cell->color_set = FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_COLOR_SET:
|
||||
cell->color_set = g_value_get_boolean (value) ? TRUE : FALSE;
|
||||
break;
|
||||
|
||||
case PROP_ACTIVATABLE:
|
||||
cell->activatable = g_value_get_boolean (value) ? TRUE : FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GtkCellRenderer *
|
||||
moo_cell_renderer_color_new (void)
|
||||
{
|
||||
return g_object_new (MOO_TYPE_CELL_RENDERER_COLOR, NULL);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
moo_cell_renderer_color_get_size (GtkCellRenderer *gtkcell,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *cell_area,
|
||||
gint *x_offset,
|
||||
gint *y_offset,
|
||||
gint *width,
|
||||
gint *height)
|
||||
{
|
||||
if (x_offset)
|
||||
*x_offset = 0;
|
||||
if (y_offset)
|
||||
*y_offset = 0;
|
||||
if (width)
|
||||
*width = 2 * gtkcell->xpad + 2 * CELL_BORDER_WIDTH + CELL_MIN_WIDTH;
|
||||
if (height)
|
||||
*height = 2 * gtkcell->ypad + 2 * CELL_BORDER_WIDTH + CELL_MIN_HEIGHT;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
moo_cell_renderer_color_render (GtkCellRenderer *gtkcell,
|
||||
GdkWindow *window,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GdkRectangle *expose_area,
|
||||
GtkCellRendererState flags)
|
||||
|
||||
{
|
||||
MooCellRendererColor *cell = MOO_CELL_RENDERER_COLOR (gtkcell);
|
||||
GdkRectangle rect;
|
||||
GdkGC *gc;
|
||||
GdkColor *color;
|
||||
|
||||
rect = *cell_area;
|
||||
rect.x += gtkcell->xpad;
|
||||
rect.y += gtkcell->ypad;
|
||||
rect.width -= gtkcell->xpad * 2;
|
||||
rect.height -= gtkcell->ypad * 2;
|
||||
|
||||
if (cell->color_set)
|
||||
{
|
||||
static GdkGCValues values;
|
||||
GdkColormap *colormap;
|
||||
|
||||
colormap = gtk_widget_get_colormap (widget);
|
||||
g_return_if_fail (colormap != NULL);
|
||||
gdk_colormap_alloc_color (colormap, &cell->color, TRUE, TRUE);
|
||||
|
||||
values.foreground = cell->color;
|
||||
|
||||
gc = gdk_gc_new_with_values (window, &values, GDK_GC_FOREGROUND);
|
||||
gdk_draw_rectangle (window, gc, TRUE, rect.x, rect.y,
|
||||
rect.width, rect.height);
|
||||
g_object_unref (gc);
|
||||
}
|
||||
|
||||
if (flags & GTK_CELL_RENDERER_SELECTED)
|
||||
gc = widget->style->text_gc[GTK_STATE_SELECTED];
|
||||
else if (flags & GTK_CELL_RENDERER_INSENSITIVE)
|
||||
gc = widget->style->text_gc[GTK_STATE_INSENSITIVE];
|
||||
else
|
||||
gc = widget->style->text_gc[GTK_STATE_NORMAL];
|
||||
|
||||
gdk_draw_rectangle (window, gc, FALSE, rect.x, rect.y,
|
||||
rect.width - 1, rect.height - 1);
|
||||
|
||||
if (!cell->color_set)
|
||||
gdk_draw_line (window, gc,
|
||||
rect.x,
|
||||
rect.y + rect.height - 1,
|
||||
rect.x + rect.width - 1,
|
||||
rect.y);
|
||||
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
moo_cell_renderer_color_activate (GtkCellRenderer *gtkcell,
|
||||
GdkEvent *event,
|
||||
GtkWidget *widget,
|
||||
const gchar *path,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GtkCellRendererState flags)
|
||||
{
|
||||
MooCellRendererColor *cell = MOO_CELL_RENDERER_COLOR (gtkcell);
|
||||
|
||||
if (cell->activatable)
|
||||
{
|
||||
GtkWidget *dialog, *toplevel;
|
||||
GtkColorSelectionDialog *color_dialog;
|
||||
GtkColorSelection *colorsel;
|
||||
GdkColor color;
|
||||
int response;
|
||||
|
||||
dialog = gtk_color_selection_dialog_new (NULL);
|
||||
color_dialog = GTK_COLOR_SELECTION_DIALOG (dialog);
|
||||
colorsel = GTK_COLOR_SELECTION (color_dialog->colorsel);
|
||||
|
||||
gtk_color_selection_set_current_color (colorsel, &cell->color);
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (widget);
|
||||
if (GTK_WIDGET_TOPLEVEL (toplevel))
|
||||
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (toplevel));
|
||||
response = gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
|
||||
if (response == GTK_RESPONSE_OK)
|
||||
gtk_color_selection_get_current_color (colorsel, &color);
|
||||
|
||||
gtk_widget_destroy (dialog);
|
||||
|
||||
if (response == GTK_RESPONSE_OK)
|
||||
g_signal_emit (cell, signals[COLOR_SET], 0, &color);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
55
moo/mooutils/moocellrenderercolor.h
Normal file
55
moo/mooutils/moocellrenderercolor.h
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* moocellrenderercolor.h
|
||||
*
|
||||
* Copyright (C) 2004-2005 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_CELL_RENDERER_COLOR_H__
|
||||
#define __MOO_CELL_RENDERER_COLOR_H__
|
||||
|
||||
#include <gtk/gtkcellrenderer.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
#define MOO_TYPE_CELL_RENDERER_COLOR (moo_cell_renderer_color_get_type ())
|
||||
#define MOO_CELL_RENDERER_COLOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOO_TYPE_CELL_RENDERER_COLOR, MooCellRendererColor))
|
||||
#define MOO_CELL_RENDERER_COLOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MOO_TYPE_CELL_RENDERER_COLOR, MooCellRendererColorClass))
|
||||
#define MOO_IS_CELL_RENDERER_COLOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MOO_TYPE_CELL_RENDERER_COLOR))
|
||||
#define MOO_IS_CELL_RENDERER_COLOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MOO_TYPE_CELL_RENDERER_COLOR))
|
||||
#define MOO_CELL_RENDERER_COLOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOO_TYPE_CELL_RENDERER_COLOR, MooCellRendererColorClass))
|
||||
|
||||
typedef struct _MooCellRendererColor MooCellRendererColor;
|
||||
typedef struct _MooCellRendererColorClass MooCellRendererColorClass;
|
||||
|
||||
struct _MooCellRendererColor
|
||||
{
|
||||
GtkCellRenderer parent;
|
||||
|
||||
GdkColor color;
|
||||
guint color_set : 1;
|
||||
guint activatable : 1;
|
||||
};
|
||||
|
||||
struct _MooCellRendererColorClass
|
||||
{
|
||||
GtkCellRendererClass parent_class;
|
||||
|
||||
void (*color_set) (MooCellRendererColor *cell,
|
||||
GdkColor *color);
|
||||
};
|
||||
|
||||
GType moo_cell_renderer_color_get_type (void) G_GNUC_CONST;
|
||||
GtkCellRenderer *moo_cell_renderer_color_new (void);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MOO_CELL_RENDERER_COLOR_H__ */
|
@ -519,13 +519,17 @@ char*
|
||||
moo_history_list_display_basename (const char *filename,
|
||||
G_GNUC_UNUSED gpointer data)
|
||||
{
|
||||
char *basename;
|
||||
char *basename, *display;
|
||||
|
||||
g_return_val_if_fail (filename != NULL, NULL);
|
||||
|
||||
basename = g_path_get_basename (filename);
|
||||
g_return_val_if_fail (basename != NULL, NULL);
|
||||
return g_filename_display_name (basename);
|
||||
|
||||
display = g_filename_display_name (basename);
|
||||
|
||||
g_free (basename);
|
||||
return display;
|
||||
}
|
||||
|
||||
|
||||
|
@ -978,24 +978,26 @@ static void moo_notebook_map (GtkWidget *widget)
|
||||
GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
|
||||
|
||||
if (nb->priv->tabs_visible)
|
||||
{
|
||||
gdk_window_show (nb->priv->tab_window);
|
||||
|
||||
if (nb->priv->action_widgets[LEFT] &&
|
||||
GTK_WIDGET_VISIBLE (nb->priv->action_widgets[LEFT]))
|
||||
if (nb->priv->action_widgets[LEFT] &&
|
||||
GTK_WIDGET_VISIBLE (nb->priv->action_widgets[LEFT]))
|
||||
gtk_widget_map (nb->priv->action_widgets[LEFT]);
|
||||
|
||||
if (nb->priv->action_widgets[RIGHT] &&
|
||||
GTK_WIDGET_VISIBLE (nb->priv->action_widgets[RIGHT]))
|
||||
if (nb->priv->action_widgets[RIGHT] &&
|
||||
GTK_WIDGET_VISIBLE (nb->priv->action_widgets[RIGHT]))
|
||||
gtk_widget_map (nb->priv->action_widgets[RIGHT]);
|
||||
|
||||
if (nb->priv->arrows_visible)
|
||||
gtk_widget_map (nb->priv->arrows);
|
||||
if (nb->priv->arrows_visible)
|
||||
gtk_widget_map (nb->priv->arrows);
|
||||
|
||||
VISIBLE_FOREACH_START (nb, page)
|
||||
{
|
||||
gtk_widget_map (page->label->widget);
|
||||
VISIBLE_FOREACH_START (nb, page)
|
||||
{
|
||||
gtk_widget_map (page->label->widget);
|
||||
}
|
||||
VISIBLE_FOREACH_END;
|
||||
}
|
||||
VISIBLE_FOREACH_END;
|
||||
|
||||
if (nb->priv->current_page)
|
||||
gtk_widget_map (nb->priv->current_page->child);
|
||||
@ -1250,7 +1252,7 @@ static void child_visible_notify (GtkWidget *child,
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_show (page->label->widget);
|
||||
gtk_widget_hide (page->label->widget);
|
||||
if (nb->priv->current_page == page)
|
||||
{
|
||||
int n;
|
||||
|
@ -16,9 +16,14 @@
|
||||
#include "mooutils/moocompat.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* MooPrefsDialog class implementation
|
||||
*/
|
||||
enum {
|
||||
ICON_COLUMN,
|
||||
ICON_ID_COLUMN,
|
||||
LABEL_COLUMN,
|
||||
PAGE_COLUMN,
|
||||
N_COLUMNS
|
||||
};
|
||||
|
||||
|
||||
static void moo_prefs_dialog_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
@ -30,6 +35,8 @@ static void moo_prefs_dialog_get_property (GObject *object,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void moo_prefs_dialog_destroy (GtkObject *object);
|
||||
static void moo_prefs_dialog_response (GtkDialog *dialog,
|
||||
int response);
|
||||
|
||||
static void moo_prefs_dialog_init_sig (MooPrefsDialog *dialog);
|
||||
static void moo_prefs_dialog_apply (MooPrefsDialog *dialog);
|
||||
@ -63,11 +70,12 @@ static void moo_prefs_dialog_class_init (MooPrefsDialogClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
GtkObjectClass *gtkobject_class = GTK_OBJECT_CLASS (klass);
|
||||
GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (klass);
|
||||
|
||||
gobject_class->set_property = moo_prefs_dialog_set_property;
|
||||
gobject_class->get_property = moo_prefs_dialog_get_property;
|
||||
|
||||
gtkobject_class->destroy = moo_prefs_dialog_destroy;
|
||||
dialog_class->response = moo_prefs_dialog_response;
|
||||
|
||||
klass->init = moo_prefs_dialog_init_sig;
|
||||
klass->apply = moo_prefs_dialog_apply;
|
||||
@ -127,7 +135,7 @@ static void moo_prefs_dialog_init (MooPrefsDialog *dialog)
|
||||
|
||||
scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_widget_show (scrolledwindow);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), scrolledwindow, TRUE, TRUE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), scrolledwindow, FALSE, FALSE, 0);
|
||||
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow), GTK_SHADOW_IN);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
||||
|
||||
@ -146,6 +154,23 @@ static void moo_prefs_dialog_init (MooPrefsDialog *dialog)
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
destroy_page (GtkTreeModel *model,
|
||||
G_GNUC_UNUSED GtkTreePath *path,
|
||||
GtkTreeIter *iter)
|
||||
{
|
||||
GtkWidget *page = NULL;
|
||||
|
||||
gtk_tree_model_get (model, iter, PAGE_COLUMN, &page, -1);
|
||||
g_return_val_if_fail (page != NULL, FALSE);
|
||||
|
||||
g_object_set_data (G_OBJECT (page), "moo-prefs-dialog-row", NULL);
|
||||
gtk_widget_destroy (page);
|
||||
g_object_unref (page);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
moo_prefs_dialog_destroy (GtkObject *object)
|
||||
{
|
||||
@ -153,8 +178,9 @@ moo_prefs_dialog_destroy (GtkObject *object)
|
||||
|
||||
if (dialog->store)
|
||||
{
|
||||
dialog->notebook = NULL;
|
||||
dialog->pages_list = NULL;
|
||||
gtk_tree_view_set_model (dialog->pages_list, NULL);
|
||||
gtk_tree_model_foreach (GTK_TREE_MODEL (dialog->store),
|
||||
(GtkTreeModelForeachFunc) destroy_page, NULL);
|
||||
g_object_unref (dialog->store);
|
||||
dialog->store = NULL;
|
||||
}
|
||||
@ -163,14 +189,6 @@ moo_prefs_dialog_destroy (GtkObject *object)
|
||||
}
|
||||
|
||||
|
||||
enum {
|
||||
ICON_COLUMN,
|
||||
ICON_ID_COLUMN,
|
||||
LABEL_COLUMN,
|
||||
PAGE_COLUMN,
|
||||
N_COLUMNS
|
||||
};
|
||||
|
||||
static void
|
||||
setup_pages_list (MooPrefsDialog *dialog)
|
||||
{
|
||||
@ -228,7 +246,7 @@ pages_list_selection_changed (MooPrefsDialog *dialog,
|
||||
gtk_tree_model_get (model, &iter, PAGE_COLUMN, &page, -1);
|
||||
g_return_if_fail (page != NULL);
|
||||
gtk_notebook_set_current_page (dialog->notebook,
|
||||
gtk_notebook_page_num (dialog->notebook, GTK_WIDGET (page)));
|
||||
gtk_notebook_page_num (dialog->notebook, GTK_WIDGET (page)));
|
||||
g_object_unref (page);
|
||||
}
|
||||
else
|
||||
@ -289,15 +307,17 @@ static void moo_prefs_dialog_get_property (GObject *object,
|
||||
/* MooPrefsDialog methods
|
||||
*/
|
||||
|
||||
GtkWidget* moo_prefs_dialog_new (const char *title)
|
||||
GtkWidget*
|
||||
moo_prefs_dialog_new (const char *title)
|
||||
{
|
||||
return GTK_WIDGET (g_object_new (MOO_TYPE_PREFS_DIALOG,
|
||||
"title", title, NULL));
|
||||
}
|
||||
|
||||
|
||||
void moo_prefs_dialog_run (MooPrefsDialog *dialog,
|
||||
GtkWidget *parent)
|
||||
void
|
||||
moo_prefs_dialog_run (MooPrefsDialog *dialog,
|
||||
GtkWidget *parent)
|
||||
{
|
||||
GtkWindow *parent_window = NULL;
|
||||
|
||||
@ -310,27 +330,35 @@ void moo_prefs_dialog_run (MooPrefsDialog *dialog,
|
||||
}
|
||||
|
||||
g_signal_emit_by_name (dialog, "init");
|
||||
gtk_window_present (GTK_WINDOW (dialog));
|
||||
}
|
||||
|
||||
while (TRUE)
|
||||
|
||||
static void
|
||||
moo_prefs_dialog_response (GtkDialog *dialog,
|
||||
int response)
|
||||
{
|
||||
G_GNUC_UNUSED GtkWindow *parent;
|
||||
|
||||
switch (response)
|
||||
{
|
||||
int res = gtk_dialog_run (GTK_DIALOG (dialog));
|
||||
|
||||
if (res == GTK_RESPONSE_OK || res == GTK_RESPONSE_APPLY)
|
||||
case GTK_RESPONSE_APPLY:
|
||||
g_signal_emit_by_name (dialog, "apply");
|
||||
break;
|
||||
|
||||
if (res != GTK_RESPONSE_APPLY)
|
||||
{
|
||||
if (dialog->hide_on_delete)
|
||||
case GTK_RESPONSE_OK:
|
||||
g_signal_emit_by_name (dialog, "apply");
|
||||
/* fallthrough */
|
||||
default:
|
||||
if (MOO_PREFS_DIALOG(dialog)->hide_on_delete)
|
||||
gtk_widget_hide (GTK_WIDGET (dialog));
|
||||
else
|
||||
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||
|
||||
#ifdef __WIN32__ /* TODO: why? */
|
||||
if (parent_window) gtk_window_present (parent_window);
|
||||
#endif /* __WIN32__ */
|
||||
|
||||
return;
|
||||
}
|
||||
#ifdef __WIN32__
|
||||
parent = gtk_window_get_transient_for (GTK_WINDOW (window));
|
||||
if (parent)
|
||||
gtk_window_present (parent);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -406,7 +434,7 @@ moo_prefs_dialog_insert_page (MooPrefsDialog *dialog,
|
||||
}
|
||||
|
||||
gtk_widget_show (page);
|
||||
gtk_notebook_append_page (dialog->notebook, page, NULL);
|
||||
gtk_notebook_insert_page (dialog->notebook, page, NULL, -1);
|
||||
|
||||
g_object_get (page,
|
||||
"label", &label,
|
||||
|
@ -326,6 +326,7 @@ moo_prefs_dialog_page_new_from_xml (const char *label,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*XXX*/
|
||||
page = moo_glade_xml_get_widget (xml, page_id);
|
||||
page->xml = xml;
|
||||
|
||||
|
@ -350,6 +350,13 @@ static void moo_window_finalize (GObject *object)
|
||||
{
|
||||
MooWindow *window = MOO_WINDOW(object);
|
||||
|
||||
if (window->priv->ui_xml)
|
||||
g_object_unref (window->priv->ui_xml);
|
||||
if (window->priv->actions)
|
||||
g_object_unref (window->priv->actions);
|
||||
|
||||
g_free (window->priv->name);
|
||||
g_free (window->priv->id);
|
||||
g_free (window->priv->menubar_ui_name);
|
||||
g_free (window->priv->toolbar_ui_name);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user