[gnome-disk-utility/wip/cdavis/ui-cleanups: 7/31] ui: Get replace Notebook with stack in the main window
- From: Kai Lüke <kailueke src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility/wip/cdavis/ui-cleanups: 7/31] ui: Get replace Notebook with stack in the main window
- Date: Sun, 7 Feb 2021 21:24:38 +0000 (UTC)
commit 510aaf2b572f4cf56e019194940ad169dbe767fe
Author: Christopher Davis <brainblasted disroot org>
Date: Fri Jan 8 15:14:51 2021 -0800
ui: Get replace Notebook with stack in the main window
We only use the Notebook for changing pages and hide
the tabs. In this case, a GtkStack is the right choice
instead of a GtkNotebook.
src/disks/gduwindow.c | 51 ++++++++++++++++++---------------------------
src/disks/ui/disks.ui | 57 +++------------------------------------------------
2 files changed, 23 insertions(+), 85 deletions(-)
---
diff --git a/src/disks/gduwindow.c b/src/disks/gduwindow.c
index fcf133a7..12c3e477 100644
--- a/src/disks/gduwindow.c
+++ b/src/disks/gduwindow.c
@@ -74,10 +74,14 @@ struct _GduWindow
GtkWidget *main_box;
GtkWidget *main_leaflet;
- GtkWidget *details_notebook;
+ GtkWidget *details_stack;
GtkWidget *device_tree_scrolledwindow;
GtkWidget *device_tree_treeview;
+ GtkWidget *disks_empty_state_box;
+ GtkWidget *disks_not_implemented;
+ GtkWidget *disks_devtab;
+
GtkWidget *devtab_app_menu_button;
GtkWidget *devtab_drive_loop_detach_button;
GtkWidget *devtab_drive_eject_button;
@@ -133,8 +137,12 @@ static const struct {
{G_STRUCT_OFFSET (GduWindow, main_leaflet), "main-leaflet"},
{G_STRUCT_OFFSET (GduWindow, device_tree_scrolledwindow), "device-tree-scrolledwindow"},
+ {G_STRUCT_OFFSET (GduWindow, disks_empty_state_box), "disks-empty-state-box"},
+ {G_STRUCT_OFFSET (GduWindow, disks_not_implemented), "disks-not-implemented"},
+ {G_STRUCT_OFFSET (GduWindow, disks_devtab), "disks-devtab"},
+
{G_STRUCT_OFFSET (GduWindow, device_tree_treeview), "device-tree-treeview"},
- {G_STRUCT_OFFSET (GduWindow, details_notebook), "disks-notebook"},
+ {G_STRUCT_OFFSET (GduWindow, details_stack), "disks-stack"},
{G_STRUCT_OFFSET (GduWindow, devtab_drive_table), "devtab-drive-table"},
{G_STRUCT_OFFSET (GduWindow, devtab_table), "devtab-table"},
{G_STRUCT_OFFSET (GduWindow, devtab_grid_hbox), "devtab-grid-hbox"},
@@ -1119,9 +1127,6 @@ gdu_window_constructed (GObject *object)
gtk_widget_set_no_show_all (GTK_WIDGET (l->data), TRUE);
}
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->details_notebook), FALSE);
- gtk_notebook_set_show_border (GTK_NOTEBOOK (window->details_notebook), FALSE);
-
context = gtk_widget_get_style_context (window->device_tree_scrolledwindow);
gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);
@@ -1582,19 +1587,11 @@ block_compare_on_preferred (UDisksObject *a,
static void update_empty_page (GduWindow *window);
static void update_device_page (GduWindow *window, ShowFlags *show_flags, gboolean is_delayed_job_update);
-/* Keep in sync with tabs in disks.ui file */
-typedef enum
-{
- DETAILS_PAGE_NOT_SELECTED,
- DETAILS_PAGE_NOT_IMPLEMENTED,
- DETAILS_PAGE_DEVICE,
-} DetailsPage;
-
static void
update_all (GduWindow *window, gboolean is_delayed_job_update)
{
ShowFlags show_flags = {0};
- DetailsPage page = DETAILS_PAGE_NOT_IMPLEMENTED;
+ GtkWidget *page = window->disks_not_implemented;
/* figure out page to display */
if (window->current_object != NULL)
@@ -1602,37 +1599,29 @@ update_all (GduWindow *window, gboolean is_delayed_job_update)
if (udisks_object_peek_drive (window->current_object) != NULL ||
udisks_object_peek_block (window->current_object) != NULL)
{
- page = DETAILS_PAGE_DEVICE;
+ page = window->disks_devtab;
}
}
else
{
- page = DETAILS_PAGE_NOT_SELECTED;
+ page = window->disks_empty_state_box;
}
- if (page == DETAILS_PAGE_NOT_IMPLEMENTED)
+ if (page == window->disks_not_implemented)
{
g_warning ("no page for object %s", g_dbus_object_get_object_path (G_DBUS_OBJECT
(window->current_object)));
}
- gtk_notebook_set_current_page (GTK_NOTEBOOK (window->details_notebook), page);
+ gtk_stack_set_visible_child (GTK_STACK (window->details_stack), page);
- switch (page)
+ if (page == window->disks_empty_state_box)
{
- case DETAILS_PAGE_NOT_SELECTED:
update_empty_page (window);
- break;
-
- case DETAILS_PAGE_NOT_IMPLEMENTED:
- /* Nothing to update */
- break;
-
- case DETAILS_PAGE_DEVICE:
+ }
+ else if (page == window->disks_devtab)
+ {
update_device_page (window, &show_flags, is_delayed_job_update);
- break;
-
- default:
- g_assert_not_reached ();
}
+
update_for_show_flags (window, &show_flags);
}
diff --git a/src/disks/ui/disks.ui b/src/disks/ui/disks.ui
index 7e24058a..c28f9dad 100644
--- a/src/disks/ui/disks.ui
+++ b/src/disks/ui/disks.ui
@@ -165,7 +165,7 @@
</object>
</child>
<child>
- <object class="GtkNotebook" id="disks-notebook">
+ <object class="GtkStack" id="disks-stack">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_start">6</property>
@@ -214,39 +214,15 @@
</child>
</object>
</child>
- <child type="tab">
- <object class="GtkLabel" id="label3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label">nothing_selected</property>
- </object>
- <packing>
- <property name="tab_fill">False</property>
- </packing>
- </child>
<child>
- <object class="GtkLabel" id="label4x">
+ <object class="GtkLabel" id="disks-not-implemented">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">Page not implemented yet</property>
</object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- <child type="tab">
- <object class="GtkLabel" id="label3x">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label">not_implemented</property>
- </object>
- <packing>
- <property name="position">1</property>
- <property name="tab_fill">False</property>
- </packing>
</child>
<child>
- <object class="GtkBox">
+ <object class="GtkBox" id="disks-devtab">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
@@ -1268,33 +1244,6 @@
</packing>
</child>
</object>
- <packing>
- <property name="position">2</property>
- <property name="tab_fill">False</property>
- </packing>
- </child>
- <child type="tab">
- <object class="GtkLabel" id="label1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label">devtab</property>
- </object>
- <packing>
- <property name="position">2</property>
- <property name="tab_fill">False</property>
- </packing>
- </child>
- <child>
- <placeholder/>
- </child>
- <child type="tab">
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child type="tab">
- <placeholder/>
</child>
</object>
</child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]