Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Schampijer <simon@schampijer.de>2011-09-07 06:00:45 (GMT)
committer Simon Schampijer <simon@schampijer.de>2011-09-07 14:51:14 (GMT)
commitb644c5e097b14810336da85c9669559d55fd7f60 (patch)
tree6773d3e13eb7d5d1b3634d6dbb4c2795611b482d
parente4f7d81e73fe445f4d4d7b1b168855835fcc09ea (diff)
Add empty messages for empty devices and empty DOCUMENTS folders
Currently the message will be the same for an empty Journal or an empty external device or an empty documents folder. This patch does distinguish between the different cases. In order to get the path of the documents folder as well from the listview the function has been moved to the model. @design team: because I could not figure out an easy way to get the volume's label in the listview I did change the text for an empty device to: 'The device is empty' This patch depends on the previous patch: "Only show DOCUMENTS folder when it is not $HOME" Signed-off-by: Simon Schampijer <simon@laptop.org> Tested-By: Gonzalo Odiard <gonzalo@laptop.org> Reviewed-By: Gonzalo Odiard <gonzalo@laptop.org>
-rw-r--r--src/jarabe/journal/listview.py27
-rw-r--r--src/jarabe/journal/model.py23
-rw-r--r--src/jarabe/journal/volumestoolbar.py26
3 files changed, 36 insertions, 40 deletions
diff --git a/src/jarabe/journal/listview.py b/src/jarabe/journal/listview.py
index a9f5a53..0d7e112 100644
--- a/src/jarabe/journal/listview.py
+++ b/src/jarabe/journal/listview.py
@@ -37,9 +37,6 @@ from jarabe.journal import misc
UPDATE_INTERVAL = 300
-MESSAGE_EMPTY_JOURNAL = 0
-MESSAGE_NO_MATCH = 1
-
class TreeView(gtk.TreeView):
__gtype_name__ = 'JournalTreeView'
@@ -315,9 +312,16 @@ class BaseListView(gtk.Bin):
if len(tree_model) == 0:
if self._is_query_empty():
- self._show_message(MESSAGE_EMPTY_JOURNAL)
+ if self._query['mountpoints'] == ['/']:
+ self._show_message(_('Your Journal is empty'))
+ elif self._query['mountpoints'] == \
+ [model.get_documents_path()]:
+ self._show_message(_('Your documents folder is empty'))
+ else:
+ self._show_message(_('The device is empty'))
else:
- self._show_message(MESSAGE_NO_MATCH)
+ self._show_message(_('No matching entries'),
+ show_clear_query=True)
else:
self._clear_message()
@@ -364,7 +368,7 @@ class BaseListView(gtk.Bin):
self.add(self._scrolled_window)
self._progress_bar = None
- def _show_message(self, message):
+ def _show_message(self, message, show_clear_query=False):
canvas = hippo.Canvas()
self.remove(self.child)
self.add(canvas)
@@ -383,20 +387,13 @@ class BaseListView(gtk.Bin):
fill_color=style.COLOR_TRANSPARENT.get_svg())
box.append(icon)
- if message == MESSAGE_EMPTY_JOURNAL:
- text = _('Your Journal is empty')
- elif message == MESSAGE_NO_MATCH:
- text = _('No matching entries')
- else:
- raise ValueError('Invalid message')
-
- text = hippo.CanvasText(text=text,
+ text = hippo.CanvasText(text=message,
xalign=hippo.ALIGNMENT_CENTER,
font_desc=style.FONT_BOLD.get_pango_desc(),
color=style.COLOR_BUTTON_GREY.get_int())
box.append(text)
- if message == MESSAGE_NO_MATCH:
+ if show_clear_query:
button = gtk.Button(label=_('Clear search'))
button.connect('clicked', self.__clear_button_clicked_cb)
button.props.image = Icon(icon_name='dialog-cancel',
diff --git a/src/jarabe/journal/model.py b/src/jarabe/journal/model.py
index 1242787..c57dfc4 100644
--- a/src/jarabe/journal/model.py
+++ b/src/jarabe/journal/model.py
@@ -17,6 +17,7 @@
import logging
import os
import errno
+import subprocess
from datetime import datetime
import time
import shutil
@@ -794,3 +795,25 @@ def is_editable(metadata):
return True
else:
return os.access(metadata['mountpoint'], os.W_OK)
+
+
+def get_documents_path():
+ """Gets the path of the DOCUMENTS folder
+
+ If xdg-user-dir can not find the DOCUMENTS folder it will
+ return the user directory instead. It also handles
+ localization (i.e. translation) of the filenames.
+
+ Returns: Path to $HOME/DOCUMENTS or None if an error occurs
+ """
+ try:
+ pipe = subprocess.Popen(['xdg-user-dir', 'DOCUMENTS'],
+ stdout=subprocess.PIPE)
+ documents_path = os.path.normpath(pipe.communicate()[0].strip())
+ if os.path.exists(documents_path) and \
+ os.environ.get('HOME') != documents_path:
+ return documents_path
+ except OSError, exception:
+ if exception.errno != errno.ENOENT:
+ logging.exception('Could not run xdg-user-dir')
+ return None
diff --git a/src/jarabe/journal/volumestoolbar.py b/src/jarabe/journal/volumestoolbar.py
index 1cc764f..77bb955 100644
--- a/src/jarabe/journal/volumestoolbar.py
+++ b/src/jarabe/journal/volumestoolbar.py
@@ -16,8 +16,6 @@
import logging
import os
-import subprocess
-import errno
import statvfs
from gettext import gettext as _
@@ -55,28 +53,6 @@ def _get_id(document):
return None
-def _get_documents_path():
- """Gets the path of the DOCUMENTS folder
-
- If xdg-user-dir can not find the DOCUMENTS folder it will
- return the user directory instead. It also handles
- localization (i.e. translation) of the filenames.
-
- Returns: Path to $HOME/DOCUMENTS or None if an error occurs
- """
- try:
- pipe = subprocess.Popen(['xdg-user-dir', 'DOCUMENTS'],
- stdout=subprocess.PIPE)
- documents_path = os.path.normpath(pipe.communicate()[0].strip())
- if os.path.exists(documents_path) and \
- os.environ.get('HOME') != documents_path:
- return documents_path
- except OSError, exception:
- if exception.errno != errno.ENOENT:
- logging.exception('Could not run xdg-user-dir')
- return None
-
-
def _convert_entries(root):
"""Convert entries written by the datastore version 0.
@@ -225,7 +201,7 @@ class VolumesToolbar(gtk.Toolbar):
self._add_button(mount)
def _set_up_documents_button(self):
- documents_path = _get_documents_path()
+ documents_path = model.get_documents_path()
if documents_path is not None:
button = DocumentsButton(documents_path)
button.props.group = self._volume_buttons[0]