From 67807e9c6567d3201e89a8af8b9c908121604433 Mon Sep 17 00:00:00 2001
From: Yevgen Muntyan <17531749+muntyan@users.noreply.github.com>
Date: Sat, 3 Sep 2005 16:39:51 +0000
Subject: [PATCH] Added stock items for Save None and Save Selected
---
moo.kdevelop | 32 +++++-----
moo/mooutils/moostock.c | 138 ++++++++++++++++++++++------------------
moo/mooutils/moostock.h | 9 ++-
tests/Makefile.am | 3 +-
tests/editor.c | 4 +-
tests/medit.c.in | 61 +++++++++++++++---
tests/meditui.xml | 91 --------------------------
7 files changed, 152 insertions(+), 186 deletions(-)
delete mode 100644 tests/meditui.xml
diff --git a/moo.kdevelop b/moo.kdevelop
index 7e16b921..af241342 100644
--- a/moo.kdevelop
+++ b/moo.kdevelop
@@ -24,7 +24,7 @@
.
false
-
+
C
@@ -36,17 +36,17 @@
debug
- tests/editor
+ tests/medit
executable
/
-
+
false
false
- --enable-debug=full --enable-all-gcc-warnings=fatal --enable-developer-mode --disable-moo-module
+ --enable-debug=full --enable-all-gcc-warnings=fatal --enable-developer-mode --disable-moo-module --without-python --without-mooterm --without-mooapp
build/debug
kdevgccoptions
kdevgppoptions
@@ -54,13 +54,13 @@
-O0 -g3 -pg
-O0 -g3 -pg
-
-
-
-
-
-
-
+
+
+
+
+
+
+
--enable-all-gcc-warnings=fatal --enable-developer-mode --without-mooapp --without-mooterm --without-python
@@ -166,10 +166,10 @@
libtool
--g-fatal-warnings --sync
-
-
-
-
+
+
+
+
true
false
true
@@ -270,7 +270,7 @@
-
+
set
m_,_
theValue
diff --git a/moo/mooutils/moostock.c b/moo/mooutils/moostock.c
index b2c9ef6b..65903e92 100644
--- a/moo/mooutils/moostock.c
+++ b/moo/mooutils/moostock.c
@@ -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;
-}
diff --git a/moo/mooutils/moostock.h b/moo/mooutils/moostock.h
index f4c77b88..00609784 100644
--- a/moo/mooutils/moostock.h
+++ b/moo/mooutils/moostock.h
@@ -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);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 61f17aa5..003e829e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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
##############################################################################
diff --git a/tests/editor.c b/tests/editor.c
index be330dd9..3c4de064 100644
--- a/tests/editor.c
+++ b/tests/editor.c
@@ -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);
}
diff --git a/tests/medit.c.in b/tests/medit.c.in
index e54c8ecb..14f38b93 100644
--- a/tests/medit.c.in
+++ b/tests/medit.c.in
@@ -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);
+}
diff --git a/tests/meditui.xml b/tests/meditui.xml
deleted file mode 100644
index 57d40118..00000000
--- a/tests/meditui.xml
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-
-
-
-