Re: Gtk::Application with a non-unique gtk appl



Basile Starynkevitch:
> Hello All,
>
>
> ### context ###
> I'm working on the MELT plugin of the GCC compiler, see http://gcc-melt.org/ for more.
>
> I'm adding to MELT the ability to interact with a graphical probe. In broad terms, 
> when you invoke the GCC compiler with specific arguments 
>   gcc -fplugin=melt -fplugin-arg-melt-mode=probe -c -O your-source.c 
> for example, a GTK application is "magically" forked by GCC and communicates with
> GCC (actually the cc1 program) to display various information about the compilation.
> The probe is communicating thru two textual asynchronous pipes with cc1.
>
> The probe (GPLv3 licensed) is written in C++11 using GtkMM 3.4 & GtkSourcecViewMM; you could find its 
> code under contrib/ of the melt-branch of GCC. In particular, see 
> http://gcc.gnu.org/viewcvs/branches/melt-branch/contrib/simplemelt-gtkmm-probe.cc
>
> This is a self-contained GtkMM application. A comment near the end of the file shows how to compile it.
> The probe is currently in bad state (svn rev 187541); in its previous revision 
> svn 187245 it worked a bit better but did not use Gtk::Application but just Gtk::Main..
>
>
> And my probe GtkMM application wants to parse some arguments, in particular it 
> could be invoked by cc1 (thru a user-provided shell script called melt-probe) as
>   simple-melt-probe -T --command-from-MELT 5 --request-to-MELT 6 
> where 5 is the file descriptor of the pipe from MELT to the probe and 6 
> is the file descriptor from the graphical probe to MELT; You might test it
> using 0 (for stdin) instead of 5 and 1 (for stdout) instead of 6. The you would
> type commands like
>
>    SHOWFILE_pcd "testfile.c" 1
>
>
>    VERSION_pcd 
>    
>    
> [notice that commands should be ended by two consecutive newlines]
>
> ### question ####
> I don't understand exactly when should I use the Gtk::Application class, 
> and when should I avoid using it and instead use Gtk::Main which is 
> marked as deprecated.
>
> In particular, my application has no "uniqueness" requirement. I would imagine 
> that some user might want to run a few processes (e.g. a few "instances") of it 
> on the same desktop.
>
> Should I still use Gtk::Application for an application which could have several
> (unrelated) processes (all running the same ELF executable)? Or is Gtk::Application 
> useless (or even harmful) in that case?
>
>
> Regards.
I am relatively new to gtk+ and gtkmm programming and now it is my
second try after two years to learn and use it in my projects. The
concept of Gtk::Application is yet poorly documented but as far as I
know it is a good practice to use it. Gtk::Application is framework-like
approach to write gtk+ (gtkmm) applications in cleaner way. You have all
common elements of typical application gathered in one place (class) in
a way that lets them "talk" to each other. For most  of common apps
there is no need to reinvent the wheel and write your custom code, but
if you feel that your plug in is so specific and that Gtk::Application
is so generic and does not fit your needs, you might want to go the old
way (with Gtk::Main).

Mateusz Marzantowicz



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]