Create  Edit  FrontPage  Index  Search  Changes  History  RSS  Login

tut-gtk2-agtkw-cal

Calendars

(11.1)

GTK+ provides the Gtk::Calendar widget, which is a widget that displays one month of a calendar. It allows the user to move among months and years with scroll arrows. You can also display three letter abbreviations of the day names and week numbers for the chosen year.

agtkw-01-cal.png

Following is a simple example from the original Japanese tutorial Ruby/GNOME2 site.

calendar_modes.rb

#!/usr/bin/env ruby
require 'gtk2'

window = Gtk::Window.new
window.signal_connect("delete_event") {Gtk.main_quit}
hbox = Gtk::HBox.new(false, 10)
window.add(hbox)

flag = 0
[
	Gtk::Calendar::SHOW_HEADING,
	Gtk::Calendar::SHOW_DAY_NAMES,
	Gtk::Calendar::NO_MONTH_CHANGE,
	Gtk::Calendar::SHOW_WEEK_NUMBERS,
	Gtk::Calendar::WEEK_START_MONDAY,
].each do |f|
	c = Gtk::Calendar.new
	flag |= f
	c.display_options(flag)
	hbox.pack_start(c, true, true, 0)
end
window.show_all
Gtk.main

Status Icons

(11.2)

The Gtk::StatusIcon object was introduced in GTK+ 2.10 and is used to display an icon in the system tray (notification area) in a platform-independent manner.

The "system tray" or notification area is normally used for transient icons that indicate some special state. For example, a system tray icon might appear to tell the user that they have new mail, or have an incoming instant message, or something along those lines. The basic idea is that creating an icon in the notification area is less annoying than popping up a dialogue.

A Gtk::StatusIcon object can be used to display an icon in a "system tray". The icon can have a tool-tip, and the user can interact with it by activating it or popping up a context menu. Critical information should not solely be displayed in a Gtk::StatusIcon, since it may not be visible (e.g. when the user doesn't have a notification area on his panel). This can be checked with Gtk::StatusIcon#embedded?.

On X11, the implementation follows the freedesktop.org "System Tray" specification. Implementations of the "tray" side of this specification can be found e.g. in the GNOME and KDE panel applications. It will also show up in the Dock or the System tray on Mac OSX and Windows, respectively.

Note that a Gtk::StatusIcon is not a widget, but just a GLib::Object. Making it a widget would be impractical, since the system tray on Win32 doesn't allow to embed arbitrary widgets.

Last modified:2013/03/12 12:54:14
Keyword(s):
References:[tut-gtk] [tut-gtk2-agtkw]