diff options
-rw-r--r-- | ChangeLog | 31 | ||||
-rw-r--r-- | GdkImlib.py | 8 | ||||
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | NEWS | 10 | ||||
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | configure.in | 4 | ||||
-rw-r--r-- | examples/simple/dnd.py | 229 | ||||
-rw-r--r-- | examples/simple/dndpixmap.py | 260 | ||||
-rw-r--r-- | gdkimlibmodule.c | 22 | ||||
-rw-r--r-- | generate/gtk.defs | 17 | ||||
-rw-r--r-- | generate/gtkcontainers.defs | 4 | ||||
-rw-r--r-- | generate/gtkdnd.defs | 7 | ||||
-rw-r--r-- | generate/gtkedit.defs | 4 | ||||
-rw-r--r-- | generate/gtklists.defs | 4 | ||||
-rw-r--r-- | generate/gtkmenus.defs | 7 | ||||
-rw-r--r-- | generate/gtkmisc.defs | 7 | ||||
-rw-r--r-- | gtk.py | 40 | ||||
-rw-r--r-- | gtkmodule.c | 92 | ||||
-rw-r--r-- | pygtk.spec | 2 |
19 files changed, 654 insertions, 98 deletions
@@ -1,3 +1,34 @@ +1999-02-02 James Henstridge <james@daa.com.au> + + * generate/gtklists.defs, gtk.py: added GtkCList.focus_row. + + * _gdkimlibmodule.c, GdkImlib.py: added push_visual and pop_visual, + that can be used to easily set GTK to use the imlib visual/colormap + combination. + + * gtkmodule.c: the PyObject -> GtkArg conversion routines were not + catching some exceptions that they generated. This would cause + wierd problems if you passed the wrong argument types to signal + handlers. This was found by Chi-Deok Hwang <cdhwang@sr.hei.co.kr> + + * examples/simple/dnd.py, examples/simple/dndpixmaps.py: and example + of drag and drop contributed by Chi-Deok Hwang <cdhwang@sr.hei.co.kr> + + * gtkmodule.c: added gtk_ctree_get_selection, that returns nodes + rather than pointers. + + * gtk.py: made changes to reflect those below. Also added + GtkWidget.get_colormap() (it was missing previously). + + * generate/gtkedit.defs (gtk_spin_button_update): added function. + + * generate/gtkmenus.defs (gtk_check_menu_item_set_active): function + renaming. + (gtk_menu_set_title): added function. + + * generate/gtkmisc.defs (gtk_toggle_button_[sg]et_active): added + functions, and removed gtk_toggle_button_set_state. + 1999-01-27 James Henstridge <james@daa.com.au> * gtkmodule.c: fixed some typos in _wrap_gtk_ctree_get_row_data and diff --git a/GdkImlib.py b/GdkImlib.py index d74195ef..53aff37e 100644 --- a/GdkImlib.py +++ b/GdkImlib.py @@ -144,3 +144,11 @@ def get_sysconfig(): return _gdkimlib.gdk_imlib_get_sysconfig() def best_color_match(r, g, b): return _gdkimlib.gdk_imlib_best_color_match(r, g, b) + +# these are to help with apps that use imlib a lot. They push/pop +# imlib's visual/colormap combination ... +def push_visual(): + _gdkimlib.gdk_imlib_push_visual() +def pop_visual(): + _gdkimlib.gdk_imlib_pop_visual() + diff --git a/Makefile.am b/Makefile.am index 1992291f..0138f9ba 100644 --- a/Makefile.am +++ b/Makefile.am @@ -57,6 +57,8 @@ EXTRA_DIST = \ examples/simple/tooltip1.py \ examples/simple/tooltip2.py \ examples/simple/scribble.py \ + examples/simple/dnd.py \ + examples/simple/dndpixmap.py \ examples/simple/README \ examples/testgtk/testgtk.py \ examples/testgtk/test.xpm \ @@ -1,3 +1,13 @@ +pygtk-0.5.10: xx-February-1999 + - Updated for gtk+-1.1.13/14. + - Fixed up some selection problems. + - Added DnD example translated by Chi-Deok Hwang. + - Some ctree fixes. + - Some function renamings. + +pygtk-0.5.9: + - Updated for gtk+-1.1.9 + pygtk-0.5.8: 10-December-1998 - I made a mistake during building the last package. I ran cvs co pygtk; aclocal; automake --add-missing; autoconf; configure @@ -49,7 +49,7 @@ Compilation This archive contains a single C module called gtkmodule. It contains an almost direct mapping of the functions in GTK including GTK signal handling, and the gtk_object_new/gtk_object_set commands. This -version REQUIRES gtk+-1.1.9 or later, as it includes support for +version REQUIRES gtk+-1.1.13 or later, as it includes support for features not found in previous versions, and there are incompatibilities between versions. Also if you want the GdkImlib extension, you must have Imlib version 1.8 or greater. I recommend diff --git a/configure.in b/configure.in index c5bd0498..f6708b09 100644 --- a/configure.in +++ b/configure.in @@ -2,12 +2,12 @@ AC_INIT dnl for gnome-python: -AM_INIT_AUTOMAKE(pygtk, 0.5.9) +AM_INIT_AUTOMAKE(pygtk, 0.5.10) AM_PATH_PYTHON AM_INIT_PYEXEC_MOD -AM_PATH_GTK(1.1.9) +AM_PATH_GTK(1.1.13) AM_PATH_GDK_IMLIB(1.8, [BUILD_IMLIB=], [BUILD_IMLIB="#"]) AC_SUBST(BUILD_IMLIB) diff --git a/examples/simple/dnd.py b/examples/simple/dnd.py index 91e2a6b0..5481fa9b 100644 --- a/examples/simple/dnd.py +++ b/examples/simple/dnd.py @@ -1,77 +1,176 @@ -#!/usr/bin/env python -from gtk import * - -# a nice easy to read fixed spacing font. -font = load_font("-*-lucidatypewriter-medium-r-*-*-14-*-*-*-*-*-*-*") - -list = "abcdefghijklmnopqrstuvwxyz" + \ - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + \ - "0123456789" + \ - "`~!@#$%^&*()-_=+\|[]{};:'\",.<>/? " -printable = '' -for c in map(chr, range(256)): - if c in list: - printable = printable + c - else: - printable = printable + '.' -del list, c - -def format_line(str): - hexstr = reduce(lambda x, a: x + hex(256+ord(a))[-2:] + ' ', str, '') - if len(hexstr) < 48: - hexstr = (hexstr + ' '*48)[:48] - return hexstr + ' ' + reduce(lambda x, a: x + printable[ord(a)],str,'') +#! /usr/bin/env python -def format_data(str): - ret = '' - while len(str) > 16: - line = str[:16] - str = str[16:] - ret = ret + format_line(line) + '\n' - if str: ret = ret + format_line(str) - return ret +from gtk import * +from GDK import * +from dndpixmap import * -def dnd_drop(b, event): - data_type.set_text(event.data_type) - data.delete_text(0, data.get_length()) - data.insert(font, black, white, format_data(event.data)) - pass +trashcan_open = None +trashcan_open_mask = None +trashcan_closed = None +trashcan_closed_mask = None -win = GtkWindow() -win.set_title("Drag to Me") -win.border_width(10) +have_drag = FALSE; +popped_up = FALSE +in_popup = FALSE +popup_timer = 0 +popdown_timer = 0 +popup_win = None -t = GtkTable(5,4) -win.add(t) -t.show() -l = GtkLabel("Data Type") -l.set_justify(JUSTIFY_RIGHT) -t.attach(l, 0,1, 0,1, xoptions=FILL) -l.show() +TARGET_STRING = 0 +TARGET_ROOTWIN = 1 -data_type = GtkLabel("*None*") -data_type.set_justify(JUSTIFY_LEFT) -t.attach(data_type, 1,2, 0,1) -data_type.show() +target = [ +('STRING', 0, TARGET_STRING), +('text/plain', 0, TARGET_STRING), +('application/x-rootwin-drop', 0, TARGET_ROOTWIN)] -l = GtkLabel("Data") -l.set_justify(JUSTIFY_RIGHT) -t.attach(l, 0,1, 1,2, xoptions=FILL) -l.show() +def target_drag_leave(w, context, time): + global trashcan_closed, trashcan_closed_mask + global have_drag + print 'leave' + have_drag = FALSE + w.set(trashcan_closed, trashcan_closed_mask) +def target_drag_motion(w, context, x, y, time): + global trashcan_open, trashcan_open_mask + global have_drag + if not have_drag: + have_drag = TRUE + w.set(trashcan_open, trashcan_open_mask) + source_widget = w.drag_get_source_widget(context) + print 'motion, source ', + if source_widget: + print source_widget.__class__.__name__ + else: + print 'unknown' + w.drag_status(context, context.suggested_action, time) + return TRUE +def target_drag_drop(w, context, x, y, time): + global trashcan_closed, trashcan_closed_mask + global have_drag + print 'drop' + have_drag = FALSE + w.set(trashcan_closed, trashcan_closed_mask) + if context.targets: + w.drag_get_data(context, context.targets[0], time) + return TRUE + return FALSE +def target_drag_data_received(w, context, x, y, data, info, time): + if data.format == 8: + print 'Received "%s" in trashcan' % data.data + w.drag_finish(context, TRUE, FALSE, time) + else: + w.drag_finish(context, FALSE, FALSE, time) +def label_drag_data_received(w, context, x, y, data, info, time): + if data and data.format == 8: + print 'Received "%s" in label' % data.data + w.drag_finish(context, TRUE, FALSE, time) + else: + w.drag_finish(context, FALSE, FALSE, time) +def source_drag_data_get(w, context, selection_data, info, time): + if info == TARGET_ROOTWIN: + print 'I was dropped on the rootwin' + else: + selection_data.set(selection_data.target, 8, "I'm Data!") -data = GtkText() -data.set_usize(600, -1) -style = data.get_style() -white = style.white -black = style.black -t.attach(data, 1,2, 1,2) -data.show() +def popdown_cb(): + global popdown_timer, popped_up + global popup_win + popdown_timer = 0 + popup_win.hide() + popped_up = FALSE + return FALSE +def popup_motion(w, context, x, y, time): + global in_popup, popdown_timer + if not in_popup: + in_popup = TRUE + if popdown_timer: + print 'removed popdown' + timeout_remove(popdown_timer) + popdown_timer = 0 + return TRUE +def popup_leave(w, context, time): + global in_popup, popdown_timer + print 'popup_leave' + if in_popup: + in_popup = FALSE + if not popdown_timer: + print 'added popdown' + popdown_timer = timeout_add(500, popdown_cb) +def popup_cb(): + global popped_up, popup_win + global popup_timer, popdown_timer + if not popped_up: + if not popup_win: + popup_win = GtkWindow(WINDOW_POPUP) + popup_win.set_position(WIN_POS_MOUSE) + table = GtkTable(3,3,FALSE) + for k in range(9): + i, j = divmod(k, 3) + b = GtkButton("%d,%d" % (i,j)) + table.attach(b, i,i+1,j,j+1) + b.drag_dest_set(DEST_DEFAULT_ALL, target, + ACTION_COPY | ACTION_MOVE) + b.connect('drag_motion', popup_motion) + b.connect('drag_leave', popup_leave) + table.show_all() + popup_win.add(table) + popup_win.show() + popped_up = TRUE + popdown_timer = timeout_add(500, popdown_cb) + print 'added popdown' + popup_timer = 0 + return FALSE +def popsite_motion(w, context, x, y, time): + global popup_timer + if not popup_timer: + popup_timer = timeout_add(500, popup_cb) + return TRUE +def popsite_leave(w, context, time): + global popup_timer + if popup_timer: + timeout_remove(popup_timer) + popup_timer = 0 +def source_drag_data_delete(w, context, data): + print 'Delete the data!' +def create_pixmap(w, xpm): + return create_pixmap_from_xpm_d(w, None, xpm) +def main(): + global trashcan_open, trashcan_open_mask + global trashcan_closed, trashcan_closed_mask + global drag_icon, drag_mask + win = GtkWindow() + win.connect('destroy', mainquit) + table = GtkTable(2,2) + win.add(table) + drag_icon, drag_mask = create_pixmap(win, drag_icon_xpm) + trashcan_open, trashcan_open_mask = create_pixmap(win, trashcan_open_xpm) + trashcan_closed, trashcan_closed_mask = create_pixmap(win, trashcan_closed_xpm) + label = GtkLabel('Drop Here!\n') + label.drag_dest_set(DEST_DEFAULT_ALL, target[:-1], ACTION_COPY | ACTION_MOVE) + label.connect('drag_data_received', label_drag_data_received) + table.attach(label, 0, 1, 0, 1) -win.connect("drop_data_available_event", dnd_drop) -win.dnd_drop_set(TRUE, ['text/plain', 'application/x-color', 'ALL'], FALSE) + label = GtkLabel('Popup\n') + label.drag_dest_set(DEST_DEFAULT_ALL, target[:-1], ACTION_COPY | ACTION_MOVE) + table.attach(label, 1, 2, 1, 2) + label.connect('drag_motion', popsite_motion) + label.connect('drag_leave', popsite_leave) -win.connect("destroy", mainquit) -win.show() + pixmap = GtkPixmap(trashcan_closed, trashcan_closed_mask) + pixmap.drag_dest_set(0, [], 0) + table.attach(pixmap, 1, 2, 0, 1) + pixmap.connect('drag_leave', target_drag_leave) + pixmap.connect('drag_motion', target_drag_motion) + pixmap.connect('drag_drop', target_drag_drop) + pixmap.connect('drag_data_received', target_drag_data_received) + b = GtkButton('Drag Here\n') + b.drag_source_set(BUTTON1_MASK|BUTTON3_MASK, target, ACTION_COPY|ACTION_MOVE) + b.drag_source_set_icon(win.get_colormap(), drag_icon, drag_mask) + table.attach(b, 0, 1, 1, 2) + b.connect('drag_data_get', source_drag_data_get) + b.connect('drag_data_delete', source_drag_data_delete) + win.show_all() +main() mainloop() diff --git a/examples/simple/dndpixmap.py b/examples/simple/dndpixmap.py new file mode 100644 index 00000000..8912365a --- /dev/null +++ b/examples/simple/dndpixmap.py @@ -0,0 +1,260 @@ +drag_icon_xpm = [ +"36 48 9 1", +" c None", +". c #020204", +"+ c #8F8F90", +"@ c #D3D3D2", +"# c #AEAEAC", +"$ c #ECECEC", +"% c #A2A2A4", +"& c #FEFEFC", +"* c #BEBEBC", +" .....................", +" ..&&&&&&&&&&&&&&&&&&&.", +" ...&&&&&&&&&&&&&&&&&&&.", +" ..&.&&&&&&&&&&&&&&&&&&&.", +" ..&&.&&&&&&&&&&&&&&&&&&&.", +" ..&&&.&&&&&&&&&&&&&&&&&&&.", +" ..&&&&.&&&&&&&&&&&&&&&&&&&.", +" ..&&&&&.&&&@&&&&&&&&&&&&&&&.", +" ..&&&&&&.*$%$+$&&&&&&&&&&&&&.", +" ..&&&&&&&.%$%$+&&&&&&&&&&&&&&.", +" ..&&&&&&&&.#&#@$&&&&&&&&&&&&&&.", +" ..&&&&&&&&&.#$**#$&&&&&&&&&&&&&.", +" ..&&&&&&&&&&.&@%&%$&&&&&&&&&&&&&.", +" ..&&&&&&&&&&&.&&&&&&&&&&&&&&&&&&&.", +" ..&&&&&&&&&&&&.&&&&&&&&&&&&&&&&&&&.", +"................&$@&&&@&&&&&&&&&&&&.", +".&&&&&&&+&&#@%#+@#@*$%$+$&&&&&&&&&&.", +".&&&&&&&+&&#@#@&&@*%$%$+&&&&&&&&&&&.", +".&&&&&&&+&$%&#@&#@@#&#@$&&&&&&&&&&&.", +".&&&&&&@#@@$&*@&@#@#$**#$&&&&&&&&&&.", +".&&&&&&&&&&&&&&&&&&&@%&%$&&&&&&&&&&.", +".&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&.", +".&&&&&&&&$#@@$&&&&&&&&&&&&&&&&&&&&&.", +".&&&&&&&&&+&$+&$&@&$@&&$@&&&&&&&&&&.", +".&&&&&&&&&+&&#@%#+@#@*$%&+$&&&&&&&&.", +".&&&&&&&&&+&&#@#@&&@*%$%$+&&&&&&&&&.", +".&&&&&&&&&+&$%&#@&#@@#&#@$&&&&&&&&&.", +".&&&&&&&&@#@@$&*@&@#@#$#*#$&&&&&&&&.", +".&&&&&&&&&&&&&&&&&&&&&$%&%$&&&&&&&&.", +".&&&&&&&&&&$#@@$&&&&&&&&&&&&&&&&&&&.", +".&&&&&&&&&&&+&$%&$$@&$@&&$@&&&&&&&&.", +".&&&&&&&&&&&+&&#@%#+@#@*$%$+$&&&&&&.", +".&&&&&&&&&&&+&&#@#@&&@*#$%$+&&&&&&&.", +".&&&&&&&&&&&+&$+&*@&#@@#&#@$&&&&&&&.", +".&&&&&&&&&&$%@@&&*@&@#@#$#*#&&&&&&&.", +".&&&&&&&&&&&&&&&&&&&&&&&$%&%$&&&&&&.", +".&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&.", +".&&&&&&&&&&&&&&$#@@$&&&&&&&&&&&&&&&.", +".&&&&&&&&&&&&&&&+&$%&$$@&$@&&$@&&&&.", +".&&&&&&&&&&&&&&&+&&#@%#+@#@*$%$+$&&.", +".&&&&&&&&&&&&&&&+&&#@#@&&@*#$%$+&&&.", +".&&&&&&&&&&&&&&&+&$+&*@&#@@#&#@$&&&.", +".&&&&&&&&&&&&&&$%@@&&*@&@#@#$#*#&&&.", +".&&&&&&&&&&&&&&&&&&&&&&&&&&&$%&%$&&.", +".&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&.", +".&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&.", +".&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&.", +"...................................."] + +trashcan_closed_xpm = [ +"64 80 17 1", +" c None", +". c #030304", +"+ c #5A5A5C", +"@ c #323231", +"# c #888888", +"$ c #1E1E1F", +"% c #767677", +"& c #494949", +"* c #9E9E9C", +"= c #111111", +"- c #3C3C3D", +"; c #6B6B6B", +"> c #949494", +", c #282828", +"' c #808080", +") c #545454", +"! c #AEAEAC", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ==......=$$...=== ", +" ..$------)+++++++++++++@$$... ", +" ..=@@-------&+++++++++++++++++++-.... ", +" =.$$@@@-&&)++++)-,$$$$=@@&+++++++++++++,..$ ", +" .$$$$@@&+++++++&$$$@@@@-&,$,-++++++++++;;;&.. ", +" $$$$,@--&++++++&$$)++++++++-,$&++++++;%%'%%;;$@ ", +" .-@@-@-&++++++++-@++++++++++++,-++++++;''%;;;%*-$ ", +" +------++++++++++++++++++++++++++++++;;%%%;;##*!. ", +" =+----+++++++++++++++++++++++;;;;;;;;;;;;%'>>). ", +" .=)&+++++++++++++++++;;;;;;;;;;;;;;%''>>#>#@. ", +" =..=&++++++++++++;;;;;;;;;;;;;%###>>###+%== ", +" .&....=-+++++%;;####''''''''''##'%%%)..#. ", +" .+-++@....=,+%#####'%%%%%%%%%;@$-@-@*++!. ", +" .+-++-+++-&-@$$=$=......$,,,@;&)+!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" =+-++-+++-+++++++++!++++!++++!+++!++!+++= ", +" $.++-+++-+++++++++!++++!++++!+++!++!+.$ ", +" =.++++++++++++++!++++!++++!+++!++.= ", +" $..+++++++++++++++!++++++...$ ", +" $$=.............=$$ ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "] + +trashcan_open_xpm = [ +"64 80 17 1", +" c None", +". c #030304", +"+ c #5A5A5C", +"@ c #323231", +"# c #888888", +"$ c #1E1E1F", +"% c #767677", +"& c #494949", +"* c #9E9E9C", +"= c #111111", +"- c #3C3C3D", +"; c #6B6B6B", +"> c #949494", +", c #282828", +"' c #808080", +") c #545454", +"! c #AEAEAC", +" ", +" ", +" ", +" ", +" ", +" ", +" .=.==.,@ ", +" ==.,@-&&&)-= ", +" .$@,&++;;;%>*- ", +" $,-+)+++%%;;'#+. ", +" =---+++++;%%%;%##@. ", +" @)++++++++;%%%%'#%$ ", +" $&++++++++++;%%;%##@= ", +" ,-++++)+++++++;;;'#%) ", +" @+++&&--&)++++;;%'#'-. ", +" ,&++-@@,,,,-)++;;;'>'+, ", +" =-++&@$@&&&&-&+;;;%##%+@ ", +" =,)+)-,@@&+++++;;;;%##%&@ ", +" @--&&,,@&)++++++;;;;'#)@ ", +" ---&)-,@)+++++++;;;%''+, ", +" $--&)+&$-+++++++;;;%%'';- ", +" .,-&+++-$&++++++;;;%''%&= ", +" $,-&)++)-@++++++;;%''%), ", +" =,@&)++++&&+++++;%'''+$@&++++++ ", +" .$@-++++++++++++;'#';,........=$@&++++ ", +" =$@@&)+++++++++++'##-.................=&++ ", +" .$$@-&)+++++++++;%#+$.....................=)+ ", +" $$,@-)+++++++++;%;@=........................,+ ", +" .$$@@-++++++++)-)@=............................ ", +" $,@---)++++&)@===............................,. ", +" $-@---&)))-$$=..............................=)!. ", +" --&-&&,,$=,==...........................=&+++!. ", +" =,=$..=$+)+++++&@$=.............=$@&+++++!++!. ", +" .)-++-+++++++++++++++++++++++++++!++!++!. ", +" .+-++-+++++++++++++++++++++++!+++!++!++!. ", +" .+-++-+++-+++++++++!+++!!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ", +" =+-++-+++-+++++++++!++++!++++!+++!++!+++= ", +" $.++-+++-+++++++++!++++!++++!+++!++!+.$ ", +" =.++++++++++++++!++++!++++!+++!++.= ", +" $..+++++++++++++++!++++++...$ ", +" $$==...........==$$ ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "] + diff --git a/gdkimlibmodule.c b/gdkimlibmodule.c index 2ae4df11..55f6b43b 100644 --- a/gdkimlibmodule.c +++ b/gdkimlibmodule.c @@ -179,7 +179,7 @@ static PyObject *_wrap_gdk_imlib_get_pixmap(PyObject *self, PyObject *args) { GdkPixmap *pix; GdkBitmap *mask; - if (!PyArg_ParseTuple(args, "O!:gdk_imlib_make_pixmap", + if (!PyArg_ParseTuple(args, "O!:gdk_imlib_get_pixmap", &PyGdkImlibImage_Type, &image)) return NULL; pix = gdk_imlib_move_image(PyGdkImlibImage_Get(image)); @@ -723,7 +723,27 @@ static PyObject *_wrap_gdk_imlib_get_filename(PyObject *self, PyObject *args) { return PyString_FromString(PyGdkImlibImage_Get(image)->filename); } +static PyObject *_wrap_gdk_imlib_push_visual(PyObject *self, PyObject *args) { + if (!PyArg_ParseTuple(args, ":gdk_imlib_push_visual")) + return NULL; + gtk_widget_push_visual(gdk_imlib_get_visual()); + gtk_widget_push_colormap(gdk_imlib_get_colormap()); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject *_wrap_gdk_imlib_pop_visual(PyObject *self, PyObject *args) { + if (!PyArg_ParseTuple(args, ":gdk_imlib_pop_visual")) + return NULL; + gtk_widget_pop_visual(); + gtk_widget_pop_colormap(); + Py_INCREF(Py_None); + return Py_None; +} + static PyMethodDef _gdkimlibMethods[] = { + { "gdk_imlib_push_visual", _wrap_gdk_imlib_push_visual, 1 }, + { "gdk_imlib_pop_visual", _wrap_gdk_imlib_pop_visual, 1 }, { "gdk_imlib_get_filename", _wrap_gdk_imlib_get_filename, 1 }, { "gdk_imlib_get_rgb_height", _wrap_gdk_imlib_get_rgb_height, 1 }, { "gdk_imlib_get_rgb_width", _wrap_gdk_imlib_get_rgb_width, 1 }, diff --git a/generate/gtk.defs b/generate/gtk.defs index b1d4ab02..87563a55 100644 --- a/generate/gtk.defs +++ b/generate/gtk.defs @@ -129,6 +129,23 @@ (GdkColor bg) (int x) (int y))) +;; misc gdk functions that are useful to GTK programmers ... +(define-func gdk_screen_width + int + ()) + +(define-func gdk_screen_height + int + ()) + +(define-func gdk_screen_width_mm + int + ()) + +(define-func gdk_screen_height_mm + int + ()) + ;; these two are used extensively -- define early (define-object GtkObject (nil)) (define-object GtkWidget (GtkObject)) diff --git a/generate/gtkcontainers.defs b/generate/gtkcontainers.defs index 0d56b061..e15c7c1d 100644 --- a/generate/gtkcontainers.defs +++ b/generate/gtkcontainers.defs @@ -264,12 +264,12 @@ (define-object GtkHBox (GtkBox)) (define-func gtk_hbox_new GtkWidget - ((int homogeneous) (int spacing))) + ((bool homogeneous) (int spacing))) (define-object GtkVBox (GtkBox)) (define-func gtk_vbox_new GtkWidget - ((int homogeneous) (int spacing))) + ((bool homogeneous) (int spacing))) ;;; ButtonBox diff --git a/generate/gtkdnd.defs b/generate/gtkdnd.defs index 83160477..1000c9d5 100644 --- a/generate/gtkdnd.defs +++ b/generate/gtkdnd.defs @@ -81,6 +81,13 @@ (GdkBitmap mask) (int hot_x) (int hot_y))) +; this is GDK, but useful for programs at the GTK level ... +(define-func gdk_drag_status + none + ((GdkDragContext context) + (GdkDragAction action) + (uint time))) + ;; Selection functions ... (define-func gdk_atom_intern diff --git a/generate/gtkedit.defs b/generate/gtkedit.defs index d5e18165..2d105386 100644 --- a/generate/gtkedit.defs +++ b/generate/gtkedit.defs @@ -185,6 +185,10 @@ ((GtkSpinButton spin_button) (bool snap_to_ticks))) +(define-func gtk_spin_button_update + none + ((GtkSpinButton spin_button))) + ;; Text (define-object GtkText (GtkEditable) diff --git a/generate/gtklists.defs b/generate/gtklists.defs index fabe136a..72d1b937 100644 --- a/generate/gtklists.defs +++ b/generate/gtklists.defs @@ -109,7 +109,9 @@ ;;; GtkCList -(define-object GtkCList (GtkContainer)) +(define-object GtkCList (GtkContainer) + (fields + (int focus_row))) (define-func gtk_clist_new GtkWidget diff --git a/generate/gtkmenus.defs b/generate/gtkmenus.defs index becd30d7..f9c33026 100644 --- a/generate/gtkmenus.defs +++ b/generate/gtkmenus.defs @@ -125,6 +125,11 @@ ((GtkMenu menu) (bool torn_off))) +(define-func gtk_menu_set_title + none + ((GtkMenu menu) + (string title))) + ;; MenuItem (define-object GtkMenuItem (GtkItem)) @@ -187,7 +192,7 @@ GtkWidget ((string label))) -(define-func gtk_check_menu_item_set_state +(define-func gtk_check_menu_item_set_active none ((GtkCheckMenuItem check_menu_item) (bool state))) diff --git a/generate/gtkmisc.defs b/generate/gtkmisc.defs index c3cf1998..c012fc6f 100644 --- a/generate/gtkmisc.defs +++ b/generate/gtkmisc.defs @@ -132,7 +132,6 @@ (define-object GtkToggleButton (GtkButton) (fields - (bool active) (bool draw_indicator))) (define-func gtk_toggle_button_new @@ -148,11 +147,15 @@ ((GtkToggleButton toggle_button) (bool draw_indicator))) -(define-func gtk_toggle_button_set_state +(define-func gtk_toggle_button_set_active none ((GtkToggleButton toggle_button) (bool state))) +(define-func gtk_toggle_button_get_active + bool + ((GtkToggleButton toggle_button))) + (define-func gtk_toggle_button_toggled none ((GtkToggleButton toggle_button))) @@ -249,6 +249,8 @@ class GtkWidget(GtkObject): hot_x, hot_y) def drag_get_source_widget(self, context): return _obj2inst(_gtk.gtk_drag_get_source_widget(context)) + def drag_status(self, context, action, time): + _gtk.gdk_drag_status(context, action, time) def draw(self, rect): _gtk.gtk_widget_draw(self._o, rect) def draw_default(self, obj=None): @@ -263,6 +265,8 @@ class GtkWidget(GtkObject): _gtk.gtk_widget_lock_accelerators(self._o) def get_ancestor(self, type): return _obj2inst(_gtk.gtk_widget_get_ancestor(self._o, type)) + def get_colormap(self): + return _gtk.gtk_widget_get_colormap(self._o) def get_composite_name(self): return _gtk.gtk_widget_get_composite_name(self._o) def get_events(self): @@ -522,7 +526,12 @@ class GtkToggleButton(GtkButton): def set_mode(self, di): _gtk.gtk_toggle_button_set_mode(self._o, di) def set_state(self, state): - _gtk.gtk_toggle_button_set_state(self._o, state) + print "GtkToggleButton.set_state deprecated -- use set_active" + self.set_active(state) + def set_active(self, active): + _gtk.gtk_toggle_button_set_active(self._o, active) + def get_active(self): + return _gtk.gtk_toggle_button_get_active(self._o) def toggled(self, obj): _gtk.gtk_toggle_button_toggled(self._o) @@ -641,7 +650,10 @@ class GtkCheckMenuItem(GtkMenuItem): def set_show_toggle(self, always): _gtk.gtk_check_menu_item_set_show_toggle(self._o, always) def set_state(self, state): - _gtk.gtk_check_menu_item_set_state(self._o, state) + print "GtkCheckMenuItem.set_state is deprecated -- use set_active" + self.set_active(state) + def set_active(self, active): + _gtk.gtk_check_menu_item_set_active(self._o, active) def toggled(self, obj=None): _gtk.gtk_check_menu_item_toggled(self._o) @@ -1051,6 +1063,7 @@ class GtkCList(GtkContainer): def __getattr__(self, attr): attrs = { 'selection':_gtk.gtk_clist_get_selection, + 'focus_row':_gtk.gtk_clist_get_focus_row, } if attrs.has_key(attr): return attrs[attr](self._o) @@ -1211,6 +1224,14 @@ class GtkCTree(GtkCList): self._o = _gtk.gtk_ctree_new_with_titles(cols, tree_col, titles) + def __getattr__(self, attr): + attrs = { + 'selection':_gtk.gtk_ctree_get_selection, + } + if attrs.has_key(attr): + return attrs[attr](self._o) + else: + return GtkCList.__getattr__(self, attr) def base_nodes(self): # this returns a list of the base nodes. Useful for recursion return _gtk.gtk_ctree_base_nodes(self._o) @@ -1492,6 +1513,8 @@ class GtkMenu(GtkMenuShell): _gtk.gtk_menu_set_accel_group(self._o, group._ag) def set_tearoff_state(self, torn_off): _gtk.gtk_menu_set_tearoff_state(self._o, torn_off) + def set_title(self, title): + _gtk.gtk_menu_set_title(self._o, title) class GtkNotebook(GtkContainer): get_type = _gtk.gtk_notebook_get_type @@ -1965,6 +1988,8 @@ class GtkSpinButton(GtkEntry): _gtk.gtk_spin_button_set_shadow_type(self._o, shadow_type) def set_snap_to_ticks(self, snap): _gtk.gtk_spin_button_set_snap_to_ticks(self._o, snap) + def update(self): + _gtk.gtk_spin_button_update(self._o) class GtkText(GtkEditable): get_type = _gtk.gtk_text_get_type @@ -2507,3 +2532,14 @@ def draw_segments(drawable, gc, segs): def draw_lines(drawable, gc, points): _gtk.gdk_draw_lines(drawable, gc, points) + +# screen size +def screen_width(): + return _gtk.gdk_screen_width() +def screen_height(): + return _gtk.gdk_screen_height() + +def screen_width_mm(): + return _gtk.gdk_screen_width_mm() +def screen_height_mm(): + return _gtk.gdk_screen_height_mm() diff --git a/gtkmodule.c b/gtkmodule.c index f9e8b756..af0482d7 100644 --- a/gtkmodule.c +++ b/gtkmodule.c @@ -370,7 +370,7 @@ PyGtkSelectionData_New(GtkSelectionData *data) { &PyGtkSelectionData_Type); if (!self) return NULL; - self->obj = gtk_selection_data_copy(data); + self->obj = data; return (PyObject *)self; } @@ -1635,7 +1635,6 @@ static PyTypeObject PyGdkDragContext_Type = { static void PyGtkSelectionData_Dealloc(PyGtkSelectionData_Object *self) { - gtk_selection_data_free(self->obj); PyMem_DEL(self); } @@ -2009,15 +2008,19 @@ static int GtkArg_FromPyObject(GtkArg *arg, PyObject *obj) { case GTK_TYPE_BOOL: if (tmp = PyNumber_Int(obj)) GTK_VALUE_BOOL(*arg) = (PyInt_AsLong(tmp) != 0); - else + else { + PyErr_Clear(); return -1; + } Py_DECREF(tmp); break; case GTK_TYPE_CHAR: if (tmp = PyObject_Str(obj)) GTK_VALUE_CHAR(*arg) = PyString_AsString(tmp)[0]; - else + else { + PyErr_Clear(); return -1; + } Py_DECREF(tmp); break; case GTK_TYPE_ENUM: @@ -2031,50 +2034,64 @@ static int GtkArg_FromPyObject(GtkArg *arg, PyObject *obj) { case GTK_TYPE_INT: if (tmp = PyNumber_Int(obj)) GTK_VALUE_INT(*arg) = PyInt_AsLong(tmp); - else + else { + PyErr_Clear(); return -1; + } Py_DECREF(tmp); break; case GTK_TYPE_UINT: if (tmp = PyNumber_Int(obj)) GTK_VALUE_UINT(*arg) = PyInt_AsLong(tmp); - else + else { + PyErr_Clear(); return -1; + } Py_DECREF(tmp); break; case GTK_TYPE_LONG: if (tmp = PyNumber_Int(obj)) GTK_VALUE_LONG(*arg) = PyInt_AsLong(tmp); - else + else { + PyErr_Clear(); return -1; + } Py_DECREF(tmp); break; case GTK_TYPE_ULONG: if (tmp = PyNumber_Int(obj)) GTK_VALUE_ULONG(*arg) = PyInt_AsLong(tmp); - else + else { + PyErr_Clear(); return -1; + } Py_DECREF(tmp); break; case GTK_TYPE_FLOAT: if (tmp = PyNumber_Float(obj)) GTK_VALUE_FLOAT(*arg) = PyFloat_AsDouble(tmp); - else + else { + PyErr_Clear(); return -1; + } Py_DECREF(tmp); break; case GTK_TYPE_DOUBLE: if (tmp = PyNumber_Float(obj)) GTK_VALUE_DOUBLE(*arg) = PyFloat_AsDouble(tmp); - else + else { + PyErr_Clear(); return -1; + } Py_DECREF(tmp); break; case GTK_TYPE_STRING: if (tmp = PyObject_Str(obj)) GTK_VALUE_STRING(*arg) = PyString_AsString(tmp); - else + else { + PyErr_Clear(); return -1; + } Py_DECREF(tmp); break; case GTK_TYPE_OBJECT: @@ -2284,15 +2301,19 @@ static void GtkRet_FromPyObject(GtkArg *ret, PyObject *py_ret) { if (tmp = PyNumber_Int(py_ret)) { *GTK_RETLOC_BOOL(*ret) = (PyInt_AsLong(tmp) != 0); Py_DECREF(tmp); - } else + } else { + PyErr_Clear(); *GTK_RETLOC_BOOL(*ret) = FALSE; + } break; case GTK_TYPE_CHAR: if (tmp = PyObject_Str(py_ret)) { *GTK_RETLOC_CHAR(*ret) = PyString_AsString(tmp)[0]; Py_DECREF(tmp); - } else + } else { + PyErr_Clear(); *GTK_RETLOC_CHAR(*ret) = '\0'; + } break; case GTK_TYPE_ENUM: if (PyGtkEnum_get_value(ret->type, py_ret, GTK_RETLOC_ENUM(*ret))) { @@ -2310,50 +2331,64 @@ static void GtkRet_FromPyObject(GtkArg *ret, PyObject *py_ret) { if (tmp = PyNumber_Int(py_ret)) { *GTK_RETLOC_INT(*ret) = PyInt_AsLong(tmp); Py_DECREF(tmp); - } else + } else { + PyErr_Clear(); *GTK_RETLOC_INT(*ret) = 0; + } break; case GTK_TYPE_UINT: if (tmp = PyNumber_Int(py_ret)) { *GTK_RETLOC_UINT(*ret) = PyInt_AsLong(tmp); Py_DECREF(tmp); - } else + } else { + PyErr_Clear(); *GTK_RETLOC_UINT(*ret) = 0; + } break; case GTK_TYPE_LONG: if (tmp = PyNumber_Int(py_ret)) { *GTK_RETLOC_LONG(*ret) = PyInt_AsLong(tmp); Py_DECREF(tmp); - } else + } else { + PyErr_Clear(); *GTK_RETLOC_LONG(*ret) = 0; + } break; case GTK_TYPE_ULONG: if (tmp = PyNumber_Int(py_ret)) { *GTK_RETLOC_ULONG(*ret) = PyInt_AsLong(tmp); Py_DECREF(tmp); - } else + } else { + PyErr_Clear(); *GTK_RETLOC_ULONG(*ret) = 0; + } break; case GTK_TYPE_FLOAT: if (tmp = PyNumber_Float(py_ret)) { *GTK_RETLOC_FLOAT(*ret) = PyFloat_AsDouble(tmp); Py_DECREF(tmp); - } else + } else { + PyErr_Clear(); *GTK_RETLOC_FLOAT(*ret) = 0; + } break; case GTK_TYPE_DOUBLE: if (tmp = PyNumber_Float(py_ret)) { *GTK_RETLOC_DOUBLE(*ret) = PyFloat_AsDouble(tmp); Py_DECREF(tmp); - } else + } else { + PyErr_Clear(); *GTK_RETLOC_DOUBLE(*ret) = 0; + } break; case GTK_TYPE_STRING: if (tmp = PyObject_Str(py_ret)) { *GTK_RETLOC_STRING(*ret) = g_strdup(PyString_AsString(py_ret)); Py_DECREF(tmp); - } else + } else { + PyErr_Clear(); *GTK_RETLOC_STRING(*ret) = NULL; + } break; case GTK_TYPE_OBJECT: if (PyGtk_Check(py_ret)) @@ -4561,6 +4596,22 @@ static PyObject *_wrap_gtk_ctree_new_with_titles(PyObject *self, PyObject *args) return item; } +static PyObject *_wrap_gtk_ctree_get_selection(PyObject *self, PyObject *args) { + GList *selection; + GtkCTreeNode *node; + PyObject *clist, *ret; + if (!PyArg_ParseTuple(args, "O!:gtk_ctree_get_selection", &PyGtk_Type, + &clist)) + return NULL; + ret = PyList_New(0); + for (selection = GTK_CLIST(PyGtk_Get(clist))->selection; selection != NULL; + selection = selection->next) { + node = selection->data; + PyList_Append(ret, PyGtkCTreeNode_New(node)); + } + return ret; +} + static PyObject *_wrap_gtk_ctree_insert_node(PyObject *self, PyObject *args) { PyObject *ctree, *py_parent, *py_sibling, *py_text; PyObject *py_pixmap_closed, *py_mask_closed; @@ -4948,6 +4999,7 @@ static PyMethodDef _gtkmoduleMethods[] = { { "gtk_drag_source_set", _wrap_gtk_drag_source_set, 1 }, { "gtk_drag_begin", _wrap_gtk_drag_begin, 1 }, { "gtk_ctree_new_with_titles", _wrap_gtk_ctree_new_with_titles, 1 }, + { "gtk_ctree_get_selection", _wrap_gtk_ctree_get_selection, 1 }, { "gtk_ctree_insert_node", _wrap_gtk_ctree_insert_node, 1 }, { "gtk_ctree_find_by_row_data", _wrap_gtk_ctree_find_by_row_data, 1 }, { "gtk_ctree_find_all_by_row_data", _wrap_gtk_ctree_find_all_by_row_data, 1 }, @@ -1,7 +1,7 @@ %define py_prefix /usr # py_ver should only be 3 characters (1.5.1 == 1.5) %define py_ver 1.5 -%define ver 0.5.9 +%define ver 0.5.10 Summary: Python bindings for the GTK+ widget set. Name: pygtk |