[gnome-control-center] search: Use AdwPreferences{Window, Page, Group} for location dialog
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] search: Use AdwPreferences{Window, Page, Group} for location dialog
- Date: Wed, 9 Feb 2022 14:05:50 +0000 (UTC)
commit ddb979abfd1415434a2a51ce35785a489f53fb97
Author: Christopher Davis <christopherdavis gnome org>
Date: Tue Feb 8 18:46:04 2022 -0800
search: Use AdwPreferences{Window,Page,Group} for location dialog
Gives us more modern styling for the search locations
window.
panels/search/cc-search-locations-dialog.c | 59 ++++++++--
panels/search/cc-search-locations-dialog.h | 2 +-
panels/search/cc-search-locations-dialog.ui | 170 +++++++++-------------------
3 files changed, 105 insertions(+), 126 deletions(-)
---
diff --git a/panels/search/cc-search-locations-dialog.c b/panels/search/cc-search-locations-dialog.c
index 73455c5ae..4d31be4d5 100644
--- a/panels/search/cc-search-locations-dialog.c
+++ b/panels/search/cc-search-locations-dialog.c
@@ -43,21 +43,39 @@ typedef struct {
} Place;
struct _CcSearchLocationsDialog {
- GtkDialog parent;
+ AdwPreferencesWindow parent;
- GSettings *tracker_preferences;
+ GSettings *tracker_preferences;
- GtkWidget *places_list;
- GtkWidget *bookmarks_list;
- GtkWidget *others_list;
- GtkWidget *locations_add;
+ GtkWidget *places_group;
+ GtkWidget *places_list;
+ GtkWidget *bookmarks_group;
+ GtkWidget *bookmarks_list;
+ GtkWidget *others_list;
+ GtkWidget *locations_add;
};
struct _CcSearchLocationsDialogClass {
- GtkDialogClass parent_class;
+ AdwPreferencesWindowClass parent_class;
};
-G_DEFINE_TYPE (CcSearchLocationsDialog, cc_search_locations_dialog, GTK_TYPE_DIALOG)
+G_DEFINE_TYPE (CcSearchLocationsDialog, cc_search_locations_dialog, ADW_TYPE_PREFERENCES_WINDOW)
+
+static gboolean
+keynav_failed_cb (CcSearchLocationsDialog *self,
+ GtkDirectionType direction)
+{
+ GtkWidget *toplevel = GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (self)));
+
+ if (!toplevel)
+ return FALSE;
+
+ if (direction != GTK_DIR_UP && direction != GTK_DIR_DOWN)
+ return FALSE;
+
+ return gtk_widget_child_focus (toplevel, direction == GTK_DIR_UP ?
+ GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD);
+}
static void
cc_search_locations_dialog_finalize (GObject *object)
@@ -570,6 +588,20 @@ create_row_for_place (CcSearchLocationsDialog *self, Place *place)
return row;
}
+static void
+update_list_visibility (CcSearchLocationsDialog *self)
+{
+ gtk_widget_set_visible (self->places_group,
+ gtk_list_box_get_row_at_index (GTK_LIST_BOX (self->places_list), 0)
+ != NULL);
+ gtk_widget_set_visible (self->bookmarks_group,
+ gtk_list_box_get_row_at_index (GTK_LIST_BOX (self->bookmarks_list), 0)
+ != NULL);
+ gtk_widget_set_visible (self->others_list,
+ gtk_list_box_get_row_at_index (GTK_LIST_BOX (self->others_list), 0)
+ != NULL);
+}
+
static void
populate_list_boxes (CcSearchLocationsDialog *self)
{
@@ -599,6 +631,8 @@ populate_list_boxes (CcSearchLocationsDialog *self)
g_assert_not_reached ();
}
}
+
+ update_list_visibility (self);
}
static void
@@ -668,6 +702,8 @@ other_places_refresh (CcSearchLocationsDialog *self)
row = create_row_for_place (self, place);
gtk_list_box_append (GTK_LIST_BOX (self->others_list), row);
}
+
+ update_list_visibility (self);
}
CcSearchLocationsDialog *
@@ -679,9 +715,7 @@ cc_search_locations_dialog_new (CcSearchPanel *panel)
GtkWidget *toplevel;
CcShell *shell;
- self = g_object_new (CC_SEARCH_LOCATIONS_DIALOG_TYPE,
- "use-header-bar", TRUE,
- NULL);
+ self = g_object_new (CC_SEARCH_LOCATIONS_DIALOG_TYPE, NULL);
source = g_settings_schema_source_get_default ();
schema = g_settings_schema_source_lookup (source, TRACKER3_SCHEMA, TRUE);
@@ -737,10 +771,13 @@ cc_search_locations_dialog_class_init (CcSearchLocationsDialogClass *klass)
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/control-center/search/cc-search-locations-dialog.ui");
+ gtk_widget_class_bind_template_child (widget_class, CcSearchLocationsDialog, places_group);
gtk_widget_class_bind_template_child (widget_class, CcSearchLocationsDialog, places_list);
+ gtk_widget_class_bind_template_child (widget_class, CcSearchLocationsDialog, bookmarks_group);
gtk_widget_class_bind_template_child (widget_class, CcSearchLocationsDialog, bookmarks_list);
gtk_widget_class_bind_template_child (widget_class, CcSearchLocationsDialog, others_list);
gtk_widget_class_bind_template_child (widget_class, CcSearchLocationsDialog, locations_add);
gtk_widget_class_bind_template_callback (widget_class, add_button_clicked);
+ gtk_widget_class_bind_template_callback (widget_class, keynav_failed_cb);
}
diff --git a/panels/search/cc-search-locations-dialog.h b/panels/search/cc-search-locations-dialog.h
index 912f2f082..4e2b5b3ed 100644
--- a/panels/search/cc-search-locations-dialog.h
+++ b/panels/search/cc-search-locations-dialog.h
@@ -23,7 +23,7 @@
#include "cc-search-panel.h"
#define CC_SEARCH_LOCATIONS_DIALOG_TYPE (cc_search_locations_dialog_get_type ())
-G_DECLARE_FINAL_TYPE (CcSearchLocationsDialog, cc_search_locations_dialog, CC, SEARCH_LOCATIONS_DIALOG,
GtkDialog)
+G_DECLARE_FINAL_TYPE (CcSearchLocationsDialog, cc_search_locations_dialog, CC, SEARCH_LOCATIONS_DIALOG,
AdwPreferencesWindow)
CcSearchLocationsDialog *cc_search_locations_dialog_new (CcSearchPanel *panel);
diff --git a/panels/search/cc-search-locations-dialog.ui b/panels/search/cc-search-locations-dialog.ui
index 9549d0b22..416ade169 100644
--- a/panels/search/cc-search-locations-dialog.ui
+++ b/panels/search/cc-search-locations-dialog.ui
@@ -1,132 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
- <template class="CcSearchLocationsDialog" parent="GtkDialog">
- <property name="default_height">400</property>
- <property name="default_width">360</property>
+ <template class="CcSearchLocationsDialog" parent="AdwPreferencesWindow">
<property name="modal">True</property>
+ <property name="hide-on-close">True</property>
+ <property name="search-enabled">False</property>
<property name="title" translatable="yes">Search Locations</property>
- <property name="use_header_bar">1</property>
<child>
- <object class="GtkBox">
- <property name="orientation">vertical</property>
+ <object class="AdwPreferencesPage">
<child>
- <object class="GtkNotebook">
- <property name="show-border">False</property>
+ <object class="AdwPreferencesGroup">
+ <property name="description" translatable="yes">Folders which are searched by system
applications, such as Files, Photos and Videos.</property>
+ </object>
+ </child>
+ <child>
+ <object class="AdwPreferencesGroup" id="places_group">
+ <property name="title" translatable="yes">Places</property>
<child>
- <object class="GtkBox">
- <property name="vexpand">True</property>
- <property name="margin-top">35</property>
- <property name="margin-bottom">35</property>
- <property name="margin-start">35</property>
- <property name="margin-end">35</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkLabel">
- <property name="wrap">True</property>
- <property name="margin-bottom">35</property>
- <property name="label" translatable="yes">Folders which are searched by system
applications, such as Files, Photos and Videos.</property>
- </object>
- </child>
- <child>
- <object class="GtkListBox" id="places_list">
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- </object>
- </child>
- </object>
- </child>
- <child type="tab">
- <object class="GtkLabel">
- <property name="label" translatable="yes">Places</property>
+ <object class="GtkListBox" id="places_list">
+ <property name="selection-mode">none</property>
+ <signal name="keynav-failed" handler="keynav_failed_cb" object="CcSearchLocationsDialog"
swapped="yes"/>
+ <accessibility name="labelled-by">places_group</accessibility>
+ <style>
+ <class name="boxed-list"/>
+ </style>
</object>
</child>
+ </object>
+ </child>
+ <child>
+ <object class="AdwPreferencesGroup" id="bookmarks_group">
+ <property name="title" translatable="yes">Bookmarks</property>
<child>
- <object class="GtkScrolledWindow">
- <child>
- <object class="GtkBox">
- <property name="vexpand">True</property>
- <property name="margin-top">35</property>
- <property name="margin-bottom">35</property>
- <property name="margin-start">35</property>
- <property name="margin-end">35</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkLabel">
- <property name="wrap">True</property>
- <property name="margin-bottom">35</property>
- <property name="label" translatable="yes">Folders which are searched by system
applications, such as Files, Photos and Videos.</property>
- </object>
- </child>
- <child>
- <object class="GtkListBox" id="bookmarks_list">
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child type="tab">
- <object class="GtkLabel">
- <property name="label" translatable="yes">Bookmarks</property>
+ <object class="GtkListBox" id="bookmarks_list">
+ <property name="selection-mode">none</property>
+ <signal name="keynav-failed" handler="keynav_failed_cb" object="CcSearchLocationsDialog"
swapped="yes"/>
+ <accessibility name="labelled-by">bookmarks_group</accessibility>
+ <style>
+ <class name="boxed-list"/>
+ </style>
</object>
</child>
- <child>
- <object class="GtkScrolledWindow">
- <child>
- <object class="GtkBox">
- <property name="vexpand">True</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkLabel">
- <property name="wrap">True</property>
- <property name="margin-top">35</property>
- <property name="margin-bottom">35</property>
- <property name="margin-start">35</property>
- <property name="margin-end">35</property>
- <property name="label" translatable="yes">Folders which are searched by system
applications, such as Files, Photos and Videos.</property>
- </object>
- </child>
- <child>
- <object class="GtkListBox" id="others_list">
- </object>
- </child>
- <child>
- <object class="GtkSeparator">
- </object>
- </child>
- <child>
- <object class="GtkButton" id="locations_add">
- <property name="halign">center</property>
- <property name="margin-top">6</property>
- <property name="margin-bottom">6</property>
- <property name="margin-start">6</property>
- <property name="margin-end">6</property>
- <signal name="clicked" handler="add_button_clicked" object="CcSearchLocationsDialog"
swapped="yes"/>
- <child>
- <object class="GtkImage">
- <property name="icon-name">list-add-symbolic</property>
- <property name="icon-size">1</property>
- </object>
- </child>
- <style>
- <class name="flat"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkSeparator">
- </object>
- </child>
+ </object>
+ </child>
+ <child>
+ <object class="AdwPreferencesGroup" id="others_group">
+ <property name="title" translatable="yes">Others</property>
+ <property name="header-suffix">
+ <object class="GtkButton" id="locations_add">
+ <property name="valign">center</property>
+ <property name="child">
+ <object class="AdwButtonContent">
+ <property name="icon-name">list-add-symbolic</property>
+ <property name="label" translatable="yes">Add Location</property>
</object>
- </child>
+ </property>
+ <signal name="clicked" handler="add_button_clicked" object="CcSearchLocationsDialog"
swapped="yes"/>
+ <style>
+ <class name="flat"/>
+ </style>
</object>
- </child>
- <child type="tab">
- <object class="GtkLabel">
- <property name="label" translatable="yes">Other</property>
+ </property>
+ <child>
+ <object class="GtkListBox" id="others_list">
+ <property name="selection-mode">none</property>
+ <signal name="keynav-failed" handler="keynav_failed_cb" object="CcSearchLocationsDialog"
swapped="yes"/>
+ <accessibility name="labelled-by">others_group</accessibility>
+ <style>
+ <class name="boxed-list"/>
+ </style>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]