More python stuff
parent
ec9b35bd9f
commit
abaf6e11ef
|
@ -181,7 +181,7 @@ static void moo_editor_class_init (MooEditorClass *klass)
|
|||
edit_window_class = g_type_class_ref (MOO_TYPE_EDIT_WINDOW);
|
||||
moo_window_class_new_action_custom (edit_window_class, RECENT_ACTION_ID,
|
||||
(MooWindowActionFunc) create_recent_action,
|
||||
NULL);
|
||||
NULL, NULL);
|
||||
g_type_class_unref (edit_window_class);
|
||||
}
|
||||
|
||||
|
|
|
@ -458,7 +458,7 @@ static void moo_edit_window_class_init (MooEditWindowClass *klass)
|
|||
|
||||
moo_window_class_new_action_custom (window_class, LANG_ACTION_ID,
|
||||
(MooWindowActionFunc) create_lang_action,
|
||||
NULL);
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@ mooedit_defs_files = \
|
|||
$(moopython_srcdir)/mooeditor.defs \
|
||||
$(moopython_srcdir)/mooplugin.defs
|
||||
|
||||
# mooutils_defs_files = \
|
||||
# $(moopython_srcdir)/mooutils.defs
|
||||
# mooutils_override_files = \
|
||||
# $(moopython_srcdir)/moowindow.override
|
||||
|
||||
moopython_extra_dist = \
|
||||
$(moopython)/moo-pygtk.c \
|
||||
|
@ -34,7 +34,8 @@ moopython_extra_dist = \
|
|||
$(mooutils_defs_files) \
|
||||
$(moopython)/mooutils-pygtk.defs \
|
||||
$(moopython)/mooutils-pygtk.override \
|
||||
$(moopython)/mooutils-mod.c
|
||||
$(moopython)/mooutils-mod.c \
|
||||
$(mooutils_override_files)
|
||||
|
||||
|
||||
if MOO_BUILD_UTILS
|
||||
|
@ -42,8 +43,6 @@ moopython_sources += $(moopython)/mooutils-mod.c
|
|||
nodist_moopython_sources += $(moopython)/mooutils-pygtk.c
|
||||
moopython_built_sources += $(moopython)/mooutils-pygtk.c
|
||||
moopython_cleanfiles += $(moopython)/mooutils-pygtk.c
|
||||
# $(moopython)/mooutils-pygtk.defs: $(mooutils_defs_files)
|
||||
# touch $(moopython_srcdir)/mooutils-pygtk.defs
|
||||
endif MOO_BUILD_UTILS
|
||||
|
||||
if MOO_BUILD_TERM
|
||||
|
@ -58,8 +57,6 @@ moopython_sources += $(moopython)/mooedit-mod.c
|
|||
nodist_moopython_sources += $(moopython)/mooedit-pygtk.c
|
||||
moopython_built_sources += $(moopython)/mooedit-pygtk.c
|
||||
moopython_cleanfiles += $(moopython)/mooedit-pygtk.c
|
||||
$(moopython)/mooedit-pygtk.defs: $(mooedit_defs_files)
|
||||
touch $(moopython_srcdir)/mooedit-pygtk.defs
|
||||
endif MOO_BUILD_EDIT
|
||||
|
||||
if MOO_BUILD_APP
|
||||
|
@ -69,7 +66,7 @@ moopython_built_sources += $(moopython)/mooapp-pygtk.c
|
|||
moopython_cleanfiles += $(moopython)/mooapp-pygtk.c
|
||||
endif MOO_BUILD_APP
|
||||
|
||||
$(moopython)/mooutils-pygtk.c: $(moopython)/mooutils-pygtk.defs $(moopython)/mooutils-pygtk.override
|
||||
$(moopython)/mooutils-pygtk.c: $(moopython)/mooutils-pygtk.defs $(moopython)/mooutils-pygtk.override $(mooutils_override_files)
|
||||
mkdir -p $(moopython)
|
||||
pygtk-codegen-2.0 --prefix moo_utils \
|
||||
--register $(PYGTK_DEFS_DIR)/gtk-types.defs \
|
||||
|
@ -88,7 +85,7 @@ $(moopython)/mooterm-pygtk.c: $(moopython)/mooterm-pygtk.defs $(moopython)/moote
|
|||
--outfilename mooterm-pygtk.c \
|
||||
$(moopython_srcdir)/mooterm-pygtk.defs > $(moopython)/mooterm-pygtk.c
|
||||
|
||||
$(moopython)/mooedit-pygtk.c: $(moopython)/mooedit-pygtk.defs $(moopython)/mooedit-pygtk.override
|
||||
$(moopython)/mooedit-pygtk.c: $(moopython)/mooedit-pygtk.defs $(moopython)/mooedit-pygtk.override $(mooedit_defs_files)
|
||||
mkdir -p $(moopython)
|
||||
pygtk-codegen-2.0 --prefix moo_edit \
|
||||
--register $(PYGTK_DEFS_DIR)/gtk-types.defs \
|
||||
|
|
|
@ -32,10 +32,10 @@ void moo_utils_mod_init (PyObject *moo_mod)
|
|||
{
|
||||
PyObject *mod;
|
||||
|
||||
mod = Py_InitModule3 ("moo.utils", moo_utils_functions, moo_utils_module_doc);
|
||||
mod = Py_InitModule3 ((char*) "moo.utils", moo_utils_functions, moo_utils_module_doc);
|
||||
g_return_if_fail (mod != NULL);
|
||||
Py_INCREF (mod);
|
||||
PyModule_AddObject (moo_mod, "utils", mod);
|
||||
PyModule_AddObject (moo_mod, (char*) "utils", mod);
|
||||
moo_utils_add_constants (mod, "MOO_");
|
||||
|
||||
moo_utils_register_classes (PyModule_GetDict (moo_mod));
|
||||
|
|
|
@ -104,6 +104,20 @@
|
|||
(gtype-id "MOO_TYPE_WINDOW")
|
||||
)
|
||||
|
||||
(define-object Action
|
||||
(in-module "Moo")
|
||||
(parent "GObject")
|
||||
(c-name "MooAction")
|
||||
(gtype-id "MOO_TYPE_ACTION")
|
||||
)
|
||||
|
||||
(define-object Closure
|
||||
(in-module "Moo")
|
||||
(parent "GtkObject")
|
||||
(c-name "MooClosure")
|
||||
(gtype-id "MOO_TYPE_CLOSURE")
|
||||
)
|
||||
|
||||
;; Enumerations and flags ...
|
||||
|
||||
(define-enum FileDialogType
|
||||
|
@ -167,11 +181,6 @@
|
|||
|
||||
;; From ../mooutils/moobigpaned.h
|
||||
|
||||
(define-function moo_big_paned_get_type
|
||||
(c-name "moo_big_paned_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function moo_big_paned_new
|
||||
(c-name "moo_big_paned_new")
|
||||
(is-constructor-of "MooBigPaned")
|
||||
|
@ -260,11 +269,6 @@
|
|||
|
||||
;; From ../mooutils/moocombo.h
|
||||
|
||||
(define-function moo_combo_get_type
|
||||
(c-name "moo_combo_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function moo_combo_new
|
||||
(c-name "moo_combo_new")
|
||||
(is-constructor-of "MooCombo")
|
||||
|
@ -424,11 +428,6 @@
|
|||
|
||||
;; From ../mooutils/moodialogs.h
|
||||
|
||||
(define-function moo_file_dialog_type_get_type
|
||||
(c-name "moo_file_dialog_type_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function moo_file_dialog
|
||||
(c-name "moo_file_dialog")
|
||||
(return-type "const-char*")
|
||||
|
@ -533,11 +532,6 @@
|
|||
|
||||
;; From ../mooutils/mooentry.h
|
||||
|
||||
(define-function moo_entry_get_type
|
||||
(c-name "moo_entry_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function moo_entry_new
|
||||
(c-name "moo_entry_new")
|
||||
(is-constructor-of "MooEntry")
|
||||
|
@ -611,21 +605,6 @@
|
|||
(return-type "GQuark")
|
||||
)
|
||||
|
||||
(define-function moo_file_watch_get_type
|
||||
(c-name "moo_file_watch_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function moo_file_watch_event_code_get_type
|
||||
(c-name "moo_file_watch_event_code_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function moo_file_watch_method_get_type
|
||||
(c-name "moo_file_watch_method_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function moo_file_watch_new
|
||||
(c-name "moo_file_watch_new")
|
||||
(is-constructor-of "MooFileWatch")
|
||||
|
@ -705,11 +684,6 @@
|
|||
|
||||
;; From ../mooutils/moofiltermgr.h
|
||||
|
||||
(define-function moo_filter_mgr_get_type
|
||||
(c-name "moo_filter_mgr_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function moo_filter_mgr_new
|
||||
(c-name "moo_filter_mgr_new")
|
||||
(is-constructor-of "MooFilterMgr")
|
||||
|
@ -797,11 +771,6 @@
|
|||
|
||||
;; From ../mooutils/mooglade.h
|
||||
|
||||
(define-function moo_glade_xml_get_type
|
||||
(c-name "moo_glade_xml_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function moo_glade_xml_new_empty
|
||||
(c-name "moo_glade_xml_new_empty")
|
||||
(return-type "MooGladeXML*")
|
||||
|
@ -922,11 +891,6 @@
|
|||
|
||||
;; From ../mooutils/moohistoryentry.h
|
||||
|
||||
(define-function moo_history_entry_get_type
|
||||
(c-name "moo_history_entry_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function moo_history_entry_new
|
||||
(c-name "moo_history_entry_new")
|
||||
(is-constructor-of "MooHistoryEntry")
|
||||
|
@ -961,16 +925,6 @@
|
|||
|
||||
;; From ../mooutils/moohistorylist.h
|
||||
|
||||
(define-function moo_history_list_get_type
|
||||
(c-name "moo_history_list_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function moo_history_list_item_get_type
|
||||
(c-name "moo_history_list_item_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function moo_history_list_new
|
||||
(c-name "moo_history_list_new")
|
||||
(is-constructor-of "MooHistoryList")
|
||||
|
@ -1201,11 +1155,6 @@
|
|||
)
|
||||
)
|
||||
|
||||
(define-function moo_markup_doc_get_type
|
||||
(c-name "moo_markup_doc_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function moo_markup_doc_new
|
||||
(c-name "moo_markup_doc_new")
|
||||
(is-constructor-of "MooMarkupDoc")
|
||||
|
@ -1391,11 +1340,6 @@
|
|||
|
||||
;; From ../mooutils/moomenumgr.h
|
||||
|
||||
(define-function moo_menu_mgr_get_type
|
||||
(c-name "moo_menu_mgr_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function moo_menu_mgr_new
|
||||
(c-name "moo_menu_mgr_new")
|
||||
(is-constructor-of "MooMenuMgr")
|
||||
|
@ -1405,11 +1349,6 @@
|
|||
|
||||
;; From ../mooutils/moonotebook.h
|
||||
|
||||
(define-function moo_notebook_get_type
|
||||
(c-name "moo_notebook_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function moo_notebook_new
|
||||
(c-name "moo_notebook_new")
|
||||
(is-constructor-of "MooNotebook")
|
||||
|
@ -1564,21 +1503,6 @@
|
|||
|
||||
;; From ../mooutils/moopaned.h
|
||||
|
||||
(define-function moo_paned_get_type
|
||||
(c-name "moo_paned_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function moo_pane_position_get_type
|
||||
(c-name "moo_pane_position_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function moo_pane_label_get_type
|
||||
(c-name "moo_pane_label_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function moo_paned_new
|
||||
(c-name "moo_paned_new")
|
||||
(is-constructor-of "MooPaned")
|
||||
|
@ -1759,11 +1683,6 @@
|
|||
|
||||
;; From ../mooutils/mooprefsdialog.h
|
||||
|
||||
(define-function moo_prefs_dialog_get_type
|
||||
(c-name "moo_prefs_dialog_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function moo_prefs_dialog_new
|
||||
(c-name "moo_prefs_dialog_new")
|
||||
(is-constructor-of "MooPrefsDialog")
|
||||
|
@ -1815,11 +1734,6 @@
|
|||
|
||||
;; From ../mooutils/mooprefsdialogpage.h
|
||||
|
||||
(define-function moo_prefs_dialog_page_get_type
|
||||
(c-name "moo_prefs_dialog_page_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function moo_prefs_dialog_page_new
|
||||
(c-name "moo_prefs_dialog_page_new")
|
||||
(is-constructor-of "MooPrefsDialogPage")
|
||||
|
@ -1883,11 +1797,6 @@
|
|||
|
||||
;; From ../mooutils/moouixml.h
|
||||
|
||||
(define-function moo_ui_xml_get_type
|
||||
(c-name "moo_ui_xml_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-function moo_ui_xml_new
|
||||
(c-name "moo_ui_xml_new")
|
||||
(is-constructor-of "MooUiXml")
|
||||
|
@ -2096,11 +2005,6 @@
|
|||
|
||||
;; From ../mooutils/moowindow.h
|
||||
|
||||
(define-function moo_window_get_type
|
||||
(c-name "moo_window_get_type")
|
||||
(return-type "GType")
|
||||
)
|
||||
|
||||
(define-method close
|
||||
(of-object "MooWindow")
|
||||
(c-name "moo_window_close")
|
||||
|
@ -2129,53 +2033,12 @@
|
|||
)
|
||||
)
|
||||
|
||||
(define-method install_action
|
||||
(of-object "MooWindowClass")
|
||||
(c-name "moo_window_class_install_action")
|
||||
(define-function _window_class_add_action
|
||||
(c-name "moo_window_class_add_action")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("const-char*" "id")
|
||||
'("MooObjectFactory*" "action")
|
||||
'("MooObjectFactory*" "closure")
|
||||
'("char**" "conditions")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method new_action
|
||||
(of-object "MooWindowClass")
|
||||
(c-name "moo_window_class_new_action")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("const-char*" "id")
|
||||
'("const-char*" "first_prop_name")
|
||||
)
|
||||
(varargs #t)
|
||||
)
|
||||
|
||||
(define-method new_actionv
|
||||
(of-object "MooWindowClass")
|
||||
(c-name "moo_window_class_new_actionv")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("const-char*" "id")
|
||||
'("const-char*" "first_prop_name")
|
||||
'("va_list" "props")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method new_action_custom
|
||||
(of-object "MooWindowClass")
|
||||
(c-name "moo_window_class_new_action_custom")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("const-char*" "id")
|
||||
'("MooWindowActionFunc" "func")
|
||||
'("gpointer" "data")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method remove_action
|
||||
(of-object "MooWindowClass")
|
||||
(define-function _window_class_remove_action
|
||||
(c-name "moo_window_class_remove_action")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
|
@ -2235,35 +2098,160 @@
|
|||
)
|
||||
|
||||
|
||||
;; From ./ggap/moo/mooutils/mooaction.h
|
||||
|
||||
;; From ../mooutils/stock-about-16.h
|
||||
(define-method activate
|
||||
(of-object "MooAction")
|
||||
(c-name "moo_action_activate")
|
||||
(return-type "none")
|
||||
)
|
||||
|
||||
(define-method get_id
|
||||
(of-object "MooAction")
|
||||
(c-name "moo_action_get_id")
|
||||
(return-type "const-char*")
|
||||
)
|
||||
|
||||
(define-method get_group_name
|
||||
(of-object "MooAction")
|
||||
(c-name "moo_action_get_group_name")
|
||||
(return-type "const-char*")
|
||||
)
|
||||
|
||||
(define-method get_name
|
||||
(of-object "MooAction")
|
||||
(c-name "moo_action_get_name")
|
||||
(return-type "const-char*")
|
||||
)
|
||||
|
||||
(define-method set_no_accel
|
||||
(of-object "MooAction")
|
||||
(c-name "moo_action_set_no_accel")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("gboolean" "no_accel")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method get_no_accel
|
||||
(of-object "MooAction")
|
||||
(c-name "moo_action_get_no_accel")
|
||||
(return-type "gboolean")
|
||||
)
|
||||
|
||||
(define-method create_menu_item
|
||||
(of-object "MooAction")
|
||||
(c-name "moo_action_create_menu_item")
|
||||
(return-type "GtkWidget*")
|
||||
)
|
||||
|
||||
(define-method create_tool_item
|
||||
(of-object "MooAction")
|
||||
(c-name "moo_action_create_tool_item")
|
||||
(return-type "GtkWidget*")
|
||||
(parameters
|
||||
'("GtkWidget*" "toolbar")
|
||||
'("int" "position")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method set_sensitive
|
||||
(of-object "MooAction")
|
||||
(c-name "moo_action_set_sensitive")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("gboolean" "sensitive")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method set_visible
|
||||
(of-object "MooAction")
|
||||
(c-name "moo_action_set_visible")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("gboolean" "visible")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method get_default_accel
|
||||
(of-object "MooAction")
|
||||
(c-name "moo_action_get_default_accel")
|
||||
(return-type "const-char*")
|
||||
)
|
||||
|
||||
(define-function moo_action_make_accel_path
|
||||
(c-name "moo_action_make_accel_path")
|
||||
(return-type "const-char*")
|
||||
(parameters
|
||||
'("const-char*" "group_id")
|
||||
'("const-char*" "action_id")
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
;; From ../mooutils/stock-about-24.h
|
||||
;; From ./ggap/moo/mooutils/mooclosure.h
|
||||
|
||||
(define-function moo_closure_new
|
||||
(c-name "moo_closure_new")
|
||||
(is-constructor-of "MooClosure")
|
||||
(return-type "MooClosure*")
|
||||
(parameters
|
||||
'("GCallback" "callback_func")
|
||||
'("gpointer" "data")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function moo_closure_new_object
|
||||
(c-name "moo_closure_new_object")
|
||||
(is-constructor-of "MooClosure")
|
||||
(return-type "MooClosure*")
|
||||
(parameters
|
||||
'("GCallback" "callback_func")
|
||||
'("gpointer" "object")
|
||||
)
|
||||
)
|
||||
|
||||
;; From ../mooutils/stock-edit-16.h
|
||||
(define-function moo_closure_new_signal
|
||||
(c-name "moo_closure_new_signal")
|
||||
(is-constructor-of "MooClosure")
|
||||
(return-type "MooClosure*")
|
||||
(parameters
|
||||
'("const-char*" "signal")
|
||||
'("gpointer" "object")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function moo_closure_new_proxy
|
||||
(c-name "moo_closure_new_proxy")
|
||||
(is-constructor-of "MooClosure")
|
||||
(return-type "MooClosure*")
|
||||
(parameters
|
||||
'("GCallback" "callback_func")
|
||||
'("GCallback" "proxy_func")
|
||||
'("gpointer" "object")
|
||||
)
|
||||
)
|
||||
|
||||
(define-function moo_closure_new_proxy_signal
|
||||
(c-name "moo_closure_new_proxy_signal")
|
||||
(is-constructor-of "MooClosure")
|
||||
(return-type "MooClosure*")
|
||||
(parameters
|
||||
'("const-char*" "signal")
|
||||
'("GCallback" "proxy_func")
|
||||
'("gpointer" "object")
|
||||
)
|
||||
)
|
||||
|
||||
;; From ../mooutils/stock-edit-24.h
|
||||
|
||||
|
||||
|
||||
;; From ../mooutils/stock-moo.h
|
||||
|
||||
|
||||
|
||||
;; From ../mooutils/stock-select-all-16.h
|
||||
|
||||
|
||||
|
||||
;; From ../mooutils/stock-select-all-24.h
|
||||
|
||||
|
||||
|
||||
;; From ../mooutils/stock-terminal-24.h
|
||||
|
||||
(define-method invoke
|
||||
(of-object "MooClosure")
|
||||
(c-name "moo_closure_invoke")
|
||||
(return-type "none")
|
||||
)
|
||||
|
||||
(define-method invalidate
|
||||
(of-object "MooClosure")
|
||||
(c-name "moo_closure_invalidate")
|
||||
(return-type "none")
|
||||
)
|
||||
|
|
|
@ -18,19 +18,21 @@ headers
|
|||
#include "mooutils/mooprefs.h"
|
||||
#include "mooutils/moonotebook.h"
|
||||
#include "mooutils/mooentry.h"
|
||||
#include "mooutils/moostock.h"
|
||||
#include "mooutils/mooutils-python.h"
|
||||
|
||||
|
||||
void moo_utils_register_classes (PyObject *dict);
|
||||
void moo_utils_add_constants (PyObject *module,
|
||||
const gchar *strip_prefix);
|
||||
void moo_utils_register_classes (PyObject *dict);
|
||||
void moo_utils_add_constants (PyObject *module,
|
||||
const char *strip_prefix);
|
||||
|
||||
|
||||
static PyTypeObject *_PyGdkColor_Type;
|
||||
#define PyGdkColor_Type (*_PyGdkColor_Type)
|
||||
%%
|
||||
modulename moo
|
||||
modulename moo.utils
|
||||
%%
|
||||
import gtk.Window as PyGtkWindow_Type
|
||||
import gtk.Widget as PyGtkWidget_Type
|
||||
import gtk.Object as PyGtkObject_Type
|
||||
import gtk.ToggleButton as PyGtkToggleButton_Type
|
||||
import gtk.Button as PyGtkButton_Type
|
||||
import gtk.Dialog as PyGtkDialog_Type
|
||||
|
@ -47,3 +49,119 @@ import gtk.gdk.Color as PyGdkColor_Type
|
|||
%%
|
||||
ignore-glob
|
||||
*_get_type
|
||||
%%
|
||||
override moo_window_class_add_action varargs
|
||||
static MooAction*
|
||||
py_action_factory_func (MooWindow *window,
|
||||
PyObject *func_n_args)
|
||||
{
|
||||
PyObject *py_window, *args, *func, *result;
|
||||
MooAction *action;
|
||||
|
||||
g_return_val_if_fail (func_n_args != NULL, NULL);
|
||||
g_return_val_if_fail (PyTuple_Check (func_n_args), NULL);
|
||||
g_return_val_if_fail (PyTuple_GET_SIZE (func_n_args) == 2, NULL);
|
||||
|
||||
func = PyTuple_GET_ITEM (func_n_args, 0);
|
||||
args = PyTuple_GET_ITEM (func_n_args, 1);
|
||||
|
||||
g_return_val_if_fail (PyCallable_Check (func), NULL);
|
||||
g_return_val_if_fail (PyTuple_Check (args), NULL);
|
||||
g_return_val_if_fail (PyTuple_GET_SIZE (args) > 0, NULL);
|
||||
|
||||
py_window = pygobject_new (G_OBJECT (window));
|
||||
PyTuple_SET_ITEM (args, 0, py_window);
|
||||
result = PyObject_Call (func, args, NULL);
|
||||
PyTuple_SET_ITEM (args, 0, NULL);
|
||||
Py_DECREF (py_window);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
PyErr_Print ();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!PyObject_TypeCheck (result, &PyMooAction_Type))
|
||||
{
|
||||
g_critical ("%s: got invalid value", G_STRLOC);
|
||||
Py_DECREF (result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
action = MOO_ACTION (pygobject_get (result));
|
||||
g_object_ref (action);
|
||||
Py_DECREF (result);
|
||||
return action;
|
||||
}
|
||||
|
||||
static void
|
||||
destroy_func_n_args (PyObject *func_n_args)
|
||||
{
|
||||
if (func_n_args)
|
||||
{
|
||||
PyTuple_SET_ITEM (PyTuple_GET_ITEM (func_n_args, 1), 0, Py_None);
|
||||
Py_INCREF (Py_None);
|
||||
Py_DECREF (func_n_args);
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
_wrap_moo_window_class_add_action (G_GNUC_UNUSED PyObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *py_type, *py_id, *py_factory_func, *func_n_args;
|
||||
GType type;
|
||||
MooWindowClass *klass;
|
||||
int i, extra;
|
||||
|
||||
extra = PyTuple_GET_SIZE (args) - 3;
|
||||
|
||||
if (extra < 0)
|
||||
return_TypeErr ("at least three arguments required");
|
||||
|
||||
py_type = PyTuple_GET_ITEM (args, 0);
|
||||
py_id = PyTuple_GET_ITEM (args, 1);
|
||||
py_factory_func = PyTuple_GET_ITEM (args, 2);
|
||||
|
||||
type = pyg_type_from_object (py_type);
|
||||
|
||||
if (!type)
|
||||
return NULL;
|
||||
|
||||
if (!g_type_is_a (type, MOO_TYPE_WINDOW))
|
||||
return_TypeErr ("type must be derived from MooWindow");
|
||||
|
||||
if (!PyString_Check (py_id))
|
||||
return_TypeErr ("id must be a string");
|
||||
|
||||
if (!PyCallable_Check (py_factory_func))
|
||||
return_TypeErr ("factory_func must be callable");
|
||||
|
||||
klass = g_type_class_ref (type);
|
||||
|
||||
func_n_args = PyTuple_New (2);
|
||||
PyTuple_SET_ITEM (func_n_args, 0, py_factory_func);
|
||||
Py_INCREF (py_factory_func);
|
||||
|
||||
PyTuple_SET_ITEM (func_n_args, 1, PyTuple_New (1 + extra));
|
||||
|
||||
for (i = 0; i < extra; ++i)
|
||||
{
|
||||
PyTuple_SET_ITEM (PyTuple_GET_ITEM (func_n_args, 1), i + 1,
|
||||
PyTuple_GET_ITEM (args, i + 3));
|
||||
Py_INCREF (PyTuple_GET_ITEM (args, i + 3));
|
||||
}
|
||||
|
||||
moo_window_class_new_action_custom (klass, PyString_AS_STRING (py_id),
|
||||
(MooWindowActionFunc) py_action_factory_func,
|
||||
func_n_args, (GDestroyNotify) destroy_func_n_args);
|
||||
|
||||
g_type_class_unref (klass);
|
||||
return_None;
|
||||
}
|
||||
%%
|
||||
override moo_window_class_remove_action kwargs
|
||||
static PyObject *
|
||||
_wrap_moo_window_class_remove_action (G_GNUC_UNUSED PyObject *self, G_GNUC_UNUSED PyObject *args, G_GNUC_UNUSED PyObject *kwargs)
|
||||
{
|
||||
return_None;
|
||||
}
|
||||
|
|
|
@ -180,7 +180,8 @@ static void moo_window_class_init (MooWindowClass *klass)
|
|||
NULL);
|
||||
|
||||
moo_window_class_new_action_custom (klass, TOOLBAR_STYLE_ACTION_ID,
|
||||
create_toolbar_style_action, NULL);
|
||||
create_toolbar_style_action,
|
||||
NULL, NULL);
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_ACCEL_GROUP,
|
||||
|
@ -836,9 +837,8 @@ create_action (const char *action_id,
|
|||
g_return_val_if_fail (action_id && action_id[0], NULL);
|
||||
|
||||
class_id = moo_window_class_get_id (MOO_WINDOW_CLASS (G_OBJECT_GET_CLASS (window)));
|
||||
action = MOO_ACTION (moo_object_factory_create_object (data->action, window,
|
||||
"id", action_id,
|
||||
NULL));
|
||||
action = MOO_ACTION (moo_object_factory_create_object (data->action, window, NULL));
|
||||
g_object_set (action, "id", action_id, NULL);
|
||||
g_return_val_if_fail (action != NULL, NULL);
|
||||
|
||||
if (g_type_is_a (data->action->object_type, MOO_TYPE_TOGGLE_ACTION))
|
||||
|
@ -966,7 +966,8 @@ void
|
|||
moo_window_class_new_action_custom (MooWindowClass *klass,
|
||||
const char *action_id,
|
||||
MooWindowActionFunc func,
|
||||
gpointer data)
|
||||
gpointer data,
|
||||
GDestroyNotify notify)
|
||||
{
|
||||
MooObjectFactory *action_factory;
|
||||
|
||||
|
@ -979,7 +980,8 @@ moo_window_class_new_action_custom (MooWindowClass *klass,
|
|||
g_object_set_data_full (G_OBJECT (action_factory), "moo-window-class-action-id",
|
||||
g_strdup (action_id), g_free);
|
||||
g_object_set_data (G_OBJECT (action_factory), "moo-window-class-action-func", func);
|
||||
g_object_set_data (G_OBJECT (action_factory), "moo-window-class-action-func-data", data);
|
||||
g_object_set_data_full (G_OBJECT (action_factory), "moo-window-class-action-func-data",
|
||||
data, notify);
|
||||
|
||||
moo_window_class_install_action (klass, action_id, action_factory, NULL, NULL);
|
||||
}
|
||||
|
|
|
@ -90,7 +90,8 @@ void moo_window_class_new_actionv (MooWindowClass *klass,
|
|||
void moo_window_class_new_action_custom (MooWindowClass *klass,
|
||||
const char *id,
|
||||
MooWindowActionFunc func,
|
||||
gpointer data);
|
||||
gpointer data,
|
||||
GDestroyNotify notify);
|
||||
|
||||
void moo_window_class_remove_action (MooWindowClass *klass,
|
||||
const char *id);
|
||||
|
|
Loading…
Reference in New Issue