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: 1375 lines (+1062/-11)
13 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 (+797/-0)
src/awn-background-lucido.h (+71/-0)
src/awn-background.c (+97/-3)
src/awn-background.h (+19/-0)
src/awn-defines.h (+1/-0)
src/awn-panel.c (+16/-0)
src/awn-panel.h (+1/-0)
To merge this branch: bzr merge lp:~albyrock87/awn/awn-lucido
Reviewer Review Type Date Requested Status
Alberto Aldegheri Needs Information
Michal Hruby (community) code-review Needs Fixing
Review via email: mp+26165@code.launchpad.net

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

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

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

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

 * awn-settings/awnSettings.py.in:
 * po/avant-window-navigator.pot:
 Fix LP bug #586670.

701. By Michal Hruby

 * applets/quick-prefs/applet.vala:
 Use async DBus calls in quick-prefs applet.

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

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 :

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 :

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 :

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

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

 * src/awn-monitor.c:
 * src/awn-monitor.h:
 * src/awn-panel.c:
 Possible fix for LP bug #562453.

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

> 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 :

Ok, all done.

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

Resubmitting :)

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
=== modified file 'awn-settings/awn-settings.ui'
--- awn-settings/awn-settings.ui 2010-03-08 12:50:07 +0000
+++ awn-settings/awn-settings.ui 2010-05-30 13:41:34 +0000
@@ -908,6 +908,22 @@
908 </packing>908 </packing>
909 </child>909 </child>
910 <child>910 <child>
911 <object class="GtkSpinButton" id="theme_stripe_width">
912 <property name="visible">True</property>
913 <property name="can_focus">True</property>
914 <property name="invisible_char">&#x25CF;</property>
915 <property name="adjustment">adj_stripe_width</property>
916 <property name="digits">2</property>
917 </object>
918 <packing>
919 <property name="left_attach">5</property>
920 <property name="right_attach">6</property>
921 <property name="top_attach">8</property>
922 <property name="bottom_attach">9</property>
923 <property name="x_options"></property>
924 </packing>
925 </child>
926 <child>
911 <object class="GtkSpinButton" id="theme_angle">927 <object class="GtkSpinButton" id="theme_angle">
912 <property name="visible">True</property>928 <property name="visible">True</property>
913 <property name="can_focus">True</property>929 <property name="can_focus">True</property>
@@ -964,6 +980,20 @@
964 </packing>980 </packing>
965 </child>981 </child>
966 <child>982 <child>
983 <object class="GtkLabel" id="label_stripe">
984 <property name="visible">True</property>
985 <property name="xalign">0</property>
986 <property name="xpad">0</property>
987 <property name="label" translatable="yes">Stripe Width</property>
988 </object>
989 <packing>
990 <property name="left_attach">3</property>
991 <property name="right_attach">5</property>
992 <property name="top_attach">8</property>
993 <property name="bottom_attach">9</property>
994 </packing>
995 </child>
996 <child>
967 <object class="GtkLabel" id="label49">997 <object class="GtkLabel" id="label49">
968 <property name="visible">True</property>998 <property name="visible">True</property>
969 <property name="xalign">0</property>999 <property name="xalign">0</property>
@@ -3406,6 +3436,10 @@
3406 <property name="upper">1</property>3436 <property name="upper">1</property>
3407 <property name="step_increment">0.01</property>3437 <property name="step_increment">0.01</property>
3408 </object>3438 </object>
3439 <object class="GtkAdjustment" id="adj_stripe_width">
3440 <property name="upper">1</property>
3441 <property name="step_increment">0.01</property>
3442 </object>
3409 <object class="GtkAdjustment" id="adj_radius">3443 <object class="GtkAdjustment" id="adj_radius">
3410 <property name="upper">100</property>3444 <property name="upper">100</property>
3411 <property name="step_increment">1</property>3445 <property name="step_increment">1</property>
34123446
=== modified file 'awn-settings/awnDefs.py.in'
--- awn-settings/awnDefs.py.in 2010-04-29 14:58:51 +0000
+++ awn-settings/awnDefs.py.in 2010-05-30 13:41:34 +0000
@@ -86,6 +86,7 @@
86PANEL_ANGLE = "panel_angle" #float86PANEL_ANGLE = "panel_angle" #float
87CURVINESS = "curviness" #float87CURVINESS = "curviness" #float
88CURVES_SYMMETRY = "curves_symmetry" #float88CURVES_SYMMETRY = "curves_symmetry" #float
89STRIPE_WIDTH = "stripe_width" #float
89TOOLTIP_FONT_NAME = "tooltip_font_name" #string90TOOLTIP_FONT_NAME = "tooltip_font_name" #string
90TOOLTIP_FONT_COLOR = "tooltip_font_color" #string91TOOLTIP_FONT_COLOR = "tooltip_font_color" #string
91TOOLTIP_BG_COLOR = "tooltip_bg_color" #string92TOOLTIP_BG_COLOR = "tooltip_bg_color" #string
9293
=== modified file 'awn-settings/awnSettings.py.in'
--- awn-settings/awnSettings.py.in 2010-05-28 08:09:17 +0000
+++ awn-settings/awnSettings.py.in 2010-05-30 13:41:34 +0000
@@ -141,7 +141,8 @@
141 #setup style mode141 #setup style mode
142 dropdown = self.wTree.get_object("stylecombo")142 dropdown = self.wTree.get_object("stylecombo")
143 self.create_dropdown(dropdown, [_("None"), _("Flat"), _("3d"),143 self.create_dropdown(dropdown, [_("None"), _("Flat"), _("3d"),
144 _("Curved"), _("Edgy"), _("Floaty")])144 _("Curved"), _("Edgy"), _("Floaty"),
145 _("Lucido")])
145146
146 #setup behaviour combo147 #setup behaviour combo
147 dropdown = self.wTree.get_object("behaviorcombo")148 dropdown = self.wTree.get_object("behaviorcombo")
@@ -578,6 +579,7 @@
578 579
579 curviness = gobject.property(type=int, default=10)580 curviness = gobject.property(type=int, default=10)
580 curves_symmetry = gobject.property(type=float, default=0)581 curves_symmetry = gobject.property(type=float, default=0)
582 stripe_width = gobject.property(type=float, default=0)
581 angle = gobject.property(type=int, default=45)583 angle = gobject.property(type=int, default=45)
582 radius = gobject.property(type=int, default=10)584 radius = gobject.property(type=int, default=10)
583 gtk_theme_mode = gobject.property(type=bool, default=False)585 gtk_theme_mode = gobject.property(type=bool, default=False)
@@ -727,6 +729,7 @@
727 (defs.THEME, defs.PANEL_ANGLE, 'float', sizes),729 (defs.THEME, defs.PANEL_ANGLE, 'float', sizes),
728 (defs.THEME, defs.CURVINESS, 'float', sizes),730 (defs.THEME, defs.CURVINESS, 'float', sizes),
729 (defs.THEME, defs.CURVES_SYMMETRY, 'float', sizes),731 (defs.THEME, defs.CURVES_SYMMETRY, 'float', sizes),
732 (defs.THEME, defs.STRIPE_WIDTH, 'float', sizes),
730 (defs.THEME, defs.TOOLTIP_FONT_NAME, 'str', icon),733 (defs.THEME, defs.TOOLTIP_FONT_NAME, 'str', icon),
731 (defs.THEME, defs.TOOLTIP_FONT_COLOR, 'str', icon),734 (defs.THEME, defs.TOOLTIP_FONT_COLOR, 'str', icon),
732 (defs.THEME, defs.TOOLTIP_BG_COLOR, 'str', icon),735 (defs.THEME, defs.TOOLTIP_BG_COLOR, 'str', icon),
@@ -823,6 +826,8 @@
823 "curviness", "theme_curviness"),826 "curviness", "theme_curviness"),
824 (self.client, defs.THEME, defs.CURVES_SYMMETRY,827 (self.client, defs.THEME, defs.CURVES_SYMMETRY,
825 "curves-symmetry", "theme_symmetry"),828 "curves-symmetry", "theme_symmetry"),
829 (self.client, defs.THEME, defs.STRIPE_WIDTH,
830 "stripe-width", "theme_stripe_width"),
826 (self.client, defs.THEME, defs.PANEL_ANGLE,831 (self.client, defs.THEME, defs.PANEL_ANGLE,
827 "angle", "theme_angle"),832 "angle", "theme_angle"),
828 (self.client, defs.THEME, defs.CORNER_RADIUS,833 (self.client, defs.THEME, defs.CORNER_RADIUS,
829834
=== modified file 'data/avant-window-navigator.schema-ini.in.in'
--- data/avant-window-navigator.schema-ini.in.in 2010-03-09 20:20:25 +0000
+++ data/avant-window-navigator.schema-ini.in.in 2010-05-30 13:41:34 +0000
@@ -159,7 +159,7 @@
159[panel/style]159[panel/style]
160type = integer160type = integer
161default = 1161default = 1
162_description=The style of the bar. (none=0, flat bar=1, 3d bar=2, curved bar=3, edgy=4, floaty=5)162_description=The style of the bar. (none=0, flat bar=1, 3d bar=2, curved bar=3, edgy=4, floaty=5,lucido=6)
163163
164[panels/panel_list]164[panels/panel_list]
165type = list-integer165type = list-integer
@@ -227,6 +227,12 @@
227_description=The curviness of the panel in Curves mode.227_description=The curviness of the panel in Curves mode.
228per_instance = false228per_instance = false
229229
230[theme/stripe_width]
231type = float
232default = 0.0
233_description=The width of the stripe in Lucido mode.
234per_instance = false
235
230[theme/dialog_gtk_mode]236[theme/dialog_gtk_mode]
231type = boolean237type = boolean
232default = true238default = true
233239
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2010-03-24 23:24:19 +0000
+++ src/Makefile.am 2010-05-30 13:41:34 +0000
@@ -41,6 +41,8 @@
41 awn-background-edgy.h \41 awn-background-edgy.h \
42 awn-background-floaty.c \42 awn-background-floaty.c \
43 awn-background-floaty.h \43 awn-background-floaty.h \
44 awn-background-lucido.c \
45 awn-background-lucido.h \
44 awn-defines.h \46 awn-defines.h \
45 $(builddir)/awn-marshal.c \47 $(builddir)/awn-marshal.c \
46 $(builddir)/awn-marshal.h \48 $(builddir)/awn-marshal.h \
4749
=== modified file 'src/awn-background-flat.c'
--- src/awn-background-flat.c 2010-03-07 18:38:07 +0000
+++ src/awn-background-flat.c 2010-05-30 13:41:34 +0000
@@ -324,20 +324,24 @@
324 switch (position)324 switch (position)
325 {325 {
326 case GTK_POS_RIGHT:326 case GTK_POS_RIGHT:
327 cairo_translate (cr, x, y+height);327 cairo_translate (cr, 0., y + height);
328 cairo_scale (cr, 1., -1.);
329 cairo_translate (cr, x, height);
328 cairo_rotate (cr, M_PI * 1.5);330 cairo_rotate (cr, M_PI * 1.5);
329 temp = width;331 temp = width;
330 width = height; height = temp;332 width = height;
333 height = temp;
331 break;334 break;
332 case GTK_POS_LEFT:335 case GTK_POS_LEFT:
333 cairo_translate (cr, x+width, y);336 cairo_translate (cr, x + width, y);
334 cairo_rotate (cr, M_PI * 0.5);337 cairo_rotate (cr, M_PI * 0.5);
335 temp = width;338 temp = width;
336 width = height; height = temp;339 width = height;
340 height = temp;
337 break;341 break;
338 case GTK_POS_TOP:342 case GTK_POS_TOP:
339 cairo_translate (cr, x+width, y+height);343 cairo_translate (cr, x, y + height);
340 cairo_rotate (cr, M_PI);344 cairo_scale (cr, 1., -1.);
341 break;345 break;
342 default:346 default:
343 cairo_translate (cr, x, y);347 cairo_translate (cr, x, y);
344348
=== added file 'src/awn-background-lucido.c'
--- src/awn-background-lucido.c 1970-01-01 00:00:00 +0000
+++ src/awn-background-lucido.c 2010-05-30 13:41:34 +0000
@@ -0,0 +1,797 @@
1/*
2 * Copyright (C) 2009 Michal Hruby <michal.mhr@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Author : Alberto Aldegheri <albyrock87+dev@gmail.com>
19 * Thanks to: Matt <sharkbaitbobby@gmail.com>
20 * for the code section to analyze expanders
21 *
22 */
23
24#include "config.h"
25
26#include <gdk/gdk.h>
27#include <libawn/awn-cairo-utils.h>
28#include <math.h>
29
30#include "awn-applet-manager.h"
31#include "awn-background-lucido.h"
32#include "awn-separator.h"
33#include "awn-panel.h"
34
35G_DEFINE_TYPE (AwnBackgroundLucido, awn_background_lucido, AWN_TYPE_BACKGROUND_FLAT)
36
37#define AWN_BACKGROUND_LUCIDO_GET_PRIVATE(obj) ( \
38 G_TYPE_INSTANCE_GET_PRIVATE (obj, AWN_TYPE_BACKGROUND_LUCIDO, \
39 AwnBackgroundLucidoPrivate))
40
41struct _AwnBackgroundLucidoPrivate
42{
43 gint expw;
44 gint expn;
45};
46
47enum
48{
49 PROP_0,
50
51 PROP_CLIENT,
52 PROP_PANEL,
53
54 PROP_GSTEP1,
55 PROP_GSTEP2,
56 PROP_GHISTEP1,
57 PROP_GHISTEP2,
58 PROP_BORDER,
59 PROP_HILIGHT,
60
61 PROP_SHOW_SEP,
62 PROP_SEP_COLOR,
63
64 PROP_ENABLE_PATTERN,
65 PROP_PATTERN_ALPHA,
66 PROP_PATTERN_FILENAME,
67
68 PROP_GTK_THEME_MODE,
69 PROP_DIALOG_GTK_MODE,
70 PROP_ROUNDED_CORNERS,
71 PROP_CORNER_RADIUS,
72 PROP_PANEL_ANGLE,
73 PROP_CURVINESS,
74 PROP_CURVES_SYMEMETRY,
75 PROP_STRIPE_WIDTH
76};
77
78static void awn_background_lucido_draw (AwnBackground *bg,
79 cairo_t *cr,
80 GtkPositionType position,
81 GdkRectangle *area);
82
83static void awn_background_lucido_get_shape_mask (AwnBackground *bg,
84 cairo_t *cr,
85 GtkPositionType position,
86 GdkRectangle *area);
87
88static void awn_background_lucido_padding_request (AwnBackground *bg,
89 GtkPositionType position,
90 guint *padding_top,
91 guint *padding_bottom,
92 guint *padding_left,
93 guint *padding_right);
94
95static gboolean
96awn_background_lucido_get_needs_redraw (AwnBackground *bg,
97 GtkPositionType position,
98 GdkRectangle *area);
99
100static
101void awn_background_lucido_property_changed (AwnBackground *bg,
102 guint prop_id);
103
104static void
105awn_background_lucido_constructed (GObject *object)
106{
107 G_OBJECT_CLASS (awn_background_lucido_parent_class)->constructed (object);
108}
109
110static void
111awn_background_lucido_dispose (GObject *object)
112{
113 G_OBJECT_CLASS (awn_background_lucido_parent_class)->dispose (object);
114}
115
116static void
117awn_background_lucido_class_init (AwnBackgroundLucidoClass *klass)
118{
119 AwnBackgroundClass *bg_class = AWN_BACKGROUND_CLASS (klass);
120
121 GObjectClass *obj_class = G_OBJECT_CLASS (klass);
122 obj_class->constructed = awn_background_lucido_constructed;
123 obj_class->dispose = awn_background_lucido_dispose;
124
125 bg_class->draw = awn_background_lucido_draw;
126 bg_class->padding_request = awn_background_lucido_padding_request;
127 bg_class->get_shape_mask = awn_background_lucido_get_shape_mask;
128 bg_class->get_input_shape_mask = awn_background_lucido_get_shape_mask;
129 bg_class->get_needs_redraw = awn_background_lucido_get_needs_redraw;
130 bg_class->property_changed = awn_background_lucido_property_changed;
131
132 g_type_class_add_private (obj_class, sizeof (AwnBackgroundLucidoPrivate));
133}
134
135static void
136awn_background_lucido_init (AwnBackgroundLucido *bg)
137{
138
139}
140
141AwnBackground *
142awn_background_lucido_new (DesktopAgnosticConfigClient *client,
143 AwnPanel *panel)
144{
145 AwnBackground *bg;
146
147 bg = g_object_new (AWN_TYPE_BACKGROUND_LUCIDO,
148 "client", client,
149 "panel", panel,
150 NULL);
151 return bg;
152}
153
154/*
155 * Drawing functions
156 */
157static void
158_line_from_to ( cairo_t *cr,
159 gfloat *xs,
160 gfloat *ys,
161 gfloat xf,
162 gfloat yf)
163{
164 if ( *xs==xf || *ys==yf ) /* Vertical/Horizontal line */
165 cairo_line_to (cr, xf, yf);
166 else
167 { /* Oblique */
168 gfloat xm = ( *xs + xf ) / 2.0;
169 cairo_curve_to (cr, xm, *ys, xm, yf, xf, yf);
170 }
171 *xs = xf;
172 *ys = yf;
173}
174
175static GList*
176_get_applet_widgets (AwnBackground* bg)
177{
178 AwnAppletManager *manager = NULL;
179 g_object_get (bg->panel, "applet-manager", &manager, NULL);
180
181 return gtk_container_get_children (GTK_CONTAINER (manager));
182}
183
184/**
185 * _create_path_lucido:
186 * @bg: The background pointer
187 * @position: The position of the bar
188 * @cairo_t: The cairo context
189 * @y: The top left coordinate of the "bar rect" - default = 0
190 * @w: The width of the bar
191 * @h: The height of the bar
192 * @stripe: The width of the stripe (0.0-1.0). Zero for auto-stripe.
193 * @d: The width of each curve in the path
194 * @dc: The width of the external curves in non-expanded&auto mode
195 * @symmetry: The symmetry of the stripe when @stripe > 0
196 * @internal: If Zero, creates the path for the stripe
197 * @expanded: If Zero, the bar is not expanded
198 *
199 * This function creates paths on which the bar will be drawn.
200 * In atuo-stripe, it searchs for expanders applet, each expander
201 * equals to one curve.
202 * If the first widget is an expander, start from bottom-left,
203 * otherwise start from top-left
204 */
205
206static void
207_create_path_lucido ( AwnBackground* bg,
208 GtkPositionType position,
209 cairo_t* cr,
210 gfloat x,
211 gfloat y,
212 gfloat w,
213 gfloat h,
214 gfloat stripe,
215 gfloat d,
216 gfloat dc,
217 gfloat symmetry,
218 gboolean internal,
219 gboolean expanded,
220 gfloat align)
221{
222 cairo_new_path (cr);
223
224 gfloat lx = x;
225 gfloat ly = y;
226 gfloat y3 = y + h;
227 gfloat y2 = y3 - 5;
228
229 if (stripe > 0)
230 {
231 if (expanded)
232 {
233 stripe = (w * stripe); /* now stripe = non-stripe */
234 if (internal)
235 {
236 /* Manual-Stripe & Expanded & Internal */
237 lx = stripe * symmetry;
238 cairo_move_to (cr, lx, ly);
239 _line_from_to (cr, &lx, &ly, lx+d, y2);
240 _line_from_to (cr, &lx, &ly, w-stripe * (1. - symmetry) - d, y2);
241 _line_from_to (cr, &lx, &ly, w-stripe * (1. - symmetry), y);
242 cairo_close_path (cr);
243 }
244 else
245 {
246 /* Manual-Stripe & Expanded & External */
247 ly = y3;
248 cairo_move_to (cr, lx, ly);
249 _line_from_to (cr, &lx, &ly, lx, y);
250 _line_from_to (cr, &lx, &ly, stripe * symmetry, y);
251 _line_from_to (cr, &lx, &ly, stripe * symmetry + d, y2);
252 _line_from_to (cr, &lx, &ly, w - stripe * (1. - symmetry) - d, y2);
253 _line_from_to (cr, &lx, &ly, w - stripe * (1. - symmetry), y);
254 _line_from_to (cr, &lx, &ly, w, y);
255 _line_from_to (cr, &lx, &ly, w, y3);
256 cairo_close_path (cr);
257 }
258 }
259 else
260 {
261 if (stripe == 1.)
262 {
263 _create_path_lucido (bg, position, cr, x, y, w, h, 0.,
264 d, dc, 0., internal, expanded, align);
265 return;
266 }
267 stripe = ((w - dc * 2) * stripe); /* now stripe = non-stripe */
268 if (internal)
269 {
270 /* Manual-Stripe & Not-Expanded & Internal */
271 lx = stripe * symmetry + dc;
272 cairo_move_to (cr, lx, ly);
273 _line_from_to (cr, &lx, &ly, lx + d, y2);
274 _line_from_to (cr, &lx, &ly, w - stripe * (1.- symmetry) - dc - d, y2);
275 _line_from_to (cr, &lx, &ly, w - stripe * (1.- symmetry) - dc, y);
276 cairo_close_path (cr);
277 }
278 else
279 {
280 /* Manual-Stripe & Not-Expanded & External */
281 ly = y3;
282 cairo_move_to (cr, lx, ly);
283 _line_from_to (cr, &lx, &ly, lx+dc, y);
284 _line_from_to (cr, &lx, &ly, stripe * symmetry + dc, y);
285 _line_from_to (cr, &lx, &ly, stripe * symmetry + d + dc, y2);
286 _line_from_to (cr, &lx, &ly, w-stripe * (1. - symmetry) - dc - d, y2);
287 _line_from_to (cr, &lx, &ly, w-stripe * (1. - symmetry) - dc, y);
288 _line_from_to (cr, &lx, &ly, w-dc, y);
289 _line_from_to (cr, &lx, &ly, w, y3);
290 cairo_close_path(cr);
291 }
292 }
293 }
294 else
295 {
296 gint exps_found = 0;
297 gfloat curx = 0.0;
298
299 if (expanded)
300 {
301 if (internal)
302 {
303 /* Auto-Stripe & Expanded & Internal */
304 GList *widgets = _get_applet_widgets (bg);
305 GList *i = widgets;
306 GtkWidget *widget = NULL;
307
308 /* analyze first widget*/
309 if (i)
310 {
311 widget = GTK_WIDGET (i->data);
312
313 /* if first widget is an expander or align==0 || 1*/
314 if ( (widget && GTK_IS_IMAGE (widget) && !AWN_IS_SEPARATOR (widget) ) ||
315 ( align == 0. || align == 1. ) )
316 {
317 /* start from bottom */
318 lx = curx;
319 ly = y;
320 cairo_move_to (cr, lx, ly);
321 _line_from_to (cr, &lx, &ly, lx, y2);
322 ++exps_found;
323 if (align != 0. && align != 1.)
324 i = i->next;
325 }
326 }
327 /* else start from top */
328
329 for (; i; i = i->next)
330 {
331 widget = GTK_WIDGET (i->data);
332
333 if (!GTK_IS_IMAGE (widget) || AWN_IS_SEPARATOR (widget))
334 {
335 /* if not expander continue */
336 continue;
337 }
338 /* expander found */
339 switch (position)
340 {
341 case GTK_POS_BOTTOM:
342 case GTK_POS_TOP:
343 curx = widget->allocation.x;
344 if (exps_found % 2 != 0)
345 curx += widget->allocation.width;
346 break;
347 default:
348 curx = widget->allocation.y;
349 if ( exps_found % 2 != 0)
350 curx += widget->allocation.height;
351 break;
352 }
353 if (curx < 0)
354 continue;
355
356 if (exps_found == 0)
357 {
358 /* this is the first expander */
359 lx = curx;
360 cairo_move_to (cr, lx, ly);
361 _line_from_to (cr, &lx, &ly, curx + d, y2);
362 }
363 else
364 {
365 if (exps_found % 2 != 0)
366 {
367 /* odd expander - curve at the end of expander */
368 _line_from_to (cr, &lx, &ly, curx - d, y2);
369 if (i->next != NULL)
370 _line_from_to (cr, &lx, &ly, curx, y);
371 /* else the last widget is an expander */
372 }
373 else
374 {
375 /* even expander - curve at the start of expander */
376 _line_from_to (cr, &lx, &ly, curx, y);
377 if (i->next != NULL)
378 _line_from_to (cr, &lx, &ly, curx + d, y2);
379 /* else the last widget is an expander */
380 }
381 }
382
383 ++exps_found;
384 }
385 g_list_free (widgets);
386
387 _line_from_to (cr, &lx, &ly, w, ly);
388
389 if (exps_found % 2 != 0)
390 _line_from_to (cr, &lx, &ly, lx, y);
391
392 cairo_close_path (cr);
393 }
394 else
395 {
396 /* Auto-Stripe & Expanded & External */
397
398 GList *widgets = _get_applet_widgets (bg);
399 GList *i = widgets;
400 GtkWidget *widget = NULL;
401
402 /* analyze first widget*/
403 if (i)
404 {
405 widget = GTK_WIDGET (i->data);
406
407 ly = y3;
408 cairo_move_to (cr, lx, ly);
409
410 /* if first widget is an expander or align==0 || 1*/
411 if ( (widget && GTK_IS_IMAGE (widget) && !AWN_IS_SEPARATOR (widget) ) ||
412 ( align == 0. || align == 1. ) )
413 {
414 /* start from bottom */
415 _line_from_to (cr, &lx, &ly, lx, y2);
416 ++exps_found;
417 if (align != 0. && align != 1.)
418 i = i->next;
419 }
420 else
421 {
422 /* start from top */
423 _line_from_to (cr, &lx, &ly, lx, y);
424 }
425 }
426
427 for (; i; i = i->next)
428 {
429 widget = GTK_WIDGET (i->data);
430
431 if (!GTK_IS_IMAGE (widget) || AWN_IS_SEPARATOR (widget))
432 {
433 /* if not expander continue */
434 continue;
435 }
436 /* expander found */
437 switch (position)
438 {
439 case GTK_POS_BOTTOM:
440 case GTK_POS_TOP:
441 curx = widget->allocation.x;
442 if (exps_found % 2 != 0)
443 curx += widget->allocation.width;
444 break;
445 default:
446 curx = widget->allocation.y;
447 if (exps_found % 2 != 0)
448 curx += widget->allocation.height;
449 break;
450 }
451 if (curx < 0)
452 continue;
453
454 if (exps_found % 2 != 0)
455 {
456 _line_from_to (cr, &lx, &ly, curx - d, y2);
457 _line_from_to (cr, &lx, &ly, curx, y);
458 }
459 else
460 {
461 _line_from_to (cr, &lx, &ly, curx, y);
462 _line_from_to (cr, &lx, &ly, curx + d, y2);
463 }
464 ++exps_found;
465 }
466 g_list_free (widgets);
467
468 _line_from_to (cr, &lx, &ly, w, ly);
469 _line_from_to (cr, &lx, &ly, lx, y3);
470
471 cairo_close_path (cr);
472 }
473 }
474 else
475 {
476 if (internal)
477 {
478 /* Auto-Stripe & Not-Expanded & Internal */
479 /* no-path */
480 }
481 else
482 {
483 /* Auto-Stripe & Not-Expanded & External */
484 ly = y3;
485 cairo_move_to (cr, lx, ly);
486
487 if (align == 0.)
488 _line_from_to (cr, &lx, &ly, lx , y);
489 else
490 _line_from_to (cr, &lx, &ly, lx + dc, y);
491
492 if (align == 1.)
493 _line_from_to (cr, &lx, &ly, w, y);
494 else
495 _line_from_to (cr, &lx, &ly, w - dc, y);
496
497 _line_from_to (cr, &lx, &ly, w, y3);
498 cairo_close_path (cr);
499 }
500 }
501 }
502}
503
504static void
505draw_top_bottom_background (AwnBackground* bg,
506 GtkPositionType position,
507 cairo_t* cr,
508 gint width,
509 gint height)
510{
511 cairo_pattern_t *pat = NULL;
512 cairo_pattern_t *pat_hi = NULL;
513
514 /* Make sure the bar gets drawn on the 0.5 pixels (for sharp edges) */
515 cairo_translate (cr, 0.5, 0.5);
516
517 /* Basic set-up */
518 cairo_set_line_width (cr, 1.0);
519 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
520
521 if(gtk_widget_is_composited (GTK_WIDGET (bg->panel) ) == FALSE)
522 {
523 goto paint_lines;
524 }
525
526 gboolean expand = FALSE;
527 g_object_get (bg->panel, "expand", &expand, NULL);
528
529 gfloat align = awn_background_get_panel_alignment (AWN_BACKGROUND (bg));
530
531 /* create internal path */
532 _create_path_lucido (bg, position, cr, -1.0, 0., width, height,
533 bg->stripe_width, bg->curviness,
534 bg->curviness, bg->curves_symmetry,
535 1, expand, align);
536
537 /* Draw internal pattern if needed */
538 if (bg->enable_pattern && bg->pattern)
539 {
540 /* Prepare pattern */
541 pat = cairo_pattern_create_for_surface (bg->pattern);
542 cairo_pattern_set_extend (pat, CAIRO_EXTEND_REPEAT);
543 /* Draw */
544 cairo_save (cr);
545 cairo_clip_preserve (cr);
546 cairo_set_source (cr, pat);
547 cairo_paint (cr);
548 cairo_restore (cr);
549 cairo_pattern_destroy (pat);
550 }
551
552 /* Prepare the internal background */
553 pat = cairo_pattern_create_linear (0, 0, 0, height);
554 awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->border_color);
555 awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->hilight_color);
556
557 /* Draw the internal background gradient */
558 cairo_save (cr);
559 cairo_clip_preserve (cr);
560 cairo_set_source (cr, pat);
561 cairo_paint (cr);
562 cairo_restore (cr);
563 cairo_pattern_destroy (pat);
564
565 /* Prepare external background gradient*/
566 pat = cairo_pattern_create_linear (0, 0, 0, height);
567 awn_cairo_pattern_add_color_stop_color (pat, 0.0, bg->g_step_1);
568 awn_cairo_pattern_add_color_stop_color (pat, 1.0, bg->g_step_2);
569
570 /* create external path */
571 _create_path_lucido (bg, position, cr, -1.0, 0., width, height,
572 bg->stripe_width, bg->curviness,
573 bg->curviness, bg->curves_symmetry,
574 0, expand, align);
575
576 /* Draw the external background */
577 cairo_save (cr);
578 cairo_clip_preserve (cr);
579 cairo_set_source (cr, pat);
580 cairo_paint (cr);
581 cairo_restore (cr);
582 cairo_pattern_destroy (pat);
583
584 /* Draw the hi-light */
585 pat_hi = cairo_pattern_create_linear (0, 0, 0, (height / 3.0));
586 awn_cairo_pattern_add_color_stop_color (pat_hi, 0.0, bg->g_histep_1);
587 awn_cairo_pattern_add_color_stop_color (pat_hi, 1.0, bg->g_histep_2);
588
589 if (expand)
590 {
591 cairo_new_path (cr);
592 cairo_rectangle (cr, 0, 0, width, (height / 3.0));
593 }
594
595 cairo_set_source (cr, pat_hi);
596 cairo_fill (cr);
597 cairo_pattern_destroy (pat_hi);
598
599 return;
600 /* if not composited */
601paint_lines:
602
603 /* Internal border */
604 awn_cairo_set_source_color (cr, bg->hilight_color);
605 cairo_rectangle (cr, 1, 1, width - 3, height + 3);
606 cairo_stroke (cr);
607
608 /* External border */
609 awn_cairo_set_source_color (cr, bg->border_color);
610 cairo_rectangle (cr, 1, 1, width - 1, height + 3);
611 cairo_stroke (cr);
612}
613
614
615static
616void awn_background_lucido_padding_request (AwnBackground *bg,
617 GtkPositionType position,
618 guint *padding_top,
619 guint *padding_bottom,
620 guint *padding_left,
621 guint *padding_right)
622{
623 #define TOP_PADDING 2
624 gboolean expand = FALSE;
625 g_object_get (bg->panel, "expand", &expand, NULL);
626 gint side_padding = expand ? 0 : bg->curviness;
627 gint zero_padding = 0;
628
629 gfloat align = awn_background_get_panel_alignment (bg);
630 if (awn_background_do_rtl_swap (bg))
631 {
632 if (align <= 0.0 || align >= 1.0)
633 {
634 zero_padding = side_padding;
635 side_padding = 0;
636 }
637 }
638
639 switch (position)
640 {
641 case GTK_POS_TOP:
642 *padding_top = 0;
643 *padding_bottom = TOP_PADDING;
644 *padding_left = align == 0.0 ? zero_padding : side_padding;
645 *padding_right = align == 1.0 ? zero_padding : side_padding;
646 break;
647 case GTK_POS_BOTTOM:
648 *padding_top = TOP_PADDING;
649 *padding_bottom = 0;
650 *padding_left = align == 0.0 ? zero_padding : side_padding;
651 *padding_right = align == 1.0 ? zero_padding : side_padding;
652 break;
653 case GTK_POS_LEFT:
654 *padding_top = align == 0.0 ? zero_padding : side_padding;
655 *padding_bottom = align == 1.0 ? zero_padding : side_padding;
656 *padding_left = 0;
657 *padding_right = TOP_PADDING;
658 break;
659 case GTK_POS_RIGHT:
660 *padding_top = align == 0.0 ? zero_padding : side_padding;
661 *padding_bottom = align == 1.0 ? zero_padding : side_padding;
662 *padding_left = TOP_PADDING;
663 *padding_right = 0;
664 break;
665 default:
666 break;
667 }
668}
669
670
671
672static void
673awn_background_lucido_draw (AwnBackground *bg,
674 cairo_t *cr,
675 GtkPositionType position,
676 GdkRectangle *area)
677{
678 gint temp;
679 gint x = area->x, y = area->y;
680 gint width = area->width, height = area->height;
681 cairo_save (cr);
682
683 switch (position)
684 {
685 case GTK_POS_RIGHT:
686 cairo_translate (cr, 0., y + height);
687 cairo_scale (cr, 1., -1.);
688 cairo_translate (cr, x, height);
689 cairo_rotate (cr, M_PI * 1.5);
690 temp = width;
691 width = height;
692 height = temp;
693 break;
694 case GTK_POS_LEFT:
695 cairo_translate (cr, x + width, y);
696 cairo_rotate (cr, M_PI * 0.5);
697 temp = width;
698 width = height;
699 height = temp;
700 break;
701 case GTK_POS_TOP:
702 cairo_translate (cr, x, y + height);
703 cairo_scale (cr, 1., -1.);
704 break;
705 default:
706 cairo_translate (cr, x, y);
707 break;
708 }
709
710 draw_top_bottom_background (bg, position, cr, width, height);
711
712 cairo_restore (cr);
713}
714
715static gboolean
716awn_background_lucido_get_needs_redraw (AwnBackground *bg,
717 GtkPositionType position,
718 GdkRectangle *area)
719{
720 /* Check default needs redraw */
721 gboolean nr = AWN_BACKGROUND_CLASS (awn_background_lucido_parent_class)->
722 get_needs_redraw (bg, position, area);
723 if (nr)
724 return TRUE;
725
726 /* Check expanders positions & sizes changed */
727 GList *widgets = _get_applet_widgets (bg);
728 GList *i = widgets;
729 GtkWidget *widget = NULL;
730 gint wcheck = 0;
731 gint ncheck = 0;
732
733 for (; i; i = i->next)
734 {
735 widget = GTK_WIDGET (i->data);
736
737 if (!GTK_IS_IMAGE (widget) || AWN_IS_SEPARATOR (widget))
738 {
739 /* if not expander continue */
740 continue;
741 }
742 switch (position)
743 {
744 case GTK_POS_BOTTOM:
745 case GTK_POS_TOP:
746 wcheck += widget->allocation.x * 2 + widget->allocation.width;
747 break;
748 default:
749 wcheck += widget->allocation.y * 2 + widget->allocation.height;
750 break;
751 }
752 ++ncheck;
753 }
754 g_list_free (widgets);
755
756 AwnBackgroundLucido *lbg = NULL;
757 lbg = AWN_BACKGROUND_LUCIDO (bg);
758 AwnBackgroundLucidoPrivate *priv;
759 priv = AWN_BACKGROUND_LUCIDO_GET_PRIVATE (lbg);
760 if (priv->expn != ncheck)
761 {
762 priv->expn = ncheck;
763 /* used to refresh bar */
764 AWN_PANEL_GET_CLASS (bg->panel)->padding_changed (bg->panel);
765 }
766 if (priv->expw != wcheck)
767 {
768 priv->expw = wcheck;
769 return TRUE;
770 }
771 return FALSE;
772}
773
774static void
775awn_background_lucido_get_shape_mask (AwnBackground *bg,
776 cairo_t *cr,
777 GtkPositionType position,
778 GdkRectangle *area)
779{
780 AWN_BACKGROUND_CLASS (awn_background_lucido_parent_class)->get_shape_mask (
781 bg, cr, position, area);
782}
783
784static
785void awn_background_lucido_property_changed (AwnBackground *bg,
786 guint prop_id)
787{
788 switch (prop_id)
789 {
790 case PROP_CURVINESS:
791 AWN_PANEL_GET_CLASS (bg->panel)->padding_changed (bg->panel);
792 break;
793 default:
794 break;
795 }
796}
797/* vim: set et ts=2 sts=2 sw=2 : */
0798
=== added file 'src/awn-background-lucido.h'
--- src/awn-background-lucido.h 1970-01-01 00:00:00 +0000
+++ src/awn-background-lucido.h 2010-05-30 13:41:34 +0000
@@ -0,0 +1,71 @@
1/*
2 * Copyright (C) 2009 Michal Hruby <michal.mhr@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Author : Alberto Aldegheri <albyrock87+dev@gmail.com>
19*/
20
21#ifndef _AWN_BACKGROUND_LUCIDO_H
22#define _AWN_BACKGROUND_LUCIDO_H
23
24#include <glib.h>
25#include <glib-object.h>
26#include <gtk/gtk.h>
27
28#include "awn-background-flat.h"
29
30G_BEGIN_DECLS
31
32#define AWN_TYPE_BACKGROUND_LUCIDO (awn_background_lucido_get_type())
33
34#define AWN_BACKGROUND_LUCIDO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AWN_TYPE_BACKGROUND_LUCIDO, \
35 AwnBackgroundLucido))
36
37#define AWN_BACKGROUND_LUCIDO_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), AWN_BACKGROUND_LUCIDO, \
38 AwnBackgroundLucidoClass))
39
40#define AWN_IS_BACKGROUND_LUCIDO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AWN_TYPE_BACKGROUND_LUCIDO))
41
42#define AWN_IS_BACKGROUND_LUCIDO_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), \
43 AWN_TYPE_BACKGROUND_LUCIDO))
44
45#define AWN_BACKGROUND_LUCIDO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
46 AWN_TYPE_BACKGROUND_LUCIDO, AwnBackgroundLucidoClass))
47
48typedef struct _AwnBackgroundLucido AwnBackgroundLucido;
49typedef struct _AwnBackgroundLucidoClass AwnBackgroundLucidoClass;
50typedef struct _AwnBackgroundLucidoPrivate AwnBackgroundLucidoPrivate;
51
52struct _AwnBackgroundLucido
53{
54 AwnBackgroundFlat parent;
55 AwnBackgroundLucidoPrivate *priv;
56};
57
58struct _AwnBackgroundLucidoClass
59{
60 AwnBackgroundFlatClass parent_class;
61};
62
63GType awn_background_lucido_get_type (void) G_GNUC_CONST;
64
65AwnBackground * awn_background_lucido_new (DesktopAgnosticConfigClient *client,
66 AwnPanel *panel);
67
68G_END_DECLS
69
70#endif /* _AWN_BACKGROUND_LUCIDO_H */
71
072
=== modified file 'src/awn-background.c'
--- src/awn-background.c 2010-04-08 15:38:05 +0000
+++ src/awn-background.c 2010-05-30 13:41:34 +0000
@@ -58,7 +58,8 @@
58 PROP_CORNER_RADIUS,58 PROP_CORNER_RADIUS,
59 PROP_PANEL_ANGLE,59 PROP_PANEL_ANGLE,
60 PROP_CURVINESS,60 PROP_CURVINESS,
61 PROP_CURVES_SYMEMETRY61 PROP_CURVES_SYMEMETRY,
62 PROP_STRIPE_WIDTH
62};63};
6364
64enum 65enum
@@ -90,6 +91,10 @@
90 GtkPositionType position,91 GtkPositionType position,
91 GdkRectangle *area);92 GdkRectangle *area);
9293
94static gboolean awn_background_get_needs_redraw (AwnBackground *bg,
95 GtkPositionType position,
96 GdkRectangle *area);
97
93static AwnPathType awn_background_path_default (AwnBackground *bg,98static AwnPathType awn_background_path_default (AwnBackground *bg,
94 gfloat *offset_mod);99 gfloat *offset_mod);
95100
@@ -186,6 +191,11 @@
186 object, "curves-symmetry", TRUE,191 object, "curves-symmetry", TRUE,
187 DESKTOP_AGNOSTIC_CONFIG_BIND_METHOD_FALLBACK,192 DESKTOP_AGNOSTIC_CONFIG_BIND_METHOD_FALLBACK,
188 NULL);193 NULL);
194 desktop_agnostic_config_client_bind (bg->client,
195 AWN_GROUP_THEME, AWN_THEME_STRIPE_WIDTH,
196 object, "stripe-width", TRUE,
197 DESKTOP_AGNOSTIC_CONFIG_BIND_METHOD_FALLBACK,
198 NULL);
189}199}
190200
191static void201static void
@@ -342,12 +352,21 @@
342 case PROP_CURVES_SYMEMETRY:352 case PROP_CURVES_SYMEMETRY:
343 bg->curves_symmetry = g_value_get_float (value);353 bg->curves_symmetry = g_value_get_float (value);
344 break;354 break;
355 case PROP_STRIPE_WIDTH:
356 bg->stripe_width = g_value_get_float (value);
357 break;
345358
346 default:359 default:
347 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);360 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
348 return;361 return;
349 }362 }
350363
364 AwnBackgroundClass *klass;
365 klass = AWN_BACKGROUND_GET_CLASS (bg);
366 if (klass->property_changed != NULL)
367 klass->property_changed (bg, prop_id);
368
369 awn_background_invalidate (bg);
351 g_signal_emit (object, _bg_signals[CHANGED], 0);370 g_signal_emit (object, _bg_signals[CHANGED], 0);
352}371}
353372
@@ -380,6 +399,12 @@
380 if (bg->hilight_color) g_object_unref (bg->hilight_color);399 if (bg->hilight_color) g_object_unref (bg->hilight_color);
381 if (bg->sep_color) g_object_unref (bg->sep_color);400 if (bg->sep_color) g_object_unref (bg->sep_color);
382401
402 if (bg->helper_surface != NULL)
403 {
404 cairo_surface_finish (bg->helper_surface);
405 cairo_surface_destroy (bg->helper_surface);
406 }
407
383 G_OBJECT_CLASS (awn_background_parent_class)->finalize (object);408 G_OBJECT_CLASS (awn_background_parent_class)->finalize (object);
384}409}
385410
@@ -398,6 +423,8 @@
398 klass->get_input_shape_mask = awn_background_mask_none;423 klass->get_input_shape_mask = awn_background_mask_none;
399 klass->get_path_type = awn_background_path_default;424 klass->get_path_type = awn_background_path_default;
400 klass->get_strut_offsets = NULL;425 klass->get_strut_offsets = NULL;
426 klass->get_needs_redraw = awn_background_get_needs_redraw;
427 klass->property_changed = NULL;
401428
402 /* Object properties */429 /* Object properties */
403 g_object_class_install_property (obj_class,430 g_object_class_install_property (obj_class,
@@ -575,6 +602,15 @@
575 0.0, 1.0, 0.5,602 0.0, 1.0, 0.5,
576 G_PARAM_READWRITE | G_PARAM_CONSTRUCT |603 G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
577 G_PARAM_STATIC_STRINGS));604 G_PARAM_STATIC_STRINGS));
605
606 g_object_class_install_property (obj_class,
607 PROP_STRIPE_WIDTH,
608 g_param_spec_float ("stripe-width",
609 "Stripe Width",
610 "The width of the stripe",
611 0.0, 1.0, 0.0,
612 G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
613 G_PARAM_STATIC_STRINGS));
578614
579 /* Add signals to the class */615 /* Add signals to the class */
580 _bg_signals[CHANGED] = 616 _bg_signals[CHANGED] =
@@ -650,6 +686,11 @@
650 bg->border_color = NULL;686 bg->border_color = NULL;
651 bg->hilight_color = NULL;687 bg->hilight_color = NULL;
652 bg->sep_color = NULL;688 bg->sep_color = NULL;
689 bg->needs_redraw = TRUE;
690 bg->helper_surface = NULL;
691 bg->cache_enabled = TRUE;
692 bg->last_height = 0;
693 bg->last_width = 0;
653}694}
654695
655void 696void
@@ -664,8 +705,40 @@
664 705
665 klass = AWN_BACKGROUND_GET_CLASS (bg);706 klass = AWN_BACKGROUND_GET_CLASS (bg);
666 g_return_if_fail (klass->draw != NULL);707 g_return_if_fail (klass->draw != NULL);
667708
668 klass->draw (bg, cr, position, area);709 /* Check if background caching is enabled - TRUE by default */
710 if (bg->cache_enabled)
711 {
712 g_return_if_fail (klass->get_needs_redraw != NULL);
713 cairo_save (cr);
714
715 /* Check if background needs to be redrawn */
716 if (klass->get_needs_redraw (bg, position, area))
717 {
718 /* Free last surface */
719 if (bg->helper_surface != NULL)
720 {
721 cairo_surface_finish (bg->helper_surface);
722 cairo_surface_destroy (bg->helper_surface);
723 }
724 /* Create new surface */
725 bg->helper_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
726 area->x + area->width,
727 area->y + area->height);
728 cairo_t* temp_cr = cairo_create (bg->helper_surface);
729 /* Draw background on temp cairo_t */
730 klass->draw (bg, temp_cr, position, area);
731 cairo_destroy (temp_cr);
732 }
733 /* Paint saved surface */
734 cairo_set_source_surface (cr, bg->helper_surface, 0., 0.);
735 cairo_paint(cr);
736 cairo_restore (cr);
737 }
738 else
739 {
740 klass->draw (bg, cr, position, area);
741 }
669}742}
670743
671void 744void
@@ -1009,4 +1082,25 @@
1009 return AWN_PATH_LINEAR;1082 return AWN_PATH_LINEAR;
1010}1083}
10111084
1085static gboolean awn_background_get_needs_redraw (AwnBackground *bg,
1086 GtkPositionType position,
1087 GdkRectangle *area)
1088{
1089 if (bg->needs_redraw == 1 ||
1090 bg->last_height != area->height ||
1091 bg->last_width != area->width)
1092 {
1093 bg->needs_redraw = 0;
1094 bg->last_height = area->height;
1095 bg->last_width = area->width;
1096 return TRUE;
1097 }
1098 return FALSE;
1099}
1100
1101void awn_background_invalidate (AwnBackground *bg)
1102{
1103 bg->needs_redraw = 1;
1104}
1105
1012/* vim: set et ts=2 sts=2 sw=2 : */1106/* vim: set et ts=2 sts=2 sw=2 : */
10131107
=== modified file 'src/awn-background.h'
--- src/awn-background.h 2010-03-07 18:38:07 +0000
+++ src/awn-background.h 2010-05-30 13:41:34 +0000
@@ -76,6 +76,15 @@
76 gfloat pattern_alpha;76 gfloat pattern_alpha;
77 GdkPixbuf *pattern_original;77 GdkPixbuf *pattern_original;
78 cairo_surface_t *pattern;78 cairo_surface_t *pattern;
79
80 /* Speedup code.
81 * We can save the bg and redraw only when properties changes
82 */
83 gboolean cache_enabled;
84 gboolean needs_redraw;
85 cairo_surface_t* helper_surface;
86 gint last_height;
87 gint last_width;
7988
80 /* FIXME:89 /* FIXME:
81 * These two should ultimately go somewhere else (once we do multiple panels)90 * These two should ultimately go somewhere else (once we do multiple panels)
@@ -89,6 +98,7 @@
89 gint panel_angle;98 gint panel_angle;
90 gfloat curviness;99 gfloat curviness;
91 gfloat curves_symmetry;100 gfloat curves_symmetry;
101 gfloat stripe_width;
92102
93 /* private */103 /* private */
94 guint changed;104 guint changed;
@@ -129,6 +139,13 @@
129 GdkRectangle *area,139 GdkRectangle *area,
130 gint *strut,140 gint *strut,
131 gint *strut_start, gint *strut_end);141 gint *strut_start, gint *strut_end);
142
143 gboolean (*get_needs_redraw) (AwnBackground *bg,
144 GtkPositionType position,
145 GdkRectangle *area);
146
147 void (*property_changed) (AwnBackground *bg,
148 guint prop_id);
132149
133 /*< signals >*/150 /*< signals >*/
134 void (*changed) (AwnBackground *bg);151 void (*changed) (AwnBackground *bg);
@@ -142,6 +159,8 @@
142 GtkPositionType position,159 GtkPositionType position,
143 GdkRectangle *area);160 GdkRectangle *area);
144161
162void awn_background_invalidate (AwnBackground *bg);
163
145void awn_background_padding_request (AwnBackground *bg,164void awn_background_padding_request (AwnBackground *bg,
146 GtkPositionType position,165 GtkPositionType position,
147 guint *padding_top,166 guint *padding_top,
148167
=== modified file 'src/awn-defines.h'
--- src/awn-defines.h 2010-02-06 13:34:02 +0000
+++ src/awn-defines.h 2010-05-30 13:41:34 +0000
@@ -87,6 +87,7 @@
87#define AWN_THEME_PANEL_ANGLE "panel_angle"87#define AWN_THEME_PANEL_ANGLE "panel_angle"
88#define AWN_THEME_CURVINESS "curviness"88#define AWN_THEME_CURVINESS "curviness"
89#define AWN_THEME_CURVES_SYMMETRY "curves_symmetry"89#define AWN_THEME_CURVES_SYMMETRY "curves_symmetry"
90#define AWN_THEME_STRIPE_WIDTH "stripe_width"
9091
91#endif /*_HAVE_AWN_DEFINES_H */92#endif /*_HAVE_AWN_DEFINES_H */
9293
9394
=== modified file 'src/awn-panel.c'
--- src/awn-panel.c 2010-05-29 17:17:22 +0000
+++ src/awn-panel.c 2010-05-30 13:41:34 +0000
@@ -43,6 +43,7 @@
43#include "awn-background-3d.h"43#include "awn-background-3d.h"
44#include "awn-background-curves.h"44#include "awn-background-curves.h"
45#include "awn-background-edgy.h"45#include "awn-background-edgy.h"
46#include "awn-background-lucido.h"
46#include "awn-background-floaty.h"47#include "awn-background-floaty.h"
47#include "awn-defines.h"48#include "awn-defines.h"
48#include "awn-marshal.h"49#include "awn-marshal.h"
@@ -222,6 +223,7 @@
222 STYLE_EDGY,223 STYLE_EDGY,
223 STYLE_FLOATY,224 STYLE_FLOATY,
224225
226 STYLE_LUCIDO,
225 STYLE_LAST227 STYLE_LAST
226};228};
227229
@@ -1075,6 +1077,9 @@
1075 }1077 }
10761078
1077 awn_panel_queue_masks_update (panel);1079 awn_panel_queue_masks_update (panel);
1080
1081 if (priv->bg)
1082 awn_background_invalidate (priv->bg);
1078}1083}
10791084
1080static1085static
@@ -1126,6 +1131,12 @@
1126 gtk_widget_queue_draw (GTK_WIDGET (panel));1131 gtk_widget_queue_draw (GTK_WIDGET (panel));
1127}1132}
11281133
1134static
1135void awn_panel_padding_changed (AwnPanel *panel)
1136{
1137 awn_panel_refresh_padding (panel, NULL);
1138}
1139
1129#ifdef DEBUG_APPLET_AREA1140#ifdef DEBUG_APPLET_AREA
1130static1141static
1131void awn_panel_get_applet_rect (AwnPanel *panel,1142void awn_panel_get_applet_rect (AwnPanel *panel,
@@ -1760,6 +1771,8 @@
1760 obj_class->finalize = awn_panel_finalize;1771 obj_class->finalize = awn_panel_finalize;
1761 obj_class->get_property = awn_panel_get_property;1772 obj_class->get_property = awn_panel_get_property;
1762 obj_class->set_property = awn_panel_set_property;1773 obj_class->set_property = awn_panel_set_property;
1774
1775 klass->padding_changed = awn_panel_padding_changed;
1763 1776
1764 cont_class->add = awn_panel_add;1777 cont_class->add = awn_panel_add;
1765 1778
@@ -3179,6 +3192,9 @@
3179 case STYLE_EDGY:3192 case STYLE_EDGY:
3180 priv->bg = awn_background_edgy_new (priv->client, panel);3193 priv->bg = awn_background_edgy_new (priv->client, panel);
3181 break;3194 break;
3195 case STYLE_LUCIDO:
3196 priv->bg = awn_background_lucido_new (priv->client, panel);
3197 break;
3182 case STYLE_FLOATY:3198 case STYLE_FLOATY:
3183 priv->bg = awn_background_floaty_new (priv->client, panel);3199 priv->bg = awn_background_floaty_new (priv->client, panel);
3184 break;3200 break;
31853201
=== modified file 'src/awn-panel.h'
--- src/awn-panel.h 2010-01-01 12:50:38 +0000
+++ src/awn-panel.h 2010-05-30 13:41:34 +0000
@@ -70,6 +70,7 @@
70 void (*offset_changed) (AwnPanel *panel, gint offset);70 void (*offset_changed) (AwnPanel *panel, gint offset);
71 void (*property_changed) (AwnPanel *panel,71 void (*property_changed) (AwnPanel *panel,
72 const gchar *prop_name, GValue *value);72 const gchar *prop_name, GValue *value);
73 void (*padding_changed) (AwnPanel *panel);
73 void (*destroy_notify) (AwnPanel *panel);74 void (*destroy_notify) (AwnPanel *panel);
74 void (*destroy_applet) (AwnPanel *panel, const gchar *uid);75 void (*destroy_applet) (AwnPanel *panel, const gchar *uid);
7576

Subscribers

People subscribed via source and target branches