• Re: cherche exemple de code GtkMM4 (C++) pour ajouter des options =?utf

    From Lamourec Alain@21:1/5 to Basile Starynkevitch on Sat Feb 10 22:00:01 2024
    Bonsoir

    Sur cet exemple, j'ai plutôt Gio::Application::OPTION_TYPE_BOOL et Gio::Application::OPTION_TYPE_STRING : https://student.cs.uwaterloo.ca/~cs246/common/gtkmm/gtkmm-examples-3.0/09-commandLine/ex2/exampleapplication.cc

    Voir également la documentation : https://gnome.pages.gitlab.gnome.org/glibmm/classGio_1_1Application.html



    Basile Starynkevitch <basile@starynkevitch.net> writes:

    Bonjour la liste,

    GTK4 interface to RefPerSys inference engine. Contribute to RefPerSys/gtk4gui-refpersys development by creating an account
    on GitHub.

    github.com

    GitHub - RefPerSys/gtk4gui-refpersys: GTK4 interface to
    RefPerSys inference engine

    GTK4 interface to RefPerSys inference engine. Contribute to RefPerSys/gtk4gui-refpersys development by creating an account
    on GitHub.

    🔗 https://github.com/RefPerSys/gtk4gui-refpersys

    est l'embryon d'un logiciel libre (sous licence MIT, je vais
    peut-être plus tard la remplacer par la licence CeCILL ou
    GPLv3+) d'interface graphique pour
    le moteur d'inférences RefPerSys, lui-même en cours de
    développement en

    Reflexive & Persistent System (artificial intelligence) - GitHub
    - RefPerSys/RefPerSys: Reflexive & Persistent System (artificial intelligence)

    github.com

    GitHub - RefPerSys/RefPerSys: Reflexive & Persistent System
    (artificial intelligence)

    Reflexive & Persistent System (artificial intelligence) - GitHub
    - RefPerSys/RefPerSys: Reflexive & Persistent System (artificial intelligence)

    🔗 https://github.com/RefPerSys/RefPerSys

    pour Linux et sous licence GPLv3+ (ou la CeCILL équivalente).

    ce gtk4gui-refpersys contient le code suivant:

    -------------------------------------------------------------------------------------------------------------------------

    // file RefPerSys/gtk4gui-refpersys/mainrps_gtk.cc
    // SPDX-License-Identifier: MIT

    /******
    * © Copyright 2023 - 2024 Basile STARYNKEVITCH and Abishek
    CHAKRAVARTI
    *
    * A GTK4mm toolkit graphical interface (see fox-toolkit.org)
    * to the RefPerSys open source (GPLv3+ licensed) inference
    engine
    *
    * see gnome.pages.gitlab.gnome.org/gtkmm-documentation/
    *
    * See refpersys.org and code on https://github.com/RefPerSys/
    *
    ******/

    #include "gtkrps.hh"

    #include "gtkmm/version.h"

    const char*gtkrps_progname;
    const char gtkrps_git_id[] = GIT_ID;
    const char gtkrps_shortgit_id[] = SHORTGIT_ID;
    const char gtkrps_buildhost[]= GTKRPS_HOST;
    const char gtkrps_arch[] = GTKRPS_ARCH;
    const char gtkrps_opersys[] = GTKRPS_OPERSYS;
    const char gtkrps_timestamp[] = __DATE__ "@" __TIME__;

    extern "C" const char guirefpersys_ui[];
    char gtkrps_myhostname[80];
    void* gtkrps_dlhandle;
    bool gtkrps_stderr_istty;

    static void
    gtkrps_show_version(void)
    {
    printf("%s version information\n", gtkrps_progname);
    printf("\t full git %s\n", gtkrps_git_id);
    printf("\t short git %s\n", gtkrps_shortgit_id);
    printf("\t build host %s\n", gtkrps_buildhost);
    printf("\t arch: %s\n", gtkrps_arch);
    printf("\t OS: %s\n", gtkrps_opersys);
    printf("\t built: %s\n", gtkrps_timestamp);
    /// for some reason, don't work!
    #if 0 && bad
    printf("\t GTKmm version: %d.%d.%d\n",
    gtkmm_major_version, gtkmm_minor_version,
    gtkmm_micro_version);
    #endif
    } // end gtkrps_show_version

    void
    gtkrps_fatal_stop_at(const char*fil, int lin)
    {
    fprintf(stderr, "%s FATAL STOP (%s:%d) pid %d shortgit %s\n",
    gtkrps_progname,
    fil, lin,
    (int)getpid(), gtkrps_shortgit_id);
    abort();

    } // end gtkrps_fatal_stop_at

    extern "C" const char gtkrpsui_guirefpersys[];

    Glib::RefPtr<Gtk::Application> gtkrps_app;
    Gtk::Window*gtkrps_mainwin;

    int
    main(int argc, char**argv)
    {
    assert(argc>0);
    gtkrps_progname = argv[0];
    gtkrps_dlhandle = dlopen(nullptr, RTLD_NOW| RTLD_GLOBAL);
    if (!gtkrps_dlhandle)
    GTKRPS_FATALOUT("failed to dlopen main program: " <<
    dlerror());
    gtkrps_stderr_istty = isatty(STDERR_FILENO);
    memset (gtkrps_myhostname, 0, sizeof(gtkrps_myhostname));
    gethostname(gtkrps_myhostname, sizeof(gtkrps_myhostname)-4);
    if (argc > 1 && !strcmp(argv[1], "--version"))
    {
    gtkrps_show_version();
    exit (EXIT_SUCCESS);
    };
    gtkrps_app = Gtk::Application::create
    ("org.refpersys.gtk4gui");
    #warning help needed here to parse program arguments
    #if 0 && badcode ///////////////////////////////=============================
    gtkrps_app->add_main_option_entry(Gtk::OPTION_TYPE_BOOL,
    "version", 'V',
    ("Print version"),
    "");
    gtkrps_app->add_main_option_entry(Gtk::Application::OPTION_TYPE_STRING,
    "fifo-prefix", 'F',
    ("set the prefix of FIFO
    used for communication"),
    "");
    #endif
    Glib::ustring builder_str(gtkrpsui_guirefpersys);
    auto builder = Gtk::Builder::create_from_string(builder_str);
    gtkrps_app->signal_activate().connect([&] ()
    {
    gtkrps_mainwin =
    builder->get_widget<Gtk::Window>("app_window");
    gtkrps_app->add_window(*gtkrps_mainwin);
    gtkrps_mainwin->show();
    });
    return gtkrps_app->run(argc, argv);
    } // end main

    /****************
    ** for Emacs...
    ** Local Variables: ;;
    ** compile-command: "make guigtkrps" ;;
    ** End: ;;
    ****************/

    -------------------------------------------------------------------------------------------------------------------------

    Voir ci dessus les lignes autour du //////////========

    Mais ça fait plusieurs jours que je bute sur l'utilisation de la
    méthode add_main_option_entry dans GTKmm4. Si j'enlève le #if 0
    j'ai une erreur de
    compilation (avec g++-13):

    rimski.x86_64 ~/gtk4gui-refpersys 16:50 .0 % make mainrps_gtk.o
    g++ -fPIE -O1 -I/usr/include/gtkmm-4.0 -I/usr/lib/x86_64-linux-gnu/gtkmm-4.0/include
    -I/usr/include/giomm-2.68
    -I/usr/lib/x86_64-linux-gnu/giomm-2.68/include
    -I/usr/include/glib-2.0
    -I/usr/lib/x86_64-linux-gnu/glib-2.0/include
    -I/usr/include/libmount -I/usr/include/blkid
    -I/usr/include/glibmm-2.68
    -I/usr/lib/x86_64-linux-gnu/glibmm-2.68/include
    -I/usr/include/sigc++-3.0
    -I/usr/lib/x86_64-linux-gnu/sigc++-3.0/include
    -I/usr/include/gtk-4.0 -I/usr/include/pango-1.0
    -I/usr/include/harfbuzz -I/usr/include/freetype2
    -I/usr/include/libpng16 -I/usr/include/fribidi
    -I/usr/include/cairo -I/usr/include/pixman-1
    -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/x86_64-linux-gnu -I/usr/include/webp -I/usr/include/graphene-1.0 -I/usr/lib/x86_64-linux-gnu/graphene-1.0/include
    -I/usr/include/cairomm-1.16
    -I/usr/lib/x86_64-linux-gnu/cairomm-1.16/include
    -I/usr/include/pangomm-2.48
    -I/usr/lib/x86_64-linux-gnu/pangomm-2.48/include -I/usr/include/gtk-4.0/unix-print -mfpmath=sse -msse -msse2
    -pthread -I/usr/include/jsoncpp -DGIT_ID=\"34e23fb9c26d316f6113f5c1a52146e80b3683d3+\" -DSHORTGIT_ID=\"34e23fb9c26d+\" -DGTKRPS_HOST=\"rimski.lesours\" -DGTKRPS_ARCH=\"x86_64\" -DGTKRPS_OPERSYS=\"GNU_Linux\" -c -o mainrps_gtk.o mainrps_gtk.cc
    mainrps_gtk.cc:85:2: warning: #warning help needed here to parse
    program arguments [-Wcpp]
    85 | #warning help needed here to parse program arguments
    | ^~~~~~~
    mainrps_gtk.cc: In function ‘int main(int, char**)’: mainrps_gtk.cc:87:42: error: ‘OPTION_TYPE_BOOL’ is not a member
    of ‘Gtk’
    87 |
    gtkrps_app->add_main_option_entry(Gtk::OPTION_TYPE_BOOL,
    "version", 'V',
    |
    ^~~~~~~~~~~~~~~~
    mainrps_gtk.cc:89:55: error: ‘OPTION_TYPE_STRING’ is not a
    member of ‘Gtk::Application’
    89 |
    gtkrps_app->add_main_option_entry(Gtk::Application::OPTION_TYPE_STRING,
    "fifo-prefix", 'F',
    |

    Où est mon erreur? Comment utiliser add_main_option_entry?

    Merci de vos lumières et de votre aide


    --
    Lamourec Alain

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)