-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Associate tasks to specific workspaces and follow changes automatically #259
base: master
Are you sure you want to change the base?
Changes from 2 commits
8ee69e5
667cbac
d4ec95d
68e5160
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# - coding: utf-8 - | ||
|
||
# Copyright (C) 2015 Aurelien Naldi <aurelien.naldi at gmail.com> | ||
|
||
# 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/>. | ||
|
||
from gi.repository import GObject as gobject | ||
from gi.repository import Wnck as wnck | ||
import dbus | ||
|
||
class WnckWatcher(gobject.GObject): | ||
""" | ||
Listen for workspace changes with Wnck and forward them to the desktop integration agent. | ||
It handles all wnck-specific parts and forwards standardised signals, based on the screensaver helper. | ||
""" | ||
__gsignals__ = { | ||
"workspace-changed": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,gobject.TYPE_PYOBJECT)) | ||
} | ||
def __init__(self): | ||
gobject.GObject.__init__(self) | ||
|
||
try: | ||
self.bus = dbus.SessionBus() | ||
except: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please only catch the specific exceptions you expect. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I'm not familiar with dbus, I copied this from idle.py, but all other places in hamster where a session bus is retrieved are unprotected, so I'm taking out the try/except here. |
||
return 0 | ||
wnck.Screen.get_default().connect("active-workspace-changed", self.on_workspace_changed) | ||
|
||
|
||
def on_workspace_changed(self, screen, previous_workspace): | ||
try: | ||
workspace_id = screen.get_active_workspace().get_number() | ||
if previous_workspace: | ||
previous_workspace = previous_workspace.get_number() | ||
except: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here I'm not so sure about what could go wrong, I guess the main source of actual problem is at import time: if wnck is missing. I will also remove this try/catch |
||
return | ||
|
||
self.emit('workspace-changed', previous_workspace, workspace_id) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm this should also include tags and other metadata, basically the whole
Fact
instance.