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

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