Re: ... bumping minimum GTK+ to 2.24 (?)
- From: Christopher Roy Bratusek <nano tuxfamily org>
- To: sawfish-list gnome org
- Subject: Re: ... bumping minimum GTK+ to 2.24 (?)
- Date: Sun, 29 May 2011 18:31:37 +0200
Am 29.05.2011 10:46, schrieb Christopher Roy Bratusek:
Am 29.05.2011 10:15, schrieb Christopher Roy Bratusek:
Hi all,
as you maybe already noticed, I'm currently updating the widgets in
the misc-1.9 branch ('file, 'font at the moment). While heading over
to 'frame-style widget, I noticed, it would be best to use
GtkComboBoxText widget. But: this widget requires GTK+ 2.24. Now I
wanted to know whether bumping requirement for Sawfish 1.9 and
rep-gtk 0.90.7/8 to that version. All distros I've checked ship that
version, except Debian/Stable, which ships 2.20 (...).
Chris
Attached is a patch to implement the widget in rep-gtk, with example
added (deprecated GtkComboBoxEntry dropped).
Chris
OK. Second patch: updated (:type choice) widget for SawfishConfig (took
a bit, until I found the correct
way of getting the symbol from a translated string, but it's fine now).
Good News: (:type symbol) will become
an alias (for backwards-compat) to (:type choice), so stuff like
'focus-mode or 'placement-mode values will
also be translatable then.
Ahh... and there's a byte-compiler warning. I couldn't find a syntax
which both works and shuts the compiler up.
Chris
diff --git a/lisp/sawfish/gtk/widget.jl b/lisp/sawfish/gtk/widget.jl
index 1c7bf93..2cea426 100644
--- a/lisp/sawfish/gtk/widget.jl
+++ b/lisp/sawfish/gtk/widget.jl
@@ -187,38 +187,28 @@
;;; Predefined widget constructors
(define (make-choice-item changed-callback . options)
- (let ((omenu (gtk-option-menu-new))
- (menu (gtk-menu-new))
- (value (or (caar options) (car options))))
- (let loop ((rest options)
- (last nil))
- (when rest
- (let ((button (gtk-radio-menu-item-new-with-label-from-widget
- last (_ (or (cadar rest)
- (symbol-name (car rest)))))))
- (gtk-menu-shell-append menu button)
- (gtk-widget-show button)
- (g-signal-connect button "toggled"
- (lambda (w)
- (when (gtk-check-menu-item-active w)
- (setq value (or (caar rest) (car rest)))
- (call-callback changed-callback))))
- (loop (cdr rest) button))))
- (gtk-option-menu-set-menu omenu menu)
- (gtk-widget-show-all omenu)
+ (let ((combo (gtk-combo-box-text-new)))
+
+ (let loop ((rest options))
+ (when rest
+ (let ((append (gtk-combo-box-text-append-text combo
+ (_ (or (cadar rest)
+ (symbol-name (car rest)))))))
+ (loop (cdr rest)))))
+
+ (when changed-callback
+ (g-signal-connect combo "changed"
+ (make-signal-callback changed-callback)))
+
+ (gtk-widget-show combo)
+
(lambda (op)
(case op
((set) (lambda (x)
- (setq value x)
- (let ((idx (option-index options x)))
- (gtk-option-menu-set-history omenu (or idx 0))
- (do ((i 0 (1+ i))
- (rest (gtk-container-get-children menu) (cdr rest)))
- ((null rest))
- (gtk-check-menu-item-set-active (car rest) (= i idx))))))
+ (gtk-combo-box-set-active combo (position x options))))
((clear) nop)
- ((ref) (lambda () value))
- ((gtk-widget) omenu)
+ ((ref) (lambda () (string->symbol (symbol-name (nth (gtk-combo-box-get-active combo) options)))))
+ ((gtk-widget) combo)
((validp) (lambda (x) (option-index options x)))))))
(define-widget-type 'choice make-choice-item)
@@ -521,6 +511,14 @@
(define string->symbol intern)
+ (define (position item l)
+ (let loop ((rest l)
+ (i 0))
+ (if (equal item (car rest))
+ i
+ (if rest
+ (loop (cdr rest) (1+ i))))))
+
(define (option-index lst x)
(let loop ((i 0) (rest lst))
(cond ((null rest) nil)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]