
HelloWorldScreenlet
Source (link to git-repo or to original if based on someone elses unmodified work): Add the source-code for this project on opencode.net
This is a demonstration screenlet, not for use by normal users. The code is commented extensively to help developers understand how to code screenlets, and to provide them with an example of screenlet that has updating text on a simple background. Hopefully this demonstration screenlet will allow you to understand how a screenlet is coded and allow you to code desklets of your own to better Gnome.
13 years ago
*Fixed Possible Memory Leak in draw_text() definition
**Changed the draw_text() definition to accept values for font type and the width of the "drawing area"
13 years ago
*Fixed Possible Memory Leak in draw_text() definition
**Changed the draw_text() definition to accept values for font type and the width of the "drawing area"
Whise
13 years ago
where did you find this? is it on the latest bzr? what does the 10,10,10 represent?
nice job
Report
Whise
13 years ago
you wrote it your self?
i should warn you that you shouldnt make people use yor funtion because of several things
you should check out this topic
http://forum.compiz-fusion.org/showthread.php?t=3576&highlight=memory+leak
because in the way you draw your text there is a memory leak , that can become very severe so i advise you to read the topic
also you should allow people to select the width of the text area pago allows you to do that
Report
mkoehle1
13 years ago
Great catch - I hadn't thought about this. I fixed that problem in the draw_text() def, but I didn't add the option to change the text width yet. I'll add that in when I get a chance - Thanks for the pointer.
Report
Whise
13 years ago
Report
mkoehle1
13 years ago
I've changed the draw_text() definition to be as follows:
=====================================
def draw_text(self, ctx, value, x, y, width, font, size):
=====================================
The added options are 'width' and 'font', which are variables representing the width of the drawing area and the font type, respectively. Please tell me if there is anything else that you would like me to modify.
Report
Whise
13 years ago
nice job
Report
Whise
13 years ago
Report
Whise
13 years ago
Report
mkoehle1
13 years ago
No, it isn't part of the bzr, I just have it defined below:
=======================================
# This is a user defined function that will tell python how to draw the text onto the background
def draw_text(self, ctx, value, x, y, size):
=======================================
The 10,10,10 represents the x coordinate, y coordinate, and the font size. Therefore, I decided to have the drawing position start 10 pixels from left of the background and 10 pixels down from the top of the background, and I decided to use size 10 font. Thanks for asking for clarification.
Report