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

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