|
|
e9b09d |
From d1690196a9007568bfce3847841ea2b509eb3150 Mon Sep 17 00:00:00 2001
|
|
|
e9b09d |
From: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
|
|
|
e9b09d |
Date: Fri, 10 Jul 2020 06:28:06 +0200
|
|
|
e9b09d |
Subject: [PATCH 11/18] Replace signals with GSimpleActions
|
|
|
e9b09d |
|
|
|
e9b09d |
This unifies actions pertaining to the application.
|
|
|
e9b09d |
|
|
|
e9b09d |
---
|
|
|
e9b09d |
src/gui/callbacks.c | 62 ++++++++++++++++++++++-----------------------
|
|
|
e9b09d |
src/gui/callbacks.h | 35 ++++++++++++++++---------
|
|
|
e9b09d |
src/gui/gtk-lshw.c | 14 ++++++++++
|
|
|
e9b09d |
src/gui/gtk-lshw.ui | 16 ++++++------
|
|
|
e9b09d |
4 files changed, 76 insertions(+), 51 deletions(-)
|
|
|
e9b09d |
|
|
|
e9b09d |
diff --git a/src/gui/callbacks.c b/src/gui/callbacks.c
|
|
|
e9b09d |
index f8aa0cb0f968..eec3e5571741 100644
|
|
|
e9b09d |
--- a/src/gui/callbacks.c
|
|
|
e9b09d |
+++ b/src/gui/callbacks.c
|
|
|
e9b09d |
@@ -17,17 +17,36 @@ static char *id = "@(#) $Id$";
|
|
|
e9b09d |
|
|
|
e9b09d |
G_MODULE_EXPORT
|
|
|
e9b09d |
void
|
|
|
e9b09d |
-refresh_display (GtkMenuItem *menuitem,
|
|
|
e9b09d |
-gpointer user_data)
|
|
|
e9b09d |
+on_go_up_activated (GSimpleAction *action,
|
|
|
e9b09d |
+ GVariant *parameter,
|
|
|
e9b09d |
+ gpointer app)
|
|
|
e9b09d |
+{
|
|
|
e9b09d |
+ go_back(mainwindow);
|
|
|
e9b09d |
+}
|
|
|
e9b09d |
+
|
|
|
e9b09d |
+G_MODULE_EXPORT
|
|
|
e9b09d |
+void
|
|
|
e9b09d |
+on_refresh_activated (GSimpleAction *action,
|
|
|
e9b09d |
+ GVariant *parameter,
|
|
|
e9b09d |
+ gpointer app)
|
|
|
e9b09d |
{
|
|
|
e9b09d |
refresh(mainwindow);
|
|
|
e9b09d |
}
|
|
|
e9b09d |
|
|
|
e9b09d |
+G_MODULE_EXPORT
|
|
|
e9b09d |
+void
|
|
|
e9b09d |
+on_save_activated (GSimpleAction *action,
|
|
|
e9b09d |
+ GVariant *parameter,
|
|
|
e9b09d |
+ gpointer app)
|
|
|
e9b09d |
+{
|
|
|
e9b09d |
+ save_as(mainwindow);
|
|
|
e9b09d |
+}
|
|
|
e9b09d |
|
|
|
e9b09d |
G_MODULE_EXPORT
|
|
|
e9b09d |
void
|
|
|
e9b09d |
-on_about1_activate (GtkMenuItem *menuitem,
|
|
|
e9b09d |
-gpointer user_data)
|
|
|
e9b09d |
+on_about_activated (GSimpleAction *action,
|
|
|
e9b09d |
+ GVariant *parameter,
|
|
|
e9b09d |
+ gpointer app)
|
|
|
e9b09d |
{
|
|
|
e9b09d |
if(GTK_IS_WIDGET(about))
|
|
|
e9b09d |
{
|
|
|
e9b09d |
@@ -35,6 +54,14 @@ gpointer user_data)
|
|
|
e9b09d |
}
|
|
|
e9b09d |
}
|
|
|
e9b09d |
|
|
|
e9b09d |
+G_MODULE_EXPORT
|
|
|
e9b09d |
+void
|
|
|
e9b09d |
+on_quit_activated (GSimpleAction *action,
|
|
|
e9b09d |
+ GVariant *parameter,
|
|
|
e9b09d |
+ gpointer app)
|
|
|
e9b09d |
+{
|
|
|
e9b09d |
+ g_application_quit(G_APPLICATION(app));
|
|
|
e9b09d |
+}
|
|
|
e9b09d |
|
|
|
e9b09d |
G_MODULE_EXPORT
|
|
|
e9b09d |
void
|
|
|
e9b09d |
@@ -147,15 +174,6 @@ gpointer user_data)
|
|
|
e9b09d |
}
|
|
|
e9b09d |
|
|
|
e9b09d |
|
|
|
e9b09d |
-G_MODULE_EXPORT
|
|
|
e9b09d |
-void
|
|
|
e9b09d |
-go_up (GtkToolButton *toolbutton,
|
|
|
e9b09d |
-gpointer user_data)
|
|
|
e9b09d |
-{
|
|
|
e9b09d |
- go_back(mainwindow);
|
|
|
e9b09d |
-}
|
|
|
e9b09d |
-
|
|
|
e9b09d |
-
|
|
|
e9b09d |
G_MODULE_EXPORT
|
|
|
e9b09d |
void
|
|
|
e9b09d |
on_lshw_map (GtkWidget *widget,
|
|
|
e9b09d |
@@ -163,21 +181,3 @@ gpointer user_data)
|
|
|
e9b09d |
{
|
|
|
e9b09d |
refresh(mainwindow);
|
|
|
e9b09d |
}
|
|
|
e9b09d |
-
|
|
|
e9b09d |
-G_MODULE_EXPORT
|
|
|
e9b09d |
-void
|
|
|
e9b09d |
-on_save_activate (GtkMenuItem *menuitem,
|
|
|
e9b09d |
- gpointer user_data)
|
|
|
e9b09d |
-{
|
|
|
e9b09d |
- save_as(mainwindow);
|
|
|
e9b09d |
-}
|
|
|
e9b09d |
-
|
|
|
e9b09d |
-
|
|
|
e9b09d |
-G_MODULE_EXPORT
|
|
|
e9b09d |
-void
|
|
|
e9b09d |
-on_savebutton_clicked (GtkToolButton *toolbutton,
|
|
|
e9b09d |
- gpointer user_data)
|
|
|
e9b09d |
-{
|
|
|
e9b09d |
- on_save_activate(NULL, NULL);
|
|
|
e9b09d |
-}
|
|
|
e9b09d |
-
|
|
|
e9b09d |
diff --git a/src/gui/callbacks.h b/src/gui/callbacks.h
|
|
|
e9b09d |
index cc856e45ddb4..b9b9141c0eb7 100644
|
|
|
e9b09d |
--- a/src/gui/callbacks.h
|
|
|
e9b09d |
+++ b/src/gui/callbacks.h
|
|
|
e9b09d |
@@ -1,8 +1,29 @@
|
|
|
e9b09d |
#include <gtk/gtk.h>
|
|
|
e9b09d |
|
|
|
e9b09d |
-void refresh_display (GtkMenuItem * menuitem, gpointer user_data);
|
|
|
e9b09d |
+void
|
|
|
e9b09d |
+on_go_up_activated (GSimpleAction *action,
|
|
|
e9b09d |
+ GVariant *parameter,
|
|
|
e9b09d |
+ gpointer app);
|
|
|
e9b09d |
+
|
|
|
e9b09d |
+void
|
|
|
e9b09d |
+on_refresh_activated (GSimpleAction *action,
|
|
|
e9b09d |
+ GVariant *parameter,
|
|
|
e9b09d |
+ gpointer app);
|
|
|
e9b09d |
|
|
|
e9b09d |
-void on_about1_activate (GtkMenuItem * menuitem, gpointer user_data);
|
|
|
e9b09d |
+void
|
|
|
e9b09d |
+on_save_activated (GSimpleAction *action,
|
|
|
e9b09d |
+ GVariant *parameter,
|
|
|
e9b09d |
+ gpointer app);
|
|
|
e9b09d |
+
|
|
|
e9b09d |
+void
|
|
|
e9b09d |
+on_about_activated (GSimpleAction *action,
|
|
|
e9b09d |
+ GVariant *parameter,
|
|
|
e9b09d |
+ gpointer app);
|
|
|
e9b09d |
+
|
|
|
e9b09d |
+void
|
|
|
e9b09d |
+on_quit_activated (GSimpleAction *action,
|
|
|
e9b09d |
+ GVariant *parameter,
|
|
|
e9b09d |
+ gpointer app);
|
|
|
e9b09d |
|
|
|
e9b09d |
void on_aboutclose_activate (GtkButton * button, gpointer user_data);
|
|
|
e9b09d |
|
|
|
e9b09d |
@@ -35,14 +56,4 @@ void on_treeview2_cursor_changed (GtkTreeView * treeview, gpointer user_data);
|
|
|
e9b09d |
|
|
|
e9b09d |
void on_treeview3_cursor_changed (GtkTreeView * treeview, gpointer user_data);
|
|
|
e9b09d |
|
|
|
e9b09d |
-void go_up (GtkToolButton * toolbutton, gpointer user_data);
|
|
|
e9b09d |
-
|
|
|
e9b09d |
void on_lshw_map (GtkWidget * widget, gpointer user_data);
|
|
|
e9b09d |
-
|
|
|
e9b09d |
-void
|
|
|
e9b09d |
-on_save_activate (GtkMenuItem *menuitem,
|
|
|
e9b09d |
- gpointer user_data);
|
|
|
e9b09d |
-
|
|
|
e9b09d |
-void
|
|
|
e9b09d |
-on_savebutton_clicked (GtkToolButton *toolbutton,
|
|
|
e9b09d |
- gpointer user_data);
|
|
|
e9b09d |
diff --git a/src/gui/gtk-lshw.c b/src/gui/gtk-lshw.c
|
|
|
e9b09d |
index 6c0f0bbdf77f..0dc3aff6d322 100644
|
|
|
e9b09d |
--- a/src/gui/gtk-lshw.c
|
|
|
e9b09d |
+++ b/src/gui/gtk-lshw.c
|
|
|
e9b09d |
@@ -6,11 +6,21 @@
|
|
|
e9b09d |
#include "config.h"
|
|
|
e9b09d |
#include "stock.h"
|
|
|
e9b09d |
#include "engine.h"
|
|
|
e9b09d |
+#include "callbacks.h"
|
|
|
e9b09d |
|
|
|
e9b09d |
static char *id = "@(#) $Id$";
|
|
|
e9b09d |
|
|
|
e9b09d |
extern GtkWidget *mainwindow;
|
|
|
e9b09d |
|
|
|
e9b09d |
+static GActionEntry app_entries[] =
|
|
|
e9b09d |
+{
|
|
|
e9b09d |
+ { "go_up", on_go_up_activated, NULL, NULL, NULL },
|
|
|
e9b09d |
+ { "refresh", on_refresh_activated, NULL, NULL, NULL },
|
|
|
e9b09d |
+ { "save", on_save_activated, NULL, NULL, NULL },
|
|
|
e9b09d |
+ { "about", on_about_activated, NULL, NULL, NULL },
|
|
|
e9b09d |
+ { "quit", on_quit_activated, NULL, NULL, NULL }
|
|
|
e9b09d |
+};
|
|
|
e9b09d |
+
|
|
|
e9b09d |
static void
|
|
|
e9b09d |
activate (GApplication *app,
|
|
|
e9b09d |
gpointer user_data)
|
|
|
e9b09d |
@@ -35,6 +45,10 @@ activate (GApplication *app,
|
|
|
e9b09d |
return;
|
|
|
e9b09d |
}
|
|
|
e9b09d |
|
|
|
e9b09d |
+ g_action_map_add_action_entries (G_ACTION_MAP (app),
|
|
|
e9b09d |
+ app_entries, G_N_ELEMENTS (app_entries),
|
|
|
e9b09d |
+ app);
|
|
|
e9b09d |
+
|
|
|
e9b09d |
lshw_gtk_stock_init();
|
|
|
e9b09d |
lshw_ui_init();
|
|
|
e9b09d |
|
|
|
e9b09d |
diff --git a/src/gui/gtk-lshw.ui b/src/gui/gtk-lshw.ui
|
|
|
e9b09d |
index 7504c76d1a1b..d24e05c3aa20 100644
|
|
|
e9b09d |
--- a/src/gui/gtk-lshw.ui
|
|
|
e9b09d |
+++ b/src/gui/gtk-lshw.ui
|
|
|
e9b09d |
@@ -136,7 +136,7 @@
|
|
|
e9b09d |
<property name="can_focus">False</property>
|
|
|
e9b09d |
<property name="use_underline">True</property>
|
|
|
e9b09d |
<property name="use_stock">True</property>
|
|
|
e9b09d |
- <signal name="activate" handler="on_save_activate" swapped="no"/>
|
|
|
e9b09d |
+ <property name="action_name">app.save</property>
|
|
|
e9b09d |
</object>
|
|
|
e9b09d |
</child>
|
|
|
e9b09d |
<child>
|
|
|
e9b09d |
@@ -152,7 +152,7 @@
|
|
|
e9b09d |
<property name="can_focus">False</property>
|
|
|
e9b09d |
<property name="use_underline">True</property>
|
|
|
e9b09d |
<property name="use_stock">True</property>
|
|
|
e9b09d |
- <signal name="activate" handler="gtk_main_quit" swapped="no"/>
|
|
|
e9b09d |
+ <property name="action_name">app.quit</property>
|
|
|
e9b09d |
</object>
|
|
|
e9b09d |
</child>
|
|
|
e9b09d |
</object>
|
|
|
e9b09d |
@@ -176,7 +176,7 @@
|
|
|
e9b09d |
<property name="can_focus">False</property>
|
|
|
e9b09d |
<property name="use_underline">True</property>
|
|
|
e9b09d |
<property name="use_stock">True</property>
|
|
|
e9b09d |
- <signal name="activate" handler="refresh_display" swapped="no"/>
|
|
|
e9b09d |
+ <property name="action_name">app.refresh</property>
|
|
|
e9b09d |
</object>
|
|
|
e9b09d |
</child>
|
|
|
e9b09d |
</object>
|
|
|
e9b09d |
@@ -200,7 +200,7 @@
|
|
|
e9b09d |
<property name="can_focus">False</property>
|
|
|
e9b09d |
<property name="use_underline">True</property>
|
|
|
e9b09d |
<property name="use_stock">True</property>
|
|
|
e9b09d |
- <signal name="activate" handler="on_about1_activate" swapped="no"/>
|
|
|
e9b09d |
+ <property name="action_name">app.about</property>
|
|
|
e9b09d |
</object>
|
|
|
e9b09d |
</child>
|
|
|
e9b09d |
</object>
|
|
|
e9b09d |
@@ -225,7 +225,7 @@
|
|
|
e9b09d |
<property name="sensitive">False</property>
|
|
|
e9b09d |
<property name="can_focus">False</property>
|
|
|
e9b09d |
<property name="stock_id">gtk-go-up</property>
|
|
|
e9b09d |
- <signal name="clicked" handler="go_up" swapped="no"/>
|
|
|
e9b09d |
+ <property name="action_name">app.go_up</property>
|
|
|
e9b09d |
</object>
|
|
|
e9b09d |
<packing>
|
|
|
e9b09d |
<property name="expand">False</property>
|
|
|
e9b09d |
@@ -238,7 +238,7 @@
|
|
|
e9b09d |
<property name="can_focus">False</property>
|
|
|
e9b09d |
<property name="tooltip_text" translatable="yes">Rescan the hardware</property>
|
|
|
e9b09d |
<property name="stock_id">gtk-refresh</property>
|
|
|
e9b09d |
- <signal name="clicked" handler="refresh_display" swapped="no"/>
|
|
|
e9b09d |
+ <property name="action_name">app.refresh</property>
|
|
|
e9b09d |
</object>
|
|
|
e9b09d |
<packing>
|
|
|
e9b09d |
<property name="expand">False</property>
|
|
|
e9b09d |
@@ -251,7 +251,7 @@
|
|
|
e9b09d |
<property name="sensitive">False</property>
|
|
|
e9b09d |
<property name="can_focus">False</property>
|
|
|
e9b09d |
<property name="stock_id">gtk-save</property>
|
|
|
e9b09d |
- <signal name="clicked" handler="on_savebutton_clicked" swapped="no"/>
|
|
|
e9b09d |
+ <property name="action_name">app.save</property>
|
|
|
e9b09d |
</object>
|
|
|
e9b09d |
<packing>
|
|
|
e9b09d |
<property name="expand">False</property>
|
|
|
e9b09d |
@@ -263,7 +263,7 @@
|
|
|
e9b09d |
<property name="visible">True</property>
|
|
|
e9b09d |
<property name="can_focus">False</property>
|
|
|
e9b09d |
<property name="stock_id">gtk-quit</property>
|
|
|
e9b09d |
- <signal name="clicked" handler="gtk_main_quit" swapped="no"/>
|
|
|
e9b09d |
+ <property name="action_name">app.quit</property>
|
|
|
e9b09d |
</object>
|
|
|
e9b09d |
<packing>
|
|
|
e9b09d |
<property name="expand">False</property>
|
|
|
e9b09d |
--
|
|
|
e9b09d |
2.17.1
|
|
|
e9b09d |
|