diff options
author | Guido Günther <agx@sigxcpu.org> | 2011-08-04 21:55:56 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2011-08-21 14:38:36 +0200 |
commit | 48da8575434ae48cdc0247ef0d71ccc7b49c9ef3 (patch) | |
tree | a8e434cc3f52a60f755e03aa694433b4745b8971 /examples |
The GNOME3 Desktop and You
Diffstat (limited to 'examples')
-rw-r--r-- | examples/Launch_Iceowl@sigxcpu.org/extension.js | 20 | ||||
-rw-r--r-- | examples/Launch_Iceowl@sigxcpu.org/metadata.json | 1 | ||||
-rw-r--r-- | examples/gvncviewer.gir.py | 12 | ||||
-rw-r--r-- | examples/gvncviewer.js | 13 | ||||
-rw-r--r-- | examples/gvncviewer.notify.py | 34 | ||||
-rw-r--r-- | examples/properties.js | 16 | ||||
-rw-r--r-- | examples/proxysettings.py | 28 |
7 files changed, 124 insertions, 0 deletions
diff --git a/examples/Launch_Iceowl@sigxcpu.org/extension.js b/examples/Launch_Iceowl@sigxcpu.org/extension.js new file mode 100644 index 0000000..773c73e --- /dev/null +++ b/examples/Launch_Iceowl@sigxcpu.org/extension.js @@ -0,0 +1,20 @@ +const Util = imports.misc.util; +const DateMenu = imports.ui.dateMenu; +const Main = imports.ui.main; + +function main() { + // MonkeyPatch the DateMenuButton prototype + DateMenu.DateMenuButton.prototype._onOpenCalendarActivate = function() { + let d = this._calendar._selectedDate.toDateString(); + + this.menu.close(); + Util.spawn(['iceowl', '-showdate', d]); + } + + + // Readd the DateMenuButton to the _centerBox + Main.panel._centerBox.destroy_children(); + Main.panel._dateMenu = new DateMenu.DateMenuButton(); + Main.panel._centerBox.add(Main.panel._dateMenu.actor, { y_fill: true }); + Main.panel._menus.addMenu(Main.panel._dateMenu.menu); +} diff --git a/examples/Launch_Iceowl@sigxcpu.org/metadata.json b/examples/Launch_Iceowl@sigxcpu.org/metadata.json new file mode 100644 index 0000000..b8d9067 --- /dev/null +++ b/examples/Launch_Iceowl@sigxcpu.org/metadata.json @@ -0,0 +1 @@ +{"shell-version": ["3.0.2"], "uuid": "Launch_Iceowl@sigxcpu.org", "name": "Launch Iceowl", "description": "Launch Iceowl instead of evolution"} diff --git a/examples/gvncviewer.gir.py b/examples/gvncviewer.gir.py new file mode 100644 index 0000000..53413c1 --- /dev/null +++ b/examples/gvncviewer.gir.py @@ -0,0 +1,12 @@ +from gi.repository import GtkVnc, Gtk + +Gtk.init(None) +win = Gtk.Window(title="GTK-VNC with Python") +disp = GtkVnc.Display() + +win.add(disp) +win.connect('delete-event', Gtk.main_quit) +disp.open_host("localhost", "5901") +win.show_all() +Gtk.main() + diff --git a/examples/gvncviewer.js b/examples/gvncviewer.js new file mode 100644 index 0000000..40c75da --- /dev/null +++ b/examples/gvncviewer.js @@ -0,0 +1,13 @@ +const Gtk = imports.gi.Gtk; +const Vnc = imports.gi.GtkVnc; + +Gtk.init(0, null); + +var win = new Gtk.Window({title: "GTK-VNC"}); +var disp = new Vnc.Display(); + +win.add(disp); +win.connect('delete-event', Gtk.main_quit); +disp.open_host("localhost", "5901"); +win.show_all(); +Gtk.main(); diff --git a/examples/gvncviewer.notify.py b/examples/gvncviewer.notify.py new file mode 100644 index 0000000..e0ec8d9 --- /dev/null +++ b/examples/gvncviewer.notify.py @@ -0,0 +1,34 @@ +from gi.repository import GVnc, GtkVnc, Gtk, GLib +from gi.repository import Notify +import sys + +def notify(obj, v): + n = Notify.Notification( + summary="Connected to %(host)s" % v, + body="Made VNC connection to " + "server %(host)s at port %(port)s" % v) + if hint: + n.set_hint(hint, GLib.Variant('b', True)) + n.show() + + +try: + hint = 'resident' if sys.argv[1].startswith('r') else 'transient' + print "Making notificaionts %s" % hint +except: + hint = None + +vncserver = dict(host='localhost', port='5901') +Gtk.init(None) +Notify.init("GTK-VNC with Python") +win = Gtk.Window(title="GTK-VNC with Python") +disp = GtkVnc.Display() +disp.connect("vnc-connected", notify, vncserver) + +win.add(disp) +win.connect('delete-event', Gtk.main_quit) +disp.open_host(vncserver['host'], + vncserver['port']) +win.show_all() +Gtk.main() + diff --git a/examples/properties.js b/examples/properties.js new file mode 100644 index 0000000..e0163e0 --- /dev/null +++ b/examples/properties.js @@ -0,0 +1,16 @@ +const Gtk = imports.gi.Gtk; + +Gtk.init(0, null); + +// GObject properties passed as map +var win = new Gtk.Window({title: "foo", opacity: 0.8}); + +// GObject property retrieval +log("Title: " + win.title); +log("Opacity: " + win["opacity"]); + +// Attach callable to a signal +win.connect('delete-event', Gtk.main_quit); + +win.show_all(); +Gtk.main(); diff --git a/examples/proxysettings.py b/examples/proxysettings.py new file mode 100644 index 0000000..a3caa62 --- /dev/null +++ b/examples/proxysettings.py @@ -0,0 +1,28 @@ +from gi.repository import Gio, GObject, Gtk + +class Proxy(GObject.GObject): + # Make useproxy a GObject property + useproxy = GObject.property(type=bool, default=True) + + def __init__(self): + super(Proxy, self).__init__() + self.connect("notify::useproxy", self.useproxy_prop_changed) + self.bind_to_gsettings() + + def useproxy_prop_changed(self, obj, param): + """Invoked when the useproxy property changes""" + print "Prop Proxy enabled: %s" % self.props.useproxy + + def bind_to_gsettings(self): + gs = Gio.Settings('org.gnome.system.proxy.http') + gs.bind('enabled', self, 'useproxy', Gio.SettingsBindFlags.DEFAULT) + + gs.connect("changed::enabled", self.enabled_changed) + + def enabled_changed(self, obj, param): + print "gesetting changed" + +proxy = Proxy() +GObject.timeout_add_seconds(20, Gtk.main_quit) + +Gtk.main() |