hamster-applet r579 - in trunk: . hamster
- From: jojeda svn gnome org
- To: svn-commits-list gnome org
- Subject: hamster-applet r579 - in trunk: . hamster
- Date: Sun, 28 Sep 2008 20:57:25 +0000 (UTC)
Author: jojeda
Date: Sun Sep 28 20:57:25 2008
New Revision: 579
URL: http://svn.gnome.org/viewvc/hamster-applet?rev=579&view=rev
Log:
* hamster/hamsterdbus.py,
hamster/Makefile.am,
hamster/applet.py: Added basic DBUS interface by J. FÃlix OntaÃÃn.
Fixs the bug #535863
* configure.ac: Updated version.
Added:
trunk/hamster/hamsterdbus.py
Modified:
trunk/ChangeLog
trunk/configure.ac
trunk/hamster/Makefile.am
trunk/hamster/applet.py
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Sun Sep 28 20:57:25 2008
@@ -1,4 +1,4 @@
-AC_INIT([hamster-applet],[2.24.1],[toms baugis gmail com])
+AC_INIT([hamster-applet],[2.24.2],[toms baugis gmail com])
AC_CONFIG_SRCDIR(hamster/__init__.py)
AC_CONFIG_HEADERS(config.h)
AC_CONFIG_MACRO_DIR([m4])
Modified: trunk/hamster/Makefile.am
==============================================================================
--- trunk/hamster/Makefile.am (original)
+++ trunk/hamster/Makefile.am Sun Sep 28 20:57:25 2008
@@ -26,6 +26,7 @@
add_custom_fact.py \
applet.py \
about.py \
+ hamsterdbus.py \
idle.py \
__init__.py
Modified: trunk/hamster/applet.py
==============================================================================
--- trunk/hamster/applet.py (original)
+++ trunk/hamster/applet.py Sun Sep 28 20:57:25 2008
@@ -24,6 +24,9 @@
import os.path
import gnomeapplet, gtk
import gobject
+import dbus
+import dbus.service
+import dbus.mainloop.glib
from hamster import dispatcher, storage, SHARED_DATA_DIR
import hamster.eds
@@ -31,6 +34,8 @@
from hamster.stuff import *
from hamster.KeyBinder import *
+from hamster.hamsterdbus import HAMSTER_URI, HamsterDbusController
+
import idle
class PanelButton(gtk.ToggleButton):
@@ -91,6 +96,13 @@
self.edit_column = gtk.TreeViewColumn("", edit_cell)
self.treeview.append_column(self.edit_column)
+ # DBus Setup
+ try:
+ dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+ name = dbus.service.BusName(HAMSTER_URI, dbus.SessionBus())
+ self.dbusController = HamsterDbusController(bus_name = name)
+ except dbus.DBusException, e:
+ print "can't init dbus: %s" % e
# Load today's data, activities and set label
self.last_activity = None
@@ -99,6 +111,9 @@
self.load_day()
self.update_label()
+ # Hamster DBusController current fact initialising
+ self.__update_fact()
+
# refresh hamster every 60 seconds to update duration
gobject.timeout_add_seconds(60, self.refresh_hamster)
@@ -201,6 +216,9 @@
self.glade.get_widget('stop_tracking').set_sensitive(0);
self.button.set_text(label)
+ # Hamster DBusController current activity updating
+ self.dbusController.update_activity(label)
+
def load_day(self):
"""sets up today's tree and fills it with records
returns information about last activity"""
@@ -257,6 +275,14 @@
self.treeview.set_cursor(cur)
+ def __update_fact(self):
+ """dbus controller current fact updating"""
+ if self.last_activity and self.last_activity['end_time'] == None:
+ self.dbusController.update_fact(self.last_activity["name"])
+ else:
+ self.dbusController.update_fact(_(u'No activity'))
+
+
def __show_toggle(self, event, is_active):
"""main window display and positioning"""
self.button.set_active(is_active)
@@ -388,6 +414,8 @@
self.load_day()
self.update_label()
+ self.__update_fact()
+
"""global shortcuts"""
def on_keybinding_activated(self, event, data):
self.__show_toggle(None, not self.button.get_active())
Added: trunk/hamster/hamsterdbus.py
==============================================================================
--- (empty file)
+++ trunk/hamster/hamsterdbus.py Sun Sep 28 20:57:25 2008
@@ -0,0 +1,47 @@
+# - coding: utf-8 -
+
+# Copyright (C) 2008, J. FÃlix OntaÃÃn <fontanon at emergya dot es>
+
+# This file is part of Project Hamster.
+
+# Project Hamster is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# Project Hamster is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with Project Hamster. If not, see <http://www.gnu.org/licenses/>.
+
+import dbus
+import dbus.service
+
+HAMSTER_URI = "org.gnome.hamster"
+HAMSTER_PATH = "/org/gnome/hamster"
+
+class HamsterDbusController(dbus.service.Object):
+ activity = "Undefined"
+ fact = "Undefined"
+
+ def __init__(self, bus_name):
+ dbus.service.Object.__init__(self, bus_name, HAMSTER_PATH)
+
+ @dbus.service.method(HAMSTER_URI)
+ def get_activity(self):
+ return self.activity
+
+ @dbus.service.signal(HAMSTER_URI)
+ def update_activity(self, activity):
+ self.activity = activity
+
+ @dbus.service.method(HAMSTER_URI)
+ def get_fact(self):
+ return self.fact
+
+ @dbus.service.signal(HAMSTER_URI)
+ def update_fact(self, fact):
+ self.fact = fact
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]