From e96f82ce459a6d503f70d6c7b0f762bf0d133edf Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sat, 1 Aug 2020 15:03:23 +0200 Subject: [PATCH 14/18] Replace the about GtkDialog with a GtkAboutDialog This reduces the amount of code needed for this feature, and integrates better with the rest of the system. --- src/gui/callbacks.c | 46 ++++++-------------- src/gui/callbacks.h | 4 -- src/gui/gtk-lshw.ui | 101 -------------------------------------------- src/gui/stock.c | 2 - 4 files changed, 12 insertions(+), 141 deletions(-) diff --git a/src/gui/callbacks.c b/src/gui/callbacks.c index eec3e5571741..b108777fe11f 100644 --- a/src/gui/callbacks.c +++ b/src/gui/callbacks.c @@ -10,7 +10,6 @@ #include "engine.h" #include -extern GtkWidget *about; extern GtkWidget *mainwindow; static char *id = "@(#) $Id$"; @@ -42,18 +41,6 @@ on_save_activated (GSimpleAction *action, save_as(mainwindow); } -G_MODULE_EXPORT -void -on_about_activated (GSimpleAction *action, - GVariant *parameter, - gpointer app) -{ - if(GTK_IS_WIDGET(about)) - { - gtk_widget_show(about); - } -} - G_MODULE_EXPORT void on_quit_activated (GSimpleAction *action, @@ -65,25 +52,20 @@ on_quit_activated (GSimpleAction *action, G_MODULE_EXPORT void -on_aboutclose_activate (GtkButton *button, -gpointer user_data) +on_about_activated (GSimpleAction *action, + GVariant *parameter, + gpointer app) { - if(GTK_IS_WIDGET(about)) - { - gtk_widget_hide(about); - } -} - + gtk_show_about_dialog(GTK_WINDOW(mainwindow), + "program-name", "GTK+ frontend for lshw", + "website", "https://www.ezix.org/", + "copyright", "© 2004-2011 Lyonel Vincent\n© 2020 Emmanuel Gil Peyrot", + "version", getpackageversion(), + "license-type", GTK_LICENSE_GPL_2_0, + NULL); -G_MODULE_EXPORT -void -on_version_realize (GtkWidget *widget, -gpointer user_data) -{ const char *latest = checkupdates(); - gtk_label_set_text(GTK_LABEL(widget), getpackageversion()); - if(latest) { if(strcmp(latest, getpackageversion()) != 0) @@ -100,18 +82,14 @@ gpointer user_data) latest); gtk_window_set_title(GTK_WINDOW(dialog), "Update available"); - /* Destroy the dialog when the user responds to it (e.g. clicks a button) */ - g_signal_connect_swapped (dialog, "response", - G_CALLBACK (gtk_widget_destroy), - dialog); } - gtk_widget_show(dialog); + gtk_dialog_run(GTK_DIALOG(dialog)); + gtk_widget_destroy(dialog); } } } - G_MODULE_EXPORT void on_treeview1_row_activated (GtkTreeView *treeview, diff --git a/src/gui/callbacks.h b/src/gui/callbacks.h index b9b9141c0eb7..e7636efdcae5 100644 --- a/src/gui/callbacks.h +++ b/src/gui/callbacks.h @@ -25,10 +25,6 @@ on_quit_activated (GSimpleAction *action, GVariant *parameter, gpointer app); -void on_aboutclose_activate (GtkButton * button, gpointer user_data); - -void on_version_realize (GtkWidget * widget, gpointer user_data); - void on_treeview1_row_activated (GtkTreeView * treeview, GtkTreePath * path, diff --git a/src/gui/gtk-lshw.ui b/src/gui/gtk-lshw.ui index b61bedf501ee..57817fd58b39 100644 --- a/src/gui/gtk-lshw.ui +++ b/src/gui/gtk-lshw.ui @@ -1,107 +1,6 @@ - - False - About - False - center-on-parent - True - dialog - True - True - - - True - False - vertical - - - True - False - end - - - gtk-close - True - True - True - False - True - - - - - False - True - 0 - - - - - False - True - end - 0 - - - - - True - False - 20 - 20 - <big><b>GTK+ front-end for <tt>lshw</tt></b></big> - -© 2004-2011 Lyonel Vincent -<tt>lyonel@ezix.org</tt> - True - center - closebutton1 - - - False - False - 1 - - - - - http://www.ezix.org/ - True - True - True - True - none - http://www.ezix.org/ - - - False - True - 2 - - - - - True - False - VERSION - center - closebutton1 - - - - False - False - 3 - - - - - - closebutton1 - - False lshw diff --git a/src/gui/stock.c b/src/gui/stock.c index 7b98c642d43f..db2e98189662 100644 --- a/src/gui/stock.c +++ b/src/gui/stock.c @@ -9,7 +9,6 @@ static char *id = "@(#) $Id$"; #define UIFILE "gtk-lshw.ui" GtkWidget *mainwindow = NULL; -GtkWidget *about = NULL; GtkWidget *list1 = NULL; GtkWidget *list2 = NULL; GtkWidget *list3 = NULL; @@ -146,7 +145,6 @@ void lshw_ui_init(GtkApplication *app) g_free(uiname); mainwindow = GTK_WIDGET( gtk_builder_get_object( builder, "mainwindow" ) ); - about = GTK_WIDGET( gtk_builder_get_object( builder, "aboutlshw" ) ); list1 = GTK_WIDGET(gtk_builder_get_object( builder, "treeview1")); list2 = GTK_WIDGET(gtk_builder_get_object( builder, "treeview2")); list3 = GTK_WIDGET(gtk_builder_get_object( builder, "treeview3")); -- 2.17.1