Christian Robottom Reis wrote:
Why not post to the list and have James and us review and check it in?
OK. The patch is attached with an example of how to use it. The gnomeuimodule.c and
the gnome/uiconsts.py files are patched as follows:
- fix list_to_ui_info() to pass on widget data that is in the UIINFO lists
- add a function to update the UIINFO lists to add the widget data after a call to:
- gnome_app_create_menus_custom()
- gnome_app_create_toolbar_custom()
- gnome_app_insert_menus_custom()
- gnome_popup_menu_new90
- fix list_to_ui_info() to pass inc_uibd to recursive calls
- add code to list_to_ui_info() and free_ui_info() to allow use of inline pixmap
data
- enable use of inline pixmap data in gnome/uiconsts.py
The UIINFO widget changes allow you to install hints in a statusbar or appbar and
to directly access the menu widgets using the UIINFO lists.
In order to save the widget info in the UIINFO lists the list items must themselves
be lists instead of tuples. If the items are tuples the original behavior will
apply so existing code should still work with these changes.
John
--- gnome/uiconsts.py.orig Tue Apr 20 07:27:54 1999
+++ gnome/uiconsts.py Wed Nov 7 10:32:23 2001
@@ -12,7 +12,7 @@
APP_PIXMAP_NONE = 0
APP_PIXMAP_STOCK= 1
-#APP_PIXMAP_DATA = 2 # not supported by pygnome
+APP_PIXMAP_DATA = 2 # now supported by pygnome
APP_PIXMAP_FILENAME = 3
# UIInfo entries are (type, label, tooltip, callback, cbdata,
@@ -24,8 +24,12 @@
APP_PIXMAP_NONE, None, 0, 0)
def UIINFO_ITEM(label, tip=None, cb=None, image=None):
if image:
- return (APP_UI_ITEM, label, tip, cb, None,
- APP_PIXMAP_FILENAME, image, 0, 0)
+ if type(image) == type([]):
+ return (APP_UI_ITEM, label, tip, cb, None,
+ APP_PIXMAP_DATA, image, 0, 0)
+ else:
+ return (APP_UI_ITEM, label, tip, cb, None,
+ APP_PIXMAP_FILENAME, image, 0, 0)
else:
return (APP_UI_ITEM, label, tip, cb, None,
APP_PIXMAP_NONE, None, 0, 0)
@@ -35,8 +39,12 @@
def UIINFO_TOGGLEITEM(label, tip=None, cb=None, image=None):
if image:
- return (APP_UI_TOGGLEITEM, label, tip, cb, None,
- APP_PIXMAP_FILENAME, image, 0, 0)
+ if type(image) == type([]):
+ return (APP_UI_TOGGLEITEM, label, tip, cb, None,
+ APP_PIXMAP_DATA, image, 0, 0)
+ else:
+ return (APP_UI_TOGGLEITEM, label, tip, cb, None,
+ APP_PIXMAP_FILENAME, image, 0, 0)
else:
return (APP_UI_TOGGLEITEM, label, tip, cb, None,
APP_PIXMAP_NONE, None, 0, 0)
@@ -58,8 +66,12 @@
def UIINFO_RADIOITEM(label, tip=None, cb=None, image=None):
print Deprecated -- just use UIINFO_ITEM for radio list items
if image:
- return (APP_UI_ITEM, label, tip, cb, None,
- APP_PIXMAP_FILENAME, image, 0, 0)
+ if type(image) == type([]):
+ return (APP_UI_ITEM, label, tip, cb, None,
+ APP_PIXMAP_DATA, image, 0, 0)
+ else:
+ return (APP_UI_ITEM, label, tip, cb, None,
+ APP_PIXMAP_FILENAME, image, 0, 0)
else:
return (APP_UI_ITEM, label, tip, cb, None,
APP_PIXMAP_NONE, None, 0, 0)
@@ -100,6 +112,9 @@
def UIINFO_MENU_NEW_ITEM(label, tip, cb=None, data=None):
return (APP_UI_ITEM_CONFIGURABLE, label, tip, cb, data,
APP_PIXMAP_NONE, None, _APP_CONFIGURABLE_ITEM_NEW, 0)
+def UIINFO_MENU_NEW_SUBTREE(tree):
+return (APP_UI_ITEM_SUBTREE_STOCK, _New, None, tree, None,
+ APP_PIXMAP_STOCK, STOCK_MENU_NEW, 0, 0 )
def UIINFO_MENU_OPEN_ITEM(cb=None, data=None):
return (APP_UI_ITEM_CONFIGURABLE, None, None, cb, data,
APP_PIXMAP_NONE, None, _APP_CONFIGURABLE_ITEM_OPEN, 0)
@@ -303,6 +318,7 @@
STOCK_PIXMAP_TABLE_FILL= Table Fill
STOCK_PIXMAP_TEXT_BULLETED_LIST = Text Bulleted List
STOCK_PIXMAP_TEXT_NUMBERED_LIST = Text Numbered List
+STOCK_PIXMAP_COLORSELECTOR = Color Select
STOCK_PIXMAP_EXIT= STOCK_PIXMAP_QUIT
--- gnomeuimodule.c.origThu Apr 6 08:19:48 2000
+++ gnomeuimodule.c Wed Nov 7 11:44:20 2001
@@ -64,10 +64,10 @@
static GnomeUIInfo *list_to_ui_info(PyObject *list, gboolean inc_uibd) {
GnomeUIInfo *ret, *inf, *sub;
- PyObject *item, *moreinfo, *ac_mods;
- int len, i;
+ PyObject *item, *moreinfo, *ac_mods, *pixmapinfo, *widget = NULL;
+ int len, i, j, pmlen;
int type, pix_type;
- char buf[100];
+ char buf[100], **data;
if (!PyList_Check(list)) {