Awn

Merge lp:~albyrock87/awn/awn-lucido into lp:awn/0.4

Proposed by Alberto Aldegheri
Status: Superseded
Proposed branch: lp:~albyrock87/awn/awn-lucido
Merge into: lp:awn/0.4
Diff against target: 1384 lines (+1087/-13)
12 files modified
awn-settings/awn-settings.ui (+34/-0)
awn-settings/awnDefs.py.in (+1/-0)
awn-settings/awnSettings.py.in (+6/-1)
data/avant-window-navigator.schema-ini.in.in (+7/-1)
src/Makefile.am (+2/-0)
src/awn-background-flat.c (+10/-6)
src/awn-background-lucido.c (+839/-0)
src/awn-background-lucido.h (+71/-0)
src/awn-background.c (+91/-4)
src/awn-background.h (+16/-0)
src/awn-defines.h (+1/-0)
src/awn-panel.c (+9/-1)
To merge this branch: bzr merge lp:~albyrock87/awn/awn-lucido
Reviewer Review Type Date Requested Status
Michal Hruby (community) Needs Fixing
Alberto Aldegheri Abstain
Review via email: mp+26383@code.launchpad.net

This proposal supersedes a proposal from 2010-05-27.

This proposal has been superseded by a proposal from 2010-05-31.

Description of the change

This is a rewrite of awn-style-lucido.

Implemented a new style, features:
- Stripe-style
- The number of stripes changes dynamically depends on "expanders"
- If you set stripe-width>0, you can manually set the stripe position and width
- Fixed all-orientation cairo "translate"
- custom curved style if panel is not expanded
- speedup code for draw background only when need (otherwise repaint last surface)

:)

To post a comment you must log in.
Revision history for this message
Alberto Aldegheri (albyrock87) wrote : Posted in a previous version of this proposal

WTF!!!

Why BZR removes 'po/avant-window-navigator.pot' if i've never touched that file?????

Revision history for this message
Michal Hruby (mhr3) wrote : Posted in a previous version of this proposal

> WTF!!!
>
> Why BZR removes 'po/avant-window-navigator.pot' if i've never touched that
> file?????

There's a bug in the build system, make clean removes it, please revert the change.
Also there are a lot of lines which break our coding conventions, I know it might sound trivial, but for the review process it makes it easier to read the code. Fix please.

review: Needs Fixing (coding-conventions)
Revision history for this message
Alberto Aldegheri (albyrock87) wrote : Posted in a previous version of this proposal

> > WTF!!!
> >
> > Why BZR removes 'po/avant-window-navigator.pot' if i've never touched that
> > file?????
>
> There's a bug in the build system, make clean removes it, please revert the
> change.
> Also there are a lot of lines which break our coding conventions, I know it
> might sound trivial, but for the review process it makes it easier to read the
> code. Fix please.

'po/avant-window-navigator.pot' -> restored from rev 699
Conding style fixes :)
Default Stripe-Width = 0 (enables auto-stripe)

review: Needs Resubmitting
Revision history for this message
moonbeam (rcryderman) wrote : Posted in a previous version of this proposal

Seems to be leaking:

revision: 707.

After leaving it running 12-24 hours.

mapped: 1539380K writeable/private: 1297488K shared: 816K

Revision history for this message
Alberto Aldegheri (albyrock87) wrote : Posted in a previous version of this proposal

> Seems to be leaking:
>
> revision: 707.
>
> After leaving it running 12-24 hours.
>
> mapped: 1539380K writeable/private: 1297488K shared: 816K

I'm very sorry for that :'(

Now it's fixed (rev 710) :)

Revision history for this message
Michal Hruby (mhr3) wrote : Posted in a previous version of this proposal

Thanks for the style fixes. Here are my comments:

1) When using cairo methods, please use doubles directly, don't have the compiler do it ( cairo_scale (cr, 1, -1) => cairo_scale (cr, 1., -1.) )
2) You're using the expander detection quite often, move it to a function (at least the g_object_get() + gtk_container_get_children() )
3) Get rid of "g_list_free (i)", it could cause problems.
4) Since you introduced the helper surface, it'd be nice to integrate it properly into the background base class and have a "cached-drawing" property that will control whether the surface is used (default TRUE). (you'll get an extra point if you provide some statistics on how often is helps)
5) The stripe-width spin is put on a strange place in awn-settings, please try to rearrange it, so that it fits nicely.

review: Needs Fixing (code review)
Revision history for this message
Alberto Aldegheri (albyrock87) wrote : Posted in a previous version of this proposal

> Thanks for the style fixes. Here are my comments:
>
> 1) When using cairo methods, please use doubles directly, don't have the
> compiler do it ( cairo_scale (cr, 1, -1) => cairo_scale (cr, 1., -1.) )
> 2) You're using the expander detection quite often, move it to a function (at
> least the g_object_get() + gtk_container_get_children() )
> 3) Get rid of "g_list_free (i)", it could cause problems.
> 4) Since you introduced the helper surface, it'd be nice to integrate it
> properly into the background base class and have a "cached-drawing" property
> that will control whether the surface is used (default TRUE). (you'll get an
> extra point if you provide some statistics on how often is helps)
> 5) The stripe-width spin is put on a strange place in awn-settings, please try
> to rearrange it, so that it fits nicely.

I'm working on this.

For now I can tell you that (in lucido style), times are:
- use helper surface: ~0ms
- redraw surface: ~10ms

If you hover an icon and then run away with your mouse with bounce effect, you get about 20 redraw (during animation):
- using helper surface: ~1ms
- not using helper surface: 20*10 = 200ms

Time calculated with:
#include <time.h>

clock_t start, end;
double elapsed;

start = clock();
... /* Do the work. */
end = clock();
elapsed = ((double) (end - start)) / (((double)CLOCKS_PER_SEC) / 1000.0 );

Revision history for this message
Alberto Aldegheri (albyrock87) wrote : Posted in a previous version of this proposal

> Thanks for the style fixes. Here are my comments:
>
> 1) When using cairo methods, please use doubles directly, don't have the
> compiler do it ( cairo_scale (cr, 1, -1) => cairo_scale (cr, 1., -1.) )
> 2) You're using the expander detection quite often, move it to a function (at
> least the g_object_get() + gtk_container_get_children() )
> 3) Get rid of "g_list_free (i)", it could cause problems.
> 4) Since you introduced the helper surface, it'd be nice to integrate it
> properly into the background base class and have a "cached-drawing" property
> that will control whether the surface is used (default TRUE). (you'll get an
> extra point if you provide some statistics on how often is helps)
> 5) The stripe-width spin is put on a strange place in awn-settings, please try
> to rearrange it, so that it fits nicely.

Ok, What do you think about?

Some statistic? mh..
On any animation's step on every icon, you get background refreshed. (with cache in O(1) time)
The same for any expose event.

However, if you want to see how often is the redraw, you can put a:
fprintf (stderr, "I'm redrawing the bg \n");
on awn-background.c row 701

You will see that the redraw is rare, then the performance gain is very often :)

Revision history for this message
Alberto Aldegheri (albyrock87) wrote : Posted in a previous version of this proposal

Resubmitting :)

PS: i've checked for mem-leaks this time, and I have not found any mem-leak.

review: Needs Resubmitting
Revision history for this message
Michal Hruby (mhr3) wrote : Posted in a previous version of this proposal

As a side note, the "Resubmit" is for reviewers when they want you to resubmit the proposal, when you want to resubmit it, there's the "Resubmit proposal" link on top of this page.

1) Please revert the 1210-1220, this should go into background's finalize method.
2) It seems that awn_background_get_needs_redraw (and also the lucido variant) is not necessary to be exposed in the .h files. Please make it a static method and use the virtual klass->get_needs_redraw to call it.
3) Also why is 1190-1192 necessary?

review: Needs Fixing
Revision history for this message
Alberto Aldegheri (albyrock87) wrote : Posted in a previous version of this proposal

> As a side note, the "Resubmit" is for reviewers when they want you to resubmit
> the proposal, when you want to resubmit it, there's the "Resubmit proposal"
> link on top of this page.
I'm sorry, but I'm new in Lauchpad&Bzr :P

> 1) Please revert the 1210-1220, this should go into background's finalize
> method.
Done :)

> 2) It seems that awn_background_get_needs_redraw (and also the lucido variant)
> is not necessary to be exposed in the .h files. Please make it a static method
> and use the virtual klass->get_needs_redraw to call it.
awn_background_get_needs_redraw needs to be in awn-background.h because it is used in awn-background-lucido.c @ awn_background_lucido_get_needs_redraw.

Moved awn_background_lucido_get_needs_redraw into .c

> 3) Also why is 1190-1192 necessary?
Because when you move panel position from bottom to top, or left to right, width&height doesn't change. So we need to notify background to redraw itself.

Revision history for this message
Michal Hruby (mhr3) wrote : Posted in a previous version of this proposal

> > 2) It seems that awn_background_get_needs_redraw (and also the lucido
> variant)
> > is not necessary to be exposed in the .h files. Please make it a static
> method
> > and use the virtual klass->get_needs_redraw to call it.
> awn_background_get_needs_redraw needs to be in awn-background.h because it is
> used in awn-background-lucido.c @ awn_background_lucido_get_needs_redraw.

It still doesn't have to be in the .h, you can use >>>
AWN_BACKGROUND_CLASS (awn_background_lucido_parent_class)-> get_needs_redraw ()

> > 3) Also why is 1190-1192 necessary?
> Because when you move panel position from bottom to top, or left to right,
> width&height doesn't change. So we need to notify background to redraw itself.

Ok, but please make a method for it (awn_background_invalidate), the usage of public variables is really unfortunate in the background class.

review: Needs Fixing
Revision history for this message
Alberto Aldegheri (albyrock87) wrote : Posted in a previous version of this proposal

> > > 2) It seems that awn_background_get_needs_redraw (and also the lucido
> > variant)
> > > is not necessary to be exposed in the .h files. Please make it a static
> > method
> > > and use the virtual klass->get_needs_redraw to call it.
> > awn_background_get_needs_redraw needs to be in awn-background.h because it
> is
> > used in awn-background-lucido.c @ awn_background_lucido_get_needs_redraw.
>
> It still doesn't have to be in the .h, you can use >>>
> AWN_BACKGROUND_CLASS (awn_background_lucido_parent_class)-> get_needs_redraw
> ()

Done, thank you :)

> > > 3) Also why is 1190-1192 necessary?
> > Because when you move panel position from bottom to top, or left to right,
> > width&height doesn't change. So we need to notify background to redraw
> itself.
>
> Ok, but please make a method for it (awn_background_invalidate), the usage of
> public variables is really unfortunate in the background class.

You're right, done

Revision history for this message
Michal Hruby (mhr3) wrote : Posted in a previous version of this proposal

Sorry for late reply, been bit busy lately...

Lines 450 and 534 will cause a crash if there are no applets setup, fix pls.

review: Needs Fixing (code-review)
Revision history for this message
Michal Hruby (mhr3) wrote : Posted in a previous version of this proposal

Also it'd be nice to use private structure for the 'expw' variable, don't expose it.

Revision history for this message
Michal Hruby (mhr3) wrote : Posted in a previous version of this proposal

Few more observations:
1) Backgrounds don't redraw properly when monitor_align is changed.
2) There are some issues with padding (no refresh) when curviness is being changed.
3) Incomplete redraw when second expander is added to the panel.

Revision history for this message
Michal Hruby (mhr3) wrote : Posted in a previous version of this proposal

And one more: On bottom orientation (expanded panel) the pixels on x == 0 have incorrect color.

Revision history for this message
Alberto Aldegheri (albyrock87) wrote : Posted in a previous version of this proposal

> 3) Incomplete redraw when second expander is added to the panel.

I need help with this.

The way to fix this problem is call a redraw of all applets when an applet gets added/removed.

But I don't know how to do that.

review: Needs Information
Revision history for this message
Alberto Aldegheri (albyrock87) wrote : Posted in a previous version of this proposal

Ok, all done.

I've found a way to fix:
> 3) Incomplete redraw when second expander is added to the panel.

Resubmitting :)

Revision history for this message
Alberto Aldegheri (albyrock87) :
review: Approve
Revision history for this message
Alberto Aldegheri (albyrock87) wrote :

Noes!! There's a bug with a special configuration, i'll fix soon :(

Revision history for this message
Alberto Aldegheri (albyrock87) wrote :

> Noes!! There's a bug with a special configuration, i'll fix soon :(
Ok, done :)

Revision history for this message
Michal Hruby (mhr3) wrote :

Sorry, but additions in 714 are completely redundant - please take a look for example at Edgy code...

1) There's no need for extra signal in awn-panel, if you need panel to ask you again for padding emit the "padding-changed" signal (using awn_background_emit_padding_changed).
2) There's no need for "property-changed", this is implemented automatically for every property which is registered using g_object_class_install_property. The only thing you need to do is connect to the "notify" signal of the object with detail id set to the property name. (see src/awn-background-edgy.c:146)

review: Needs Fixing (code-review)
Revision history for this message
Michal Hruby (mhr3) wrote :

And I also have one question - what is the rationale behind using curviness instead of corner_radius?

Revision history for this message
Alberto Aldegheri (albyrock87) wrote :

> And I also have one question - what is the rationale behind using curviness
> instead of corner_radius?

Because Lucido consists in curves:
- curves symmetry
- curviness

Lucido's boundary rect has no rounded corners.

Revision history for this message
Alberto Aldegheri (albyrock87) wrote :

How can I remove myself from reviewers? :D

review: Approve
Revision history for this message
Michal Hruby (mhr3) wrote :

Good question... Change it to Abstain?!

Revision history for this message
Alberto Aldegheri (albyrock87) wrote :

Tanks Michal! ;)

However, Lucido seems to be ready now :)

review: Abstain
Revision history for this message
Michal Hruby (mhr3) wrote :

Looking at the latest changes, shouldn't you monitor also changes to "expand" property and emit padding-changed?

Revision history for this message
Alberto Aldegheri (albyrock87) wrote :

I think that "expand" already refreshes padding. So there's no need to observ "expand"..

Revision history for this message
Michal Hruby (mhr3) wrote :

I see, you derive from FLAT background, and it monitors expand property. Is this really intentional?

Revision history for this message
Alberto Aldegheri (albyrock87) wrote :

Haha!

Great! No, that was not intentional :P

It was intentional for some methods, but not for monitor expand :P

Revision history for this message
Michal Hruby (mhr3) wrote :

Which methods exactly? It seems to me that Lucido should be derived directly from AwnBackground, not Flat...

Revision history for this message
Alberto Aldegheri (albyrock87) wrote :

For the shape mask, and initally for the padding method, but after i must reimplement that for use curviness in not-expanded mode..

Revision history for this message
Michal Hruby (mhr3) wrote :

Yep :)

review: Needs Fixing
Revision history for this message
Alberto Aldegheri (albyrock87) wrote :

review: Needs Fixing?

In what? I don't understand, do you want that i change the parent to AwnBackground?

Revision history for this message
Michal Hruby (mhr3) wrote :

Oh sorry, we didn't understand each other... Yes, please change the base class to AwnBackground and implement correct version of get_shape_mask.

Revision history for this message
Alberto Aldegheri (albyrock87) wrote :

I understand that my english is not so good :D

I'll do the job soon then I resubmit :)

lp:~albyrock87/awn/awn-lucido updated
703. By Michal Hruby

Merge Lucido style from <lp:~albyrock87/awn/awn-lucido>

704. By Michal Hruby

 * awn-settings/awn-settings.ui:
 * awn-settings/awnDefs.py.in:
 * awn-settings/awnSettings.py.in:
 * data/avant-window-navigator.schema-ini.in.in:
 * src/awn-background-floaty.c:
 * src/awn-background-lucido.c:
 * src/awn-background.c:
 * src/awn-background.h:
 * src/awn-defines.h:
 Stop misusing curviness in Floaty, don't use it in Lucido either.

705. By Michal Hruby

Merge Lucido changes from <lp:~albyrock87/awn/awn-lucido>

706. By Alberto <alby@CASA>

FixTo:(0.5 pixel line not colored)

707. By Alberto <alby@CASA>

Merge from trunk

708. By Alberto <alby@CASA>

First version of separator-lucido

709. By Alberto <alby@CASA>

Stripe Width deleted

710. By Alberto <alby@CASA>

Draw bugfix

711. By Alberto <alby@CASA>

Draw bugfix number 2

712. By Alberto <alby@CASA>

Ops, removing test code

713. By Alberto <alby@CASA>

Better hi-light pattern

714. By Alberto <alby@CASA>

SEP_WIDTH to SEP_SIZE

715. By Alberto <alby@CASA>

Fix to expanded+align background position

716. By Alberto <alby@CASA>

Ops, fix mem leak

717. By Alberto <alby@CASA>

Fix: Refresh bug in expanded+align+no-expanders

718. By Alberto <alby@CASA>

Test version on separators.

719. By Alberto <alby@CASA>

ops

720. By Alberto <alby@CASA>

Fix to a bug when changing corner radius

721. By Alberto <alby@alby-laptop>

Some fixes and code restyle

722. By Alberto <alby@CASA>

Revert all animation changes for getting back stability. Animation -for now and for me- cant work. Feel free to fork rev 721.

723. By Alberto <alby@CASA>

Merge with lp:awn

724. By Alberto <alby@CASA>

Minor code restyling

725. By Alberto <alby@CASA>

Bug fixes for separators in first position. Restyle of docklet-mode.

726. By Alberto <alby@CASA>

For simil-3D lovers: Now 3D angle acts on lucido too.

727. By Alberto <alby@CASA>

Fix to shape mask

728. By Alberto <alby@CASA>

Bug fixes to an old bug in cairo-utils: rounded_rect. Rect explode if radius is bigger than available space. Consecutive fix to highlights. Simplify and speedup to Edgy code. Bugfix to 3D style, not listening on corner-radius changes. Fix on Lucdio shape mask.

729. By Alberto <alby@CASA>

3D style rewritten. Now full customizable.

730. By Alberto <alby@CASA>

I hate when I forget things.

731. By Alberto <alby@CASA>

Add thickness to 3D style.

732. By Alberto <alby@CASA>

Better padding

733. By Alberto <alby@CASA>

Better painting

734. By Alberto <alby@CASA>

Other drawing adjust for glass looking

735. By Alberto <alby@CASA>

Cleanups

736. By Alberto <alby@CASA>

Thickness set to 7px

737. By Alberto <alby@CASA>

Better drawing. Thinner and more defined border. Improved padding.

738. By Alberto <alby@CASA>

s(e)(i)x is better :P

739. By Alberto <alby@CASA>

Thickness in 3D style, replacing floaty offset. Removed Lucido 3D style. Lucido now uses Curves Symmetry too.

740. By Alberto <alby@CASA>

Animation added to Lucido. There are some minor glitches sometime...

741. By Alberto <alby@CASA>

A little speedup

742. By Alberto <alby@CASA>

Shit. I've forgot this.

743. By Alberto <alby@CASA>

More consistent with other style engines

744. By Alberto <alby@CASA>

Huge speedup and cleanup. Fixed an old bug. Now listening on applets position change.

745. By Alberto <alby@CASA>

Too much cleanup. Now works on expanded mode too.

746. By Alberto <alby@CASA>

Fix to 3D background padding

747. By Alberto <alby@CASA>

Rewrite of lucido path code. Bugs fixed and curves symmetry fully working.

748. By Alberto <alby@CASA>

Emit applets refreshed on docklet mode changed too.

749. By Alberto <alby@CASA>

Good looking start :)

750. By Alberto <alby@CASA>

Little fixes

751. By Alberto <alby@CASA>

Merged from lp:awn

752. By Alberto <alby@CASA>

Get and Set for separator new properties. Added awn_panel_get_docklet_mode to panel, removed the similar method in awn-applet-manager, because it returns -wrong- (updated too late) values.

753. By Alberto <alby@CASA>

I made an error while editing awn-panel.c, reverted that error.

754. By Alberto <alby@CASA>

Reverted changes on debian/changelog

755. By Alberto <alby@CASA>

Last fix to 3D edges when corner radius > height

756. By Alberto <alby@CASA>

I had removed too much things :P

757. By Alberto <alby@CASA>

There was a drawing bug when corner radius = 0, fixed.

758. By Alberto <alby@CASA>

Merge with lp:awn rev 713

759. By Alberto <alby@CASA>

Fixed 3065, sorry michal

760. By Alberto <alby@CASA>

Fixed Edgy. Auto invalidate bg on changed signal.

761. By Alberto <alby@CASA>

Revert changes to flat

762. By Alberto <alby@CASA>

Better start animation. Fix to Criticals on lucido start. Pot Updated with make check.

763. By Alberto <alby@CASA>

Fixes to bug #608927

764. By Alberto <alby@CASA>

Avoid merge problems with gutted-core-icons branch

765. By Alberto <alby@CASA>

Patch for bug #608927

766. By Alberto <alby@CASA>

Remove unused refresh method from awnClass.py. A little fix to a translation string.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'awn-settings/awn-settings.ui'
2--- awn-settings/awn-settings.ui 2010-03-08 12:50:07 +0000
3+++ awn-settings/awn-settings.ui 2010-05-31 11:01:08 +0000
4@@ -908,6 +908,22 @@
5 </packing>
6 </child>
7 <child>
8+ <object class="GtkSpinButton" id="theme_stripe_width">
9+ <property name="visible">True</property>
10+ <property name="can_focus">True</property>
11+ <property name="invisible_char">&#x25CF;</property>
12+ <property name="adjustment">adj_stripe_width</property>
13+ <property name="digits">2</property>
14+ </object>
15+ <packing>
16+ <property name="left_attach">5</property>
17+ <property name="right_attach">6</property>
18+ <property name="top_attach">8</property>
19+ <property name="bottom_attach">9</property>
20+ <property name="x_options"></property>
21+ </packing>
22+ </child>
23+ <child>
24 <object class="GtkSpinButton" id="theme_angle">
25 <property name="visible">True</property>
26 <property name="can_focus">True</property>
27@@ -964,6 +980,20 @@
28 </packing>
29 </child>
30 <child>
31+ <object class="GtkLabel" id="label_stripe">
32+ <property name="visible">True</property>
33+ <property name="xalign">0</property>
34+ <property name="xpad">0</property>
35+ <property name="label" translatable="yes">Stripe Width</property>
36+ </object>
37+ <packing>
38+ <property name="left_attach">3</property>
39+ <property name="right_attach">5</property>
40+ <property name="top_attach">8</property>
41+ <property name="bottom_attach">9</property>
42+ </packing>
43+ </child>
44+ <child>
45 <object class="GtkLabel" id="label49">
46 <property name="visible">True</property>
47 <property name="xalign">0</property>
48@@ -3406,6 +3436,10 @@
49 <property name="upper">1</property>
50 <property name="step_increment">0.01</property>
51 </object>
52+ <object class="GtkAdjustment" id="adj_stripe_width">
53+ <property name="upper">1</property>
54+ <property name="step_increment">0.01</property>
55+ </object>
56 <object class="GtkAdjustment" id="adj_radius">
57 <property name="upper">100</property>
58 <property name="step_increment">1</property>
59
60=== modified file 'awn-settings/awnDefs.py.in'
61--- awn-settings/awnDefs.py.in 2010-04-29 14:58:51 +0000
62+++ awn-settings/awnDefs.py.in 2010-05-31 11:01:08 +0000
63@@ -86,6 +86,7 @@
64 PANEL_ANGLE = "panel_angle" #float
65 CURVINESS = "curviness" #float
66 CURVES_SYMMETRY = "curves_symmetry" #float
67+STRIPE_WIDTH = "stripe_width" #float
68 TOOLTIP_FONT_NAME = "tooltip_font_name" #string
69 TOOLTIP_FONT_COLOR = "tooltip_font_color" #string
70 TOOLTIP_BG_COLOR = "tooltip_bg_color" #string
71
72=== modified file 'awn-settings/awnSettings.py.in'
73--- awn-settings/awnSettings.py.in 2010-05-28 08:09:17 +0000
74+++ awn-settings/awnSettings.py.in 2010-05-31 11:01:08 +0000
75@@ -141,7 +141,8 @@
76 #setup style mode
77 dropdown = self.wTree.get_object("stylecombo")
78 self.create_dropdown(dropdown, [_("None"), _("Flat"), _("3d"),
79- _("Curved"), _("Edgy"), _("Floaty")])
80+ _("Curved"), _("Edgy"), _("Floaty"),
81+ _("Lucido")])
82
83 #setup behaviour combo
84 dropdown = self.wTree.get_object("behaviorcombo")
85@@ -578,6 +579,7 @@
86
87 curviness = gobject.property(type=int, default=10)
88 curves_symmetry = gobject.property(type=float, default=0)
89+ stripe_width = gobject.property(type=float, default=0)
90 angle = gobject.property(type=int, default=45)
91 radius = gobject.property(type=int, default=10)
92 gtk_theme_mode = gobject.property(type=bool, default=False)
93@@ -727,6 +729,7 @@
94 (defs.THEME, defs.PANEL_ANGLE, 'float', sizes),
95 (defs.THEME, defs.CURVINESS, 'float', sizes),
96 (defs.THEME, defs.CURVES_SYMMETRY, 'float', sizes),
97+ (defs.THEME, defs.STRIPE_WIDTH, 'float', sizes),
98 (defs.THEME, defs.TOOLTIP_FONT_NAME, 'str', icon),
99 (defs.THEME, defs.TOOLTIP_FONT_COLOR, 'str', icon),
100 (defs.THEME, defs.TOOLTIP_BG_COLOR, 'str', icon),
101@@ -823,6 +826,8 @@
102 "curviness", "theme_curviness"),
103 (self.client, defs.THEME, defs.CURVES_SYMMETRY,
104 "curves-symmetry", "theme_symmetry"),
105+ (self.client, defs.THEME, defs.STRIPE_WIDTH,
106+ "stripe-width", "theme_stripe_width"),
107 (self.client, defs.THEME, defs.PANEL_ANGLE,
108 "angle", "theme_angle"),
109 (self.client, defs.THEME, defs.CORNER_RADIUS,
110
111=== modified file 'data/avant-window-navigator.schema-ini.in.in'
112--- data/avant-window-navigator.schema-ini.in.in 2010-03-09 20:20:25 +0000
113+++ data/avant-window-navigator.schema-ini.in.in 2010-05-31 11:01:08 +0000
114@@ -159,7 +159,7 @@
115 [panel/style]
116 type = integer
117 default = 1
118-_description=The style of the bar. (none=0, flat bar=1, 3d bar=2, curved bar=3, edgy=4, floaty=5)
119+_description=The style of the bar. (none=0, flat bar=1, 3d bar=2, curved bar=3, edgy=4, floaty=5,lucido=6)
120
121 [panels/panel_list]
122 type = list-integer
123@@ -227,6 +227,12 @@
124 _description=The curviness of the panel in Curves mode.
125 per_instance = false
126
127+[theme/stripe_width]
128+type = float
129+default = 0.0
130+_description=The width of the stripe in Lucido mode.
131+per_instance = false
132+
133 [theme/dialog_gtk_mode]
134 type = boolean
135 default = true
136
137=== modified file 'src/Makefile.am'
138--- src/Makefile.am 2010-03-24 23:24:19 +0000
139+++ src/Makefile.am 2010-05-31 11:01:08 +0000
140@@ -41,6 +41,8 @@
141 awn-background-edgy.h \
142 awn-background-floaty.c \
143 awn-background-floaty.h \
144+ awn-background-lucido.c \
145+ awn-background-lucido.h \
146 awn-defines.h \
147 $(builddir)/awn-marshal.c \
148 $(builddir)/awn-marshal.h \
149
150=== modified file 'src/awn-background-flat.c'
151--- src/awn-background-flat.c 2010-03-07 18:38:07 +0000
152+++ src/awn-background-flat.c 2010-05-31 11:01:08 +0000
153@@ -324,20 +324,24 @@
154 switch (position)
155 {
156 case GTK_POS_RIGHT:
157- cairo_translate (cr, x, y+height);
158+ cairo_translate (cr, 0., y + height);
159+ cairo_scale (cr, 1., -1.);
160+ cairo_translate (cr, x, height);
161 cairo_rotate (cr, M_PI * 1.5);
162 temp = width;
163- width = height; height = temp;
164+ width = height;
165+ height = temp;
166 break;
167 case GTK_POS_LEFT:
168- cairo_translate (cr, x+width, y);
169+ cairo_translate (cr, x + width, y);
170 cairo_rotate (cr, M_PI * 0.5);
171 temp = width;
172- width = height; height = temp;
173+ width = height;
174+ height = temp;
175 break;
176 case GTK_POS_TOP:
177- cairo_translate (cr, x+width, y+height);
178- cairo_rotate (cr, M_PI);
179+ cairo_translate (cr, x, y + height);
180+ cairo_scale (cr, 1., -1.);
181 break;
182 default:
183 cairo_translate (cr, x, y);
184
185=== added file 'src/awn-background-lucido.c'
186--- src/awn-background-lucido.c 1970-01-01 00:00:00 +0000
187+++ src/awn-background-lucido.c 2010-05-31 11:01:08 +0000
188@@ -0,0 +1,839 @@
189+/*
190+ * Copyright (C) 2009 Michal Hruby <michal.mhr@gmail.com>
191+ *
192+ * This program is free software; you can redistribute it and/or modify
193+ * it under the terms of the GNU General Public License as published by
194+ * the Free Software Foundation; either version 2 of the License, or
195+ * (at your option) any later version.
196+ *
197+ * This program is distributed in the hope that it will be useful,
198+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
199+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
200+ * GNU General Public License for more details.
201+ *
202+ * You should have received a copy of the GNU General Public License
203+ * along with this program; if not, write to the Free Software
204+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
205+ *
206+ * Author : Alberto Aldegheri <albyrock87+dev@gmail.com>
207+ * Thanks to: Matt <sharkbaitbobby@gmail.com>
208+ * for the code section to analyze expanders
209+ *
210+ */
211+
212+#include "config.h"
213+
214+#include <gdk/gdk.h>
215+#include <libawn/awn-cairo-utils.h>
216+#include <math.h>
217+
218+#include "awn-applet-manager.h"
219+#include "awn-background-lucido.h"
220+#include "awn-separator.h"
221+
222+G_DEFINE_TYPE (AwnBackgroundLucido, awn_background_lucido, AWN_TYPE_BACKGROUND)
223+
224+#define AWN_BACKGROUND_LUCIDO_GET_PRIVATE(obj) ( \
225+ G_TYPE_INSTANCE_GET_PRIVATE (obj, AWN_TYPE_BACKGROUND_LUCIDO, \
226+ AwnBackgroundLucidoPrivate))
227+
228+struct _AwnBackgroundLucidoPrivate
229+{
230+ gint expw;
231+ gint expn;
232+};
233+
234+static void awn_background_lucido_draw (AwnBackground *bg,
235+ cairo_t *cr,
236+ GtkPositionType position,
237+ GdkRectangle *area);
238+
239+static void awn_background_lucido_get_shape_mask (AwnBackground *bg,
240+ cairo_t *cr,
241+ GtkPositionType position,
242+ GdkRectangle *area);
243+
244+static void awn_background_lucido_padding_request (AwnBackground *bg,
245+ GtkPositionType position,
246+ guint *padding_top,
247+ guint *padding_bottom,
248+ guint *padding_left,
249+ guint *padding_right);
250+
251+static gboolean
252+awn_background_lucido_get_needs_redraw (AwnBackground *bg,
253+ GtkPositionType position,
254+ GdkRectangle *area);
255+
256+static void
257+awn_background_lucido_curviness_changed (AwnBackground *bg)
258+{
259+ gboolean expand = FALSE;
260+ g_object_get (bg->panel, "expand", &expand, NULL);
261+
262+ if (!expand)
263+ awn_background_emit_padding_changed (bg);
264+}
265+
266+static void
267+awn_background_lucido_expand_changed (AwnBackground *bg)
268+{
269+ awn_background_emit_padding_changed (bg);
270+}
271+
272+static void
273+awn_background_lucido_align_changed (AwnBackground *bg)
274+{
275+ awn_background_emit_padding_changed (bg);
276+}
277+
278+static void
279+awn_background_lucido_constructed (GObject *object)
280+{
281+ G_OBJECT_CLASS (awn_background_lucido_parent_class)->constructed (object);
282+
283+ AwnBackground *bg = AWN_BACKGROUND (object);
284+ gpointer monitor = NULL;
285+
286+ g_signal_connect_swapped (bg, "notify::curviness",
287+ G_CALLBACK (awn_background_lucido_curviness_changed),
288+ object);
289+
290+ g_return_if_fail (bg->panel);
291+
292+ g_signal_connect_swapped (bg->panel, "notify::expand",
293+ G_CALLBACK (awn_background_lucido_expand_changed),
294+ object);
295+
296+ g_object_get (bg->panel, "monitor", &monitor, NULL);
297+
298+ g_return_if_fail (monitor);
299+
300+ g_signal_connect_swapped (monitor, "notify::monitor-align",
301+ G_CALLBACK (awn_background_lucido_align_changed),
302+ object);
303+}
304+
305+static void
306+awn_background_lucido_dispose (GObject *object)
307+{
308+ gpointer monitor = NULL;
309+ if (AWN_BACKGROUND (object)->panel)
310+ g_object_get (AWN_BACKGROUND (object)->panel, "monitor", &monitor, NULL);
311+
312+ if (monitor)
313+ g_signal_handlers_disconnect_by_func (monitor,
314+ G_CALLBACK (awn_background_lucido_align_changed), object);
315+
316+ g_signal_handlers_disconnect_by_func (AWN_BACKGROUND (object)->panel,
317+ G_CALLBACK (awn_background_lucido_expand_changed), object);
318+
319+ g_signal_handlers_disconnect_by_func (AWN_BACKGROUND (object),
320+ G_CALLBACK (awn_background_lucido_curviness_changed), object);
321+
322+ G_OBJECT_CLASS (awn_background_lucido_parent_class)->dispose (object);
323+}
324+
325+static void
326+awn_background_lucido_class_init (AwnBackgroundLucidoClass *klass)
327+{
328+ AwnBackgroundClass *bg_class = AWN_BACKGROUND_CLASS (klass);
329+
330+ GObjectClass *obj_class = G_OBJECT_CLASS (klass);
331+ obj_class->constructed = awn_background_lucido_constructed;
332+ obj_class->dispose = awn_background_lucido_dispose;
333+
334+ bg_class->draw = awn_background_lucido_draw;
335+ bg_class->padding_request = awn_background_lucido_padding_request;
336+ bg_class->get_shape_mask = awn_background_lucido_get_shape_mask;
337+ bg_class->get_input_shape_mask = awn_background_lucido_get_shape_mask;
338+ bg_class->get_needs_redraw = awn_background_lucido_get_needs_redraw;
339+
340+ g_type_class_add_private (obj_class, sizeof (AwnBackgroundLucidoPrivate));
341+}
342+
343+static void
344+awn_background_lucido_init (AwnBackgroundLucido *bg)
345+{
346+
347+}
348+
349+AwnBackground *
350+awn_background_lucido_new (DesktopAgnosticConfigClient *client,
351+ AwnPanel *panel)
352+{
353+ AwnBackground *bg;
354+
355+ bg = g_object_new (AWN_TYPE_BACKGROUND_LUCIDO,
356+ "client", client,
357+ "panel", panel,
358+ NULL);
359+ return bg;
360+}
361+
362+/*
363+ * Drawing functions
364+ */
365+static void
366+_line_from_to ( cairo_t *cr,
367+ gfloat *xs,
368+ gfloat *ys,
369+ gfloat xf,
370+ gfloat yf)
371+{
372+ if ( *xs==xf || *ys==yf ) /* Vertical/Horizontal line */
373+ cairo_line_to (cr, xf, yf);
374+ else
375+ { /* Oblique */
376+ gfloat xm = ( *xs + xf ) / 2.0;
377+ cairo_curve_to (cr, xm, *ys, xm, yf, xf, yf);
378+ }
379+ *xs = xf;
380+ *ys = yf;
381+}
382+
383+static GList*
384+_get_applet_widgets (AwnBackground* bg)
385+{
386+ AwnAppletManager *manager = NULL;
387+ g_object_get (bg->panel, "applet-manager", &manager, NULL);
388+
389+ return gtk_container_get_children (GTK_CONTAINER (manager));
390+}
391+
392+/**
393+ * _create_path_lucido:
394+ * @bg: The background pointer
395+ * @position: The position of the bar
396+ * @cairo_t: The cairo context
397+ * @y: The top left coordinate of the "bar rect" - default = 0
398+ * @w: The width of the bar
399+ * @h: The height of the bar
400+ * @stripe: The width of the stripe (0.0-1.0). Zero for auto-stripe.
401+ * @d: The width of each curve in the path
402+ * @dc: The width of the external curves in non-expanded&auto mode
403+ * @symmetry: The symmetry of the stripe when @stripe > 0
404+ * @internal: If Zero, creates the path for the stripe
405+ * @expanded: If Zero, the bar is not expanded
406+ *
407+ * This function creates paths on which the bar will be drawn.
408+ * In atuo-stripe, it searchs for expanders applet, each expander
409+ * equals to one curve.
410+ * If the first widget is an expander, start from bottom-left,
411+ * otherwise start from top-left
412+ */
413+
414+static void
415+_create_path_lucido ( AwnBackground* bg,
416+ GtkPositionType position,
417+ cairo_t* cr,
418+ gfloat x,
419+ gfloat y,
420+ gfloat w,
421+ gfloat h,
422+ gfloat stripe,
423+ gfloat d,
424+ gfloat dc,
425+ gfloat symmetry,
426+ gboolean internal,
427+ gboolean expanded,
428+ gfloat align)
429+{
430+ cairo_new_path (cr);
431+
432+ gfloat lx = x;
433+ gfloat ly = y;
434+ gfloat y3 = y + h;
435+ gfloat y2 = y3 - 5;
436+
437+ if (stripe > 0)
438+ {
439+ if (expanded)
440+ {
441+ stripe = (w * stripe); /* now stripe = non-stripe */
442+ if (internal)
443+ {
444+ /* Manual-Stripe & Expanded & Internal */
445+ lx = stripe * symmetry;
446+ cairo_move_to (cr, lx, ly);
447+ _line_from_to (cr, &lx, &ly, lx+d, y2);
448+ _line_from_to (cr, &lx, &ly, w-stripe * (1. - symmetry) - d, y2);
449+ _line_from_to (cr, &lx, &ly, w-stripe * (1. - symmetry), y);
450+ cairo_close_path (cr);
451+ }
452+ else
453+ {
454+ /* Manual-Stripe & Expanded & External */
455+ ly = y3;
456+ cairo_move_to (cr, lx, ly);
457+ _line_from_to (cr, &lx, &ly, lx, y);
458+ _line_from_to (cr, &lx, &ly, stripe * symmetry, y);
459+ _line_from_to (cr, &lx, &ly, stripe * symmetry + d, y2);
460+ _line_from_to (cr, &lx, &ly, w - stripe * (1. - symmetry) - d, y2);
461+ _line_from_to (cr, &lx, &ly, w - stripe * (1. - symmetry), y);
462+ _line_from_to (cr, &lx, &ly, w, y);
463+ _line_from_to (cr, &lx, &ly, w, y3);
464+ cairo_close_path (cr);
465+ }
466+ }
467+ else
468+ {
469+ if (stripe == 1.)
470+ {
471+ _create_path_lucido (bg, position, cr, x, y, w, h, 0.,
472+ d, dc, 0., internal, expanded, align);
473+ return;
474+ }
475+ stripe = ((w - dc * 2) * stripe); /* now stripe = non-stripe */
476+ if (internal)
477+ {
478+ /* Manual-Stripe & Not-Expanded & Internal */
479+ lx = stripe * symmetry + dc;
480+ cairo_move_to (cr, lx, ly);
481+ _line_from_to (cr, &lx, &ly, lx + d, y2);
482+ _line_from_to (cr, &lx, &ly, w - stripe * (1.- symmetry) - dc - d, y2);
483+ _line_from_to (cr, &lx, &ly, w - stripe * (1.- symmetry) - dc, y);
484+ cairo_close_path (cr);
485+ }
486+ else
487+ {
488+ /* Manual-Stripe & Not-Expanded & External */
489+ ly = y3;
490+ cairo_move_to (cr, lx, ly);
491+ _line_from_to (cr, &lx, &ly, lx+dc, y);
492+ _line_from_to (cr, &lx, &ly, stripe * symmetry + dc, y);
493+ _line_from_to (cr, &lx, &ly, stripe * symmetry + d + dc, y2);
494+ _line_from_to (cr, &lx, &ly, w-stripe * (1. - symmetry) - dc - d, y2);
495+ _line_from_to (cr, &lx, &ly, w-stripe * (1. - symmetry) - dc, y);
496+ _line_from_to (cr, &lx, &ly, w-dc, y);
497+ _line_from_to (cr, &lx, &ly, w, y3);
498+ cairo_close_path(cr);
499+ }
500+ }
501+ }
502+ else
503+ {
504+ gint exps_found = 0;
505+ gfloat curx = 0.0;
506+
507+ if (expanded)
508+ {
509+ if (internal)
510+ {
511+ /* Auto-Stripe & Expanded & Internal */
512+ GList *widgets = _get_applet_widgets (bg);
513+ GList *i = widgets;
514+ GtkWidget *widget = NULL;
515+
516+ /* analyze first widget*/
517+ if (i)
518+ {
519+ widget = GTK_WIDGET (i->data);
520+
521+ /* if first widget is an expander or align==0 || 1*/
522+ if ( (widget && GTK_IS_IMAGE (widget) && !AWN_IS_SEPARATOR (widget) ) ||
523+ ( align == 0. || align == 1. ) )
524+ {
525+ /* start from bottom */
526+ lx = curx;
527+ ly = y;
528+ cairo_move_to (cr, lx, ly);
529+ _line_from_to (cr, &lx, &ly, lx, y2);
530+ ++exps_found;
531+ if (align != 0. && align != 1.)
532+ i = i->next;
533+ }
534+ }
535+ /* else start from top */
536+
537+ for (; i; i = i->next)
538+ {
539+ widget = GTK_WIDGET (i->data);
540+
541+ if (!GTK_IS_IMAGE (widget) || AWN_IS_SEPARATOR (widget))
542+ {
543+ /* if not expander continue */
544+ continue;
545+ }
546+ /* expander found */
547+ switch (position)
548+ {
549+ case GTK_POS_BOTTOM:
550+ case GTK_POS_TOP:
551+ curx = widget->allocation.x;
552+ if (exps_found % 2 != 0)
553+ curx += widget->allocation.width;
554+ break;
555+ default:
556+ curx = widget->allocation.y;
557+ if ( exps_found % 2 != 0)
558+ curx += widget->allocation.height;
559+ break;
560+ }
561+ if (curx < 0)
562+ continue;
563+
564+ if (exps_found == 0)
565+ {
566+ /* this is the first expander */
567+ lx = curx;
568+ cairo_move_to (cr, lx, ly);
569+ _line_from_to (cr, &lx, &ly, curx + d, y2);
570+ }
571+ else
572+ {
573+ if (exps_found % 2 != 0)
574+ {
575+ /* odd expander - curve at the end of expander */
576+ _line_from_to (cr, &lx, &ly, curx - d, y2);
577+ if (i->next == NULL)
578+ _line_from_to (cr, &lx, &ly, curx, y2);
579+ _line_from_to (cr, &lx, &ly, curx, y);
580+ }
581+ else
582+ {
583+ /* even expander - curve at the start of expander */
584+ _line_from_to (cr, &lx, &ly, curx, y);
585+ _line_from_to (cr, &lx, &ly, curx + d, y2);
586+ /* else the last widget is an expander */
587+ }
588+ }
589+
590+ ++exps_found;
591+ }
592+ g_list_free (widgets);
593+
594+ _line_from_to (cr, &lx, &ly, w, ly);
595+
596+ if (exps_found % 2 != 0)
597+ _line_from_to (cr, &lx, &ly, lx, y);
598+
599+ cairo_close_path (cr);
600+ }
601+ else
602+ {
603+ /* Auto-Stripe & Expanded & External */
604+
605+ GList *widgets = _get_applet_widgets (bg);
606+ GList *i = widgets;
607+ GtkWidget *widget = NULL;
608+
609+ /* analyze first widget*/
610+ if (i)
611+ {
612+ widget = GTK_WIDGET (i->data);
613+
614+ ly = y3;
615+ cairo_move_to (cr, lx, ly);
616+
617+ /* if first widget is an expander or align==0 || 1*/
618+ if ( (widget && GTK_IS_IMAGE (widget) && !AWN_IS_SEPARATOR (widget) ) ||
619+ ( align == 0. || align == 1. ) )
620+ {
621+ /* start from bottom */
622+ _line_from_to (cr, &lx, &ly, lx, y2);
623+ ++exps_found;
624+ if (align != 0. && align != 1.)
625+ i = i->next;
626+ }
627+ else
628+ {
629+ /* start from top */
630+ _line_from_to (cr, &lx, &ly, lx, y);
631+ }
632+ }
633+
634+ for (; i; i = i->next)
635+ {
636+ widget = GTK_WIDGET (i->data);
637+
638+ if (!GTK_IS_IMAGE (widget) || AWN_IS_SEPARATOR (widget))
639+ {
640+ /* if not expander continue */
641+ continue;
642+ }
643+ /* expander found */
644+ switch (position)
645+ {
646+ case GTK_POS_BOTTOM:
647+ case GTK_POS_TOP:
648+ curx = widget->allocation.x;
649+ if (exps_found % 2 != 0)
650+ curx += widget->allocation.width;
651+ break;
652+ default:
653+ curx = widget->allocation.y;
654+ if (exps_found % 2 != 0)
655+ curx += widget->allocation.height;
656+ break;
657+ }
658+ if (curx < 0)
659+ continue;
660+
661+ if (exps_found % 2 != 0)
662+ {
663+ _line_from_to (cr, &lx, &ly, curx - d, y2);
664+ if (i->next != NULL)
665+ _line_from_to (cr, &lx, &ly, curx, y);
666+ }
667+ else
668+ {
669+ _line_from_to (cr, &lx, &ly, curx, y);
670+ _line_from_to (cr, &lx, &ly, curx + d, y2);
671+ }
672+ ++exps_found;
673+ }
674+ g_list_free (widgets);
675+
676+ _line_from_to (cr, &lx, &ly, w, ly);
677+ _line_from_to (cr, &lx, &ly, lx, y3);
678+
679+ cairo_close_path (cr);
680+ }
681+ }
682+ else
683+ {
684+ if (internal)
685+ {
686+ /* Auto-Stripe & Not-Expanded & Internal */
687+ /* no-path */
688+ }
689+ else
690+ {
691+ /* Auto-Stripe & Not-Expanded & External */
692+ ly = y3;
693+ cairo_move_to (cr, lx, ly);
694+
695+ if (align == 0.)
696+ _line_from_to (cr, &lx, &ly, lx , y);
697+ else
698+ _line_from_to (cr, &lx, &ly, lx + dc, y);
699+
700+ if (align == 1.)
701+ _line_from_to (cr, &lx, &ly, w, y);
702+ else
703+ _line_from_to (cr, &lx, &ly, w - dc, y);
704+
705+ _line_from_to (cr, &lx, &ly, w, y3);
706+ cairo_close_path (cr);
707+ }
708+ }
709+ }
710+}
711+
712+static void
713+draw_top_bottom_background (AwnBackground* bg,
714+ GtkPositionType position,
715+ cairo_t* cr,
716+ gint width,
717+ gint height)
718+{
719+ cairo_pattern_t *pat = NULL;
720+ cairo_pattern_t *pat_hi = NULL;
721+
722+ /* Make sure the bar gets drawn on the 0.5 pixels (for sharp edges) */
723+ cairo_translate (cr, 0.5, 0.5);
724+
725+ /* Basic set-up */
726+ cairo_set_line_width (cr, 1.0);
727+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
728+
729+ if(gtk_widget_is_composited (GTK_WIDGET (bg->panel) ) == FALSE)
730+ {
731+ goto paint_lines;
732+ }
733+
734+ gboolean expand = FALSE;
735+ g_object_get (bg->panel, "expand", &expand, NULL);
736+
737+ gfloat align = awn_background_get_panel_alignment (AWN_BACKGROUND (bg));
738+
739+ /* create internal path */
740+ _create_path_lucido (bg, position, cr, -1.0, 0., width, height,
741+ bg->stripe_width, bg->curviness,
742+ bg->curviness, bg->curves_symmetry,
743+ 1, expand, align);
744+
745+ /* Draw internal pattern if needed */
746+ if (bg->enable_pattern && bg->pattern)
747+ {
748+ /* Prepare pattern */
749+ pat = cairo_pattern_create_for_surface (bg->pattern);
750+ cairo_pattern_set_extend (pat, CAIRO_EXTEND_REPEAT);
751+ /* Draw */
752+ cairo_save (cr);
753+ cairo_clip_preserve (cr);
754+ cairo_set_source (cr, pat);
755+ cairo_paint (cr);
756+ cairo_restore (cr);
757+ cairo_pattern_destroy (pat);
758+ }
759+
760+ /* Prepare the internal background */
761+ pat = cairo_pattern_create_linear (0, 0, 0, height);
762+ awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->border_color);
763+ awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->hilight_color);
764+
765+ /* Draw the internal background gradient */
766+ cairo_save (cr);
767+ cairo_clip_preserve (cr);
768+ cairo_set_source (cr, pat);
769+ cairo_paint (cr);
770+ cairo_restore (cr);
771+ cairo_pattern_destroy (pat);
772+
773+ /* Prepare external background gradient*/
774+ pat = cairo_pattern_create_linear (0, 0, 0, height);
775+ awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->g_step_1);
776+ awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_step_2);
777+
778+ /* create external path */
779+ _create_path_lucido (bg, position, cr, -1.0, 0., width, height,
780+ bg->stripe_width, bg->curviness,
781+ bg->curviness, bg->curves_symmetry,
782+ 0, expand, align);
783+
784+ /* Draw the external background */
785+ cairo_save (cr);
786+ cairo_clip_preserve (cr);
787+ cairo_set_source (cr, pat);
788+ cairo_paint (cr);
789+ cairo_restore (cr);
790+ cairo_pattern_destroy (pat);
791+
792+ /* Draw the hi-light */
793+ pat_hi = cairo_pattern_create_linear (0, 0, 0, (height / 3.0));
794+ awn_cairo_pattern_add_color_stop_color (pat_hi, 0.0, bg->g_histep_1);
795+ awn_cairo_pattern_add_color_stop_color (pat_hi, 1.0, bg->g_histep_2);
796+
797+ if (expand)
798+ {
799+ cairo_new_path (cr);
800+ cairo_rectangle (cr, 0, 0, width, (height / 3.0));
801+ }
802+
803+ cairo_set_source (cr, pat_hi);
804+ cairo_fill (cr);
805+ cairo_pattern_destroy (pat_hi);
806+
807+ return;
808+ /* if not composited */
809+paint_lines:
810+
811+ /* Internal border */
812+ awn_cairo_set_source_color (cr, bg->hilight_color);
813+ cairo_rectangle (cr, 1, 1, width - 3, height + 3);
814+ cairo_stroke (cr);
815+
816+ /* External border */
817+ awn_cairo_set_source_color (cr, bg->border_color);
818+ cairo_rectangle (cr, 1, 1, width - 1, height + 3);
819+ cairo_stroke (cr);
820+}
821+
822+
823+static
824+void awn_background_lucido_padding_request (AwnBackground *bg,
825+ GtkPositionType position,
826+ guint *padding_top,
827+ guint *padding_bottom,
828+ guint *padding_left,
829+ guint *padding_right)
830+{
831+ #define TOP_PADDING 2
832+ gboolean expand = FALSE;
833+ g_object_get (bg->panel, "expand", &expand, NULL);
834+ gint side_padding = expand ? 0 : bg->curviness;
835+ gint zero_padding = 0;
836+
837+ gfloat align = awn_background_get_panel_alignment (bg);
838+ if (awn_background_do_rtl_swap (bg))
839+ {
840+ if (align <= 0.0 || align >= 1.0)
841+ {
842+ zero_padding = side_padding;
843+ side_padding = 0;
844+ }
845+ }
846+
847+ switch (position)
848+ {
849+ case GTK_POS_TOP:
850+ *padding_top = 0;
851+ *padding_bottom = TOP_PADDING;
852+ *padding_left = align == 0.0 ? zero_padding : side_padding;
853+ *padding_right = align == 1.0 ? zero_padding : side_padding;
854+ break;
855+ case GTK_POS_BOTTOM:
856+ *padding_top = TOP_PADDING;
857+ *padding_bottom = 0;
858+ *padding_left = align == 0.0 ? zero_padding : side_padding;
859+ *padding_right = align == 1.0 ? zero_padding : side_padding;
860+ break;
861+ case GTK_POS_LEFT:
862+ *padding_top = align == 0.0 ? zero_padding : side_padding;
863+ *padding_bottom = align == 1.0 ? zero_padding : side_padding;
864+ *padding_left = 0;
865+ *padding_right = TOP_PADDING;
866+ break;
867+ case GTK_POS_RIGHT:
868+ *padding_top = align == 0.0 ? zero_padding : side_padding;
869+ *padding_bottom = align == 1.0 ? zero_padding : side_padding;
870+ *padding_left = TOP_PADDING;
871+ *padding_right = 0;
872+ break;
873+ default:
874+ break;
875+ }
876+}
877+
878+
879+
880+static void
881+awn_background_lucido_draw (AwnBackground *bg,
882+ cairo_t *cr,
883+ GtkPositionType position,
884+ GdkRectangle *area)
885+{
886+ gint temp;
887+ gint x = area->x, y = area->y;
888+ gint width = area->width, height = area->height;
889+ cairo_save (cr);
890+
891+ switch (position)
892+ {
893+ case GTK_POS_RIGHT:
894+ cairo_translate (cr, 0., y + height);
895+ cairo_scale (cr, 1., -1.);
896+ cairo_translate (cr, x, height);
897+ cairo_rotate (cr, M_PI * 1.5);
898+ temp = width;
899+ width = height;
900+ height = temp;
901+ break;
902+ case GTK_POS_LEFT:
903+ cairo_translate (cr, x + width, y);
904+ cairo_rotate (cr, M_PI * 0.5);
905+ temp = width;
906+ width = height;
907+ height = temp;
908+ break;
909+ case GTK_POS_TOP:
910+ cairo_translate (cr, x, y + height);
911+ cairo_scale (cr, 1., -1.);
912+ break;
913+ default:
914+ cairo_translate (cr, x, y);
915+ break;
916+ }
917+
918+ draw_top_bottom_background (bg, position, cr, width, height);
919+
920+ cairo_restore (cr);
921+}
922+
923+static gboolean
924+awn_background_lucido_get_needs_redraw (AwnBackground *bg,
925+ GtkPositionType position,
926+ GdkRectangle *area)
927+{
928+ /* Check default needs redraw */
929+ gboolean nr = AWN_BACKGROUND_CLASS (awn_background_lucido_parent_class)->
930+ get_needs_redraw (bg, position, area);
931+ if (nr)
932+ return TRUE;
933+
934+ /* Check expanders positions & sizes changed */
935+ GList *widgets = _get_applet_widgets (bg);
936+ GList *i = widgets;
937+ GtkWidget *widget = NULL;
938+ gint wcheck = 0;
939+ gint ncheck = 0;
940+
941+ for (; i; i = i->next)
942+ {
943+ widget = GTK_WIDGET (i->data);
944+
945+ if (!GTK_IS_IMAGE (widget) || AWN_IS_SEPARATOR (widget))
946+ {
947+ /* if not expander continue */
948+ continue;
949+ }
950+ switch (position)
951+ {
952+ case GTK_POS_BOTTOM:
953+ case GTK_POS_TOP:
954+ wcheck += (widget->allocation.x * 3) / 2 + widget->allocation.width;
955+ break;
956+ default:
957+ wcheck += (widget->allocation.y * 3 ) / 2 + widget->allocation.height;
958+ break;
959+ }
960+ ++ncheck;
961+ }
962+ g_list_free (widgets);
963+
964+ AwnBackgroundLucido *lbg = NULL;
965+ lbg = AWN_BACKGROUND_LUCIDO (bg);
966+ AwnBackgroundLucidoPrivate *priv;
967+ priv = AWN_BACKGROUND_LUCIDO_GET_PRIVATE (lbg);
968+ if (priv->expn != ncheck)
969+ {
970+ priv->expn = ncheck;
971+ /* used to refresh bar */
972+ awn_background_emit_padding_changed (bg);
973+ }
974+ if (priv->expw != wcheck)
975+ {
976+ priv->expw = wcheck;
977+ return TRUE;
978+ }
979+ return FALSE;
980+}
981+
982+static void
983+awn_background_lucido_get_shape_mask (AwnBackground *bg,
984+ cairo_t *cr,
985+ GtkPositionType position,
986+ GdkRectangle *area)
987+{
988+ gint temp;
989+ gint x = area->x, y = area->y;
990+ gint width = area->width, height = area->height;
991+ gfloat align = 0.5;
992+ gboolean expand = FALSE;
993+
994+ cairo_save (cr);
995+
996+ align = awn_background_get_panel_alignment (bg);
997+ g_object_get (bg->panel, "expand", &expand, NULL);
998+
999+ switch (position)
1000+ {
1001+ case GTK_POS_RIGHT:
1002+ cairo_translate (cr, x, y+height);
1003+ cairo_rotate (cr, M_PI * 1.5);
1004+ temp = width;
1005+ width = height; height = temp;
1006+ break;
1007+ case GTK_POS_LEFT:
1008+ cairo_translate (cr, x+width, y);
1009+ cairo_rotate (cr, M_PI * 0.5);
1010+ temp = width;
1011+ width = height; height = temp;
1012+ break;
1013+ case GTK_POS_TOP:
1014+ cairo_translate (cr, x+width, y+height);
1015+ cairo_rotate (cr, M_PI);
1016+ break;
1017+ default:
1018+ cairo_translate (cr, x, y);
1019+ break;
1020+ }
1021+
1022+ cairo_rectangle (cr, 0, 0, width, height + 2);
1023+ cairo_fill (cr);
1024+
1025+ cairo_restore (cr);
1026+}
1027+/* vim: set et ts=2 sts=2 sw=2 : */
1028
1029=== added file 'src/awn-background-lucido.h'
1030--- src/awn-background-lucido.h 1970-01-01 00:00:00 +0000
1031+++ src/awn-background-lucido.h 2010-05-31 11:01:08 +0000
1032@@ -0,0 +1,71 @@
1033+/*
1034+ * Copyright (C) 2009 Michal Hruby <michal.mhr@gmail.com>
1035+ *
1036+ * This program is free software; you can redistribute it and/or modify
1037+ * it under the terms of the GNU General Public License as published by
1038+ * the Free Software Foundation; either version 2 of the License, or
1039+ * (at your option) any later version.
1040+ *
1041+ * This program is distributed in the hope that it will be useful,
1042+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1043+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1044+ * GNU General Public License for more details.
1045+ *
1046+ * You should have received a copy of the GNU General Public License
1047+ * along with this program; if not, write to the Free Software
1048+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1049+ *
1050+ * Author : Alberto Aldegheri <albyrock87+dev@gmail.com>
1051+*/
1052+
1053+#ifndef _AWN_BACKGROUND_LUCIDO_H
1054+#define _AWN_BACKGROUND_LUCIDO_H
1055+
1056+#include <glib.h>
1057+#include <glib-object.h>
1058+#include <gtk/gtk.h>
1059+
1060+#include "awn-background.h"
1061+
1062+G_BEGIN_DECLS
1063+
1064+#define AWN_TYPE_BACKGROUND_LUCIDO (awn_background_lucido_get_type())
1065+
1066+#define AWN_BACKGROUND_LUCIDO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AWN_TYPE_BACKGROUND_LUCIDO, \
1067+ AwnBackgroundLucido))
1068+
1069+#define AWN_BACKGROUND_LUCIDO_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), AWN_BACKGROUND_LUCIDO, \
1070+ AwnBackgroundLucidoClass))
1071+
1072+#define AWN_IS_BACKGROUND_LUCIDO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AWN_TYPE_BACKGROUND_LUCIDO))
1073+
1074+#define AWN_IS_BACKGROUND_LUCIDO_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), \
1075+ AWN_TYPE_BACKGROUND_LUCIDO))
1076+
1077+#define AWN_BACKGROUND_LUCIDO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
1078+ AWN_TYPE_BACKGROUND_LUCIDO, AwnBackgroundLucidoClass))
1079+
1080+typedef struct _AwnBackgroundLucido AwnBackgroundLucido;
1081+typedef struct _AwnBackgroundLucidoClass AwnBackgroundLucidoClass;
1082+typedef struct _AwnBackgroundLucidoPrivate AwnBackgroundLucidoPrivate;
1083+
1084+struct _AwnBackgroundLucido
1085+{
1086+ AwnBackground parent;
1087+ AwnBackgroundLucidoPrivate *priv;
1088+};
1089+
1090+struct _AwnBackgroundLucidoClass
1091+{
1092+ AwnBackgroundClass parent_class;
1093+};
1094+
1095+GType awn_background_lucido_get_type (void) G_GNUC_CONST;
1096+
1097+AwnBackground * awn_background_lucido_new (DesktopAgnosticConfigClient *client,
1098+ AwnPanel *panel);
1099+
1100+G_END_DECLS
1101+
1102+#endif /* _AWN_BACKGROUND_LUCIDO_H */
1103+
1104
1105=== modified file 'src/awn-background.c'
1106--- src/awn-background.c 2010-04-08 15:38:05 +0000
1107+++ src/awn-background.c 2010-05-31 11:01:08 +0000
1108@@ -58,7 +58,8 @@
1109 PROP_CORNER_RADIUS,
1110 PROP_PANEL_ANGLE,
1111 PROP_CURVINESS,
1112- PROP_CURVES_SYMEMETRY
1113+ PROP_CURVES_SYMEMETRY,
1114+ PROP_STRIPE_WIDTH
1115 };
1116
1117 enum
1118@@ -90,6 +91,10 @@
1119 GtkPositionType position,
1120 GdkRectangle *area);
1121
1122+static gboolean awn_background_get_needs_redraw (AwnBackground *bg,
1123+ GtkPositionType position,
1124+ GdkRectangle *area);
1125+
1126 static AwnPathType awn_background_path_default (AwnBackground *bg,
1127 gfloat *offset_mod);
1128
1129@@ -186,6 +191,11 @@
1130 object, "curves-symmetry", TRUE,
1131 DESKTOP_AGNOSTIC_CONFIG_BIND_METHOD_FALLBACK,
1132 NULL);
1133+ desktop_agnostic_config_client_bind (bg->client,
1134+ AWN_GROUP_THEME, AWN_THEME_STRIPE_WIDTH,
1135+ object, "stripe-width", TRUE,
1136+ DESKTOP_AGNOSTIC_CONFIG_BIND_METHOD_FALLBACK,
1137+ NULL);
1138 }
1139
1140 static void
1141@@ -342,12 +352,15 @@
1142 case PROP_CURVES_SYMEMETRY:
1143 bg->curves_symmetry = g_value_get_float (value);
1144 break;
1145+ case PROP_STRIPE_WIDTH:
1146+ bg->stripe_width = g_value_get_float (value);
1147+ break;
1148
1149 default:
1150 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1151 return;
1152 }
1153-
1154+ awn_background_invalidate (bg);
1155 g_signal_emit (object, _bg_signals[CHANGED], 0);
1156 }
1157
1158@@ -380,6 +393,12 @@
1159 if (bg->hilight_color) g_object_unref (bg->hilight_color);
1160 if (bg->sep_color) g_object_unref (bg->sep_color);
1161
1162+ if (bg->helper_surface != NULL)
1163+ {
1164+ cairo_surface_finish (bg->helper_surface);
1165+ cairo_surface_destroy (bg->helper_surface);
1166+ }
1167+
1168 G_OBJECT_CLASS (awn_background_parent_class)->finalize (object);
1169 }
1170
1171@@ -398,6 +417,7 @@
1172 klass->get_input_shape_mask = awn_background_mask_none;
1173 klass->get_path_type = awn_background_path_default;
1174 klass->get_strut_offsets = NULL;
1175+ klass->get_needs_redraw = awn_background_get_needs_redraw;
1176
1177 /* Object properties */
1178 g_object_class_install_property (obj_class,
1179@@ -575,6 +595,15 @@
1180 0.0, 1.0, 0.5,
1181 G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
1182 G_PARAM_STATIC_STRINGS));
1183+
1184+ g_object_class_install_property (obj_class,
1185+ PROP_STRIPE_WIDTH,
1186+ g_param_spec_float ("stripe-width",
1187+ "Stripe Width",
1188+ "The width of the stripe",
1189+ 0.0, 1.0, 0.0,
1190+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
1191+ G_PARAM_STATIC_STRINGS));
1192
1193 /* Add signals to the class */
1194 _bg_signals[CHANGED] =
1195@@ -650,6 +679,11 @@
1196 bg->border_color = NULL;
1197 bg->hilight_color = NULL;
1198 bg->sep_color = NULL;
1199+ bg->needs_redraw = TRUE;
1200+ bg->helper_surface = NULL;
1201+ bg->cache_enabled = TRUE;
1202+ bg->last_height = 0;
1203+ bg->last_width = 0;
1204 }
1205
1206 void
1207@@ -664,8 +698,40 @@
1208
1209 klass = AWN_BACKGROUND_GET_CLASS (bg);
1210 g_return_if_fail (klass->draw != NULL);
1211-
1212- klass->draw (bg, cr, position, area);
1213+
1214+ /* Check if background caching is enabled - TRUE by default */
1215+ if (bg->cache_enabled)
1216+ {
1217+ g_return_if_fail (klass->get_needs_redraw != NULL);
1218+ cairo_save (cr);
1219+
1220+ /* Check if background needs to be redrawn */
1221+ if (klass->get_needs_redraw (bg, position, area))
1222+ {
1223+ /* Free last surface */
1224+ if (bg->helper_surface != NULL)
1225+ {
1226+ cairo_surface_finish (bg->helper_surface);
1227+ cairo_surface_destroy (bg->helper_surface);
1228+ }
1229+ /* Create new surface */
1230+ bg->helper_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
1231+ area->x + area->width,
1232+ area->y + area->height);
1233+ cairo_t* temp_cr = cairo_create (bg->helper_surface);
1234+ /* Draw background on temp cairo_t */
1235+ klass->draw (bg, temp_cr, position, area);
1236+ cairo_destroy (temp_cr);
1237+ }
1238+ /* Paint saved surface */
1239+ cairo_set_source_surface (cr, bg->helper_surface, 0., 0.);
1240+ cairo_paint(cr);
1241+ cairo_restore (cr);
1242+ }
1243+ else
1244+ {
1245+ klass->draw (bg, cr, position, area);
1246+ }
1247 }
1248
1249 void
1250@@ -1009,4 +1075,25 @@
1251 return AWN_PATH_LINEAR;
1252 }
1253
1254+static gboolean awn_background_get_needs_redraw (AwnBackground *bg,
1255+ GtkPositionType position,
1256+ GdkRectangle *area)
1257+{
1258+ if (bg->needs_redraw == 1 ||
1259+ bg->last_height != area->height ||
1260+ bg->last_width != area->width)
1261+ {
1262+ bg->needs_redraw = 0;
1263+ bg->last_height = area->height;
1264+ bg->last_width = area->width;
1265+ return TRUE;
1266+ }
1267+ return FALSE;
1268+}
1269+
1270+void awn_background_invalidate (AwnBackground *bg)
1271+{
1272+ bg->needs_redraw = 1;
1273+}
1274+
1275 /* vim: set et ts=2 sts=2 sw=2 : */
1276
1277=== modified file 'src/awn-background.h'
1278--- src/awn-background.h 2010-03-07 18:38:07 +0000
1279+++ src/awn-background.h 2010-05-31 11:01:08 +0000
1280@@ -76,6 +76,15 @@
1281 gfloat pattern_alpha;
1282 GdkPixbuf *pattern_original;
1283 cairo_surface_t *pattern;
1284+
1285+ /* Speedup code.
1286+ * We can save the bg and redraw only when properties changes
1287+ */
1288+ gboolean cache_enabled;
1289+ gboolean needs_redraw;
1290+ cairo_surface_t* helper_surface;
1291+ gint last_height;
1292+ gint last_width;
1293
1294 /* FIXME:
1295 * These two should ultimately go somewhere else (once we do multiple panels)
1296@@ -89,6 +98,7 @@
1297 gint panel_angle;
1298 gfloat curviness;
1299 gfloat curves_symmetry;
1300+ gfloat stripe_width;
1301
1302 /* private */
1303 guint changed;
1304@@ -129,6 +139,10 @@
1305 GdkRectangle *area,
1306 gint *strut,
1307 gint *strut_start, gint *strut_end);
1308+
1309+ gboolean (*get_needs_redraw) (AwnBackground *bg,
1310+ GtkPositionType position,
1311+ GdkRectangle *area);
1312
1313 /*< signals >*/
1314 void (*changed) (AwnBackground *bg);
1315@@ -142,6 +156,8 @@
1316 GtkPositionType position,
1317 GdkRectangle *area);
1318
1319+void awn_background_invalidate (AwnBackground *bg);
1320+
1321 void awn_background_padding_request (AwnBackground *bg,
1322 GtkPositionType position,
1323 guint *padding_top,
1324
1325=== modified file 'src/awn-defines.h'
1326--- src/awn-defines.h 2010-02-06 13:34:02 +0000
1327+++ src/awn-defines.h 2010-05-31 11:01:08 +0000
1328@@ -87,6 +87,7 @@
1329 #define AWN_THEME_PANEL_ANGLE "panel_angle"
1330 #define AWN_THEME_CURVINESS "curviness"
1331 #define AWN_THEME_CURVES_SYMMETRY "curves_symmetry"
1332+#define AWN_THEME_STRIPE_WIDTH "stripe_width"
1333
1334 #endif /*_HAVE_AWN_DEFINES_H */
1335
1336
1337=== modified file 'src/awn-panel.c'
1338--- src/awn-panel.c 2010-05-29 17:17:22 +0000
1339+++ src/awn-panel.c 2010-05-31 11:01:08 +0000
1340@@ -43,6 +43,7 @@
1341 #include "awn-background-3d.h"
1342 #include "awn-background-curves.h"
1343 #include "awn-background-edgy.h"
1344+#include "awn-background-lucido.h"
1345 #include "awn-background-floaty.h"
1346 #include "awn-defines.h"
1347 #include "awn-marshal.h"
1348@@ -222,6 +223,7 @@
1349 STYLE_EDGY,
1350 STYLE_FLOATY,
1351
1352+ STYLE_LUCIDO,
1353 STYLE_LAST
1354 };
1355
1356@@ -1075,6 +1077,9 @@
1357 }
1358
1359 awn_panel_queue_masks_update (panel);
1360+
1361+ if (priv->bg)
1362+ awn_background_invalidate (priv->bg);
1363 }
1364
1365 static
1366@@ -1760,7 +1765,7 @@
1367 obj_class->finalize = awn_panel_finalize;
1368 obj_class->get_property = awn_panel_get_property;
1369 obj_class->set_property = awn_panel_set_property;
1370-
1371+
1372 cont_class->add = awn_panel_add;
1373
1374 wid_class->expose_event = awn_panel_expose;
1375@@ -3179,6 +3184,9 @@
1376 case STYLE_EDGY:
1377 priv->bg = awn_background_edgy_new (priv->client, panel);
1378 break;
1379+ case STYLE_LUCIDO:
1380+ priv->bg = awn_background_lucido_new (priv->client, panel);
1381+ break;
1382 case STYLE_FLOATY:
1383 priv->bg = awn_background_floaty_new (priv->client, panel);
1384 break;

Subscribers

People subscribed via source and target branches