[gnome-disk-utility] smartdialog: Use PopoverMenu instead of GtkMenu
- From: Kai Lüke <kailueke src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility] smartdialog: Use PopoverMenu instead of GtkMenu
- Date: Mon, 18 Oct 2021 19:18:17 +0000 (UTC)
commit 959b359c78a94d784343c1bd62e63a7797082051
Author: Maximiliano Sandoval R <msandova gnome org>
Date: Tue Oct 12 12:16:28 2021 +0200
smartdialog: Use PopoverMenu instead of GtkMenu
src/disks/gduatasmartdialog.c | 39 ++++++++++++++++++++++--------------
src/disks/ui/smart-dialog.ui | 46 ++++++++++++++++---------------------------
2 files changed, 41 insertions(+), 44 deletions(-)
---
diff --git a/src/disks/gduatasmartdialog.c b/src/disks/gduatasmartdialog.c
index 3db2487b..361cafac 100644
--- a/src/disks/gduatasmartdialog.c
+++ b/src/disks/gduatasmartdialog.c
@@ -62,10 +62,6 @@ typedef struct
GtkWidget *stop_selftest_button;
GtkWidget *refresh_button;
- GtkWidget *selftest_menu;
- GtkWidget *selftest_short_menuitem;
- GtkWidget *selftest_extended_menuitem;
- GtkWidget *selftest_conveyance_menuitem;
} DialogData;
static const struct {
@@ -85,10 +81,6 @@ static const struct {
{G_STRUCT_OFFSET (DialogData, self_assessment_label), "self-assessment-label"},
{G_STRUCT_OFFSET (DialogData, overall_assessment_label), "overall-assessment-label"},
{G_STRUCT_OFFSET (DialogData, attributes_treeview), "attributes-treeview"},
- {G_STRUCT_OFFSET (DialogData, selftest_menu), "selftest-menu"},
- {G_STRUCT_OFFSET (DialogData, selftest_short_menuitem), "selftest-short-menuitem"},
- {G_STRUCT_OFFSET (DialogData, selftest_extended_menuitem), "selftest-extended-menuitem"},
- {G_STRUCT_OFFSET (DialogData, selftest_conveyance_menuitem), "selftest-conveyance-menuitem"},
{G_STRUCT_OFFSET (DialogData, start_selftest_button), "start-selftest-button"},
{G_STRUCT_OFFSET (DialogData, stop_selftest_button), "stop-selftest-button"},
@@ -1398,7 +1390,8 @@ selftest_do (DialogData *data,
}
static void
-on_selftest_short (GtkMenuItem *menu_item,
+on_selftest_short (GAction *action,
+ GVariant *parameter,
gpointer user_data)
{
DialogData *data = user_data;
@@ -1406,7 +1399,8 @@ on_selftest_short (GtkMenuItem *menu_item,
}
static void
-on_selftest_extended (GtkMenuItem *menu_item,
+on_selftest_extended (GAction *action,
+ GVariant *parameter,
gpointer user_data)
{
DialogData *data = user_data;
@@ -1414,8 +1408,9 @@ on_selftest_extended (GtkMenuItem *menu_item,
}
static void
-on_selftest_conveyance (GtkMenuItem *menu_item,
- gpointer user_data)
+on_selftest_conveyance (GAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
DialogData *data = user_data;
selftest_do (data, "conveyance");
@@ -1486,6 +1481,8 @@ gdu_ata_smart_dialog_show (GduWindow *window,
GtkCellRenderer *renderer;
gulong notify_id;
guint timeout_id;
+ GSimpleActionGroup *group;
+ GSimpleAction *action;
data = g_new0 (DialogData, 1);
data->ref_count = 1;
@@ -1645,9 +1642,21 @@ gdu_ata_smart_dialog_show (GduWindow *window,
notify_id = g_signal_connect (data->ata, "notify", G_CALLBACK (on_ata_notify), data);
timeout_id = g_timeout_add_seconds (1, on_timeout, data);
- g_signal_connect (data->selftest_short_menuitem, "activate", G_CALLBACK (on_selftest_short), data);
- g_signal_connect (data->selftest_extended_menuitem, "activate", G_CALLBACK (on_selftest_extended), data);
- g_signal_connect (data->selftest_conveyance_menuitem, "activate", G_CALLBACK (on_selftest_conveyance),
data);
+ group = g_simple_action_group_new ();
+
+ action = g_simple_action_new ("short", NULL);
+ g_signal_connect (action, "activate", G_CALLBACK (on_selftest_short), data);
+ g_simple_action_group_insert (group, G_ACTION (action));
+
+ action = g_simple_action_new ("extended", NULL);
+ g_signal_connect (action, "activate", G_CALLBACK (on_selftest_extended), data);
+ g_simple_action_group_insert (group, G_ACTION (action));
+
+ action = g_simple_action_new ("conveyance", NULL);
+ g_signal_connect (action, "activate", G_CALLBACK (on_selftest_conveyance), data);
+ g_simple_action_group_insert (group, G_ACTION (action));
+
+ gtk_widget_insert_action_group (GTK_WIDGET (data->dialog), "test", G_ACTION_GROUP (group));
update_dialog (data);
gtk_widget_grab_focus (data->attributes_treeview);
diff --git a/src/disks/ui/smart-dialog.ui b/src/disks/ui/smart-dialog.ui
index 923beda0..6628370e 100644
--- a/src/disks/ui/smart-dialog.ui
+++ b/src/disks/ui/smart-dialog.ui
@@ -20,7 +20,7 @@
<property name="layout_style">end</property>
<child>
<object class="GtkMenuButton" id="start-selftest-button">
- <property name="popup">selftest-menu</property>
+ <property name="menu_model">selftest-menu</property>
<property name="label" translatable="yes">_Start Self-test</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -354,32 +354,20 @@
<action-widget response="2">refresh-button</action-widget>
</action-widgets>
</object>
- <object class="GtkMenu" id="selftest-menu">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkMenuItem" id="selftest-short-menuitem">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Short</property>
- <property name="use_underline">True</property>
- </object>
- </child>
- <child>
- <object class="GtkMenuItem" id="selftest-extended-menuitem">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Extended</property>
- <property name="use_underline">True</property>
- </object>
- </child>
- <child>
- <object class="GtkMenuItem" id="selftest-conveyance-menuitem">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Conveyance</property>
- <property name="use_underline">True</property>
- </object>
- </child>
- </object>
+ <menu id="selftest-menu">
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_Short</attribute>
+ <attribute name="action">test.short</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Extended</attribute>
+ <attribute name="action">test.extended</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Conveyance</attribute>
+ <attribute name="action">test.conveyance</attribute>
+ </item>
+ </section>
+ </menu>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]