Re: [pygtk] How to use UIINFO_TOGGLEITEM

2001-11-07 Thread John Finlay

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)) {
 

Re: [pygtk] How to use UIINFO_TOGGLEITEM

2001-11-04 Thread finlay


Yotam Medini wrote:

 On Thu, Nov 01, 2001 at 09:57:20AM -0800, [EMAIL PROTECTED] wrote:
  Yotam Medini wrote:
  
  AFAICT there is no way to access the menu items short of walking the
  widget list and locating the widgets. This is the same problem that I
  referred to in an earlier message that prevents install_menu_hints() from
  working.
  I have some patches for gnomeuimodule.c that save the widget info in the
  UIINFO lists so that install_menu_hints() works and you can access the
  menu widgets. The same patch also works for toolbars created using UIINFO.
  If you can use this patch let me know and I'll send it to you.

 Was this patch considered to enter the official pygtk release?
 I somehow gave up, and just changed my application default behaviour...:(

No - I haven't looked into how to submit a patch for inclusion. I ran into the
same problem as you and developed the patch to fix the problem.

John

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk



[pygtk] How to use UIINFO_TOGGLEITEM

2000-02-21 Thread Juergen Ehrensberger

Hi all,

in a GnomeApp I created menus including a UIINFO_TOGGLEITEM. However, the
connected callback cannot determine the value of the toggle item, since it
receives a GtkObject of type GtkCheckMenuItem instead of the GtkCheckMenuItem
itself. Therefore the method call __getattr__("active") does not work. Is it
possible to access the GtkCheckMenuItem inside the GtkObject ? For GtkMenus
everything works just fine.

Cheers
Juergen


from gtk import *
from gnome.ui import *

def toggled(checkMenuItem):
print checkMenuItem
print checkMenuItem.__getattr__("active")

win = GnomeApp()
win.connect("destroy", mainquit)

# Gnome Menu
toggle_menu = [UIINFO_TOGGLEITEM("Toggle", cb=toggled)]
main_menu = [UIINFO_SUBTREE('GnomeMenu', toggle_menu)]
win.create_menus(main_menu)

# GtkMenu
vbox = GtkVBox()
gtkMenuBar = GtkMenuBar()
gtkMenuItem = GtkMenuItem("GtkMenu")
gtkSubMenu = GtkMenu()
gtkCheck = GtkCheckMenuItem("Toggle")
gtkCheck.connect("toggled", toggled)
gtkSubMenu.append(gtkCheck)
gtkMenuItem.set_submenu(gtkSubMenu)
gtkMenuBar.append(gtkMenuItem)
vbox.pack_start(gtkMenuBar, expand=TRUE)

win.set_contents(vbox)
win.set_usize(100,100)
win.show_all()
mainloop()

-- 
_

 /  __  /  /  / Jürgen Ehrensberger
/  /   /  /  /  Laboratoire de Télécommunications
   /  /  /  /   Ecole Polytechnique Fédérale de Lausanne
  /  /  /  /1015 Lausanne, Switzerland
_/ _/ _/ _/ Tel:  +41 21 693 46 94, Fax: +41 21 693 26 83
Mail: [EMAIL PROTECTED]
_
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]