a rep-gtk patch for use Status Icon(Display an icon in the system tray)
- From: Wang Diancheng <dcwang redflag-linux com>
- To: sawfish-list gnome org
- Subject: a rep-gtk patch for use Status Icon(Display an icon in the system tray)
- Date: Sat, 19 Jan 2008 15:43:34 +0800
maybe someone need this, so I paste it to here.
BTW:
why sawfish can not create a Status Icon? it sometimes crash when create
a status icon.
diff -ru trunk/gtk-compat.c trunk-hacked/gtk-compat.c
--- trunk/gtk-compat.c 2008-01-11 10:49:39.000000000 +0800
+++ trunk-hacked/gtk-compat.c 2008-01-13 12:42:06.000000000 +0800
@@ -267,3 +267,36 @@
{
gtk_widget_draw (widget, NULL);
}
+
+/* status icon hack */
+
+void
+gtk_status_icon_popup_menu(GtkStatusIcon *status_icon,
+ GtkMenu *menu,
+ guint button,
+ guint32 activate_time)
+{
+ GtkMenuPositionFunc pos_func = gtk_status_icon_position_menu;
+ gpointer user_data = status_icon;
+ gtk_menu_popup (menu, NULL, NULL,
+ pos_func, user_data, button, activate_time);
+}
+
+gboolean
+gtk_status_icon_get_geometry_interp(GtkStatusIcon *status_icon,
+ gint *x,
+ gint *y,
+ GtkOrientation *orientation)
+{
+ GdkRectangle area;
+ gboolean ret = gtk_status_icon_get_geometry(status_icon,
+ NULL,
+ &area,
+ orientation);
+ if(!ret)
+ return ret;
+ *x = area.x;
+ *y = area.y;
+ return ret;
+}
+
diff -ru trunk/gtk.defs trunk-hacked/gtk.defs
--- trunk/gtk.defs 2008-01-11 10:49:39.000000000 +0800
+++ trunk-hacked/gtk.defs 2008-01-13 12:41:56.000000000 +0800
@@ -4569,6 +4569,130 @@
(define-func gtk_separator_menu_item_new
GtkWidget
())
+;; hack for status icon
+(define-object GtkStatusIcon (GObject))
+
+(define-enum GtkImageType
+ (empty GTK_IMAGE_EMPTY)
+ (pixmap GTK_IMAGE_PIXMAP)
+ (image GTK_IMAGE_IMAGE)
+ (pixbuf GTK_IMAGE_PIXBUF)
+ (stock GTK_IMAGE_STOCK)
+ (icon-set GTK_IMAGE_ICON_SET)
+ (animation GTK_IMAGE_ANIMATION)
+ (icon-name GTK_IMAGE_ICON_NAME))
+
+(define-func gtk_status_icon_new
+ GtkStatusIcon
+ ())
+
+(define-func gtk_status_icon_new_from_pixbuf
+ GtkStatusIcon
+ ((GdkPixbuf pixbuf)))
+
+(define-func gtk_status_icon_new_from_file
+ GtkStatusIcon
+ ((string filename)))
+
+(define-func gtk_status_icon_new_from_stock
+ GtkStatusIcon
+ ((string stock_id)))
+
+(define-func gtk_status_icon_new_from_icon_name
+ GtkStatusIcon
+ ((string icon_name)))
+
+
+(define-func gtk_status_icon_set_from_pixbuf
+ none
+ ((GtkStatusIcon status_icon)
+ (GdkPixbuf pixbuf)))
+
+(define-func gtk_status_icon_set_from_file
+ none
+ ((GtkStatusIcon status_icon)
+ (string filename)))
+
+(define-func gtk_status_icon_set_from_stock
+ none
+ ((GtkStatusIcon status_icon)
+ (string stock_id)))
+
+(define-func gtk_status_icon_set_from_icon_name
+ none
+ ((GtkStatusIcon status_icon)
+ (string icon_name)))
+
+(define-func gtk_status_icon_get_storage_type
+ GtkImageType
+ ((GtkStatusIcon status_icon)))
+
+(define-func gtk_status_icon_get_pixbuf
+ GdkPixbuf
+((GtkStatusIcon status_icon)))
+
+(define-func gtk_status_icon_get_stock
+ string
+ ((GtkStatusIcon status_icon)))
+
+(define-func gtk_status_icon_get_icon_name
+ string
+ ((GtkStatusIcon status_icon)))
+
+(define-func gtk_status_icon_get_size
+ int
+ ((GtkStatusIcon status_icon)))
+
+;(define-func gtk_status_icon_set_screen
+; none
+; ((GtkStatusIcon status_icon)
+; (GdkScreen screen)))
+
+;(define-func gtk_status_icon_get_screen
+; GdkScreen
+; ((GtkStatusIcon status_icon)))
+
+(define-func gtk_status_icon_set_tooltip
+ none
+ ((GtkStatusIcon status_icon)
+ (string tooltip_text)))
+
+(define-func gtk_status_icon_set_visible
+ none
+ ((GtkStatusIcon status_icon)
+ (bool visible)))
+
+(define-func gtk_status_icon_get_visible
+ bool
+ ((GtkStatusIcon status_icon)))
+
+(define-func gtk_status_icon_set_blinking
+ none
+ ((GtkStatusIcon status_icon)
+ (bool blinking)))
+
+(define-func gtk_status_icon_get_blinking
+ bool
+ ((GtkStatusIcon status_icon)))
+
+(define-func gtk_status_icon_is_embedded
+ bool
+ ((GtkStatusIcon status_icon)))
+
+(define-func gtk_status_icon_popup_menu
+ none
+ ((GtkStatusIcon status_icon)
+ (GtkMenu menu)
+ (uint button)
+ (uint activate_time)))
+
+; remove screen
+(define-func gtk_status_icon_get_geometry_interp
+ bool
+ ((GtkStatusIcon status_icon)
+ ((ret int) x)
+ ((ret int) y)
+ ((ret GtkOrientation) orientation)))
;; More defs files
following is a example to use it.
#! /bin/sh
exec rep --batch "$0" "$@"
!#
;;;; rep-gtk hello world program
(structure ()
(open rep
rep.system
gui.gtk-2.gtk)
(define window (gtk-window-new 'toplevel))
(define button (gtk-button-new-with-label "say hello"))
(gtk-container-set-border-width window 10)
(g-signal-connect window "delete_event" (lambda (w) (throw 'quit 0)))
(g-signal-connect button "clicked"
(lambda ()
(write standard-output "hello, world\n")))
(gtk-container-add window button)
(gtk-widget-show-all window)
(define tray_icon (gtk-status-icon-new))
;(gtk-status-icon-set-from-file tray_icon "/usr/share/pixmaps/mplayer.xpm")
(gtk-status-icon-set-from-icon-name tray_icon "stock_mail-unread")
(gtk-status-icon-set-tooltip tray_icon
"Example Tray Icon")
(gtk-status-icon-set-blinking tray_icon t)
(g-signal-connect tray_icon "activate"
(lambda ()
(write standard-output "activate tray_icon\n")))
(define menu (gtk-menu-new))
(define item (gtk-menu-item-new-with-label "Test Menu"))
(gtk-menu-shell-append menu item)
(gtk-widget-show-all menu)
(g-signal-connect tray_icon "popup-menu"
(lambda ()
(gtk-status-icon-popup-menu tray_icon menu 0 0)))
(let ((x (list #f))(y (list #f))(z (list #f)))
(gtk-status-icon-get-geometry-interp tray_icon x y z)
(write standard-output (format nil "(%d,%d) %s\n" (car x) (car y) (car z))))
;(define x (gtk-status-icon-get-geometry-interp tray_icon))
(setq interrupt-mode 'exit)
(recursive-edit))
;; Local variables:
;; major-mode: lisp-mode
;; End:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]