From d2f7d1781a2f99d460e46ae68d97929013649843 Mon Sep 17 00:00:00 2001 From: Dmitry Kalyanov Date: Sun, 13 Sep 2009 15:01:19 +0400 Subject: [PATCH] Refactoring of GtkStatusbar --- gtk/gtk.demo.lisp | 12 ++++++------ gtk/gtk.status-bar.lisp | 34 ++++++++++++++++++++-------------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/gtk/gtk.demo.lisp b/gtk/gtk.demo.lisp index 9118d1a..6d2f59c 100644 --- a/gtk/gtk.demo.lisp +++ b/gtk/gtk.demo.lisp @@ -6,7 +6,7 @@ #:test-pixbuf #:test-image #:test-progress-bar - #:test-status-bar + #:test-statusbar #:test-scale-button #:test-text-view #:demo-code-editor @@ -160,13 +160,13 @@ (coerce (read-from-string (entry-text entry)) 'real)))) (widget-show window)))) -(defun test-status-bar () +(defun test-statusbar () (within-main-loop (let* ((window (make-instance 'gtk-window :title "Text status bar")) (v-box (make-instance 'v-box)) (h-box (make-instance 'h-box)) (label (make-instance 'label :label "Test of status bar" :xalign 0.5 :yalign 0.5)) - (status-bar (make-instance 'statusbar :has-resize-grip t)) + (statusbar (make-instance 'statusbar :has-resize-grip t)) (button-push (make-instance 'button :label "Push")) (button-pop (make-instance 'button :label "Pop")) (entry (make-instance 'entry)) @@ -178,10 +178,10 @@ (leave-gtk-main))) (g-signal-connect button-push "clicked" (lambda (b) (declare (ignore b)) - (status-bar-push status-bar "lisp-prog" (entry-text entry)))) + (statusbar-push statusbar "lisp-prog" (entry-text entry)))) (g-signal-connect button-pop "clicked" (lambda (b) (declare (ignore b)) - (status-bar-pop status-bar "lisp-prog"))) + (statusbar-pop statusbar "lisp-prog"))) (g-signal-connect icon "activate" (lambda (i) (declare (ignore i)) (let ((message-dialog (make-instance 'message-dialog @@ -195,7 +195,7 @@ (box-pack-start h-box button-push :expand nil) (box-pack-start h-box button-pop :expand nil) (box-pack-start v-box label) - (box-pack-start v-box status-bar :expand nil) + (box-pack-start v-box statusbar :expand nil) (widget-show window) (setf (status-icon-screen icon) (gtk-window-screen window))))) diff --git a/gtk/gtk.status-bar.lisp b/gtk/gtk.status-bar.lisp index 45cc2c7..b0313a2 100644 --- a/gtk/gtk.status-bar.lisp +++ b/gtk/gtk.status-bar.lisp @@ -1,32 +1,38 @@ (in-package :gtk) -(defcfun gtk-statusbar-get-context-id :uint - (status-bar (g-object statusbar)) +(defcfun (statusbar-get-context-id "gtk_statusbar_get_context_id") :uint + (statusbar (g-object statusbar)) (context-description :string)) (defcfun gtk-statusbar-push :uint - (status-bar (g-object statusbar)) + (statusbar (g-object statusbar)) (context-id :uint) (text :string)) (defcfun gtk-statusbar-pop :void - (status-bar (g-object statusbar)) + (statusbar (g-object statusbar)) (context-id :uint)) (defcfun gtk-statusbar-remove :void - (status-bar (g-object statusbar)) + (statusbar (g-object statusbar)) (context-id :uint) (message-id :uint)) -(defun status-bar-push (status-bar context text) - (gtk-statusbar-push status-bar (gtk-statusbar-get-context-id status-bar context) text)) +(defun statusbar-context-id (statusbar context) + (etypecase context + (integer context) + (string (statusbar-get-context-id statusbar context)))) -(defun status-bar-pop (status-bar context) - (gtk-statusbar-pop status-bar (gtk-statusbar-get-context-id status-bar context))) +(defun statusbar-push (statusbar context text) + (gtk-statusbar-push statusbar (statusbar-context-id statusbar context) text)) -(defun status-bar-remove (status-bar context message-id) - (gtk-statusbar-remove status-bar (gtk-statusbar-get-context-id status-bar context) message-id)) +(defun statusbar-pop (statusbar context) + (gtk-statusbar-pop statusbar (statusbar-context-id statusbar context))) -(export 'status-bar-push) -(export 'status-bar-pop) -(export 'status-bar-remove) \ No newline at end of file +(defun statusbar-remove (statusbar context message-id) + (gtk-statusbar-remove statusbar (statusbar-context-id statusbar context) message-id)) + +(export 'statusbar-push) +(export 'statusbar-pop) +(export 'statusbar-remove) +(export 'statusbar-context-id) \ No newline at end of file -- 1.7.10.4