diff options
| author | Neil Jagdish Patel <njpatel@Pulse> | 2010-07-28 16:46:51 +0100 |
|---|---|---|
| committer | Neil Jagdish Patel <njpatel@Pulse> | 2010-07-28 16:46:51 +0100 |
| commit | eb3d95c018b56377fff7ca28c7bad086dd7646b8 (patch) | |
| tree | 380f374d81d02ac941407d1345c3fc83a39ed792 /unity-private/panel | |
| parent | b2dadfee7137227dfde38a6cc321546d3df8a1e3 (diff) | |
Make the ubuntu button behave right
(bzr r403.2.21)
Diffstat (limited to 'unity-private/panel')
| -rw-r--r-- | unity-private/panel/panel-home-button.vala | 116 |
1 files changed, 63 insertions, 53 deletions
diff --git a/unity-private/panel/panel-home-button.vala b/unity-private/panel/panel-home-button.vala index ca712a106..eb8651d25 100644 --- a/unity-private/panel/panel-home-button.vala +++ b/unity-private/panel/panel-home-button.vala @@ -38,53 +38,6 @@ namespace Unity.Panel this); } - private override void allocate (Clutter.ActorBox box, - Clutter.AllocationFlags flags) - { - float cwidth; - float cheight; - float lwidth; - float pheight; - Ctk.Padding pad = { 0 }; - - lwidth = (float) shell.get_launcher_width_foobar (); - pheight = (float) shell.get_panel_height_foobar (); - theme_image.get_preferred_size (out cwidth, out cheight, - out cwidth, out cheight); - - /* adapt icon-width to launcher-width with padding */ - if (lwidth - cwidth <= 0.0f) - { - /* icon is wider or as wide as launcher */ - pad.left = 0.0f; - pad.right = pad.left; - } - else - { - /* icon is narrower than launcher */ - pad.left = (box.x2 - box.x1 - cwidth) / 2.0f; - pad.right = pad.left; - } - - /* adapt icon-height to panel-height with padding */ - if (pheight - cheight <= 0.0f) - { - /* icon higher or as high as launcher */ - pad.top = 0.0f; - pad.bottom = pad.top; - } - else - { - /* icon is smaller than launcher */ - pad.top = (box.y2 - box.y1 - cheight) / 2.0f; - pad.bottom = pad.top; - } - - padding = pad; - - base.allocate (box, flags); - } - construct { theme_image = new Ctk.Image.from_filename (22, "/usr/share/icons/unity-icon-theme/places/22/distributor-logo.png"); @@ -95,6 +48,8 @@ namespace Unity.Panel motion_event.connect (on_motion_event); clicked.connect (on_clicked); + shell.mode_changed.connect (on_mode_changed); + notify["state"].connect (on_state_changed); width += 3.0f; @@ -147,6 +102,53 @@ namespace Unity.Panel search_shown = false; } + private override void allocate (Clutter.ActorBox box, + Clutter.AllocationFlags flags) + { + float cwidth; + float cheight; + float lwidth; + float pheight; + Ctk.Padding pad = { 0 }; + + lwidth = (float) shell.get_launcher_width_foobar (); + pheight = (float) shell.get_panel_height_foobar (); + theme_image.get_preferred_size (out cwidth, out cheight, + out cwidth, out cheight); + + /* adapt icon-width to launcher-width with padding */ + if (lwidth - cwidth <= 0.0f) + { + /* icon is wider or as wide as launcher */ + pad.left = 0.0f; + pad.right = pad.left; + } + else + { + /* icon is narrower than launcher */ + pad.left = (box.x2 - box.x1 - cwidth) / 2.0f; + pad.right = pad.left; + } + + /* adapt icon-height to panel-height with padding */ + if (pheight - cheight <= 0.0f) + { + /* icon higher or as high as launcher */ + pad.top = 0.0f; + pad.bottom = pad.top; + } + else + { + /* icon is smaller than launcher */ + pad.top = (box.y2 - box.y1 - cheight) / 2.0f; + pad.bottom = pad.top; + } + + padding = pad; + + base.allocate (box, flags); + } + private void on_state_changed () { switch (this.get_state ()) @@ -180,13 +182,9 @@ namespace Unity.Panel nat_width = shell.get_launcher_width_foobar (); } - private void on_clicked () + private void on_mode_changed (ShellMode mode) { - shell.show_unity (); - MenuManager manager = MenuManager.get_default (); - manager.popdown_current_menu (); - - if (search_shown) + if (mode == ShellMode.MINIMIZED) { set_background_for_state (Ctk.ActorState.STATE_NORMAL, bfb_bg_normal); set_background_for_state (Ctk.ActorState.STATE_PRELIGHT, bfb_bg_prelight); @@ -200,9 +198,21 @@ namespace Unity.Panel set_background_for_state (Ctk.ActorState.STATE_ACTIVE, null); search_shown = true; } + + debug ("MODE_CHANGED"); + do_queue_redraw (); } + private void on_clicked () + { + shell.show_unity (); + MenuManager manager = MenuManager.get_default (); + manager.popdown_current_menu (); + + on_mode_changed (shell.get_mode ()); + } + private bool on_motion_event (Clutter.Event event) { shell.about_to_show_places (); |
