Added stock items for Save None and Save Selected

master
Yevgen Muntyan 2005-09-03 16:39:51 +00:00
parent 3057ece3a8
commit 67807e9c65
7 changed files with 152 additions and 186 deletions

View File

@ -24,7 +24,7 @@
</ignoreparts>
<projectdirectory>.</projectdirectory>
<absoluteprojectpath>false</absoluteprojectpath>
<description/>
<description></description>
<secondaryLanguages>
<language>C</language>
</secondaryLanguages>
@ -36,17 +36,17 @@
<useconfiguration>debug</useconfiguration>
</general>
<run>
<mainprogram>tests/editor</mainprogram>
<mainprogram>tests/medit</mainprogram>
<directoryradio>executable</directoryradio>
<customdirectory>/</customdirectory>
<programargs/>
<programargs></programargs>
<terminal>false</terminal>
<autocompile>false</autocompile>
<envvars/>
</run>
<configurations>
<debug>
<configargs>--enable-debug=full --enable-all-gcc-warnings=fatal --enable-developer-mode --disable-moo-module</configargs>
<configargs>--enable-debug=full --enable-all-gcc-warnings=fatal --enable-developer-mode --disable-moo-module --without-python --without-mooterm --without-mooapp</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>
<optimized>
<configargs>--enable-all-gcc-warnings=fatal --enable-developer-mode --without-mooapp --without-mooterm --without-python</configargs>
@ -166,10 +166,10 @@
<general>
<dbgshell>libtool</dbgshell>
<programargs>--g-fatal-warnings --sync</programargs>
<gdbpath/>
<configGdbScript/>
<runShellScript/>
<runGdbScript/>
<gdbpath></gdbpath>
<configGdbScript></configGdbScript>
<runShellScript></runShellScript>
<runGdbScript></runGdbScript>
<breakonloadinglibs>true</breakonloadinglibs>
<separatetty>false</separatetty>
<floatingtoolbar>true</floatingtoolbar>
@ -270,7 +270,7 @@
</codecompletion>
<references/>
<creategettersetter>
<prefixGet/>
<prefixGet></prefixGet>
<prefixSet>set</prefixSet>
<prefixVariable>m_,_</prefixVariable>
<parameterName>theValue</parameterName>

View File

@ -26,6 +26,13 @@
#define REAL_SMALL 6
static GtkStockItem stock_items[] = {
{(char*) MOO_STOCK_SAVE_NONE, (char*) "Save _None", 0, 0, NULL},
{(char*) MOO_STOCK_SAVE_SELECTED, (char*) "Save _Selected", 0, 0, NULL}
};
#if GTK_CHECK_VERSION(2,4,0)
static void register_stock_icon (GtkIconFactory *factory,
@ -80,6 +87,71 @@ static void add_icon2 (GtkIconFactory *factory,
#endif /* !GTK_CHECK_VERSION(2,6,0) */
#else /* !GTK_CHECK_VERSION(2,4,0) */
/* TODO: take code from gtk */
static void add_icon (GtkIconFactory *factory,
const gchar *stock_id,
G_GNUC_UNUSED gint size,
const guchar *data)
{
GtkIconSet *set = NULL;
GdkPixbuf *pixbuf = NULL;
pixbuf = gdk_pixbuf_new_from_inline (-1, data, FALSE, NULL);
if (pixbuf)
{
set = gtk_icon_set_new_from_pixbuf (pixbuf);
gdk_pixbuf_unref (pixbuf);
}
else
{
set = gtk_icon_set_new ();
}
gtk_icon_factory_add (factory, stock_id, set);
gtk_icon_set_unref (set);
}
static void add_icon2 (GtkIconFactory *factory,
const gchar *stock_id,
gint size1,
const guchar *data1,
G_GNUC_UNUSED gint size2,
G_GNUC_UNUSED const guchar *data2)
{
add_icon (factory, stock_id, size1, data1);
}
#endif /* !GTK_CHECK_VERSION(2,4,0) */
GtkIconSize moo_get_icon_size_real_small (void)
{
static GtkIconSize size = 0;
if (!size)
size = gtk_icon_size_register ("moo-real-small", 4, 4);
return size;
}
static void register_stock_icon_alias (GtkIconFactory *factory,
const gchar *stock_id,
const gchar *new_stock_id)
{
/* must use gtk_icon_factory_lookup_default() to initialize gtk icons */
GtkIconSet *set = gtk_icon_factory_lookup_default (stock_id);
g_return_if_fail (set != NULL);
gtk_icon_factory_add (factory, new_stock_id, set);
}
void moo_create_stock_items (void)
{
static gboolean created = FALSE;
@ -118,69 +190,9 @@ void moo_create_stock_items (void)
16, STOCK_EDIT_16);
#endif
g_object_unref (G_OBJECT (factory));
}
#else /* !GTK_CHECK_VERSION(2,4,0) */
/* TODO: take code from gtk */
void moo_create_stock_items (void)
{
static gboolean created = FALSE;
GtkIconSet *set = NULL;
GdkPixbuf *pixbuf = NULL;
GtkIconFactory *factory;
if (created) return;
else created = TRUE;
factory = gtk_icon_factory_new ();
gtk_icon_factory_add_default (factory);
pixbuf = gdk_pixbuf_new_from_inline (-1, MOO_GNOME_TERMINAL_ICON, FALSE, NULL);
if (pixbuf) {
set = gtk_icon_set_new_from_pixbuf (pixbuf);
gdk_pixbuf_unref (pixbuf);
}
else
set = gtk_icon_set_new ();
gtk_icon_factory_add (factory, MOO_STOCK_TERMINAL, set);
gtk_icon_set_unref (set);
pixbuf = gdk_pixbuf_new_from_inline (-1, STOCK_ABOUT_24, FALSE, NULL);
if (pixbuf) {
set = gtk_icon_set_new_from_pixbuf (pixbuf);
gdk_pixbuf_unref (pixbuf);
}
else
set = gtk_icon_set_new ();
gtk_icon_factory_add (factory, GTK_STOCK_ABOUT, set);
gtk_icon_set_unref (set);
pixbuf = gdk_pixbuf_new_from_inline (-1, STOCK_EDIT_24, FALSE, NULL);
if (pixbuf) {
set = gtk_icon_set_new_from_pixbuf (pixbuf);
gdk_pixbuf_unref (pixbuf);
}
else
set = gtk_icon_set_new ();
gtk_icon_factory_add (factory, GTK_STOCK_EDIT, set);
gtk_icon_set_unref (set);
gtk_stock_add_static (stock_items, G_N_ELEMENTS (stock_items));
register_stock_icon_alias (factory, GTK_STOCK_NO, MOO_STOCK_SAVE_NONE);
register_stock_icon_alias (factory, GTK_STOCK_SAVE, MOO_STOCK_SAVE_SELECTED);
g_object_unref (G_OBJECT (factory));
}
#endif /* !GTK_CHECK_VERSION(2,4,0) */
GtkIconSize moo_get_icon_size_real_small (void)
{
static GtkIconSize size = 0;
if (!size)
size = gtk_icon_size_register ("moo-real-small", 4, 4);
return size;
}

View File

@ -24,14 +24,19 @@ G_BEGIN_DECLS
#define MOO_STOCK_TERMINAL "moo-terminal"
#define MOO_STOCK_TERMINAL "moo-terminal"
#define MOO_STOCK_KEYBOARD GTK_STOCK_SELECT_FONT
#define MOO_STOCK_DOC_DELETED GTK_STOCK_DIALOG_ERROR
#define MOO_STOCK_DOC_MODIFIED_ON_DISK GTK_STOCK_DIALOG_WARNING
#define MOO_STOCK_CLOSE "moo-close"
#define MOO_STOCK_STICKY "moo-sticky"
#define MOO_STOCK_DETACH "moo-detach"
#define MOO_STOCK_ATTACH "moo-attach"
#define MOO_STOCK_KEEP_ON_TOP "moo-keep-on-top"
#define MOO_STOCK_DOC_DELETED GTK_STOCK_DIALOG_ERROR
#define MOO_STOCK_DOC_MODIFIED_ON_DISK GTK_STOCK_DIALOG_WARNING
#define MOO_STOCK_DOC_MODIFIED GTK_STOCK_SAVE
#define MOO_STOCK_SAVE_NONE "moo-save-none"
#define MOO_STOCK_SAVE_SELECTED "moo-save-selected"
#define MOO_ICON_SIZE_REAL_SMALL (moo_get_icon_size_real_small ())
void moo_create_stock_items (void);

View File

@ -8,7 +8,6 @@ noinst_PROGRAMS =
EXTRA_DIST = \
pyapp.py.in \
meditui.xml \
editor-ui.xml
BUILT_SOURCES = editor-ui.h
@ -70,7 +69,7 @@ if MINGW_BUILD
medit_LDFLAGS += -mwindows
endif MINGW_BUILD
medit_SOURCES = medit.c
medit_SOURCES = medit.c editor-ui.h
##############################################################################

View File

@ -52,8 +52,8 @@ int main (int argc, char *argv[])
win = moo_editor_new_window (editor);
if (argc > 1)
moo_editor_open (editor, MOO_EDIT_WINDOW (win),
GTK_WIDGET (win), argv[1], NULL);
moo_editor_open_file (editor, MOO_EDIT_WINDOW (win),
GTK_WIDGET (win), argv[1], NULL);
return moo_app_run (app);
}

View File

@ -11,13 +11,13 @@
* See COPYING file that comes with this distribution.
*/
#define MOOEDIT_COMPILATION
#line 16 "@srcdir@/medit.c.in"
#include "mooedit/mooeditor.h"
#include "mooedit/mooeditlangmgr.h"
#include "mooui/moouiobject.h"
#include "mooedit/mooeditor.h"
#include "editor-ui.h"
static void init_actions (void);
int main (int argc, char **argv)
{
char *rcfile;
@ -28,6 +28,8 @@ int main (int argc, char **argv)
gtk_init (&argc, &argv);
init_actions ();
rcfile = g_build_filename (g_get_home_dir (), ".meditrc", NULL);
moo_prefs_load (rcfile);
@ -37,19 +39,58 @@ int main (int argc, char **argv)
moo_edit_lang_mgr_add_lang_files_dir (mgr, "@MOO_EDIT_LANG_FILES_DIR@");
g_signal_connect (editor, "all-windows-closed", G_CALLBACK (gtk_main_quit), NULL);
xml = moo_editor_get_ui_xml (editor);
if (!moo_ui_xml_add_ui_from_string (xml, MEDIT_UI, -1, NULL))
g_error ("%s", G_STRLOC);
win = moo_editor_new_window (editor);
xml = moo_ui_object_get_ui_xml (MOO_UI_OBJECT (win));
if (!moo_ui_xml_add_ui_from_file (xml, "@srcdir@/meditui.xml", NULL))
if (!moo_ui_xml_add_ui_from_file (xml, "meditui.xml", NULL))
g_error ("could not find medui.xml");
if (argc > 1) _moo_edit_window_open (MOO_EDIT_WINDOW (win), argv[1], NULL);
if (argc > 1)
moo_editor_open_file (editor, win, NULL,
argv[1], NULL);
gtk_main ();
moo_prefs_save (rcfile);
g_object_unref (editor);
g_free (rcfile);
return 0;
}
static void init_actions (void)
{
GObjectClass *klass = g_type_class_ref (MOO_TYPE_EDIT_WINDOW);
g_return_if_fail (klass != NULL);
moo_ui_object_class_new_action (klass,
"id", "SendToTerminal",
"dead", TRUE,
NULL);
moo_ui_object_class_new_action (klass,
"id", "Terminal",
"dead", TRUE,
NULL);
moo_ui_object_class_new_action (klass,
"id", "PythonMenu",
"dead", TRUE,
NULL);
moo_ui_object_class_new_action (klass,
"id", "Preferences",
"dead", TRUE,
NULL);
moo_ui_object_class_new_action (klass,
"id", "About",
"dead", TRUE,
NULL);
moo_ui_object_class_new_action (klass,
"id", "Quit",
"dead", TRUE,
NULL);
g_type_class_unref (klass);
}

View File

@ -1,91 +0,0 @@
<ui>
<object name="EditorWindow">
<menubar name="Menubar">
<menu name="File" label="_File">
<separator/>
<item name="NewWindow" action="NewWindow"/>
<item name="NewTab" action="NewTab"/>
<separator/>
<item name="Open" action="Open"/>
<item name="Save" action="Save"/>
<item name="SaveAs" action="SaveAs"/>
<separator/>
<item name="Reload" action="Reload"/>
<separator/>
<item name="CloseTab" action="CloseTab"/>
<separator/>
</menu>
<menu name="Edit" label="_Edit">
<separator/>
<item name="Undo" action="Undo"/>
<item name="Redo" action="Redo"/>
<separator/>
<item name="Cut" action="Cut"/>
<item name="Copy" action="Copy"/>
<item name="Paste" action="Paste"/>
<item name="Delete" action="Delete"/>
<separator/>
<item name="SelectAll" action="SelectAll"/>
<separator/>
</menu>
<menu name="Search" label="_Search">
<separator/>
<item name="Find" action="Find"/>
<item name="FindNext" action="FindNext"/>
<item name="FindPrevious" action="FindPrevious"/>
<item name="Replace" action="Replace"/>
<separator/>
<item name="GoToLine" action="GoToLine"/>
<separator/>
</menu>
<menu name="View" label="_View">
<separator/>
<item name="PreviousTab" action="PreviousTab"/>
<item name="NextTab" action="NextTab"/>
<separator/>
<item name="SyntaxMenu" action="SyntaxMenu"/>
<separator/>
</menu>
<menu name="Settings" label="_Settings">
<separator/>
<item name="ShowToolbar" action="ShowToolbar"/>
<item name="ToolbarStyle" action="ToolbarStyle"/>
<separator/>
<item name="ConfigureShortcuts" action="ConfigureShortcuts"/>
<separator/>
</menu>
</menubar> <!-- Menubar -->
<toolbar name="Toolbar">
<separator/>
<item name="NewWindow" action="NewWindow"/>
<separator/>
<item name="Open" action="Open"/>
<item name="Save" action="Save"/>
<separator/>
<item name="Undo" action="Undo"/>
<item name="Redo" action="Redo"/>
<separator/>
<item name="Cut" action="Cut"/>
<item name="Copy" action="Copy"/>
<item name="Paste" action="Paste"/>
<separator/>
<item name="Find" action="Find"/>
<item name="Replace" action="Replace"/>
<separator/>
</toolbar> <!-- Toolbar -->
</object> <!-- EditorWindow -->
</ui>