After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 127958 - add GtkApplication class
add GtkApplication class
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Class: GtkApplication
unspecified
Other All
: Normal enhancement
: 3.0
Assigned To: gtk-bugs
gtk-bugs
: 533003 588855 (view as bug list)
Depends on: 79285 79287 120649 127956
Blocks: 353076 588969
 
 
Reported: 2003-11-26 09:00 UTC by Matthias Clasen
Modified: 2011-01-04 13:46 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Header file of my code (2.14 KB, text/x-chdr)
2007-01-18 14:00 UTC, Sven Herzberg
  Details
C-Source file of my code (5.40 KB, text/x-csrc)
2007-01-18 14:01 UTC, Sven Herzberg
  Details
Add GtkApplication (31.36 KB, patch)
2010-04-13 18:09 UTC, Colin Walters
none Details | Review
Add GtkApplication (17.19 KB, patch)
2010-04-18 19:03 UTC, Colin Walters
none Details | Review
Add GtkApplication (19.91 KB, patch)
2010-04-21 18:46 UTC, Colin Walters
none Details | Review

Description Matthias Clasen 2003-11-26 09:00:40 UTC
a tracker bug.
Comment 1 Matthias Clasen 2003-11-26 09:02:46 UTC
Leaving this open to deal with documenting how to do it manually in 
the meantime, e.g. by moving the testmerge code to gtk-demo and/or 
adding it as an example to the connect-proxy signal documentation.
Comment 2 Matthias Clasen 2003-11-26 09:03:45 UTC
Urk, that comment was obviously meant for the other side of the 
dependency...
Comment 3 Sven Herzberg 2006-08-14 15:01:16 UTC
I have some code that provides a main window class (deriving from GtkWindow) which includes these features:

* UI Manager based menus (using some placeholders to arrange them properly)
* Quit and Close menu items (though these two need to be implemented yet)
* Optional statusbar (depends on a construct property)
* displays the tooltips for menu items in the status bar
* provides callback to save/restore window position and size

Do you want me to attach it?
Comment 4 Sven Herzberg 2006-08-14 15:46:46 UTC
The different and missing part is basically implementing a these MDI schemes (and a way to choose one):

Single-Window-App
 * hide "Quit" as "Close" is the same (and in case the user opens multiple
   windows, "Close" will still behave as with SDI - "Quit" would not)

SDI
 * implement quit as "go through the list and close one after the other"
 * this should use one list per class/type

MDI
 * implement quit as "close window" after emitting a "close" signal for every
   open document
Comment 5 Federico Mena Quintero 2006-08-14 17:42:33 UTC
Herzi: yes, please attach that code!

I think MDI issues are orthogonal to an AppWindow widget.  The MDI handler could wrap the appropriate bits of the menu API.
Comment 6 Christian Neumair 2007-01-18 12:43:51 UTC
herzi: ping
Comment 7 Sven Herzberg 2007-01-18 14:00:54 UTC
Created attachment 80599 [details]
Header file of my code
Comment 8 Sven Herzberg 2007-01-18 14:01:51 UTC
Created attachment 80600 [details]
C-Source file of my code

These are the files that I'm using in several projects.
Comment 9 Javier Jardón (IRC: jjardon) 2009-05-25 16:38:08 UTC
Progress in abstract base class for applications: http://live.gnome.org/GTK%2B/ApplicationClass
Comment 10 Matthias Clasen 2009-07-17 13:06:53 UTC
*** Bug 588855 has been marked as a duplicate of this bug. ***
Comment 11 Sven Herzberg 2010-02-10 19:55:11 UTC
*** Bug 533003 has been marked as a duplicate of this bug. ***
Comment 12 Colin Walters 2010-04-13 18:09:49 UTC
Created attachment 158630 [details] [review]
Add GtkApplication

This is a work in progress to stub out an application class.  The
primary goal is to provide a mechanism for applications to export
GtkActions, and there is a standard "Quit".

Future work:
 * Rebase on GApplication
 * Manage toplevel GtkWindows
 * Add a way to say "This is my application menubar", which gets
   put into all toplevel windows on non-OS-X, and into the top
   on OS X.
Comment 13 Sven Herzberg 2010-04-14 10:20:12 UTC
(In reply to comment #12)
>  * Add a way to say "This is my application menubar", which gets
>    put into all toplevel windows on non-OS-X, and into the top
>    on OS X.

Do I understand this right if I think "this patch is a preparation for the appwindow widget"?

The appwindow would then automatically have a GtkMenubar being built from the GtkApplication (unless being executed on Mac OS X or a GNU/Linux desktop using a global menu bar).

Will we need to have GtkUIManager support for the global menu? It would be great if the global menu could be managed by a GtkUIManager.

It would be great to have an analysis if we would need to break GtkUIManager (ABI and/or API) for this.
Comment 14 Colin Walters 2010-04-18 19:03:35 UTC
Created attachment 159032 [details] [review]
Add GtkApplication

This is a work in progress to stub out an application class.  The
primary goal is to provide a mechanism for applications to export
GtkActions, and there is a standard "Quit".

This is based on GApplication; see
http://people.gnome.org/~walters/gapplication-standalone.git/

Future work:
 * Manage toplevel GtkWindows
 * Add a way to say "This is my application menubar", which gets
   put into all toplevel windows on non-OS-X, and into the top
   on OS X.
Comment 15 Javier Jardón (IRC: jjardon) 2010-04-18 19:18:12 UTC
Review of attachment 159032 [details] [review]:

A little comment: Do not use gtk_application_get_private() but app->priv instead. Also, I think It's not needed to seal the priv member in public structure.
Comment 16 Colin Walters 2010-04-21 18:46:19 UTC
Created attachment 159277 [details] [review]
Add GtkApplication

This is a work in progress to stub out an application class.  The
primary goal is to provide a mechanism for applications to export
GtkActions, and there is a standard "Quit".

This is based on GApplication; see
http://people.gnome.org/~walters/gapplication-standalone.git/

Future work:
 * Manage toplevel GtkWindows
 * Add a way to say "This is my application menubar", which gets
   put into all toplevel windows on non-OS-X, and into the top
   on OS X.
Comment 17 Bastien Nocera 2010-04-30 18:29:01 UTC
My comments to Colin were that, the GApplication interface should make it easy to add new "actions" (remote object methods) that would require arguments, or return arguments. Either through the GApplication API, or making it easy to implement new methods through GDBus (although it might lose some of its cross-platform appeal).

Also, should GtkApplication have a "present" action, to show the main window?
Comment 18 Bastien Nocera 2010-04-30 18:33:56 UTC
The patch to add GtkApplication should have one example of a stand-alone app, a single-instance application passing extra options, and an app that shows the exported actions for a running app.
Comment 19 Emmanuele Bassi (:ebassi) 2010-05-18 13:33:03 UTC
just for reference: the wip/gapplication branch in GLib has the GApplication code from gapplication-standalone and is currently under review.
Comment 20 Colin Walters 2010-05-19 02:10:32 UTC
The GtkApplication patch now exists as a GTK+ branch off of gtk-2-22:

http://git.gnome.org/browse/gtk+/log/?h=wip/gapplication-2-22
Comment 21 Havoc Pennington 2010-06-11 03:42:08 UTC
I've always thought it would be nice to handle "initial launch of first instance" with the exact same callback as "new document filenames received from a second invocation" e.g. 
http://mail.gnome.org/archives/gtk-devel-list/2007-August/msg00039.html
in order to ensure that there weren't two codepaths, one rarely-tested.
Another advantage of this is that it actively discourages "args that only make sense for the first instance" / "args that cannot be forwarded"

Another random question is whether it automatically (by default) quits on losing the bus name, allowing --replace . If it does do this, then Quit dbus method isn't really required, since anyone can just take the bus name then drop it. Though Quit is perhaps more obvious. Also, --replace could be a default option automatically provided by gtk.

btw, gtk-example-application.c could be shorter ... some kind of convenience function would really be nice, or just an example with fewer bells and whistles in the docs.
Compare to: http://doc.trolltech.com/4.3/tutorial-t1.html
Yeah that program isn't doing quite as much, but nonetheless. The builder and action group stuff in the example looks like it's just itching for some kind of convenience API.
Comment 22 Bastien Nocera 2010-08-04 00:18:03 UTC
(In reply to comment #20)
> The GtkApplication patch now exists as a GTK+ branch off of gtk-2-22:
> 
> http://git.gnome.org/browse/gtk+/log/?h=wip/gapplication-2-22

Will this be merged in GTK+ 2.22, or just for GTK+ 3.x?
Comment 23 Javier Jardón (IRC: jjardon) 2011-01-04 13:46:00 UTC
This was already merged in GTK+3