Skip to content
Browse files

pynotify migrated and GdkPixbuf

  • Loading branch information...
1 parent 7ecf054 commit 52a05aefcdd63575647ef0a13459dc441e419383 @chuchiperriman committed May 6, 2012
View
1 .gitignore
@@ -1 +1,2 @@
*.pyc
+*~
View
10 src/cloudsn/cloudsn.py
@@ -1,15 +1,15 @@
#!/usr/bin/python
-from .core.controller import Controller
-from .core import config, utils, notification
from . import logger
+from core import config, utils, notification
+from core.controller import Controller
from os.path import join, abspath
import gettext
import locale
from const import *
def setup_locale_and_gettext():
- """Set up localization with gettext"""
+ #Set up localization with gettext
localedir = join (config.get_base_data_prefix(),"locale")
# Install _() builtin for gettext; always returning unicode objects
# also install ngettext()
@@ -27,14 +27,17 @@ def setup_locale_and_gettext():
pass
def start ():
+ logger.info("1")
try:
setup_locale_and_gettext()
except Exception, e:
logger.exception("Error loading the internationalitation: %s", e)
try:
+ logger.debug("aaaww")
cr = Controller.get_instance()
cr.start()
+ logger.debug("aaaasdas")
except Exception, e:
logger.exception("Error starting cloudsn: %s", e)
#We not traduce this notification because the problem can be gettext
@@ -43,6 +46,7 @@ def start ():
utils.get_error_pixbuf())
if __name__ == "__main__":
+ logger.debug("0")
start()
View
2 src/cloudsn/core/config.py
@@ -191,7 +191,7 @@ def save_accounts (self):
def get_cloudsn_icon():
global __cloudsn_icon
if not __cloudsn_icon:
- __cloudsn_icon = Gtk.gdk.pixbuf_new_from_file(add_data_prefix('cloudsn.png'))
+ __cloudsn_icon = Gtk.Gdk.pixbuf_new_from_file(add_data_prefix('cloudsn.png'))
return __cloudsn_icon
def get_startup_file_dir():
View
6 src/cloudsn/core/controller.py
@@ -2,7 +2,7 @@
from cloudsn.core.provider import Provider, ProviderManager
from cloudsn.core import account, config, networkmanager, notification, utils, indicator
from cloudsn import logger
-from ..ui.authwarning import check_auth_configuration
+from cloudsn.ui.authwarning import check_auth_configuration
from time import time
from gi.repository import Gtk
from gi.repository import GObject
@@ -216,8 +216,11 @@ def update_accounts(self, data=None):
def _start_idle(self):
try:
+ logger.debug("aaa")
check_auth_configuration()
+ logger.debug("aaab")
self.nm.set_statechange_callback(self.on_nm_state_changed)
+ logger.debug("aaac")
self.set_active (True)
self.update_accounts()
self.started = True
@@ -233,6 +236,7 @@ def _start_idle(self):
return False
def start(self):
+ logger.debug("aaasss")
GObject.threads_init()
GObject.idle_add(self._start_idle)
try:
View
2 src/cloudsn/core/keyrings/base64keyring.py
@@ -2,7 +2,7 @@
import base64
import gettext
from cloudsn import logger
-from ..keyring import Keyring, KeyringException, Credentials
+from cloudsn.core.keyring import Keyring, KeyringException, Credentials
class Base64Keyring(Keyring):
View
2 src/cloudsn/core/keyrings/gkeyring.py
@@ -1,6 +1,6 @@
# -*- mode: python; tab-width: 4; indent-tabs-mode: nil -*-
import gnomekeyring as gk
-from ..keyring import Keyring, KeyringException, Credentials
+from cloudsn.core.keyring import Keyring, KeyringException, Credentials
from cloudsn import logger
import threading
View
2 src/cloudsn/core/keyrings/plainkeyring.py
@@ -1,5 +1,5 @@
# -*- mode: python; tab-width: 4; indent-tabs-mode: nil -*-
-from ..keyring import Keyring, KeyringException, Credentials
+from cloudsn.core.keyring import Keyring, KeyringException, Credentials
from cloudsn import logger
import gettext
View
12 src/cloudsn/core/notification.py
@@ -11,13 +11,13 @@
last_notify = tstart = datetime.now()
try:
- import pynotify
- if pynotify.init("Cloud Services Notifications"):
+ from gi.repository import Notify
+ if Notify.init("Cloud Services Notifications"):
disable = False
else:
logger.error("Cannot initialize libnotify")
except Exception, e:
- logger.exception ("there was a problem initializing the pynotify module: %s" % (e))
+ logger.exception ("there was a problem initializing the Notify module: %s" % (e))
#def notify_closed_cb (n, data=None):
@@ -56,11 +56,11 @@ def notify_process ():
def notify (title, message, icon = None):
if disable == True:
- raise NotificationError ("there was a problem initializing the pynotify module")
+ raise NotificationError ("there was a problem initializing the Notify module")
global notifications
- n = pynotify.Notification(title, message)
- n.set_urgency(pynotify.URGENCY_LOW)
+ n = Notify.Notification.new(title, message, None)
+ n.set_urgency(Notify.Urgency.LOW)
#n.set_timeout(3000)
if icon:
View
13 src/cloudsn/core/utils.py
@@ -1,5 +1,5 @@
-import gconf
-from gi.repository import Gtk
+#import gconf
+from gi.repository import Gtk, Gio
import os
import subprocess
from email.header import decode_header
@@ -23,7 +23,8 @@ def invoke_subprocess(cmdline):
subprocess.Popen(cmdline, close_fds = True, preexec_fn = setsid)
def get_default_mail_reader():
- client = gconf.client_get_default()
+ #client = gconf.client_get_default()
+ client = Gio.Settings.new()
cmd = client.get_string("/desktop/gnome/url-handlers/mailto/command")
return cmd.split()[0]
@@ -46,9 +47,9 @@ def get_boolean (value):
return False
def get_error_pixbuf():
- icons = Gtk.icon_theme_get_default()
- l = Gtk.ICON_LOOKUP_USE_BUILTIN
- return icons.load_icon(Gtk.STOCK_DIALOG_ERROR, 32, l)
+ icons = Gtk.IconTheme.get_default()
+ #TODO How can I set this value with gir ? l = Gtk.ICON_LOOKUP_USE_BUILTIN
+ return icons.load_icon(Gtk.STOCK_DIALOG_ERROR, 32, 0)
def get_account_error_pixbuf (acc):
original = acc.get_provider().get_icon().copy()
View
4 src/cloudsn/providers/feedsprovider.py
@@ -7,7 +7,7 @@
from cloudsn import logger
from os.path import join
import os
-from gi.repository import Gtk
+from gi.repository import Gtk, GdkPixbuf
import urllib2
import csv
@@ -27,7 +27,7 @@ def __init__(self):
if FeedsProvider.__default:
raise FeedsProvider.__default
ProviderUtilsBuilder.__init__(self, _("RSS news"), 'rss')
- self.icon = Gtk.gdk.pixbuf_new_from_file(config.add_data_prefix('rss.png'))
+ self.icon = GdkPixbuf.Pixbuf.new_from_file(config.add_data_prefix('rss.png'))
@staticmethod
def get_instance():
View
4 src/cloudsn/providers/gmailprovider.py
@@ -8,7 +8,7 @@
from cloudsn import logger
from xml.sax.handler import ContentHandler
from xml import sax
-from gi.repository import Gtk
+from gi.repository import Gtk, GdkPixbuf
import urllib2
class GMailProvider(Provider):
@@ -19,7 +19,7 @@ def __init__(self):
if GMailProvider.__default:
raise GMailProvider.__default
Provider.__init__(self, "GMail")
- self.icon = Gtk.gdk.pixbuf_new_from_file(config.add_data_prefix('gmail.png'))
+ self.icon = GdkPixbuf.Pixbuf.new_from_file(config.add_data_prefix('gmail.png'))
@staticmethod
def get_instance():
View
4 src/cloudsn/providers/imapprovider.py
@@ -14,7 +14,7 @@
from cloudsn import logger
import imaplib
from email.Parser import HeaderParser
-from gi.repository import Gtk
+from gi.repository import Gtk, GdkPixbuf
class ImapProvider(ProviderBase):
__default = None
@@ -23,7 +23,7 @@ def __init__(self):
if ImapProvider.__default:
raise ImapProvider.__default
ProviderBase.__init__(self, "Imap")
- self.icon = Gtk.gdk.pixbuf_new_from_file(config.add_data_prefix('imap.png'))
+ self.icon = GdkPixbuf.Pixbuf.new_from_file(config.add_data_prefix('imap.png'))
@staticmethod
def get_instance():
View
4 src/cloudsn/providers/providersbase.py
@@ -6,7 +6,7 @@
from cloudsn.ui.utils import create_provider_widget, get_widget_by_label
from xml.sax.handler import ContentHandler
from xml import sax
-from gi.repository import Gtk
+from gi.repository import Gtk, GdkPixbuf
import urllib2
class ProviderBase(Provider):
@@ -17,7 +17,7 @@ def __init__(self, name, id_provider = None):
if not id_provider:
self.id_provider = name
self.id_provider = self.id_provider.lower()
- self.icon = Gtk.gdk.pixbuf_new_from_file(config.add_data_prefix(self.id_provider + '.png'))
+ self.icon = GdkPixbuf.Pixbuf.new_from_file(config.add_data_prefix(self.id_provider + '.png'))
class ProviderGtkBuilder(ProviderBase):
View
2 src/cloudsn/ui/about.py
@@ -10,7 +10,7 @@ def show_about_dialog():
dialog.set_copyright (const.APP_COPYRIGHT)
dialog.set_comments(const.APP_DESCRIPTION)
dialog.set_website (const.APP_WEBSITE)
- dialog.set_logo(Gtk.gdk.pixbuf_new_from_file(config.add_data_prefix('cloudsn120.png')))
+ dialog.set_logo(Gtk.Gdk.pixbuf_new_from_file(config.add_data_prefix('cloudsn120.png')))
dialog.set_authors (["Jesús Barbero Rodríguez"])
dialog.run()
dialog.hide()
View
8 src/cloudsn/ui/authwarning.py
@@ -1,10 +1,10 @@
from gi.repository import Gtk
import gettext
from cloudsn import logger
-from ..core.config import SettingsController, get_cloudsn_icon
-from ..core.utils import get_boolean
-from ..const import *
-from ..core.keyring import get_keyring
+from cloudsn.core.config import SettingsController, get_cloudsn_icon
+from cloudsn.core.utils import get_boolean
+from cloudsn.const import *
+from cloudsn.core.keyring import get_keyring
AUTH_DONT_ASK_KEY = "auth_dont_ask"

0 comments on commit 52a05ae

Please sign in to comment.
Something went wrong with that request. Please try again.