OK
Pages: 1 2
Rating:
3.99
Thread Listing » General AWN Discussion
Developers: AWNLib
#18488 by pavpanchekha (1.0000) posted on 12:01pm Saturday, December 22nd, 2007
UPDATE: New release (1.5): No longer on Mediafire. Comes officially with awn-extras.
[Q]






Now does:
Icon: set or get icon
Title: set the title, AWNLib does the rest
Dialogs: register dialog to automatically pop up or not when the user clicks the icon (handles focus-out and everything)
Modules: import a module, warn the user if they don't have it
Settings: GConf the easy way
Timing: Set a function to run on a timer
Notification: send stuff to libnotify
Keychain: store passwords securely
Effects: Use the cool awn effects easily.
[Q]



This is for anyone who wants to develop AWN applet in Python.
[Q]



Developing with the AWN Python module is quite a pain. The new developer needs to keep quite a few things in mind. Even the experienced developer needs to keep a few thousand small helper functions in memory. Instead, I present you an alternative: AWNLib, and AWN applet API. It's written in Python, and it simply wraps around the default AWN API.
[Q]



For example, the Python test-applet becomes:
[Q]



 

#!/usr/bin/env python
[Q]
  


import AWN # AWNLib
import gtk
[Q]
  


if __name__ == "__main__":
applet = AWN.initiate()
applet.icon.set(applet.icon.getTheme("gtk-apply")) # Get icon from a theme
applet.title.set("Test Case Applet") # Setting a title
dlog = applet.dialog.new() # Get a dialog
button = gtk.Button(stock="gtk-apply") # C&P from python-test
dlog.add(button)
button.show_all()
applet.dialog.register(dlog, "main") # Set as the main dialog
AWN.start(applet) # Start the applet
[Q]
 



Download: http://www.mediafire.com/?8ylobzrdcbm
This contains both the library and the test applet
[Q]



This is a natural outgrowth of the AWN GMail Applet 2.0. Currently it wraps around Icon, Dialog, and Title:
[Q]



Icon: get and set icons. Use icon.getFile or icon.getTheme and pass that to icon.set
Title: title.set the title and AWNLib does the rest
Dialogs: dialog.new to make a new dialog and then dialog.register("main" or "secondary") to apply it. Optionally, pass "main" or "secondary" to dialog.new. AWNLib handles Style-Guide compatible clicking on icon and also focus-out.
[Q]



Hopefully, this will grow to encompass even more, such as settings, timing, and all the other things that will help developers write better applets faster.
[Q]



I note that I will soon be converting the GMail Applet to AWNLib.
[Q]



Feedback, bugs, questions? Right here!
[Q]



*Edited at 2:15pm, 04/06/08
Score: 0 points
Any particular reason?
#18489 by moonbeam (1.0000) posted on 12:07pm Saturday, December 22nd, 2007
( no avatar )
pavpanchekha said:
Developing with the AWN Python module is quite a pain. The new developer needs to keep quite a few things in mind. Even the experienced developer needs to keep a few thousand small helper functions in memory. Instead, I present you an alternative: AWNLib, and AWN applet API. It's written in Python, and it simply wraps around the default AWN API.
[Q]



Reusable code s good :-)
[Q]



You might want to check my branch and see if this is something that can be integrated in libawn-extras that is in the source tree there. The plan is to push it into the awn-extras trunk once the python bindings are done. After that awn-core could pull stuff into libawn as desired.
[Q]



The goal for libawn-extras it is to provide a convenient place for commonly used functions. And it sounds like this project might fit in, though malept might have a better idea on whether they should be integrated or not.
[Q]



I've discussed this with njpatel and he has indicated support for the concept.
[Q]

--
http://moon-shiny.blogspot.com/

*Edited at 12:11pm, 12/22/07
Score: 0 points
Any particular reason?
#18493 by pavpanchekha (1.0000) posted on 12:39pm Saturday, December 22nd, 2007
moonbeam said:
Reusable code s good :-)
[Q]



Thanks. I took a look at your branch. Its great to have a place to put commonly used functions, since there are a lot of them. For now you have C files there only though, right? This is in python, so it'll need a separate build system (or so I'm guessing).
[Q]



But otherwise, it'd be great if this was pushed to your branch, since it is a really big help.
[Q]

Score: 0 points
Any particular reason?
#18494 by moonbeam (1.0000) posted on 12:49pm Saturday, December 22nd, 2007
( no avatar )
pavpanchekha said:
Thanks. I took a look at your branch. Its great to have a place to put commonly used functions, since there are a lot of them. For now you have C files there only though, right? This is in python, so it'll need a separate build system (or so I'm guessing).
[Q]



The build system stuff is not my strong point :-)
[Q]



I'll have a chat with malept and see what he thinks is the best way to add in a python only module.
[Q]


Score: 0 points
Any particular reason?
#18499 by pavpanchekha (1.0000) posted on 4:19pm Saturday, December 22nd, 2007
pavpanchekha said:
I note that I will soon be converting the GMail Applet to AWNLib.
[Q]



I said I would, I did.
http://www.mediafire.com/?3vdn2akcjzq
[Q]



https://planetblur.org/hosted/awnforum/index.php?shard=forum&action=g_reply&ID=1440&page=1&isLive=true
[Q]



If you want to learn how to use AWNLib, that could be a good place to start.
[Q]

Score: 0 points
Any particular reason?
#18500 by malept (1.0000) posted on 4:23pm Saturday, December 22nd, 2007
( no avatar )
I disagree with the package name you're giving AWNLib. If it's going to eventually go with libawnextras (which I think it a very good idea), I'd like it to be in the namespace "awn.extras". The python bindings for libawnextras would also go in this namespace.
[Q]

--
/
Score: 0 points
Any particular reason?
#18501 by pavpanchekha (1.0000) posted on 4:37pm Saturday, December 22nd, 2007
malept said:
I disagree with the package name you're giving AWNLib. If it's going to eventually go with libawnextras (which I think it a very good idea), I'd like it to be in the namespace "awn.extras". The python bindings for libawnextras would also go in this namespace.
[Q]



I'd agree, but this already replaces much, if not all, of the Python API of AWN. (Missing: Effects)
[Q]



I think it'd be better were it separate or a layer on top of. Though in the end it doesn't particularly matter, one can always
import awn.extras as AWN.
[Q]



In general we need a library of functions.
[Q]

Score: 0 points
Any particular reason?
#18514 by malept (1.0000) posted on 11:57am Sunday, December 23rd, 2007
( no avatar )
The last thing I want to do is confuse people - having an AWN module *and* an awn module would bring about so many unneccessary support questions, e.g., "Why doesn't AWN.xyz work?!" (Answer: it's actually awn.xyz)
[Q]

--
/
Score: 0 points
Any particular reason?
#18520 by pavpanchekha (1.0000) posted on 1:12pm Sunday, December 23rd, 2007
malept said:
The last thing I want to do is confuse people - having an AWN module *and* an awn module would bring about so many unneccessary support questions, e.g., "Why doesn't AWN.xyz work?!" (Answer: it's actually awn.xyz)
[Q]



I see. It could be renamed to AWNLib. I just don't see that it should necessarily be "extra" to the awn module. That would imply that the awn module is prefered, where on the other hand it is probably better if AWNLib is used, since it'd be easier for applets to stay usable.
[Q]



Case in point: aparently, it is now incorrect to use set_temp_icon. And a while back, it became necessary to manually scale applet icons. In both cases, if an abstraction layer like AWNLb was used, the applets would continue to be fairly consistent.
[Q]



In other words, awn.extras seems like some miscellanious functions you dip into once per applet or so. AWN or AWNLib (or AWNApplet or something else similar) seems like an actual module you'd use as a base.
[Q]

Score: 0 points
Any particular reason?
#18521 by malept (1.0000) posted on 1:27pm Sunday, December 23rd, 2007
( no avatar )
My reasoning for putting it in "awn.extras" is because it would be installed via the awn-extras project, along with libawnextras. There's nothing there that says that you can't put wrappers like you propose in there.
[Q]

--
/
Score: 0 points
Any particular reason?
#18522 by pavpanchekha (1.0000) posted on 2:21pm Sunday, December 23rd, 2007
Meh. My only argument is the name, I have no other problems with your suggestions. We can always symlink AWNLib to awn.extras
[Q]

Score: 0 points
Any particular reason?
#18536 by pavpanchekha (1.0000) posted on 4:56pm Sunday, December 23rd, 2007
New Release!
[Q]






The test applet has a few new tricks. Check it out:
[Q]



 

#!/usr/bin/env python
[Q]
  


import AWN
import gobject
import gtk
from gtk import gdk
import random
[Q]
  


if __name__ == "__main__":
applet = AWN.initiate()
applet.title.set("Test Case Applet") # Setting a title
applet.settings.update("awnlib-test") # Sets folder applet uses for settings
applet.settings.get("test-key") # Gets the key. This line does nothing overall since I do nothing with the return value
rnd = str(int(random.random()*1000000))
applet.settings.set("test-key", rnd, "string") # The string is unnecessary if I know that the key is there
rnd2 = applet.settings.get("test-key")
if rnd == rnd2:
a = "gtk-apply"
else:
a = "gtk-cancel"
applet.icon.set(applet.icon.getTheme(a)) # Should be green check mark if all goes well
def switchIcon(applet):
"""Used as timed callback"""
applet.icon.set(applet.icon.getTheme("gtk-about"))
time = applet.timing.time(lambda: switchIcon(applet), 10) # lambda to wrap applet as argument
dlog = applet.dialog.new("main") # Get a dialog
button = gtk.Button(stock="gtk-apply") # C&P from python-test
dlog.add(button)
button.show_all()
#applet.dialog.register(dlog, "main") # Set as the main dialog
# Above line unneeded since passing "main" or "secondary" to dialog.new registers it
AWN.start(applet) # Start the applet
[Q]
 



(Note: I remove all blank lines because they look ugly on the forum. Sorry if readability suffers)
[Q]



Yep, that's right, AWNLib now handles settings (this applet creates a dummy key with a random value, then checks if its there) and timing (the applet should show the "gtk-about" icon 10 seconds after it is started)
[Q]



It also now has Modules (which the test applet doesn't use, but GMail Applet does):
[Q]



[applet].modules.visual("module-i-need", {"distro": "package-name"}, callback)
[Q]



should give the nice user a nice popup if they don't have the necessary module installed. It'll then call your callback with your module as an argument.
[Q]



Nice, eh?
[Q]



Comments, feedback, bugs? Right here!
[Q]



*Edited at 7:02pm, 12/23/07
Score: 0 points
Any particular reason?
#18537 by pavpanchekha (1.0000) posted on 5:00pm Sunday, December 23rd, 2007
Lets see how AWNLib helps with the Development Guidelines:
[Q]



 

* 1.1 Applet Appearance
o 1.1.1 Dialog Colors
o 1.1.2 Dialog Style
o 1.1.3 Icon Style Yep!
* 1.2 Applet Behavior
o 1.2.1 Notifications Next Release?
o 1.2.2 Icon Behavior Yep!
o 1.2.3 Python Applet Dependencies Yep!
* 1.3 Infrastructure
o 1.3.1 Build System
o 1.3.2 Applet License and Copyright
o 1.3.3 Desktop Files
* 1.4 Discussion
* 1.5 Development Guidelines Document Conventions
[Q]
 



Also, I'm doing a Meta module for the next release, which'll hold applet info for things like error dialogs, about dialogs, etc.
[Q]



I might get Notify in there too.
[Q]



*Edited at 5:01pm, 12/23/07
Score: 0 points
Any particular reason?
#18538 by pavpanchekha (1.0000) posted on 5:07pm Sunday, December 23rd, 2007
Score: 0 points
Any particular reason?
#18539 by moonbeam (1.0000) posted on 5:08pm Sunday, December 23rd, 2007
( no avatar )
pavpanchekha said:
Comments, feedback, bugs? Right here!
[Q]



Looks useful. If only I used python :-)
[Q]



Score: 0 points
Any particular reason?
#18540 by pavpanchekha (1.0000) posted on 5:27pm Sunday, December 23rd, 2007
moonbeam said:
Looks useful. If only I used python :-)
[Q]



You know, its not too hard to learn. And GTK is supposed to be more or less exactly the same, so the GUI-building is similar.
[Q]



If you want, go look at a few applets. Hell, look at the example I posted and play around.
[Q]

Score: 0 points
Any particular reason?
#18541 by moonbeam (1.0000) posted on 5:42pm Sunday, December 23rd, 2007
( no avatar )

pavpanchekha said:
You know, its not too hard to learn. And GTK is supposed to be more or less exactly the same, so the GUI-building is similar.
[Q]



oh... I'm sure it's not too hard. But from my time spent looking at it there's aspects of it that just make me cringe. Nothing against python... just the way I am.
[Q]



When/if vala binding make there way into trunk I'll definitely be giving vala a try. May even do so before the using Desktop agnostic (which as them already) once malept tracks down his applet bug. It seems to be more aesthetically pleasing to this old C/C++ person.
[Q]
Score: 0 points
Any particular reason?
#18542 by pavpanchekha (1.0000) posted on 5:43pm Sunday, December 23rd, 2007
pavpanchekha said:
Yep, that's right, AWNLib now handles settings (this applet creates a dummy key with a random value, then checks if its there) and timing (the applet should show the "gtk-about" icon 10 seconds after it is started)
[Q]



Hmmm, Forgot to mention that icon.pixbufFromSurface(surface) now does the expected. Anyone who needs text (or more) on their icon should now be happy.
[Q]



Also, dialog.new("main") (or "secondary") auto-registers the dialog, focus-out and all.
[Q]

Score: 0 points
Any particular reason?
#18544 by moonbeam (1.0000) posted on 5:44pm Sunday, December 23rd, 2007
( no avatar )
pavpanchekha said:
Hmmm, Forgot to mention that icon.pixbufFromSurface(surface) now does the expected. Anyone who needs text (or more) on their icon should now be happy.
[Q]



how are you copying from surface to pixbuf? the png hack or something else?
[Q]


Score: 0 points
Any particular reason?
#18548 by pavpanchekha (1.0000) posted on 6:12pm Sunday, December 23rd, 2007
moonbeam said:
how are you copying from surface to pixbuf? the png hack or something else?
[Q]



Whatever mosburger posted on his blog aka what blingswitcher & weather use
[Q]

Score: 0 points
Any particular reason?
#18550 by moonbeam (1.0000) posted on 6:17pm Sunday, December 23rd, 2007
( no avatar )
pavpanchekha said:
Whatever mosburger posted on his blog aka what blingswitcher & weather use
[Q]



ah ok. the png hack. It works but it's nasty.
[Q]



We'll have a much faster implementation for python to use some time real soon. At this point in time there doesn't seem to be any better solution for python that the method you're using.
[Q]







Score: 0 points
Any particular reason?
#18554 by pavpanchekha (1.0000) posted on 6:54pm Sunday, December 23rd, 2007
moonbeam said:
We'll have a much faster implementation for python to use some time real soon. At this point in time there doesn't seem to be any better solution for python that the method you're using.
[Q]



I personally have never needed this, and have a rusty knowledge at best of cairo. Thus, I'm not completely sure that the code works/is the right way to do things. Having a function built in will probably be nicer, but again I'm not to judge.
[Q]

Score: 0 points
Any particular reason?
#18556 by moonbeam (1.0000) posted on 7:00pm Sunday, December 23rd, 2007
( no avatar )
pavpanchekha said:
I personally have never needed this, and have a rusty knowledge at best of cairo. Thus, I'm not completely sure that the code works/is the right way to do things. Having a function built in will probably be nicer, but again I'm not to judge.
[Q]



For infrequent updates it seems to work fine. And at this time it seems to be the only choice. But there's definitely some real overhead involved when it is used for frequent updates. Essentially what happens is the surface gets written out as a png (so there's the encode) and then gets decoded when it gets read into the pixbuf. My understanding is that some of the python implementations of this at least do it all in memory but still...
[Q]



The implementation that will be pushed out in libawn-extras is a fairly fast, in memory, cairo surface -> pixbuf transfer. It's essentially the abiword code (that's been mentioned a few times) modified for this very specific task.
[Q]





--
http://moon-shiny.blogspot.com/

*Edited at 7:01pm, 12/23/07
Score: 0 points
Any particular reason?
#18557 by pavpanchekha (1.0000) posted on 7:04pm Sunday, December 23rd, 2007
moonbeam said:
The implementation that will be pushed out in libawn-extras is a fairly fast, in memory, cairo surface -> pixbuf transfer. It's essentially the abiword code (that's been mentioned a few times) modified for this very specific task.
[Q]



Cool. I'll push it to the lib as soon as its ready.
[Q]



Also, next release will have Effects, Notification, Keyring, and Meta if all goes well.
[Q]



Lastly, I need someone to explain the desktop-agnostic config binding to me so that I implement them, the wiki isn't too understandable.
[Q]

Score: 0 points
Any particular reason?
#18558 by malept (1.0000) posted on 7:56pm Sunday, December 23rd, 2007
( no avatar )
What's confusing about it? It's mostly modeled after gconf, so if you think AwnConfigClient is confusing... :)
[Q]

--
/
Score: 0 points
Any particular reason?
#18563 by mosburger (1.0000) posted on 5:58am Monday, December 24th, 2007
This looks awesome, Pavel. I think it's great to abstract the infamous "PNG hack" into a library for when we come up with a better way to do it. The weather and calendar applets both do it in-memory, not with a file. I've seen rumors of the "AbiWord solution" online before but never tracked it down.
[Q]



Maybe you could put the applet title, and maybe even a default icon, into the initialize method, 'cuz it's basically required for every applet?
[Q]



Awesome work!
[Q]
Score: 0 points
Any particular reason?
#18565 by pavpanchekha (1.0000) posted on 6:15am Monday, December 24th, 2007
mosburger said:
Maybe you could put the applet title, and maybe even a default icon, into the initialize method, 'cuz it's basically required for every applet?
[Q]



Sure. I'll get some sort of filler icon for it. Or maybe I'll just steal something from my test applet
[Q]

Score: 0 points
Any particular reason?
#18568 by pavpanchekha (1.0000) posted on 9:39am Monday, December 24th, 2007
malept said:
What's confusing about it? It's mostly modeled after gconf, so if you think AwnConfigClient is confusing... :)
[Q]



How do I find out what type the key is? In gconf, you can client.get() the key and then do key.type.value_nick to get the name. That way, I don't need the user to pass the type of key, since I can just find out.
[Q]



*Edited at 9:39am, 12/24/07
Score: 0 points
Any particular reason?
#18569 by pavpanchekha (1.0000) posted on 9:40am Monday, December 24th, 2007
pavpanchekha said:
Sure. I'll get some sort of filler icon for it. Or maybe I'll just steal something from my test applet
[Q]



Or did you mean that those would be arguments to the method, as in the initialize method would require them?
[Q]

Score: 0 points
Any particular reason?
#18570 by malept (1.0000) posted on 10:23am Monday, December 24th, 2007
( no avatar )
 

cfg = awn.Config()
vtype = cfg.get_value_type(group, key)
[Q]
 

--
/
Score: 0 points
Any particular reason?
#18571 by pavpanchekha (1.0000) posted on 11:40am Monday, December 24th, 2007



Note the following additions to the test applet:
[Q]



 

# Test Effects
applet.effects.launch()
applet.effects.notify()
[Q]
  


# Test KeyRing
applet.keyring.require()
t = applet.keyring.set("awnlib-test-user", "MyCoolPass42")
if applet.keyring.getPass(t) == "MyCoolPass42":
keyring_good = True
[Q]
  


# Test Notify
applet.notify.require()
applet.notify.send("AWNLib-Test", "Notifications Work!")
[Q]
 



Yep! AWNLib now does:
Effects:
effects.launch and effects.notify. If anyone needs the other effects, I can add them, but for now these just run the attention and launching effects.
[Q]



KeyRing:
AWNLib now gnome-does keyring! A usable wrapper around a really bad API! Just run keyring.set(usr, password) and you'll be returned a token. Pass the token to keyring.getPass and you get back your password.
[Q]



Notify:
notify.sent(subject, body) is all you need to do. I'd like to note that this implementation does not use the python module because:
* There is not documentation
* I can't even figure out what the module is called or how to install it (there's not module notify or libnotify after you install python-notify)
Instead, AWNLib just calls the notify-send command. The applet checks that you have it installed.
[Q]



Meta:
Pass a dictionary to AWN.initiate of information about your applet. AWNLib uses this for default values. For now, the only important values are:
"name": The applet's full name
"short": A short name. Used for, for example, default values for settings keys.
[Q]



You can change this later by using meta.update.
[Q]



Changes:
settings.folder is used instead of settings.update
you must call settings.require, notify.require, and keyring.require before using those modules. Those functions check for dependencies. If you don't call those, things will probably crash.
[Q]



This release does not yet use awn.Config. But I'm getting to it
[Q]



Any feedback?
[Q]



Roadmap:
Wiki Article
GMail Applet 2.1
Try to convert other applets to AWNLib to see where AWNLib needs fixing.
If any issues come up, I'll make a 1.2.1 release. If there are requests for more additions to AWNLib (I don't see what else to add), I'll release 1.3
[Q]

Score: 0 points
Any particular reason?
#18572 by moonbeam (1.0000) posted on 12:44pm Monday, December 24th, 2007
( no avatar )
Looking good.
[Q]



pavpanchekha said:
Notify:
notify.sent(subject, body) is all you need to do. I'd like to note that this implementation does not use the python module because:
* There is not documentation
* I can't even figure out what the module is called or how to install it (there's not module notify or libnotify after you install python-notify)
Instead, AWNLib just calls the notify-send command. The applet checks that you have it installed.
[Q]



there's a notify function in libawnextras that you can use once the bindings are done (the current implementation is synchronous but I'll probably doing an async one also). notify-send works well... but, as you know, it doesn't seem to be on some systems by default (so it's good that you're checking)... I had been using it one of my applets and I found this out the hard way.
[Q]


Score: 0 points
Any particular reason?
#18573 by pavpanchekha (1.0000) posted on 12:54pm Monday, December 24th, 2007
moonbeam said:
there's a notify function in libawnextras that you can use once the bindings are done (the current implementation is synchronous but I'll probably doing an async one also). notify-send works well... but, as you know, it doesn't seem to be on some systems by default (so it's good that you're checking)... I had been using it one of my applets and I found this out the hard way.
[Q]



Cool, thanks. For now I'm checking for notify-send, but you're right, and it does feel like an ugly hack
[Q]

Score: 0 points
Any particular reason?
#18607 by malept (1.0000) posted on 4:38pm Wednesday, December 26th, 2007
( no avatar )
I've taken some time to look over the AWN.py code. Here are my comments:
[Q]



* You should use 4 spaces per indentation instead of tabs, per PEP8.
* You need to import the StringIO class for Icon.pixbufToSurface().
* In Modules.visual(), you don't declare dlog anywhere, to my knowledge.
* In Dialogs.__context(), it should be self.menu.popup(...), I think.
* The naming of method Dialogs.new() strikes me as a little odd.
* The API docs should also be inline with the classes/methods. It's rather difficult to see what everything does without it.
* I noticed that there were several methods with optional arguments that weren't used anywhere. That confused me a little.
[Q]



In general, I'm not really a fan of putting all of the applet code into the "main()" block, so to speak. It just doesn't look very clean and maintainable.
[Q]

--
/
Score: 0 points
Any particular reason?
#18610 by pavpanchekha (1.0000) posted on 6:12pm Wednesday, December 26th, 2007
malept said:
* You should use 4 spaces per indentation instead of tabs, per PEP8.
* You need to import the StringIO class for Icon.pixbufToSurface().
* In Modules.visual(), you don't declare dlog anywhere, to my knowledge.
* In Dialogs.__context(), it should be self.menu.popup(...), I think.
* The naming of method Dialogs.new() strikes me as a little odd.
* The API docs should also be inline with the classes/methods. It's rather difficult to see what everything does without it.
* I noticed that there were several methods with optional arguments that weren't used anywhere. That confused me a little.
[Q]



1: Yep, I've already changed that
2: Same
3: Wierd. Must have deleted that at one point, since I did test the modules part a bit and the dialog did appear.
3: Thanks for catching that.
5: Why? Creates a new dialog, (optionally) registers it, and returns it. Is there another name you think fits better?
6: In other words, I need more comments. I know, I'm working on it.
7: Blame GTK. x, y are widget, error. I rarely need them, so they just hang around there. They're optional so that I don't have to worry about them in case I ever called the function myself
[Q]



malept said:
In general, I'm not really a fan of putting all of the applet code into the "main()" block, so to speak. It just doesn't look very clean and maintainable.
[Q]



It is split into separate classes, which I find is better (specially since I can ask the text editor to just straight to one)
[Q]



Also, there is a new bug fix release soon, no new things, but keyring was completely rewritten, and gconf was fixed a bit.
[Q]

Score: 0 points
Any particular reason?
#18616 by malept (1.0000) posted on 7:28pm Wednesday, December 26th, 2007
( no avatar )
I should note that I was looking at the latest version in moonbeam's branch. I avoid mediafire whenever possible.
[Q]



What I meant about the main() block was that the resulting new wrapped applet code (for example, a slideshow applet) would be just a bunch of procedural statements, which in my view is not ideal for maintaining.
[Q]

--
/
Score: 0 points
Any particular reason?
#18617 by moonbeam (1.0000) posted on 7:36pm Wednesday, December 26th, 2007
( no avatar )
malept said:
I should note that I was looking at the latest version in moonbeam's branch. I avoid mediafire whenever possible.
[Q]



I thought I had commited v1.2... but seems I hadn't. I have now committed it to my branch.
[Q]
Score: 0 points
Any particular reason?
#18618 by malept (1.0000) posted on 7:53pm Wednesday, December 26th, 2007
( no avatar )
I just looked over the Keyring class; don't you want to use the network password type instead? I would say that based on the current applets in awn-extras, the common use case is storing/retrieving passwords for website-related things like google-based services, meebo, websites' feeds, etc.
[Q]

--
/
Score: 0 points
Any particular reason?
#18628 by pavpanchekha (1.0000) posted on 7:11am Thursday, December 27th, 2007
malept said:
What I meant about the main() block was that the resulting new wrapped applet code (for example, a slideshow applet) would be just a bunch of procedural statements, which in my view is not ideal for maintaining.
[Q]



Oh, I see. If you take a look at the GMail applet, it is broken into classes. Though I may rewrite it to be procedural. Personally, I dislike using objects for no reason other than to wrap code inside, eg: if you're using an object to communicate with a web service, that's alright, you may want more than one at a time or, say, you may want to be able to dynamically choose the object you're going to use. But you're only making one Applet instance, ever.
[Q]



Still, the fact that the test applet s procedural does not mean that using an object-oriented style is bad, or even harder. Just personal preference.
[Q]



malept said:
I just looked over the Keyring class; don't you want to use the network password type instead? I would say that based on the current applets in awn-extras, the common use case is storing/retrieving passwords for website-related things like google-based services, meebo, websites' feeds, etc.
[Q]



The new Keyring class allows for that. You can ask for a network type key when you create one.
[Q]

Score: 0 points
Any particular reason?
#18637 by pavpanchekha (1.0000) posted on 9:16am Thursday, December 27th, 2007



This time, no new features but Settings and Keyring are completely redone. Settings is now used as a dict:
[Q]



 

applet.settings.require()
SETTINGS = applet.settings
SETTINGS["answer"] = 42
[Q]
 



But wait, there's more!
[Q]



 

class MyClass:
def __init__(self):
self.value = 42
def set(self, v):
self.value = v
[Q]
  


# ...
[Q]
  


SETTINGS["classOBJ"] = MyClass()
value = SETTINGS["classOBJ"].set(13)
value == 13 # True
[Q]
 



Yeah, that's right, you can store arbitrary objects, by way of cPickle.
[Q]



A few notes:
If cPickle can't do it sorry. There are a few exceptions. In particular, all classes MUST be defined in your own module or an importable one (I think. Not sure, consult the docs). So its better not to store Key objects (from my Keyring object), store Key.token instead. A bit more work, but the former may or may not work.
[Q]



*Edited at 9:25am, 12/27/07
Score: 0 points
Any particular reason?
#18638 by pavpanchekha (1.0000) posted on 9:24am Thursday, December 27th, 2007
More notes:
[Q]



Pickled entries SHOULD NOT BE EDITED BY USERS. Make a note of this. If you want users to be able to edit your objects, make sure you only store ints, strings, bools, or floats.
[Q]



GConf may not like your pickled objects. It might not like really long entries. Don't get it pissed off. In any case, the \n's pickle uses a lot screw up GConf's interface. Don't overuse it.
[Q]



Pickle-made entries are prefixed with !pickle; If you are natively using gconf (ie, not through the new interface for my AWNLib class) DO NOT REMOVE THOSE. DO NOT EDIT THOSE FIRST 9 CHARACTERS. If you do, AWNLib won't unpickle that entry and you'll have a really long string that you'll need to unpickle yourself. That would be bad for you.
[Q]

Score: 0 points
Any particular reason?
#18639 by moonbeam (1.0000) posted on 9:27am Thursday, December 27th, 2007
( no avatar )
pavpanchekha said:
Pickled entries SHOULD NOT BE EDITED BY USERS. Make a note of this. If you want users to be able to edit your objects, make sure you only store ints, strings, bools, or floats.
[Q]



If I understand your description of cPickle it allows the storing of arbitrary objects in gconf?
[Q]



--
http://moon-shiny.blogspot.com/

*Edited at 9:28am, 12/27/07
Score: 0 points
Any particular reason?
#18640 by pavpanchekha (1.0000) posted on 9:28am Thursday, December 27th, 2007
moonbeam said:
If I understand your description of cPickle it allows the storing of arbitrary objects in gconf?
[Q]



cPickle allows converting arbitrary objects to strings and back. I then store the string to gconf. Its a C version of pickle, which was a native python module. I use that instead of pickle because of the performance boost.
[Q]

Score: 0 points
Any particular reason?
#18641 by moonbeam (1.0000) posted on 9:31am Thursday, December 27th, 2007
( no avatar )
pavpanchekha said:
cPickle allows converting arbitrary objects to strings and back. I then store the string to gconf. Its a C version of pickle, which was a native python module. I use that instead of pickle because of the performance boost.
[Q]



hmmm. ok. My intuition is that this might not be a good thing (storing in gconf). But it's just an intuition. I'll look into it / think about it a bit more.
[Q]


Score: 0 points
Any particular reason?
#18643 by pavpanchekha (1.0000) posted on 9:42am Thursday, December 27th, 2007
moonbeam said:
hmmm. ok. My intuition is that this might not be a good thing (storing in gconf). But it's just an intuition. I'll look into it / think about it a bit more.
[Q]



I'm not entirely sure its such a good idea either, which is why there are so many warnings. But for now, I'm leaving it in, its very useful.
[Q]

Score: 0 points
Any particular reason?
#18645 by malept (1.0000) posted on 10:22am Thursday, December 27th, 2007
( no avatar )
Yeah, I agree with moonbeam on this one...it doesn't really feel right, even though serializing objects certainly makes this sort of thing possible. Are there any legitimate use cases for this that can't be reworked in a non-complicated way to simply use more config keys?
[Q]

--
/
Score: 0 points
Any particular reason?
#18647 by pavpanchekha (1.0000) posted on 10:31am Thursday, December 27th, 2007
malept said:
Yeah, I agree with moonbeam on this one...it doesn't really feel right, even though serializing objects certainly makes this sort of thing possible. Are there any legitimate use cases for this that can't be reworked in a non-complicated way to simply use more config keys?
[Q]



Obviously anything can be done with more config keys (basic definition of classes) but in some cases serialization is really the best way to go. eg, storing an array. Now, GConf does provide a way to do this, but only of one type. (IE, C arrays). So a multi-type array is almost impossible. I'm going to leave it in for now, and see if there is a definate need/there is none. Later, we can remove the feature if need be.
[Q]

Score: 0 points
Any particular reason?
#19247 by pavpanchekha (1.0000) posted on 3:35pm Thursday, January 24th, 2008



No new objects, but AWNLib now attempts to use the default awn-testing functions if available. If not, there shouldn't be regressions.
[Q]



So:
awn.Config() Usage
awn.extras functions
function renames and cleanups
[Q]






This is in the process of being updated for the 1.4 release (everything is already there, just switching from future to present test)
[Q]



GMail Applet 2.2 will follow shortly, I promise
[Q]



Also, the serialization > config is still there, but I can remove it if we deam it detrimental. For now, its in, but I do caution against its usage.
[Q]



Latest cool feature: Will use awn.Config automatically, so you get free brownie points with your applet working on xfce :D
[Q]



Score: 0 points
Any particular reason?
#19248 by moonbeam (1.0000) posted on 3:46pm Thursday, January 24th, 2008
( no avatar )



good stuff. I'll put a copy into my branch some time tonight. And I know some thought needs to go into how this can actually be integrated into awn-extras.
[Q]



pavpanchekha said:
Latest cool feature: Will use awn.Config automatically, so you get free brownie points with your applet working on xfce :D
[Q]



Very good.
[Q]
Score: 0 points
Any particular reason?
#19272 by pavpanchekha (1.0000) posted on 6:28pm Friday, January 25th, 2008
New version. 1.4.1.
http://www.mediafire.com/?9lesnvd
[Q]



Not a major release, but it includes the fixes required for GMail applet 2.2. The biggest change is that dialog.new accepts a focus parameter, that, if false, does not register the focus-out-event for the new dialog. This is used in the GMail applet preference dialogs where the dropdowns make a focus-out approach impossible.
[Q]



No other major changes.
[Q]

Score: 0 points
Any particular reason?
#19355 by pavpanchekha (1.0000) posted on 6:04pm Monday, January 28th, 2008



This is the current version in awn-extras testing. In includes MAJOR upgrades. All users are strongly encouraged to upgrade. Doing so might fix a LOT of problems.
[Q]



From now on, most of the changes to AWNLib will take place in the testing branch of AWN-Extras, with only the major fixes pushed to here.
[Q]

Score: 0 points
Any particular reason?
#19633 by pavpanchekha (1.0000) posted on 11:44am Tuesday, February 05th, 2008
Version 1.4.3
[Q]



More bug fixes. Corrects an especially egregious error on my part.
[Q]




Score: 0 points
Any particular reason?
#21413 by bmario (0.2928) posted on 12:50pm Sunday, April 06th, 2008
hello, i've done some changes to your icon class.
specially to the getTheme function.
[Q]



with your version i hade problems with the icontheme Mist, i use.
it doesn't find those icons, that aren't implementet to it... (this are very much, because mist changes mainly the foldericons.
[Q]



so i use this instead:
[Q]



 

class Icon:
def getTheme(self, name):
try:
self.theme = gtk.IconTheme()
icon = self.theme.load_icon (name, self.height, 0)
except:
self.theme = gtk.icon_theme_get_default()
icon = self.theme.load_icon (name, self.height, 0)
return icon
[Q]
 



would be nice if could chang that purpos.
[Q]



anyways can you write the version of your library in top of the file? because i wondering about the version. because in the awnwiki there was an outdatet version...
and the API doc (linked there) is much outdateder than the download link... Oo
[Q]



*Edited at 1:00pm, 04/06/08
Score: 0 points
Any particular reason?
#21420 by pavpanchekha (1.0000) posted on 2:16pm Sunday, April 06th, 2008
 
bmario said:

class Icon:
def getTheme(self, name):
try:
self.theme = gtk.IconTheme()
icon = self.theme.load_icon (name, self.height, 0)
except:
self.theme = gtk.icon_theme_get_default()
icon = self.theme.load_icon (name, self.height, 0)
return icon
[Q]
 



Will add. I'll fix it to be for 1.5, but other than that, i'll add your fix. Thanks for noticing the bug - I use the default tango theme, so I didn't have a chance to notice.
[Q]

Score: 0 points
Any particular reason?
#21425 by bmario (0.2928) posted on 2:47pm Sunday, April 06th, 2008
now i've play a bit and test your Notify.send() function.
there's a bug too.
[Q]



should use this:
[Q]



 
os.system("notify-send \"%s\" \"%s\"" % (subject.replace("\"", "\\\""), body.replace("\"", "\\\"")))
[Q]
 



instead of this:
[Q]



 
os.system("notify-send %s \"%s\"" % (subject, body.replace("\"", "\\\"")))
[Q]
 



*Edited at 2:47pm, 04/06/08
Score: 0 points
Any particular reason?
#21427 by pavpanchekha (1.0000) posted on 3:33pm Sunday, April 06th, 2008
bmario: thanks. I'll fix that as well. Though I have to say, that probably doesn't matter as the user will almost certainly have the libawn-extras notification function.
[Q]

Score: 0 points
Any particular reason?
#21428 by bmario (0.2928) posted on 3:55pm Sunday, April 06th, 2008
hello pavpanchekha,
[Q]



first i want to say, that your library is a great piece of code :)
it makes really easy to write a applet for awn.
[Q]



but again i found a bug.
in the class Settings
if you override the if, which detects awn.Config() in Settings.require() to use GConfUser as client
[Q]



i had problems. it says that the path is incorrect, so i edit the function Settings.GConfUser.update() to this:
[Q]



 
def update(self, folder):
self.folder = "/app/avant-window-navigator/applets/" + folder
[Q]
 



i had no libawn-extras :( so i found this bug above
[Q]



thx bmario
[Q]



*Edited at 3:55pm, 04/06/08
Score: 0 points
Any particular reason?
#21432 by pavpanchekha (1.0000) posted on 5:11pm Sunday, April 06th, 2008
bmario: libawn-extras comes with awn-extras (download the source as you would, AWNLib is in src/libawn-extras/bindings/python/AWNLib.py)
[Q]



I've incorporated your first two fixes. As for the third, why is it /app? Isn't /apps correct? Perhaps it is a peculiarity of your system?
[Q]

Score: 0 points
Any particular reason?
#21433 by bmario (0.2928) posted on 5:20pm Sunday, April 06th, 2008
oh yes it is apps.
thats my fault...
[Q]



and now i found libawn-extras... had to link it in my /lib folder, debian does did it :(
[Q]

Score: 0 points
Any particular reason?
#21435 by c.atterly (0.9959) posted on 6:18pm Sunday, April 06th, 2008
First of all, great work, this is a brilliant idea. clap
[Q]



pavpanchekha said:
Case in point: aparently, it is now incorrect to use set_temp_icon. And a while back, it became necessary to manually scale applet icons. In both cases, if an abstraction layer like AWNLb was used, the applets would continue to be fairly consistent.
[Q]



In other words, awn.extras seems like some miscellanious functions you dip into once per applet or so. AWN or AWNLib (or AWNApplet or something else similar) seems like an actual module you'd use as a base.
[Q]



I really agree with all these points. I think awnlib would be the perfect name for it. I am not sure about the caps, I have been using python for about 8 years and have never seen anything use them like that; all lowercase is more pythonic I would say, but that is a small issue.
[Q]



Anyway I just wanted to add that this seems like a really good idea and if enough devs think so too, I think the applets should be rewritten to use it. This way bugs, performance increases, and style can be changed in just one easy place and everything gains, as well as is consistent.
[Q]



Plus newcomers to writing applets will see it more and have an easier time, and not make mistakes or introduce bugs.
[Q]

--
-Chaz

*Edited at 6:19pm, 04/06/08
Score: 0 points
Any particular reason?
Pages: 1 2
Thread Listing » General AWN Discussion » Developers: AWNLib

Post A Reply:

Powered by Metaforum ©2004-2012
Get your own Free AJAX Forum Messageboard by visiting the offical site.
.