Blame SOURCES/0031-Move-to-GtkApplication.patch

a436c4
From 5fd82e398ba94766f0981f97988c8f14ab4297c5 Mon Sep 17 00:00:00 2001
a436c4
From: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
a436c4
Date: Fri, 10 Jul 2020 05:53:57 +0200
a436c4
Subject: [PATCH 31/65] Move to GtkApplication
a436c4
a436c4
This will eventually let us use GActions to build our menus and buttons.
a436c4
---
a436c4
 src/gui/gtk-lshw.c  | 36 ++++++++++++++++++++++--------------
a436c4
 src/gui/gtk-lshw.ui |  3 +--
a436c4
 2 files changed, 23 insertions(+), 16 deletions(-)
a436c4
a436c4
diff --git a/src/gui/gtk-lshw.c b/src/gui/gtk-lshw.c
a436c4
index 9ac525c..6c0f0bb 100644
a436c4
--- a/src/gui/gtk-lshw.c
a436c4
+++ b/src/gui/gtk-lshw.c
a436c4
@@ -11,17 +11,10 @@ static char *id = "@(#) $Id$";
a436c4
 
a436c4
 extern GtkWidget *mainwindow;
a436c4
 
a436c4
-int
a436c4
-main (int argc, char *argv[])
a436c4
+static void
a436c4
+activate (GApplication *app,
a436c4
+          gpointer      user_data)
a436c4
 {
a436c4
-#ifndef NONLS
a436c4
-  bindtextdomain (PACKAGE, LOCALEDIR);
a436c4
-  bind_textdomain_codeset (PACKAGE, "UTF-8");
a436c4
-  textdomain (PACKAGE);
a436c4
-#endif
a436c4
-
a436c4
-  gtk_init (&argc, &argv);
a436c4
-
a436c4
   if(geteuid() != 0)
a436c4
   {
a436c4
     bool proceed = false;
a436c4
@@ -39,19 +32,34 @@ main (int argc, char *argv[])
a436c4
     gtk_widget_destroy (dialog);
a436c4
 
a436c4
     if(!proceed)
a436c4
-      return -1;
a436c4
+      return;
a436c4
   }
a436c4
 
a436c4
   lshw_gtk_stock_init();
a436c4
   lshw_ui_init();
a436c4
 
a436c4
   if(!mainwindow)
a436c4
-    return(1);
a436c4
+    return;
a436c4
 
a436c4
   gtk_widget_show(mainwindow);
a436c4
-  gtk_main ();
a436c4
+  gtk_application_add_window(GTK_APPLICATION(app), GTK_WINDOW(mainwindow));
a436c4
+}
a436c4
+
a436c4
+int
a436c4
+main (int argc, char *argv[])
a436c4
+{
a436c4
+#ifndef NONLS
a436c4
+  bindtextdomain (PACKAGE, LOCALEDIR);
a436c4
+  bind_textdomain_codeset (PACKAGE, "UTF-8");
a436c4
+  textdomain (PACKAGE);
a436c4
+#endif
a436c4
+
a436c4
+  GtkApplication *app = gtk_application_new ("org.ezix.gtk-lshw", G_APPLICATION_FLAGS_NONE);
a436c4
+  g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
a436c4
+  int status = g_application_run (G_APPLICATION (app), argc, argv);
a436c4
+  g_object_unref (app);
a436c4
 
a436c4
   (void) &id;                                     // avoid warning "id defined but not used"
a436c4
 
a436c4
-  return 0;
a436c4
+  return status;
a436c4
 }
a436c4
diff --git a/src/gui/gtk-lshw.ui b/src/gui/gtk-lshw.ui
a436c4
index 1656f80..7504c76 100644
a436c4
--- a/src/gui/gtk-lshw.ui
a436c4
+++ b/src/gui/gtk-lshw.ui
a436c4
@@ -102,14 +102,13 @@
a436c4
       <action-widget response="-7">closebutton1</action-widget>
a436c4
     </action-widgets>
a436c4
   </object>
a436c4
-  <object class="GtkWindow" id="mainwindow">
a436c4
+  <object class="GtkApplicationWindow" id="mainwindow">
a436c4
     <property name="visible">True</property>
a436c4
     <property name="can_focus">False</property>
a436c4
     <property name="title" translatable="yes">lshw</property>
a436c4
     <property name="default_width">700</property>
a436c4
     <property name="default_height">480</property>
a436c4
     <property name="startup_id">org.ezix.gtk-lshw</property>
a436c4
-    <signal name="delete-event" handler="gtk_main_quit" swapped="no"/>
a436c4
     <signal name="map" handler="on_lshw_map" after="yes" swapped="no"/>
a436c4
     <child>
a436c4
       <object class="GtkBox" id="main-box">
a436c4
-- 
a436c4
2.33.1
a436c4