Forgot script was Re: A small example and GC-API

 Sorry forgot the python script

>>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<

On 5/22/00, 1:02:21 AM, Hassan Aurag <aurag@CRM.UMontreal.CA> wrote 
regarding A small example and GC-API:

>  Enclosed, you will find a small ill-written python script that wants
> to make a point.

>  The point is the following:

>  I have looked as a user at gnome equivalents of WinZip .... to no
> avail.

>  Gxtar et al. Are all particularly ugly and incredibly slow.

>  Indeed, these tools all use GtkTree, because it is easy even though
> on big archives it can become quite ugly.

>  Now try with script attached to this mail and you will notice a
> visual enhancement. This is not even an app, just a way to show Big
> Fat Archives in a better way.

>  Btw, nothing forbids you guys from actually unarchiving the tar.gz in
> some /tmp and have user manipulate it in a speedy way.

>  Now to the serious part of my post:

>  Again I will take an unexisting situation. For now at least.

>  I use GnomeZip and GnomeWord (please insert any names you like)

>  I open a tar.bz3(4,5,6) with GnomeZip.

>  Take my little script as example. Imagine I have actually enabled you
> the user to open files by clicking on them. It is easy with mime
> types. Now I open it with GnomeWord, change some lines, save and close 

>  In Windows world, somehow Word or Winzip knows about it, and it will
> automagically update your archive accordingly.

>  If I want to implement this under Gnome, the only way I could think
> of is an inter-app callback mechanism for gnome compliant apps.

>  Example in python for simplicity's sake:

>   def double-click(file):
>    gnome_open_foreign_whatever_name_you_wish({"GnomeWord", "file",
> "open"},{"update", optional_data})

>  Of course I'd as GnomeZip creator implement update, but all gnome
> compliant apps would be able once done with "file" to do the same and
> launch
>  gnome_open_foreign({"GnomeZip", "file", "update"}, None)

>  None here is because GnomeWord doesn't want anything to do with that
> file anymore.

>  Am I babbling here or what?

> _______________________________________________
> gnome-devel-list mailing list

from gtk import *
from gnome.ui import *
import os, os.path, time, gnome.mime, string
from GtkExtra import *

bnode = {}

#GtkCTree List of files.
treelist = GtkCTree(cols=5, titles=["Name", "Size in Bytes", "Date", "Time", "Guessed Type"])
win = GtkScrolledWindow()

#Testing stuff
def tar_tzvf(what):
	res = {}
	for i in what:
		base = string.strip(i)
		full_path = string.split(base)[-1]
		res[full_path] = string.split(base)[:-1]
	return res

def build_nodes(what):
	global bnode
	#Sort keys
	mykeys = what.keys()
	#Build nodes
	for x in mykeys:
		tmp = string.split(x, "/")
		mytype = string.capwords(gnome.mime.type(x))
		if tmp[-1] == "":
			if len(tmp[:-1]) == 1:
				arg = None
			else: arg = bnode[string.join(tmp[:-2], "/") + "/"]
			bnode[x] = treelist.insert_node(arg, None, (tmp[-2],"", "", "", "Directory"), is_leaf=0, expanded=1)
		if tmp[-1] != "" and len(tmp) > 1:
			for i in range(len(tmp)):
				if i == 0:
					indice = tmp[0] + "/"
					if indice not in bnode.keys():
						bnode[indice] = treelist.insert_node(None, None, (tmp[-2],"", "", "", "Directory"), is_leaf=0, expanded=1)
				elif i < len(tmp) -1 and i > 0:
					indice = string.join(tmp[:-i], "/")+"/"
					parent = string.join(tmp[:-i-1],"/")+ "/"
					if indice not in bnode.keys():
						bnode[indice] =  treelist.insert_node(bnode[parent], None, (tmp[-1], what[x][2], what[x][3], what[x][4], "Directory"))
					if x not in bnode.keys():
						parent = string.join(tmp[:-1], "/") + "/"
						bnode[x] = treelist.insert_node(bnode[parent], None, (tmp[-1], what[x][2], what[x][3], what[x][4], mytype))

def open_arch(*what):
	global bnode
	bnode = {}
	for x in treelist.base_nodes():
	build_nodes(tar_tzvf(os.popen("tar -tzvf "+myfile).readlines()))

file_menu = [UIINFO_MENU_EXIT_ITEM(cb=mainquit)]
menus = [UIINFO_SUBTREE("File", file_menu)]
toolbar = [
	UIINFO_ITEM_STOCK("Open", tip="Open An Archive", cb=open_arch, stock=STOCK_PIXMAP_OPEN)
app = GnomeApp("archivewiz", "Archive Wizard")

#We create a default view for CTree for testing purposes
app.connect("destroy", mainquit)
app.set_default_size(2*screen_width()/3, 2*screen_height()/3)

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]