deskbar-applet r2244 - in trunk: . deskbar deskbar/core
- From: sebp svn gnome org
- To: svn-commits-list gnome org
- Subject: deskbar-applet r2244 - in trunk: . deskbar deskbar/core
- Date: Fri, 11 Jul 2008 19:22:22 +0000 (UTC)
Author: sebp
Date: Fri Jul 11 19:22:22 2008
New Revision: 2244
URL: http://svn.gnome.org/viewvc/deskbar-applet?rev=2244&view=rev
Log:
Place user's modules in $XDG_DATA_HOME/deskbar-applet/modules-2.20-compatible and history file together with modules' configuration data into $XDG_CONFIG_HOME/deskbar-applet
When on of the directories doesn't exist and the old location ~/.gnome2/deskbar-applet still does the files are copied to the new locations. Fixes bug #522813
Modified:
trunk/ChangeLog
trunk/deskbar/__init__.py
trunk/deskbar/core/BrowserMatch.py
Modified: trunk/deskbar/__init__.py
==============================================================================
--- trunk/deskbar/__init__.py (original)
+++ trunk/deskbar/__init__.py Fri Jul 11 19:22:22 2008
@@ -1,4 +1,5 @@
import os
+import shutil
from os.path import join, exists, isdir, isfile, dirname, abspath, expanduser
import logging
@@ -22,6 +23,13 @@
if _check(name):
UNINSTALLED_DESKBAR = True
+# From pyxdg
+_home = os.environ.get('HOME', '/')
+XDG_DATA_HOME = os.environ.get('XDG_DATA_HOME',
+ os.path.join(_home, '.local', 'share'))
+XDG_CONFIG_HOME = os.environ.get('XDG_CONFIG_HOME',
+ os.path.join(_home, '.config'))
+
# Sets SHARED_DATA_DIR to local copy, or the tem location
# Shared data dir is most the time /usr/share/deskbar-applet
if UNINSTALLED_DESKBAR:
@@ -36,19 +44,42 @@
HANDLERS_DIR += [join(LIB_DIR, "deskbar-applet", "modules-2.20-compatible")]
-USER_DESKBAR_DIR = expanduser("~/.gnome2/deskbar-applet")
-if not exists(USER_DESKBAR_DIR):
- try:
- os.makedirs(USER_DESKBAR_DIR, 0744)
- except Exception , msg:
- LOGGER.error('Could not create user handlers dir (%s): %s', USER_DESKBAR_DIR, msg)
+OLD_USER_DESKBAR_DIR = expanduser("~/.gnome2/deskbar-applet")
+USER_CONFIG_DIR = join(XDG_CONFIG_HOME, "deskbar-applet")
-USER_HANDLERS_DIR = expanduser("~/.gnome2/deskbar-applet/modules-2.20-compatible")
-if not exists(USER_HANDLERS_DIR):
- try:
- os.makedirs(USER_HANDLERS_DIR, 0744)
- except Exception , msg:
- LOGGER.error('Could not create user handlers dir (%s): %s', USER_HANDLERS_DIR, msg)
+USER_DATA_DIR = join(XDG_DATA_HOME, "deskbar-applet")
+USER_HANDLERS_DIR = join(USER_DATA_DIR, "modules-2.20-compatible")
+
+if not (exists(USER_DATA_DIR) and exists(USER_CONFIG_DIR)):
+ error = False
+
+ if not exists(USER_CONFIG_DIR):
+ try:
+ os.makedirs(USER_CONFIG_DIR, 0744)
+ except Exception , msg:
+ LOGGER.error('Could not create user handlers dir (%s): %s', USER_CONFIG_DIR, msg)
+ error = True
+
+ if not exists(USER_HANDLERS_DIR):
+ try:
+ os.makedirs(USER_HANDLERS_DIR, 0744)
+ except Exception , msg:
+ LOGGER.error('Could not create user handlers dir (%s): %s', USER_HANDLERS_DIR, msg)
+ error = True
+
+ if not error and exists(OLD_USER_DESKBAR_DIR):
+ # Move files from old ~/.gnome2 directory to fd.o compliant dirs
+ for root, dirs, files in os.walk(OLD_USER_DESKBAR_DIR):
+ if "modules-2.20-compatible" in root:
+ destdir = USER_HANDLERS_DIR
+ else:
+ destdir = USER_CONFIG_DIR
+
+ for name in files:
+ filepath = join(root, name)
+ LOGGER.debug("Copying %s to %s", filepath, destdir)
+ shutil.copy (filepath, destdir)
+
USER_HANDLERS_DIR = [USER_HANDLERS_DIR]
MODULES_DIRS = USER_HANDLERS_DIR+HANDLERS_DIR
@@ -65,7 +96,7 @@
ICON_WIDTH = 28
ICON_HEIGHT = 16
-HISTORY_FILE = join(USER_DESKBAR_DIR, "history-2.20-compatible.pickle")
+HISTORY_FILE = join(USER_DATA_DIR, "history-2.20-compatible.pickle")
# FIXME: this , here ?
DEFAULT_RESULTS_PER_HANDLER = 6
Modified: trunk/deskbar/core/BrowserMatch.py
==============================================================================
--- trunk/deskbar/core/BrowserMatch.py (original)
+++ trunk/deskbar/core/BrowserMatch.py Fri Jul 11 19:22:22 2008
@@ -198,7 +198,7 @@
shortcuts_to_smart_bookmarks_map.clear()
url_to_shortcuts = {}
try:
- for line in file(os.path.join(deskbar.USER_DESKBAR_DIR, "search-bookmarks-shortcuts.txt")):
+ for line in file(os.path.join(deskbar.USER_CONFIG_DIR, "search-bookmarks-shortcuts.txt")):
line = line.strip()
if len(line) > 0:
url, shortcut = line.split()
@@ -214,7 +214,7 @@
pass
def _save_shortcuts(shortcuts_to_smart_bookmarks_map):
- f = open(os.path.join(deskbar.USER_DESKBAR_DIR, "search-bookmarks-shortcuts.txt"), "w")
+ f = open(os.path.join(deskbar.USER_CONFIG_DIR, "search-bookmarks-shortcuts.txt"), "w")
for shortcut in shortcuts_to_smart_bookmarks_map.keys():
bookmark = shortcuts_to_smart_bookmarks_map[shortcut]
f.write(bookmark.url)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]