[longomatch] Use a toolbar for the dashboard config



commit 1f162b735d965921e8335ff23a5782f56d0a44df
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Fri Aug 29 20:01:50 2014 +0200

    Use a toolbar for the dashboard config

 LongoMatch.GUI/Gui/Component/DashboardWidget.cs    |   82 ++++++++++++----
 .../LongoMatch.Gui.Component.DashboardWidget.cs    |   89 -----------------
 LongoMatch.GUI/gtk-gui/gui.stetic                  |  100 +-------------------
 3 files changed, 62 insertions(+), 209 deletions(-)
---
diff --git a/LongoMatch.GUI/Gui/Component/DashboardWidget.cs b/LongoMatch.GUI/Gui/Component/DashboardWidget.cs
index 751b504..d7f34b7 100644
--- a/LongoMatch.GUI/Gui/Component/DashboardWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/DashboardWidget.cs
@@ -44,7 +44,10 @@ namespace LongoMatch.Gui.Component
                Dashboard tagger;
                Categories template;
                TaggerButton selected;
-               bool internalButtons, edited, inFitModeChange;
+               Gtk.Image editimage;
+               ToggleToolButton editbutton;
+               RadioToolButton d11button, fillbutton, fitbutton;
+               bool internalButtons, edited, ignoreChanges;
 
                public DashboardWidget()
                {
@@ -68,21 +71,11 @@ namespace LongoMatch.Gui.Component
                        addscorebutton.Clicked += HandleAddClicked;
                        addtagbutton.Clicked += HandleAddClicked;
                        addcardbutton.Clicked += HandleAddClicked;
-                       editbutton.Clicked += HandleClicked;
 
-                       fitbutton.Toggled += HandleFitModeToggled;
-                       fillbutton.Toggled += HandleFitModeToggled;
-                       d11button.Toggled += HandleFitModeToggled;
-                       fitimage.Pixbuf = IconTheme.Default.LoadIcon ("longomatch-dash-fit",
-                                                                     22, IconLookupFlags.ForceSvg);
-                       fillimage.Pixbuf = IconTheme.Default.LoadIcon ("longomatch-dash-fill",
-                                                                      22, IconLookupFlags.ForceSvg);
-                       d11image.Pixbuf = IconTheme.Default.LoadIcon ("longomatch-dash-11",
-                                                                     22, IconLookupFlags.ForceSvg);
+                       FillToolbar ();
+                       FitMode = FitMode.Original;
                        Edited = false;
                        Mode = TagMode.Predefined;
-                       FitMode = FitMode.Original;
-
                        // Initialize to a sane default value.
                        tagproperties.Sensitive = false;
                }
@@ -101,15 +94,17 @@ namespace LongoMatch.Gui.Component
                
                public FitMode FitMode {
                        set {
-                               inFitModeChange = true;
-                               fillbutton.Active = value == FitMode.Fill;
-                               fitbutton.Active = value == FitMode.Fit;
-                               d11button.Active = value == FitMode.Original;
-                               inFitModeChange = false;
+                               ignoreChanges = true;
                                if (value == FitMode.Original) {
+                                       d11button.Active = true;
                                        dashscrolledwindow.HscrollbarPolicy = PolicyType.Automatic;
                                        dashscrolledwindow.VscrollbarPolicy = PolicyType.Automatic;
                                } else {
+                                       if (value == FitMode.Fill) {
+                                               fillbutton.Active = true;
+                                       } else if (value == FitMode.Fit) {
+                                               fitbutton.Active = true;
+                                       }
                                        drawingarea.WidthRequest = -1;
                                        drawingarea.HeightRequest = -1;
                                        dashscrolledwindow.HscrollbarPolicy = PolicyType.Never;
@@ -117,6 +112,7 @@ namespace LongoMatch.Gui.Component
                                }
                                tagger.FitMode = value;
                                tagger.Refresh ();
+                               ignoreChanges = false;
                        }
                }
 
@@ -145,19 +141,22 @@ namespace LongoMatch.Gui.Component
 
                public TagMode Mode {
                        set {
+                               ignoreChanges = true;
                                tagMode = value;
                                tagger.TagMode = value;
                                // Properties only visible in edit mode
                                rightbox.Visible = tagMode == TagMode.Edit;
                                // Add buttons for cards/tags/etc.. can be handled remotely.
                                hbuttonbox2.Visible = tagMode == TagMode.Edit && internalButtons;
-                               if (Mode == TagMode.Edit) {
+                               editbutton.Active = value == TagMode.Edit;
+                               if (value == TagMode.Edit) {
                                        editimage.Pixbuf = IconTheme.Default.LoadIcon 
("longomatch-dash-edit_active",
                                                                                       22, 
IconLookupFlags.ForceSvg);
                                } else {
                                        editimage.Pixbuf = IconTheme.Default.LoadIcon ("longomatch-dash-edit",
                                                                                       22, 
IconLookupFlags.ForceSvg);
                                }
+                               ignoreChanges = false;
                        }
                        get {
                                return tagMode;
@@ -208,6 +207,36 @@ namespace LongoMatch.Gui.Component
                        }
                }
                
+               void FillToolbar () {
+                       Toolbar toolbar = new Toolbar ();
+                       toolbar.Orientation = Orientation.Vertical;
+                       toolbar.ToolbarStyle = ToolbarStyle.Icons;
+                       
+                       editimage = new Gtk.Image (IconTheme.Default.LoadIcon ("longomatch-dash-edit_active",
+                                                                              22, IconLookupFlags.ForceSvg));
+                       editbutton = new ToggleToolButton ();
+                       editbutton.IconWidget = editimage;
+                       editbutton.Active = true;
+                       editbutton.Toggled += HandleEditToggled;
+                       toolbar.Add (editbutton);
+                       toolbar.Add (new SeparatorToolItem ());
+                       
+                       fitbutton = new RadioToolButton ((GLib.SList) null);
+                       fitbutton.IconName = "longomatch-dash-fit";
+                       fitbutton.Toggled += HandleFitModeToggled;
+                       toolbar.Add (fitbutton);
+                       fillbutton = new RadioToolButton (fitbutton);
+                       fillbutton.IconName = "longomatch-dash-fill";
+                       fillbutton.Toggled += HandleFitModeToggled;
+                       toolbar.Add (fillbutton);
+                       d11button = new RadioToolButton (fitbutton);
+                       d11button.IconName = "longomatch-dash-11";
+                       d11button.Toggled += HandleFitModeToggled;
+                       toolbar.Add (d11button);
+                       toolbar.ShowAll ();
+                       hbox2.PackEnd (toolbar, false, false, 0);
+               }
+
                void UpdateBackground (Image background, int index)
                {
                        if (index == 0) {
@@ -223,6 +252,18 @@ namespace LongoMatch.Gui.Component
                        Edited = true;
                }
                
+               void HandleEditToggled (object sender, EventArgs e)
+               {
+                       if (ignoreChanges) {
+                               return;
+                       }
+                       if (editbutton.Active) {
+                               Mode = TagMode.Edit;
+                       } else {
+                               Mode = TagMode.Predefined;
+                       }
+               }
+
                void HandleTaggersSelectedEvent (List<TaggerButton> taggers)
                {
                        if (taggers.Count == 1) {
@@ -359,7 +400,7 @@ namespace LongoMatch.Gui.Component
 
                void HandleFitModeToggled (object sender, EventArgs e)
                {
-                       if (inFitModeChange || !(sender as ToggleButton).Active) {
+                       if (ignoreChanges || !(sender as RadioToolButton).Active) {
                                return;
                        }
                        
@@ -372,6 +413,5 @@ namespace LongoMatch.Gui.Component
                        }
                        
                }
-
        }
 }
diff --git a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.DashboardWidget.cs 
b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.DashboardWidget.cs
index 8848b04..706fee7 100644
--- a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.DashboardWidget.cs
+++ b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.DashboardWidget.cs
@@ -48,16 +48,6 @@ namespace LongoMatch.Gui.Component
                private global::Gtk.Button resetgoalbutton;
                private global::Gtk.ScrolledWindow propertiesscrolledwindow;
                private global::LongoMatch.Gui.Component.CategoryProperties tagproperties;
-               private global::Gtk.VBox vbox4;
-               private global::Gtk.ToggleButton editbutton;
-               private global::Gtk.Image editimage;
-               private global::Gtk.HSeparator hseparator1;
-               private global::Gtk.ToggleButton fitbutton;
-               private global::Gtk.Image fitimage;
-               private global::Gtk.ToggleButton fillbutton;
-               private global::Gtk.Image fillimage;
-               private global::Gtk.ToggleButton d11button;
-               private global::Gtk.Image d11image;
 
                protected virtual void Build ()
                {
@@ -551,85 +541,6 @@ namespace LongoMatch.Gui.Component
                        w111.Position = 1;
                        w111.Expand = false;
                        w111.Fill = false;
-                       // Container child hbox2.Gtk.Box+BoxChild
-                       this.vbox4 = new global::Gtk.VBox ();
-                       this.vbox4.Name = "vbox4";
-                       this.vbox4.Spacing = 6;
-                       // Container child vbox4.Gtk.Box+BoxChild
-                       this.editbutton = new global::Gtk.ToggleButton ();
-                       this.editbutton.CanFocus = true;
-                       this.editbutton.Name = "editbutton";
-                       this.editbutton.Relief = ((global::Gtk.ReliefStyle)(2));
-                       // Container child editbutton.Gtk.Container+ContainerChild
-                       this.editimage = new global::Gtk.Image ();
-                       this.editimage.Name = "editimage";
-                       this.editbutton.Add (this.editimage);
-                       this.editbutton.Label = null;
-                       this.vbox4.Add (this.editbutton);
-                       global::Gtk.Box.BoxChild w113 = ((global::Gtk.Box.BoxChild)(this.vbox4 
[this.editbutton]));
-                       w113.Position = 0;
-                       w113.Expand = false;
-                       w113.Fill = false;
-                       // Container child vbox4.Gtk.Box+BoxChild
-                       this.hseparator1 = new global::Gtk.HSeparator ();
-                       this.hseparator1.Name = "hseparator1";
-                       this.vbox4.Add (this.hseparator1);
-                       global::Gtk.Box.BoxChild w114 = ((global::Gtk.Box.BoxChild)(this.vbox4 
[this.hseparator1]));
-                       w114.Position = 1;
-                       w114.Expand = false;
-                       w114.Fill = false;
-                       // Container child vbox4.Gtk.Box+BoxChild
-                       this.fitbutton = new global::Gtk.ToggleButton ();
-                       this.fitbutton.CanFocus = true;
-                       this.fitbutton.Name = "fitbutton";
-                       this.fitbutton.FocusOnClick = false;
-                       this.fitbutton.Relief = ((global::Gtk.ReliefStyle)(2));
-                       this.fitbutton.Active = true;
-                       // Container child fitbutton.Gtk.Container+ContainerChild
-                       this.fitimage = new global::Gtk.Image ();
-                       this.fitimage.Name = "fitimage";
-                       this.fitbutton.Add (this.fitimage);
-                       this.fitbutton.Label = null;
-                       this.vbox4.Add (this.fitbutton);
-                       global::Gtk.Box.BoxChild w116 = ((global::Gtk.Box.BoxChild)(this.vbox4 
[this.fitbutton]));
-                       w116.Position = 2;
-                       w116.Expand = false;
-                       w116.Fill = false;
-                       // Container child vbox4.Gtk.Box+BoxChild
-                       this.fillbutton = new global::Gtk.ToggleButton ();
-                       this.fillbutton.CanFocus = true;
-                       this.fillbutton.Name = "fillbutton";
-                       this.fillbutton.Relief = ((global::Gtk.ReliefStyle)(2));
-                       // Container child fillbutton.Gtk.Container+ContainerChild
-                       this.fillimage = new global::Gtk.Image ();
-                       this.fillimage.Name = "fillimage";
-                       this.fillbutton.Add (this.fillimage);
-                       this.fillbutton.Label = null;
-                       this.vbox4.Add (this.fillbutton);
-                       global::Gtk.Box.BoxChild w118 = ((global::Gtk.Box.BoxChild)(this.vbox4 
[this.fillbutton]));
-                       w118.Position = 3;
-                       w118.Expand = false;
-                       w118.Fill = false;
-                       // Container child vbox4.Gtk.Box+BoxChild
-                       this.d11button = new global::Gtk.ToggleButton ();
-                       this.d11button.CanFocus = true;
-                       this.d11button.Name = "d11button";
-                       this.d11button.Relief = ((global::Gtk.ReliefStyle)(2));
-                       // Container child d11button.Gtk.Container+ContainerChild
-                       this.d11image = new global::Gtk.Image ();
-                       this.d11image.Name = "d11image";
-                       this.d11button.Add (this.d11image);
-                       this.d11button.Label = null;
-                       this.vbox4.Add (this.d11button);
-                       global::Gtk.Box.BoxChild w120 = ((global::Gtk.Box.BoxChild)(this.vbox4 
[this.d11button]));
-                       w120.Position = 4;
-                       w120.Expand = false;
-                       w120.Fill = false;
-                       this.hbox2.Add (this.vbox4);
-                       global::Gtk.Box.BoxChild w121 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.vbox4]));
-                       w121.Position = 2;
-                       w121.Expand = false;
-                       w121.Fill = false;
                        this.Add (this.hbox2);
                        if ((this.Child != null)) {
                                this.Child.ShowAll ();
diff --git a/LongoMatch.GUI/gtk-gui/gui.stetic b/LongoMatch.GUI/gtk-gui/gui.stetic
index f7f5d93..811eeda 100644
--- a/LongoMatch.GUI/gtk-gui/gui.stetic
+++ b/LongoMatch.GUI/gtk-gui/gui.stetic
@@ -597,105 +597,7 @@
           </packing>
         </child>
         <child>
-          <widget class="Gtk.VBox" id="vbox4">
-            <property name="MemberName" />
-            <property name="Spacing">6</property>
-            <child>
-              <widget class="Gtk.ToggleButton" id="editbutton">
-                <property name="MemberName" />
-                <property name="CanFocus">True</property>
-                <property name="Type">Custom</property>
-                <property name="Relief">None</property>
-                <child>
-                  <widget class="Gtk.Image" id="editimage">
-                    <property name="MemberName" />
-                  </widget>
-                </child>
-              </widget>
-              <packing>
-                <property name="Position">0</property>
-                <property name="AutoSize">True</property>
-                <property name="Expand">False</property>
-                <property name="Fill">False</property>
-              </packing>
-            </child>
-            <child>
-              <widget class="Gtk.HSeparator" id="hseparator1">
-                <property name="MemberName" />
-              </widget>
-              <packing>
-                <property name="Position">1</property>
-                <property name="AutoSize">True</property>
-                <property name="Expand">False</property>
-                <property name="Fill">False</property>
-              </packing>
-            </child>
-            <child>
-              <widget class="Gtk.ToggleButton" id="fitbutton">
-                <property name="MemberName" />
-                <property name="CanFocus">True</property>
-                <property name="Type">Custom</property>
-                <property name="FocusOnClick">False</property>
-                <property name="Relief">None</property>
-                <property name="Active">True</property>
-                <child>
-                  <widget class="Gtk.Image" id="fitimage">
-                    <property name="MemberName" />
-                  </widget>
-                </child>
-              </widget>
-              <packing>
-                <property name="Position">2</property>
-                <property name="AutoSize">True</property>
-                <property name="Expand">False</property>
-                <property name="Fill">False</property>
-              </packing>
-            </child>
-            <child>
-              <widget class="Gtk.ToggleButton" id="fillbutton">
-                <property name="MemberName" />
-                <property name="CanFocus">True</property>
-                <property name="Type">Custom</property>
-                <property name="Relief">None</property>
-                <child>
-                  <widget class="Gtk.Image" id="fillimage">
-                    <property name="MemberName" />
-                  </widget>
-                </child>
-              </widget>
-              <packing>
-                <property name="Position">3</property>
-                <property name="AutoSize">True</property>
-                <property name="Expand">False</property>
-                <property name="Fill">False</property>
-              </packing>
-            </child>
-            <child>
-              <widget class="Gtk.ToggleButton" id="d11button">
-                <property name="MemberName" />
-                <property name="CanFocus">True</property>
-                <property name="Type">Custom</property>
-                <property name="Relief">None</property>
-                <child>
-                  <widget class="Gtk.Image" id="d11image">
-                    <property name="MemberName" />
-                  </widget>
-                </child>
-              </widget>
-              <packing>
-                <property name="Position">4</property>
-                <property name="AutoSize">True</property>
-                <property name="Expand">False</property>
-                <property name="Fill">False</property>
-              </packing>
-            </child>
-          </widget>
-          <packing>
-            <property name="Position">2</property>
-            <property name="AutoSize">True</property>
-            <property name="Expand">False</property>
-            <property name="Fill">False</property>
-          </packing>
+          <placeholder />
         </child>
       </widget>
     </child>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]