Blame SOURCES/0035-Replace-the-about-GtkDialog-with-a-GtkAboutDialog.patch

a436c4
From e96f82ce459a6d503f70d6c7b0f762bf0d133edf Mon Sep 17 00:00:00 2001
a436c4
From: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
a436c4
Date: Sat, 1 Aug 2020 15:03:23 +0200
a436c4
Subject: [PATCH 35/65] Replace the about GtkDialog with a GtkAboutDialog
a436c4
a436c4
This reduces the amount of code needed for this feature, and integrates
a436c4
better with the rest of the system.
a436c4
---
a436c4
 src/gui/callbacks.c |  46 ++++++--------------
a436c4
 src/gui/callbacks.h |   4 --
a436c4
 src/gui/gtk-lshw.ui | 101 --------------------------------------------
a436c4
 src/gui/stock.c     |   2 -
a436c4
 4 files changed, 12 insertions(+), 141 deletions(-)
a436c4
a436c4
diff --git a/src/gui/callbacks.c b/src/gui/callbacks.c
a436c4
index eec3e55..b108777 100644
a436c4
--- a/src/gui/callbacks.c
a436c4
+++ b/src/gui/callbacks.c
a436c4
@@ -10,7 +10,6 @@
a436c4
 #include "engine.h"
a436c4
 #include <string.h>
a436c4
 
a436c4
-extern GtkWidget *about;
a436c4
 extern GtkWidget *mainwindow;
a436c4
 
a436c4
 static char *id = "@(#) $Id$";
a436c4
@@ -42,18 +41,6 @@ on_save_activated                      (GSimpleAction   *action,
a436c4
   save_as(mainwindow);
a436c4
 }
a436c4
 
a436c4
-G_MODULE_EXPORT
a436c4
-void
a436c4
-on_about_activated                     (GSimpleAction   *action,
a436c4
-                                        GVariant        *parameter,
a436c4
-                                        gpointer         app)
a436c4
-{
a436c4
-  if(GTK_IS_WIDGET(about))
a436c4
-  {
a436c4
-    gtk_widget_show(about);
a436c4
-  }
a436c4
-}
a436c4
-
a436c4
 G_MODULE_EXPORT
a436c4
 void
a436c4
 on_quit_activated                      (GSimpleAction   *action,
a436c4
@@ -65,25 +52,20 @@ on_quit_activated                      (GSimpleAction   *action,
a436c4
 
a436c4
 G_MODULE_EXPORT
a436c4
 void
a436c4
-on_aboutclose_activate          (GtkButton       *button,
a436c4
-gpointer         user_data)
a436c4
+on_about_activated                     (GSimpleAction   *action,
a436c4
+                                        GVariant        *parameter,
a436c4
+                                        gpointer         app)
a436c4
 {
a436c4
-  if(GTK_IS_WIDGET(about))
a436c4
-  {
a436c4
-    gtk_widget_hide(about);
a436c4
-  }
a436c4
-}
a436c4
-
a436c4
+  gtk_show_about_dialog(GTK_WINDOW(mainwindow),
a436c4
+                        "program-name", "GTK+ frontend for lshw",
a436c4
+                        "website", "https://www.ezix.org/",
a436c4
+                        "copyright", "© 2004-2011 Lyonel Vincent\n© 2020 Emmanuel Gil Peyrot",
a436c4
+                        "version", getpackageversion(),
a436c4
+                        "license-type", GTK_LICENSE_GPL_2_0,
a436c4
+                        NULL);
a436c4
 
a436c4
-G_MODULE_EXPORT
a436c4
-void
a436c4
-on_version_realize                     (GtkWidget       *widget,
a436c4
-gpointer         user_data)
a436c4
-{
a436c4
   const char *latest = checkupdates();
a436c4
 
a436c4
-  gtk_label_set_text(GTK_LABEL(widget), getpackageversion());
a436c4
-
a436c4
   if(latest)
a436c4
   {
a436c4
     if(strcmp(latest, getpackageversion()) != 0)
a436c4
@@ -100,18 +82,14 @@ gpointer         user_data)
a436c4
                                   latest);
a436c4
 
a436c4
         gtk_window_set_title(GTK_WINDOW(dialog), "Update available");
a436c4
-        /* Destroy the dialog when the user responds to it (e.g. clicks a button) */
a436c4
-        g_signal_connect_swapped (dialog, "response",
a436c4
-                           G_CALLBACK (gtk_widget_destroy),
a436c4
-                           dialog);
a436c4
       }
a436c4
 
a436c4
-      gtk_widget_show(dialog);
a436c4
+      gtk_dialog_run(GTK_DIALOG(dialog));
a436c4
+      gtk_widget_destroy(dialog);
a436c4
     }
a436c4
   }
a436c4
 }
a436c4
 
a436c4
-
a436c4
 G_MODULE_EXPORT
a436c4
 void
a436c4
 on_treeview1_row_activated             (GtkTreeView     *treeview,
a436c4
diff --git a/src/gui/callbacks.h b/src/gui/callbacks.h
a436c4
index b9b9141..e7636ef 100644
a436c4
--- a/src/gui/callbacks.h
a436c4
+++ b/src/gui/callbacks.h
a436c4
@@ -25,10 +25,6 @@ on_quit_activated                      (GSimpleAction   *action,
a436c4
                                         GVariant        *parameter,
a436c4
                                         gpointer         app);
a436c4
 
a436c4
-void on_aboutclose_activate (GtkButton * button, gpointer user_data);
a436c4
-
a436c4
-void on_version_realize (GtkWidget * widget, gpointer user_data);
a436c4
-
a436c4
 void
a436c4
 on_treeview1_row_activated (GtkTreeView * treeview,
a436c4
 			    GtkTreePath * path,
a436c4
diff --git a/src/gui/gtk-lshw.ui b/src/gui/gtk-lshw.ui
a436c4
index cf9d678..a3c6248 100644
a436c4
--- a/src/gui/gtk-lshw.ui
a436c4
+++ b/src/gui/gtk-lshw.ui
a436c4
@@ -1,107 +1,6 @@
a436c4
 
a436c4
 <interface>
a436c4
   <requires lib="gtk+" version="3.24"/>
a436c4
-  <object class="GtkDialog" id="aboutlshw">
a436c4
-    <property name="can_focus">False</property>
a436c4
-    <property name="title" translatable="yes">About</property>
a436c4
-    <property name="resizable">False</property>
a436c4
-    <property name="window_position">center-on-parent</property>
a436c4
-    <property name="destroy_with_parent">True</property>
a436c4
-    <property name="type_hint">dialog</property>
a436c4
-    <property name="skip_taskbar_hint">True</property>
a436c4
-    <property name="skip_pager_hint">True</property>
a436c4
-    <child internal-child="vbox">
a436c4
-      <object class="GtkBox" id="dialog-vbox1">
a436c4
-        <property name="visible">True</property>
a436c4
-        <property name="can_focus">False</property>
a436c4
-        <property name="orientation">vertical</property>
a436c4
-        <child internal-child="action_area">
a436c4
-          <object class="GtkButtonBox" id="dialog-action_area1">
a436c4
-            <property name="visible">True</property>
a436c4
-            <property name="can_focus">False</property>
a436c4
-            <property name="layout_style">end</property>
a436c4
-            <child>
a436c4
-              <object class="GtkButton" id="closebutton1">
a436c4
-                <property name="label">gtk-close</property>
a436c4
-                <property name="visible">True</property>
a436c4
-                <property name="can_focus">True</property>
a436c4
-                <property name="can_default">True</property>
a436c4
-                <property name="receives_default">False</property>
a436c4
-                <property name="use_stock">True</property>
a436c4
-                <signal name="activate" handler="on_aboutclose_activate" swapped="no"/>
a436c4
-                <signal name="clicked" handler="on_aboutclose_activate" swapped="no"/>
a436c4
-              </object>
a436c4
-              <packing>
a436c4
-                <property name="expand">False</property>
a436c4
-                <property name="fill">True</property>
a436c4
-                <property name="position">0</property>
a436c4
-              </packing>
a436c4
-            </child>
a436c4
-          </object>
a436c4
-          <packing>
a436c4
-            <property name="expand">False</property>
a436c4
-            <property name="fill">True</property>
a436c4
-            <property name="pack_type">end</property>
a436c4
-            <property name="position">0</property>
a436c4
-          </packing>
a436c4
-        </child>
a436c4
-        <child>
a436c4
-          <object class="GtkLabel" id="aboutext">
a436c4
-            <property name="visible">True</property>
a436c4
-            <property name="can_focus">False</property>
a436c4
-            <property name="xpad">20</property>
a436c4
-            <property name="ypad">20</property>
a436c4
-            <property name="label" translatable="yes"><big><b>GTK+ front-end for <tt>lshw</tt></b></big>
a436c4
-
a436c4
-© 2004-2011 Lyonel Vincent
a436c4
-<tt>lyonel@ezix.org</tt></property>
a436c4
-            <property name="use_markup">True</property>
a436c4
-            <property name="justify">center</property>
a436c4
-            <property name="mnemonic_widget">closebutton1</property>
a436c4
-          </object>
a436c4
-          <packing>
a436c4
-            <property name="expand">False</property>
a436c4
-            <property name="fill">False</property>
a436c4
-            <property name="position">1</property>
a436c4
-          </packing>
a436c4
-        </child>
a436c4
-        <child>
a436c4
-          <object class="GtkLinkButton" id="linkbutton1">
a436c4
-            <property name="label" translatable="yes">http://www.ezix.org/</property>
a436c4
-            <property name="visible">True</property>
a436c4
-            <property name="can_focus">True</property>
a436c4
-            <property name="receives_default">True</property>
a436c4
-            <property name="has_tooltip">True</property>
a436c4
-            <property name="relief">none</property>
a436c4
-            <property name="uri">http://www.ezix.org/</property>
a436c4
-          </object>
a436c4
-          <packing>
a436c4
-            <property name="expand">False</property>
a436c4
-            <property name="fill">True</property>
a436c4
-            <property name="position">2</property>
a436c4
-          </packing>
a436c4
-        </child>
a436c4
-        <child>
a436c4
-          <object class="GtkLabel" id="version">
a436c4
-            <property name="visible">True</property>
a436c4
-            <property name="can_focus">False</property>
a436c4
-            <property name="label" translatable="yes">VERSION</property>
a436c4
-            <property name="justify">center</property>
a436c4
-            <property name="mnemonic_widget">closebutton1</property>
a436c4
-            <signal name="realize" handler="on_version_realize" swapped="no"/>
a436c4
-          </object>
a436c4
-          <packing>
a436c4
-            <property name="expand">False</property>
a436c4
-            <property name="fill">False</property>
a436c4
-            <property name="position">3</property>
a436c4
-          </packing>
a436c4
-        </child>
a436c4
-      </object>
a436c4
-    </child>
a436c4
-    <action-widgets>
a436c4
-      <action-widget response="-7">closebutton1</action-widget>
a436c4
-    </action-widgets>
a436c4
-  </object>
a436c4
   <object class="GtkApplicationWindow" id="mainwindow">
a436c4
     <property name="can_focus">False</property>
a436c4
     <property name="title" translatable="yes">lshw</property>
a436c4
diff --git a/src/gui/stock.c b/src/gui/stock.c
a436c4
index ce0b42a..c3159b8 100644
a436c4
--- a/src/gui/stock.c
a436c4
+++ b/src/gui/stock.c
a436c4
@@ -8,7 +8,6 @@ static char *id = "@(#) $Id$";
a436c4
 #define UIFILE "gtk-lshw.ui"
a436c4
 
a436c4
 GtkWidget *mainwindow = NULL;
a436c4
-GtkWidget *about = NULL;
a436c4
 GtkWidget *list1 = NULL;
a436c4
 GtkWidget *list2 = NULL;
a436c4
 GtkWidget *list3 = NULL;
a436c4
@@ -145,7 +144,6 @@ void lshw_ui_init(GtkApplication *app)
a436c4
   g_free(uiname);
a436c4
 
a436c4
   mainwindow = GTK_WIDGET( gtk_builder_get_object( builder, "mainwindow" ) );
a436c4
-  about = GTK_WIDGET( gtk_builder_get_object( builder, "aboutlshw" ) );
a436c4
   list1 = GTK_WIDGET(gtk_builder_get_object( builder, "treeview1"));
a436c4
   list2 = GTK_WIDGET(gtk_builder_get_object( builder, "treeview2"));
a436c4
   list3 = GTK_WIDGET(gtk_builder_get_object( builder, "treeview3"));
a436c4
-- 
a436c4
2.33.1
a436c4