diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2024-07-02 06:27:09 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2024-07-02 06:27:09 (GMT) |
commit | d3c74213cf2306453b21779c80d05d121fbffe66 (patch) | |
tree | 4222409777f72f77238c95adba34ed5b07746567 | |
parent | 21788df2799eb8976c1c68cd84abf0ffe92a7a45 (diff) |
Ensure minimal desktop support for icon and name.
-rw-r--r-- | configure.ac | 13 | ||||
-rw-r--r-- | src/Makefile.am | 5 | ||||
-rw-r--r-- | src/app.c | 137 | ||||
-rw-r--r-- | src/app.h | 34 | ||||
-rw-r--r-- | src/framework.c | 8 | ||||
-rw-r--r-- | src/gui/Makefile.am | 5 | ||||
-rw-r--r-- | src/gui/gresource.xml | 4 |
7 files changed, 199 insertions, 7 deletions
diff --git a/configure.ac b/configure.ac index fe4a45f..6bf6ca1 100644 --- a/configure.ac +++ b/configure.ac @@ -434,6 +434,18 @@ else fi +PKG_CHECK_MODULES(LIBGIOUNIX,gio-unix-2.0 >= 2.74.6,[libgiounix_found=yes],[libgiounix_found=no]) + +if test "$libgiounix_found" = "yes"; then + libgiounix_version=`pkg-config gio-unix-2.0 --modversion` +else + libgiounix_version='-' +fi + +AC_SUBST(LIBGIOUNIX_CFLAGS) +AC_SUBST(LIBGIOUNIX_LIBS) + + #--- Checks for libxml2 PKG_CHECK_MODULES(LIBXML,libxml-2.0 >= 2.6.11,[libxml_found=yes],[libxml_found=no]) @@ -852,6 +864,7 @@ echo The thread support for GLib.................. : $libgthread_version echo The dynamic module loader for GLib........... : $libgmod_version echo The GNU Image Manipulation Program Toolkit... : $libgtk_version echo The GNU Image Manipulation Program Toolkit.4. : $libgtk4_version +echo The GIO UNIX specific APIs................... : $libgiounix_version echo The XML C parser and toolkit of Gnome........ : $libxml_version echo The flexible interface for archives I/O...... : $libarchive_version echo The small, fast and reliable database engine. : $libsqlite_version diff --git a/src/Makefile.am b/src/Makefile.am index 1250b59..66dcbdd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -130,11 +130,12 @@ chrysalide_LDADD = $(LIBINTL) EXTRA_framework_DEPENDENCIES = libchrysacore4.la libchrysacoreui.la framework_SOURCES = \ + app.h app.c \ framework.h framework.c -framework_CFLAGS = $(TOOLKIT4_CFLAGS) +framework_CFLAGS = $(TOOLKIT4_CFLAGS) $(LIBGIOUNIX_CFLAGS) -framework_LDFLAGS = $(TOOLKIT4_LIBS) \ +framework_LDFLAGS = $(TOOLKIT4_LIBS) $(LIBGIOUNIX_LIBS) \ -L.libs -lchrysacore4 -lchrysacoreui framework_LDADD = diff --git a/src/app.c b/src/app.c new file mode 100644 index 0000000..bb0fa8a --- /dev/null +++ b/src/app.c @@ -0,0 +1,137 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * app.c - fichier d'entrée du programme + * + * Copyright (C) 2024 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include <assert.h> +#include <fcntl.h> +#include <gio/gdesktopappinfo.h> +#include <gio/gio.h> +#include <sys/auxv.h> + + +#include "app.h" +#include "common/io.h" +#include "common/xdg.h" +#include "core/logs.h" +#include "glibext/helpers.h" + + + +#define CHRYSALIDE_APP_ID "re.chrysalide.framework.gui" // REMME + + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Installe au besoin une définition locale pour le système. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void ensure_wm_icon_and_name(void) +{ + GDesktopAppInfo *info; /* Information du système */ + GKeyFile *kfile; /* Définition d'application */ + unsigned long exec_path; /* Chemin du programme */ + char *filename; /* Nom de fichier à écrire */ + GBytes *res; /* Données brutes d'une image */ + gsize size; /* Taille de ces données */ + gconstpointer data; /* Pointeur vers les données */ + int fd; /* Flux ouvert en écriture */ + + /* Evaluation du besoin */ + + info = g_desktop_app_info_new(CHRYSALIDE_APP_ID ".desktop"); + + /** + * Si l'exécutable n'est pas valide (inconnu de $PATH), + * la variable info n'est pas initialisée. + */ + + if (info != NULL) + { + unref_object(info); + goto done; + } + + /* Mise en place d'une définition d'application */ + + exec_path = getauxval(AT_EXECFN); + assert(exec_path != 0); + + kfile = g_key_file_new(); + + g_key_file_set_string(kfile, "Desktop Entry", "Name", "Chrysalide"); + g_key_file_set_string(kfile, "Desktop Entry", "Comment[fr]", "Cadriciel de rétronception ciblant principalement les systèmes embarqués"); + g_key_file_set_string(kfile, "Desktop Entry", "Comment", "Reverse Engineering Framework focused on embedded systems"); + g_key_file_set_string(kfile, "Desktop Entry", "Type", "Application"); + g_key_file_set_string(kfile, "Desktop Entry", "Exec", (const char *)exec_path); + g_key_file_set_string(kfile, "Desktop Entry", "Icon", "chrysalide-logo"); + g_key_file_set_string(kfile, "Desktop Entry", "StartupNotify", "true"); + g_key_file_set_string(kfile, "Desktop Entry", "MimeType", "application/vnd.android.package-archive"); + + filename = get_xdg_data_dir("applications/re.chrysalide.framework.gui.desktop", true); + + g_key_file_save_to_file(kfile, filename, NULL); + + free(filename); + + g_key_file_free(kfile); + + /* Ecriture de l'image */ + + res = g_resources_lookup_data("/re/chrysalide/framework/images/chrysalide-logo.svg", + G_RESOURCE_LOOKUP_FLAGS_NONE, NULL); + assert(res != NULL); + + data = g_bytes_get_data(res, &size); + + filename = get_xdg_data_dir("icons/hicolor/scalable/apps/chrysalide-logo.svg", true); + + fd = open(filename, O_WRONLY | O_CREAT); + + if (fd == -1) + LOG_ERROR_N("open"); + + else + { + safe_write(fd, data, size); + close(fd); + } + + free(filename); + + g_bytes_unref(res); + + /* Sortie */ + + done: + + ; + +} diff --git a/src/app.h b/src/app.h new file mode 100644 index 0000000..7696df5 --- /dev/null +++ b/src/app.h @@ -0,0 +1,34 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * app.h - prototypes pour le fichier d'entrée du programme + * + * Copyright (C) 2024 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Chrysalide. If not, see <http://www.gnu.org/licenses/>. + */ + + +#ifndef _APP_H +#define _APP_H + + + +/* Installe au besoin une définition locale pour le système. */ +void ensure_wm_icon_and_name(void); + + + +#endif /* _APP_H */ diff --git a/src/framework.c b/src/framework.c index 96c97c3..9e4f81c 100644 --- a/src/framework.c +++ b/src/framework.c @@ -26,6 +26,7 @@ #include <gtk/gtk.h> +#include "app.h" // REMME #include "framework.h" #include "glibext/helpers.h" #include "gui/core/core.h" @@ -37,6 +38,9 @@ /* --------------------- DEFINITION D'APPLICATION PERSONNALISEE --------------------- */ +#define CHRYSALIDE_APP_ID "re.chrysalide.framework.gui" + + /* Définition de l'application principale graphique (instance) */ struct _GtkChrysalideFramework { @@ -197,7 +201,7 @@ GtkChrysalideFramework *gtk_chrysalide_framework_new(void) GtkChrysalideFramework *result; /* Instance à retourner */ result = g_object_new(GTK_TYPE_CHRYSALIDE_FRAMEWORK, - "application-id", "re.chrysalide.framework", + "application-id", CHRYSALIDE_APP_ID, "flags", G_APPLICATION_DEFAULT_FLAGS, NULL); @@ -348,6 +352,8 @@ int main(int argc, char **argv) if (!load_gui_components(AGC_BUFFER_FEATURES)) return EXIT_FAILURE; + ensure_wm_icon_and_name(); + app = gtk_chrysalide_framework_new(); result = g_application_run(G_APPLICATION(app), argc, argv); diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am index f4a682c..2faef41 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -28,9 +28,10 @@ libgui_la_LIBADD = \ libgui_la_CFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) -libgui4_la_SOURCES = +libgui4_la_SOURCES = \ + resources.h resources.c -libgui4_la_LIBADD = \ +libgui4_la_LIBADD = \ core/libguicore4.la libgui4_la_CFLAGS = $(LIBGTK4_CFLAGS) diff --git a/src/gui/gresource.xml b/src/gui/gresource.xml index 011281d..f8baf25 100644 --- a/src/gui/gresource.xml +++ b/src/gui/gresource.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <gresources> - <gresource prefix="/org/chrysalide/gui"> - <file compressed="true">editor.ui</file> + <gresource prefix="/re/chrysalide/framework/images"> + <file compressed="true" alias="chrysalide-logo.svg">../../pixmaps/chrysalide-logo.svg</file> </gresource> </gresources> |