[gnome-control-center/wip/feborges/new-search-panel: 25/25] search: Add notification advertising the reordering shortcuts



commit f53595b91d0c001cb2a90c7fbc072451a161ee2a
Author: Felipe Borges <felipeborges gnome org>
Date:   Wed Aug 9 16:17:47 2017 +0200

    search: Add notification advertising the reordering shortcuts
    
    When a list row is selected, reveal a notification instructing
    how to reorder the list with the keyboard shortcuts.
    
    "Use Alt+↑ and Alt+↓ to move rows"
    
    https://bugzilla.gnome.org/show_bug.cgi?id=775958

 panels/search/cc-search-panel.c |   16 ++++++++++++++--
 panels/search/search.ui         |   24 +++++++++++++++++++++++-
 2 files changed, 37 insertions(+), 3 deletions(-)
---
diff --git a/panels/search/cc-search-panel.c b/panels/search/cc-search-panel.c
index 27b8bcc..2358252 100644
--- a/panels/search/cc-search-panel.c
+++ b/panels/search/cc-search-panel.c
@@ -36,6 +36,7 @@ struct _CcSearchPanelPrivate
 {
   GtkBuilder *builder;
   GtkWidget  *list_box;
+  GtkWidget  *notification;
 
   GCancellable *load_cancellable;
   GSettings  *search_settings;
@@ -869,6 +870,14 @@ populate_search_providers (CcSearchPanel *self)
 }
 
 static void
+on_row_selected (GtkListBox *list_box,
+                 GtkListBoxRow *row,
+                 CcSearchPanel *self)
+{
+  gtk_revealer_set_reveal_child (GTK_REVEALER (self->priv->notification), TRUE);
+}
+
+static void
 cc_search_panel_dispose (GObject *object)
 {
   CcSearchPanelPrivate *priv = CC_SEARCH_PANEL (object)->priv;
@@ -993,6 +1002,9 @@ cc_search_panel_init (CcSearchPanel *self)
   gtk_container_add (GTK_CONTAINER (frame), widget);
   self->priv->list_box = widget;
   gtk_widget_show (widget);
+  g_signal_connect (widget, "row-selected", G_CALLBACK (on_row_selected), self);
+
+  self->priv->notification = WID ("notification");
 
   /* Drag and Drop */
   gtk_drag_dest_set (self->priv->list_box,
@@ -1028,7 +1040,7 @@ cc_search_panel_init (CcSearchPanel *self)
 
   populate_search_providers (self);
 
-  widget = WID ("search_vbox");
+  widget = WID ("scrolled_window");
 
   /* For the cc_list_box_adjust_scrolling () helper function. */
   g_object_set_data (G_OBJECT (self->priv->list_box),
@@ -1036,7 +1048,7 @@ cc_search_panel_init (CcSearchPanel *self)
   g_object_set_data (G_OBJECT (self->priv->list_box),
                      "cc-max-rows-visible", GUINT_TO_POINTER (MAX_ROWS_VISIBLE));
 
-  gtk_container_add (GTK_CONTAINER (self), widget);
+  gtk_container_add (GTK_CONTAINER (self), WID ("search_vbox"));
 }
 
 static void
diff --git a/panels/search/search.ui b/panels/search/search.ui
index 4f446dc..2d97564 100644
--- a/panels/search/search.ui
+++ b/panels/search/search.ui
@@ -1,7 +1,27 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
-  <object class="GtkScrolledWindow" id="search_vbox">
+<object class="GtkOverlay" id="search_vbox">
+  <property name="visible">True</property>
+  <child type="overlay">
+    <object class="GtkRevealer" id="notification">
+      <property name="visible">True</property>
+      <property name="halign">center</property>
+      <property name="valign">start</property>
+      <property name="border-width">6</property>
+      <child>
+        <object class="GtkLabel">
+          <property name="visible">True</property>
+          <property name="label" translatable="yes">Use Alt+↑ and Alt+↓ to move rows</property>
+          <style>
+            <class name="app-notification"/>
+          </style>
+        </object>
+      </child>
+    </object>
+  </child>
+  <child>
+  <object class="GtkScrolledWindow" id="scrolled_window">
     <property name="visible">True</property>
     <property name="hscrollbar_policy">never</property>
     <property name="min_content_height">450</property>
@@ -85,4 +105,6 @@
       </object>
     </child>
  </object>
+  </child>
+</object>
 </interface>


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