[epiphany] history-dialog: Add the empty and no results panels



commit f8ccff522c002aefaea60d04020f0ce4adf01dee
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Wed May 29 14:49:48 2019 +0200

    history-dialog: Add the empty and no results panels
    
    Show better looking panels when the history is empty and when the search
    gave no results.

 src/ephy-history-dialog.c           |  13 +++
 src/resources/gtk/history-dialog.ui | 158 ++++++++++++++++++++++++++++++++++--
 2 files changed, 166 insertions(+), 5 deletions(-)
---
diff --git a/src/ephy-history-dialog.c b/src/ephy-history-dialog.c
index 5570ba7a3..b20d066e0 100644
--- a/src/ephy-history-dialog.c
+++ b/src/ephy-history-dialog.c
@@ -54,6 +54,7 @@ struct _EphyHistoryDialog {
   GtkWidget *popup_menu;
   GtkWidget *search_bar;
   GtkWidget *search_button;
+  GtkWidget *stack;
 
   GActionGroup *action_group;
 
@@ -326,6 +327,16 @@ add_urls_source (EphyHistoryDialog *self)
   EphyHistoryURL *url;
   GList *element;
   GtkWidget *row;
+  GList *children;
+
+  children = gtk_container_get_children (GTK_CONTAINER (self->listbox));
+  if (!children) {
+    if (!self->search_text || g_strcmp0 (self->search_text, "") == 0)
+      gtk_stack_set_visible_child_name (GTK_STACK (self->stack), "empty");
+    else
+      gtk_stack_set_visible_child_name (GTK_STACK (self->stack), "no-results");
+  }
+  g_list_free (children);
 
   if (self->urls == NULL || !self->num_fetch) {
     self->sorter_source = 0;
@@ -338,6 +349,7 @@ add_urls_source (EphyHistoryDialog *self)
 
   row = create_row (self, url);
   gtk_list_box_insert (GTK_LIST_BOX(self->listbox), row, -1);
+  gtk_stack_set_visible_child_name (GTK_STACK (self->stack), "results");
 
   self->urls = g_list_remove_link (self->urls, element);
   ephy_history_url_free (url);
@@ -774,6 +786,7 @@ ephy_history_dialog_class_init (EphyHistoryDialogClass *klass)
   gtk_widget_class_bind_template_child (widget_class, EphyHistoryDialog, popup_menu);
   gtk_widget_class_bind_template_child (widget_class, EphyHistoryDialog, search_bar);
   gtk_widget_class_bind_template_child (widget_class, EphyHistoryDialog, search_button);
+  gtk_widget_class_bind_template_child (widget_class, EphyHistoryDialog, stack);
 
   gtk_widget_class_bind_template_callback (widget_class, on_listbox_row_activated);
   gtk_widget_class_bind_template_callback (widget_class, on_listbox_row_selected);
diff --git a/src/resources/gtk/history-dialog.ui b/src/resources/gtk/history-dialog.ui
index 3cbd69437..f029d4df2 100644
--- a/src/resources/gtk/history-dialog.ui
+++ b/src/resources/gtk/history-dialog.ui
@@ -82,14 +82,87 @@
           </packing>
         </child>
         <child>
-          <object class="GtkScrolledWindow" id="scrolled_window">
+          <object class="GtkStack" id="stack">
+            <property name="can_focus">False</property>
+            <property name="expand">True</property>
             <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <signal name="edge-reached" handler="on_edge_reached" object="EphyHistoryDialog" swapped="no"/>
             <child>
-              <object class="GtkViewport">
-                <property name="visible">True</property>
+              <object class="GtkScrolledWindow">
                 <property name="can_focus">False</property>
+                <property name="expand">True</property>
+                <property name="hscrollbar_policy">never</property>
+                <property name="visible">True</property>
+                <child>
+                  <object class="GtkBox">
+                    <property name="can_focus">False</property>
+                    <property name="halign">center</property>
+                    <property name="orientation">vertical</property>
+                    <property name="valign">center</property>
+                    <property name="vexpand">True</property>
+                    <property name="visible">True</property>
+                    <child>
+                      <object class="GtkImage">
+                        <property name="can_focus">False</property>
+                        <property name="icon_name">web-browser-symbolic</property>
+                        <property name="icon_size">0</property>
+                        <property name="margin_bottom">18</property>
+                        <property name="pixel_size">128</property>
+                        <property name="valign">center</property>
+                        <property name="visible">True</property>
+                        <style>
+                          <class name="dim-label"/>
+                        </style>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkBox">
+                        <property name="can_focus">False</property>
+                        <property name="margin_end">12</property>
+                        <property name="margin_start">12</property>
+                        <property name="orientation">vertical</property>
+                        <property name="visible">True</property>
+                        <child>
+                          <object class="GtkLabel">
+                            <property name="can_focus">False</property>
+                            <property name="halign">center</property>
+                            <property name="justify">center</property>
+                            <property name="label" translatable="yes">The History is Empty</property>
+                            <property name="margin_bottom">12</property>
+                            <property name="opacity">0.5</property>
+                            <property name="visible">True</property>
+                            <property name="wrap">True</property>
+                            <attributes>
+                              <attribute name="scale" value="2"/>
+                              <attribute name="weight" value="bold"/>
+                            </attributes>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkLabel">
+                            <property name="can_focus">False</property>
+                            <property name="justify">center</property>
+                            <property name="label" translatable="yes">Visited pages will be listed 
here</property>
+                            <property name="margin_bottom">6</property>
+                            <property name="opacity">0.5</property>
+                            <property name="use_markup">True</property>
+                            <property name="visible">True</property>
+                            <property name="wrap">True</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="name">empty</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkScrolledWindow" id="scrolled_window">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <signal name="edge-reached" handler="on_edge_reached" object="EphyHistoryDialog" 
swapped="no"/>
                 <child>
                   <object class="HdyColumn">
                     <property name="visible">True</property>
@@ -118,6 +191,81 @@
                   </object>
                 </child>
               </object>
+              <packing>
+                <property name="name">results</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkScrolledWindow">
+                <property name="can_focus">False</property>
+                <property name="expand">True</property>
+                <property name="hscrollbar_policy">never</property>
+                <property name="visible">True</property>
+                <child>
+                  <object class="GtkBox">
+                    <property name="can_focus">False</property>
+                    <property name="halign">center</property>
+                    <property name="orientation">vertical</property>
+                    <property name="valign">center</property>
+                    <property name="vexpand">True</property>
+                    <property name="visible">True</property>
+                    <child>
+                      <object class="GtkImage">
+                        <property name="can_focus">False</property>
+                        <property name="icon_name">edit-find-symbolic</property>
+                        <property name="icon_size">0</property>
+                        <property name="margin_bottom">18</property>
+                        <property name="pixel_size">128</property>
+                        <property name="valign">center</property>
+                        <property name="visible">True</property>
+                        <style>
+                          <class name="dim-label"/>
+                        </style>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkBox">
+                        <property name="can_focus">False</property>
+                        <property name="margin_end">12</property>
+                        <property name="margin_start">12</property>
+                        <property name="orientation">vertical</property>
+                        <property name="visible">True</property>
+                        <child>
+                          <object class="GtkLabel">
+                            <property name="can_focus">False</property>
+                            <property name="halign">center</property>
+                            <property name="justify">center</property>
+                            <property name="label" translatable="yes">No Results Found</property>
+                            <property name="margin_bottom">12</property>
+                            <property name="opacity">0.5</property>
+                            <property name="visible">True</property>
+                            <property name="wrap">True</property>
+                            <attributes>
+                              <attribute name="scale" value="2"/>
+                              <attribute name="weight" value="bold"/>
+                            </attributes>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkLabel">
+                            <property name="can_focus">False</property>
+                            <property name="justify">center</property>
+                            <property name="label" translatable="yes">Try a different search</property>
+                            <property name="margin_bottom">6</property>
+                            <property name="opacity">0.5</property>
+                            <property name="use_markup">True</property>
+                            <property name="visible">True</property>
+                            <property name="wrap">True</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="name">no-results</property>
+              </packing>
             </child>
           </object>
           <packing>


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