[gnome-music] Work on the searchbar (not searching yet, just showing up)



commit edb08d013aa7a6340b1a748f8324b7b3b26f33c6
Author: CÃsar GarcÃa Tapia <cesar garcia tapia openshine com>
Date:   Mon Nov 5 14:32:23 2012 +0100

    Work on the searchbar (not searching yet, just showing up)

 src/music-app.vala       |   21 +++++++++++++++------
 src/music-searchbar.vala |    7 ++++++-
 2 files changed, 21 insertions(+), 7 deletions(-)
---
diff --git a/src/music-app.vala b/src/music-app.vala
index e4ae0d8..4349ab2 100644
--- a/src/music-app.vala
+++ b/src/music-app.vala
@@ -131,6 +131,13 @@ private class Music.App {
                                    "wrap-license", true);
         });
         application.add_action (action);
+
+        action = new GLib.SimpleAction ("search", null);
+        action.activate.connect (() => {
+            this.search_mode = true;
+        });
+        application.add_action (action);
+        application.add_accelerator ("<Primary>f", "app.search", null);
     }
 
     private void setup_app () {
@@ -182,13 +189,8 @@ private class Music.App {
         layout.pack_start (topbar.actor, false, false);
 
         searchbar = new Music.Searchbar ();
-        if (search_mode == true) {
-            searchbar.show();
-        }
-        else {
-            searchbar.hide();
-        }
         layout.pack_start (searchbar.actor, false, false);
+        this.search_mode = false;
 
         notebook = new Gtk.Notebook ();
         notebook.show_border = false;
@@ -296,6 +298,13 @@ private class Music.App {
             if (value != this.search_mode) {
                 settings.set_boolean ("search", value);
             }
+            if (value == true) {
+                searchbar.show();
+                searchbar.grab_focus();
+            }
+            else {
+                searchbar.hide();
+            }
         }
     }
 
diff --git a/src/music-searchbar.vala b/src/music-searchbar.vala
index d33d5bb..7ffade0 100644
--- a/src/music-searchbar.vala
+++ b/src/music-searchbar.vala
@@ -29,6 +29,8 @@ private class Music.Searchbar {
 
     private void setup_ui () {
         eventbox = new Gtk.EventBox ();
+        eventbox.margin_top = 5;
+        eventbox.margin_bottom = 5;
         //eventbox.get_style_context ().add_class ("music-topbar");
 
         var container = new Gd.MarginContainer ();
@@ -37,7 +39,6 @@ private class Music.Searchbar {
         eventbox.add (container);
 
         var box = new Gtk.Box (Orientation.HORIZONTAL, 0);
-        box.set_padding (5, 5, 5, 5);
         container.add (box);
 
         search_entry = new Gd.TaggedEntry();
@@ -76,4 +77,8 @@ private class Music.Searchbar {
     public void hide () {
         actor.hide();
     }
+
+    public void grab_focus () {
+        search_entry.grab_focus ();
+    }
 }
\ No newline at end of file



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