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

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