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

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