[prev in list] [next in list] [prev in thread] [next in thread]
List: klik-devel
Subject: [klik-devel] [klikclient commit] r1472 - in trunk/client/trunk:
From: codesite-noreply () google ! com
Date: 2008-04-27 8:22:30
Message-ID: 00c09ffb4e960ecd0d044bd68058 () google ! com
[Download RAW message or body]
Author: KillerKiwi2005
Date: Sun Apr 27 01:21:24 2008
New Revision: 1472
Modified:
trunk/client/trunk/install/gnome/cmg-gnome-thumbnail.schema
trunk/client/trunk/klikclient/bin/klik
trunk/client/trunk/klikclient/lib/klik/cmg.py
trunk/client/trunk/klikclient/lib/klik/compat/kde.py
trunk/client/trunk/klikclient/lib/klik/compat/mono.py
trunk/client/trunk/klikclient/lib/klik/settings.py
trunk/client/trunk/klikclient/lib/klik/utils/images.py
Log:
Fix for gnome thumbnailer, note there is a regression in nautilus which
addes frames and resizes the icons....
Modified: trunk/client/trunk/install/gnome/cmg-gnome-thumbnail.schema
==============================================================================
--- trunk/client/trunk/install/gnome/cmg-gnome-thumbnail.schema (original)
+++ trunk/client/trunk/install/gnome/cmg-gnome-thumbnail.schema Sun Apr
27 01:21:24 2008
@@ -18,7 +18,7 @@
<applyto>/desktop/gnome/thumbnailers/application@x-application-cmg/command</applyto>
<owner>Thumbnailer</owner>
<type>string</type>
- <default>klik icon %i %o %s</default>
+ <default>klik icon %i %o</default>
<locale name="C">
<short>Create thumbnail for cmg</short>
<long>Create thumbnail for cmg</long>
Modified: trunk/client/trunk/klikclient/bin/klik
==============================================================================
--- trunk/client/trunk/klikclient/bin/klik (original)
+++ trunk/client/trunk/klikclient/bin/klik Sun Apr 27 01:21:24 2008
@@ -212,7 +212,7 @@
if len(args) > 2:
result = cmg.extract_icon(args[1], resize=int(args[2]))
else:
- result = cmg.extract_icon(args[1])
+ result = cmg.extract_icon(args[1], -1)
if not result:
print "Error: Could not extract icon"
Modified: trunk/client/trunk/klikclient/lib/klik/cmg.py
==============================================================================
--- trunk/client/trunk/klikclient/lib/klik/cmg.py (original)
+++ trunk/client/trunk/klikclient/lib/klik/cmg.py Sun Apr 27 01:21:24 2008
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# klik2
+# klik2
# Copyright (C) 2008 Jason Taylor - killerkiwi2005@gmail.com
#
# This program is free software; you can redistribute it and/or modify
@@ -41,7 +41,7 @@
def __init__(self, klik, path):
-
+
# Make sure path is absolute
path = os.path.expanduser( path )
path = os.path.expandvars( path )
@@ -58,12 +58,12 @@
self.path = path
self.sandbox = KlikSandBox(path)
self.mount_point_path = None
-
+
self.klik = klik
-
+
def exists(self):
return os.path.exists(self.path)
-
+
def find_sub_directories(self, path):
directories = []
p = subprocess.Popen(["cmginfo", "-f", self.path, "-l", path, "-v"], \
stdout=subprocess.PIPE) @@ -75,11 +75,11 @@
return directories
def __get_command(self, args, force_prompt):
-
+
command = None
-
+
if self.cmg_version == 2:
-
+
desktop_object = None
# Need to check recipe command
@@ -93,10 +93,10 @@
elif parse_args:
args.append(r.group(0))
parse_count = parse_count + 1
-
+
# look at desktop files
if force_prompt or not command or self.klik.settings.always_show_app_chooser:
-
+
desktop_objects = self.get_desktop_objects(False)
if force_prompt or self.klik.xdg.get_is_x_display() and
len(desktop_objects) > 1:
@@ -104,11 +104,11 @@
# if self.klik.xdg.get_desktop_enviroment() == "GNOME" and :
if self.klik.xdg.get_is_gtk_installed():
-
+
# this dialouge will return the selected desktop object
from klik.gtk.multiple import MultipleApplications
ma = MultipleApplications(self.klik)
-
+
desktop_object = ma.load_items( desktop_objects )
# QT ?
@@ -126,11 +126,11 @@
else:
# klik 1
command = "/wrapper"
-
+
return command
def execute(self, args, command=None, capture_error=False,
force_prompt=False ):
-
+
# CLI should add commands to line
if force_prompt or not command:
command = self.__get_command(args, force_prompt)
@@ -138,14 +138,14 @@
ex = KlikExecute(self.klik)
return ex.execute( self, command, args, capture_error )
return 0, "Cancelled"
-
+
def execute_shell(self):
ex = KlikExecute(self.klik)
command = self.__get_command([None], False)
if command:
return ex.execute_shell(self, command)
return 0, "Cancelled"
-
+
def get_recipe(self):
if not self.__recipe:
temp_path = self.extract_file("/recipe.xml")
@@ -155,39 +155,39 @@
except Exception, e:
print "cmg.get_recipe() - Error:", e
return self.__recipe
-
+
def open_pipe(self, file_path_from):
-
+
if self.cmg_version == 1:
return open( self.extract_file(file_path_from), "r")
else:
- # Klik2 packages: if file_path_to != None, extract file; otherwise
write file to a pipe
+ # Klik2 packages: if file_path_to != None, extract file; otherwise
write file to a pipe
p = subprocess.Popen(["cmginfo", "-f", self.path, "-e",
file_path_from], stdout=subprocess.PIPE)
return p.stdout
-
+
def extract_file(self, file_path_from, file_path_to=None):
# If you do not pass in a file path to a temp file will be created
that you should delete
-
+
if not file_path_to:
file_path_to = tempfile.mktemp()
-
+
if self.cmg_version == 1:
# ALWAYS use KlikExecute!!!!
ex = KlikExecute(self.klik)
ex.extract_file( self, file_path_from, file_path_to)
else:
- # Klik2 packages: if file_path_to != None, extract file; otherwise
write file to a pipe
+ # Klik2 packages: if file_path_to != None, extract file; otherwise
write file to a pipe
if file_path_to:
subprocess.Popen(["cmginfo", "-f", self.path, "-e",
file_path_from, "-o", file_path_to]).wait()
-
+
if os.path.exists( file_path_to ):
return file_path_to
-
+
return None
-
-
+
+
def is_valid_cmg(self):
-
+
if self.__cmg_version == -1:
if os.path.isfile( self.path ):
# Try system mimetype first
@@ -235,7 +235,7 @@
f.close()
self.__cmg_version = 0
return self.__cmg_version
-
+
# Return all the files in a given CMG that match pre and post text
def find_files(self, pre_text=None, post_text=None, omit_extension=False):
if omit_extension:
@@ -295,7 +295,7 @@
for file in self.find_files("/usr/share/applications/", ".desktop"):
# Extract and parse the .desktop file
temp_path = self.extract_file( file )
-
+
if temp_path:
do = DesktopParser( temp_path )
os.remove( temp_path )
@@ -308,14 +308,14 @@
# Attempt to generate desktop files from debian menu
if len(desktop_objects) == 0:
-
+
menu_files = self.find_files("/usr/share/menu/")
for menu_file in menu_files:
# Extract and parse the .desktop file
temp_path = self.extract_file( menu_file )
for mo in MenuParser( temp_path ).menu_objects:
do = DesktopParser()
-
+
do.set("Type", "Application")
do.set("Exec", mo.command)
do.set("Name", mo.title.capitalize())
@@ -323,19 +323,19 @@
do.set("Icon", mo.icon)
do.set("Categories", mo.freedesktop_category)
do.set("X-CMG", self.path)
-
+
desktop_objects.append( do )
-
+
os.remove( temp_path )
-
+
# Couldn't find any desktop file, build a basic one
if len(desktop_objects) == 0:
-
+
# With klik2 packages, extract information from recipe
# With klik1 packages, make up information
-
+
cmg_version = self.is_valid_cmg()
-
+
if cmg_version == 2:
recipe = self.get_recipe()
else:
@@ -352,9 +352,9 @@
command = ""
name = os.path.splitext( os.path.basename( self.path ) )[0].capitalize()
terminal = False
-
+
do = DesktopParser()
-
+
do.set("Name", name)
do.set("Terminal", terminal)
do.set("Exec", command)
@@ -367,9 +367,9 @@
category =
klik.utils.freedesktop.get_freedesktop_category_from_debtag(
recipe.debtags["use"] )
if category != None:
do.set("Categories", category)
-
+
desktop_objects.append( do )
-
+
return desktop_objects
def extract_icon(self, file_path_to, resize=None):
@@ -378,20 +378,20 @@
if resize:
if resize < 0:
resize = self.klik.settings.desktop_icon_size # TODO: review this behaviour
- klik.utils.images.resize(file_path_to, resize)
- else:
- shutil.move( file_path_to,
- os.path.splitext(file_path_to)[0] +"."+
klik.utils.images.guess_type(file_path_to) )
+ path = klik.utils.images.resize(file_path_to, resize)
+ if path:
+ shutil.copy( path, file_path_to )
+ os.remove( path )
return True
return False
-
+
def check_for_missing_library(self, command=None):
ex = KlikExecute(self.klik)
command = self.__get_command([None], False)
if command:
return ex.check_for_missing_library(self, command)
return "Cancelled"
-
+
def get_unique_id(self, name=None):
# If given a desktop entry name, returns the complete pakage id
# Otherwise, returns only the package id prefix
@@ -399,9 +399,7 @@
if name:
return prefix + '-' + urllib.quote_plus( name )
return prefix
-
+
# Properties
cmg_version = property(fget=is_valid_cmg)
recipe = property(fget=get_recipe)
-
-
Modified: trunk/client/trunk/klikclient/lib/klik/compat/kde.py
==============================================================================
--- trunk/client/trunk/klikclient/lib/klik/compat/kde.py (original)
+++ trunk/client/trunk/klikclient/lib/klik/compat/kde.py Sun Apr 27
01:21:24 2008
@@ -2,24 +2,23 @@
from subprocess import *
class KlikCompatKDE(object):
-
+
def __init__(self, klik):
self.klik = klik
-
- # what happend to our old mono wapi path hack?
+
def init_enviroment(self, cmg):
-
+
if "KDE" in cmg.recipe.needs:
os.environ["KDE_FORK_SLAVES"] = "1"
-
+
# KDE - kdeinit
# if starting a kde app make sure kdeinit is running first
if self.klik.xdg.get_desktop_enviroment != "KDE":
-
+
if Popen(["which", "start_kdeinit_wrapper"], stdout=PIPE, \
stderr=open(os.devnull, "w")).communicate()[0].strip():
if not Popen(["pidof", "-x", "kdeinit"], stdout=PIPE, stderr=open(os.devnull, \
"w")).communicate()[0].strip(): call(["start_kdeinit_wrapper"])
-
+
if not Popen(["pidof", "-x", "kdeinit"], stdout=PIPE, stderr=open(os.devnull, \
"w")).communicate()[0].strip(): call(["start_kdeinit"])
return
Modified: trunk/client/trunk/klikclient/lib/klik/compat/mono.py
==============================================================================
--- trunk/client/trunk/klikclient/lib/klik/compat/mono.py (original)
+++ trunk/client/trunk/klikclient/lib/klik/compat/mono.py Sun Apr 27
01:21:24 2008
@@ -1,11 +1,11 @@
import os
class KlikCompatMono(object):
- # All patches we need to run python applications in a cross distro manner
-
+ # All patches we need to run mono applications in a cross distro manner
+
def __init__(self, klik):
self.klik = klik
-
+
# what happend to our old mono wapi path hack?
# I think we removed it as didnt need it any more...
def init_enviroment(self, cmg):
Modified: trunk/client/trunk/klikclient/lib/klik/settings.py
==============================================================================
--- trunk/client/trunk/klikclient/lib/klik/settings.py (original)
+++ trunk/client/trunk/klikclient/lib/klik/settings.py Sun Apr 27
01:21:24 2008
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# klik2
+# klik2
# Copyright (C) 2008 Jason Taylor - killerkiwi2005@gmail.com
#
# This program is free software; you can redistribute it and/or modify
@@ -48,7 +48,7 @@
def __init__(self):
xdg = XdgUtils()
-
+
# Can we use a custom glib loader?
self.glibc_loader = os.path.exists("/lib/ld-klik2.so.2")
@@ -58,10 +58,10 @@
f = open(svnversion_path, "r")
self.version = self.version + "." + f.readline().strip() + "svn"
f.close()
-
+
# default destination
self.destination = xdg.get_desktop_dir()
-
+
# Hardcoded default values
self.desktop_icon_size = 48
self.debug = False
@@ -89,16 +89,16 @@
os.mkdir(user_settings_directory)
if not os.path.exists(user_settings_path):
shutil.copy(system_settings_path, user_settings_path)
-
+
if os.getenv("KLIK_DEBUG") != None:
self.debug = (os.getenv("KLIK_DEBUG") == "1")
def __load_file(self, path):
-
+
# private method to eval an arg to a bool value
def mk_bool( arg ):
return arg == "1" or arg.lower() == "true"
-
+
if os.path.exists(path):
# Load XML document
@@ -173,8 +173,6 @@
print var
print
return 0
-
+
except:
return 1
-
-
Modified: trunk/client/trunk/klikclient/lib/klik/utils/images.py
==============================================================================
--- trunk/client/trunk/klikclient/lib/klik/utils/images.py (original)
+++ trunk/client/trunk/klikclient/lib/klik/utils/images.py Sun Apr 27
01:21:24 2008
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# klik2
+# klik2
# Copyright (C) 2008 Jason Taylor - killerkiwi2005@gmail.com
#
# This program is free software; you can redistribute it and/or modify
@@ -26,12 +26,16 @@
# more portable, more poserful
# http://www.pythonware.com/library/pil/handbook/index.htm
# (RazZziel)
+ # PIL is not always installed, remember minimise deps - Killerkiwi
import gtk
pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(file_path, size, size)
os.remove(file_path)
- pixbuf.save(os.path.splitext(file_path)[0] + ".png", "png")
+ path = os.path.splitext(file_path)[0] + ".png"
+ pixbuf.save(path, "png")
+ return path
except Exception, text:
print "Image resize failed:", text
+ return None
def guess_type(file_path):
_______________________________________________
klik-devel mailing list
klik-devel@kde.org
https://mail.kde.org/mailman/listinfo/klik-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic