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 666816 - Use GtkApplication
Use GtkApplication
Status: RESOLVED FIXED
Product: gnome-nibbles
Classification: Applications
Component: general
git master
Other Linux
: Normal enhancement
: ---
Assigned To: gnome-nibbles-maint
gnome-nibbles-maint
Depends on:
Blocks: 708101
 
 
Reported: 2011-12-24 23:26 UTC by Robert Ancell
Modified: 2014-02-15 21:07 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
initial try at gtkapplication switch (3.05 KB, patch)
2014-01-09 03:41 UTC, gQuigs
none Details | Review
current patch to switch to gtk application (29.64 KB, application/octet-stream)
2014-01-15 04:08 UTC, gQuigs
  Details
screenshot (375.50 KB, image/png)
2014-02-02 16:37 UTC, Michael Catanzaro
  Details
My AppMenu on Gnome Shell (124.27 KB, image/png)
2014-02-03 04:43 UTC, gQuigs
  Details
AppMenu on Unity (27.02 KB, image/png)
2014-02-03 04:44 UTC, gQuigs
  Details

Description Robert Ancell 2011-12-24 23:26:53 UTC
Use GtkApplication
Comment 1 gQuigs 2014-01-09 03:41:39 UTC
Created attachment 265816 [details] [review]
initial try at gtkapplication switch

It breaks screen resizing/fullscreening/quiting but I think those need to be redone anyway to finish this.

If anyone else wants to hack on this before UI freeze, let me know and I'll commit it to master..  I think we should be able to have it working at least as before by the freeze date.
Comment 2 Michael Catanzaro 2014-01-11 16:18:42 UTC
FYI: this is near the top of my to-do list.  We'll probably need to create a NibblesApplication GObject that inherits from GtkApplication. At least, I've never seen anyone create a plain GtkApplication before, so I don't know if that will work.

It'd probably be better to keep this in Bugzilla until it's ready.
Comment 3 gQuigs 2014-01-15 04:08:49 UTC
Created attachment 266328 [details]
current patch to switch to gtk application

Making good progress.. 
I'm ignoring the lack or resizing by the clutter object right now
Pause works, but unpause doesn't
Fullscreen doesn't currently work, but AppMenu plumbing is up (and it worked via F11 before I tried to make a menu item)
Sensitivity needs to be re-added so you can't launch preferences when running a game, etc.

I'm thinking about committing as soon as I fix 2/4 of the above so that work on GtkHeaderBar can proceed easier.. I'm guessing we don't want to release it with no menu and no HeaderBar?
Comment 4 Michael Catanzaro 2014-01-15 16:45:55 UTC
I'd prefer if we not break anything when we land this!

I do want to add an application menu for 3.12, and we need GtkApplication for that, but it's the difference between being two years late and two and a half years late: not a huge deal. Breaking resizing or unpause would be a huge deal. :)  (A headerbar would be a nice bonus, but one thing at a time: GtkApplication needs to come first so that we can remove the menu bar.)

I do not care about fullscreen, though: like the other games, Nibbles looks terrible in fullscreen, and I'd prefer we remove features that make the game look terrible.  I've removed fullscreen from half the other games already. Of course, whether we do that for Nibbles is up to you.
Comment 5 gQuigs 2014-01-16 17:47:36 UTC
Committed in: https://git.gnome.org/browse/gnome-nibbles/commit/?id=f54f2b22fb5ad43838a6dafdcc1f993d23ebdac2
GtkApplication Port w/ AppMenu
The Pause button now causes the game to pause 
Fullscreen has been removed 
Removing mouse pointer on the clutter instance was also removed 

Pause works fully as does resize (or as well as it did on GtkAspectFrame, but may revert to GamesGridFrames ~ unrelated to this bug)


AppMenu items don't show sensitivity to the situation, yet..  this is the only user facing open issue.
Comment 6 Michael Catanzaro 2014-01-17 07:07:58 UTC
Looks good!

A couple thoughts:

* We need to rename Pause to Resume if the game is currently paused. Unfortunately I don't think this is possible with a menu built with GtkBuilder. :S [1] shows how to handle this.
* You left a couple TODO lines in main()

> AppMenu items don't show sensitivity to the situation, yet..  this is the only
> user facing open issue.

You can use g_action_map_lookup_action() to access the GAction, cast it to a GSimpleAction (any action added with GActionEntry is a GSimpleAction), and then use g_simple_action_set_enabled(). [2] is a Vala example; not sure how much that will help you.

[1] https://git.gnome.org/browse/gnome-chess/commit/?id=af1d76a4dcde59be1f1bbc1226b8e508da3eae2f
[2] https://github.com/GNOME/gnome-chess/blob/5bb130607e1e758a6cc982a91e7d58a9a7e2199b/src/gnome-chess.vala#L2100
Comment 7 gQuigs 2014-02-02 05:11:37 UTC
>* We need to rename Pause to Resume if the game is currently paused.

I was going to ask if you didn't like having it be a switch on/off.. but could that really be dependent on themes?  I just tried on another machine and it doesn't show up at all :/

>>> AppMenu items don't show sensitivity to the situation, yet..
Thanks for the suggestion, it did help fixed in https://git.gnome.org/browse/gnome-nibbles/commit/?id=260dd25dfcac0b84e36b574abf3bb2879fe0cfbc

>* You left a couple TODO lines in main()
The other TODOs were fixed.
Comment 8 Michael Catanzaro 2014-02-02 16:29:07 UTC
(In reply to comment #7)
> I was going to ask if you didn't like having it be a switch on/off.. but could
> that really be dependent on themes?  I just tried on another machine and it
> doesn't show up at all :/

Could you post screenshots of what you're seeing?  Sometimes the app menu behaves a bit differently from other menus.... I don't see anything wrong with your code, but I've never tried to do this before, either.

Long-term, we actually don't want Pause/Resume in the app menu at all: ideally there would be a single button for Pause, Resume, and New Game inside the window itself.  (See e.g. the latest versions of Mines or Quadrapassel.)  It would go on the bottom-right, underneath the scoreboard, which would be removed from the status bar.  (This is just my brainstorming how to make Nibbles match the other newly-redesigned games: there's plenty of other ways we could do this.) But if you don't have time to redesign everything again in the next two weeks before freeze :) then it'd be simplest to just build the menu like I did in Mines.
Comment 9 Michael Catanzaro 2014-02-02 16:37:45 UTC
Created attachment 267856 [details]
screenshot

There's a few different possibilities for where the app menu might be shown:

1) Shell shows app menu
--- GNOME: the screenshot above, no toggle button here :(
--- Unity, OS X: the leftmost menu on the global menu bar (for Nibbles, the only menu)

2) Window shows app menu (Windows, MATE, Cinnamon, KDE, Xfce, etc.)
--- Apps with header bars: leftmost item in the header bar. (Thanks to your work removing the menu bar, Nibbles is now ready for a header bar.)
--- Apps without header bars: again the leftmost menu in the menu bar. The menu bar will be shown only for this menu, and it will be ugly.
--- We could also manually override this (but we don't want to)
Comment 10 gQuigs 2014-02-03 04:43:45 UTC
Created attachment 267913 [details]
My AppMenu on Gnome Shell
Comment 11 gQuigs 2014-02-03 04:44:52 UTC
Created attachment 267914 [details]
AppMenu on Unity

Attached what shows up in the AppMenu on Unity/Gnome Shell.
Comment 12 Michael Catanzaro 2014-02-03 18:10:28 UTC
We might be looking at a regression in GNOME Shell.  Between 3.8 (is that the version you're using?) and 3.10 the toggle buttons in other app menus (Rhythmbox, Packages) changed to check marks, but both of those app menus are using GSettingsAction rather than GSimpleAction so we're not quite in the same situation....

Anyway, that's really worth creating a separate bug: Nibbles now does use GtkApplication, so this one is fixed IMO.
Comment 13 gQuigs 2014-02-15 21:07:06 UTC
Opened a new bug here to track the Pause issue: https://bugzilla.gnome.org/show_bug.cgi?id=724439

Closing this one