Browse Source

Images are related to the UI, not a general thing.

master
Julio Biason 16 years ago
parent
commit
bed1415bff
  1. 31
      mitterlib/__init__.py
  2. 48
      mitterlib/ui/helpers/image_helpers.py
  3. 31
      mitterlib/ui/helpers/utils.py
  4. 24
      mitterlib/ui/ui_pygtk.py

31
mitterlib/__init__.py

@ -19,37 +19,6 @@
import os.path
import glob
import logging
def find_image(image_name):
"""Using the iamge_name, search in the common places. Return the path for
the image or None if the image couldn't be found."""
# just because I'm a logging nut
log = logging.getLogger('mitterlib.find_image')
import os.path
import sys
# the order is the priority, so keep global paths before local paths
current_dir = os.path.abspath(os.path.dirname(__file__))
common_paths = [
os.path.join(sys.prefix, 'share', 'pixmaps'),
os.path.join('.', 'pixmaps'),
os.path.join(current_dir, '..', 'pixmaps')]
for path in common_paths:
filename = os.path.join(path, image_name)
log.debug('Checking %s...' % (filename))
if os.access(filename, os.F_OK):
log.debug('Default image is %s' % (filename))
return filename
return None
def module_search(source, ignore):
"""Search for modules in the source directory. Ignore any modules

48
mitterlib/ui/helpers/image_helpers.py

@ -0,0 +1,48 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Mitter, a Maemo client for Twitter.
# Copyright (C) 2007-2009 The Mitter Contributors
#
# This program 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.
#
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
import os.path
import sys
import logging
def find_image(image_name):
"""Using the iamge_name, search in the common places. Return the path for
the image or None if the image couldn't be found."""
# just because I'm a logging nut
log = logging.getLogger('mitterlib.find_image')
# the order is the priority, so keep global paths before local paths
current_dir = os.path.abspath(os.path.dirname(__file__))
common_paths = [
os.path.join(sys.prefix, 'share', 'pixmaps'),
os.path.join('.', 'pixmaps'),
os.path.join(current_dir, '..', 'pixmaps')]
for path in common_paths:
filename = os.path.join(path, image_name)
log.debug('Checking %s...' % (filename))
if os.access(filename, os.F_OK):
log.debug('Default image is %s' % (filename))
return filename
return None

31
mitterlib/ui/helpers/utils.py

@ -1,31 +0,0 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Mitter, a Maemo client for Twitter.
# Copyright (C) 2007, 2008 Julio Biason, Deepak Sarda
#
# This program 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.
#
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
def str_len(s):
"""Get length of string which may be unicode or encoded"""
return len(to_unicode(s))
def to_unicode(s, encoding='utf-8'):
"""Converts string to unicode if it isn't one already"""
if not isinstance(s, unicode):
return unicode(s, encoding)

24
mitterlib/ui/ui_pygtk.py

@ -17,24 +17,19 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import pygtk
pygtk.require('2.0')
import gtk
import gobject
gobject.threads_init()
gtk.gdk.threads_init()
import datetime
import re
import logging
import mitterlib as util
from mitterlib.ui.helpers.image_helpers import find_image
from mitterlib.constants import gpl_3, version
from mitterlib.ui.helpers.utils import str_len
from mitterlib.ui.helpers.notify import Notify
from mitterlib.ui.helpers import timesince
#from mitterlib.constants import gpl_3, version
#from mitterlib.ui.helpers.utils import str_len
#from mitterlib.ui.helpers.notify import Notify
#from mitterlib.ui.helpers import timesince
# Constants
@ -441,10 +436,10 @@ class Interface(object):
self._pic_queue = set()
# Load images
self._app_icon = util.find_image('mitter.png')
self._app_icon_alert = util.find_image('mitter-new.png')
self._app_icon = find_image('mitter.png')
self._app_icon_alert = find_image('mitter-new.png')
unknown_pixbuf = util.find_image('unknown.png')
unknown_pixbuf = find_image('unknown.png')
if unknown_pixbuf:
self._default_pixmap = gtk.gdk.pixbuf_new_from_file(
unknown_pixbuf)
@ -454,9 +449,6 @@ class Interface(object):
self._main_window = self._create_main_window()
#self._main_window()
#self._systray_setup()
# self.create_settings_dialog()
# self.username_field.set_text(default_username)

Loading…
Cancel
Save