Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • pygobject pygobject
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 279
    • Issues 279
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 16
    • Merge requests 16
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOME
  • pygobjectpygobject
  • Issues
  • #29

Closed
Open
Created Jun 22, 2012 by Bugzilla@bugzilla-migration💬Reporter

Need an override for g_action_map_add_action_entries()

Submitted by Micah Carrick

Link to original bug (#678655)

Description

I've been tinkering with Gtk.Application.set_menubar() and Gtk.Application.set_app_menu() in Python and have encountered a few issues.

The g_action_map_add_action_entries() doesn't seem to play nice into python. (it wants a Gio.Action but gets StructMeta). Ideally it could work something like:

# window is Gtk.ApplicationWindow
entries = [
    ("fullscreen", window.activate_toggle, False, change_fullscreen_state),
    # etc.
]
window.add_action_entries(entries)

I thought I could simple hack together a patch in gi/overrides/Gio.py similar to what is done with the Gtk.ActionGroup.add_actions(), but, all the GVariant stuff went over my head.

So this is what DOES work. It results in a lot of tedious typing.

# window is Gtk.ApplicationWindow
action = Gio.SimpleAction.new_stateful("fullscreen", None, 
                                       GLib.Variant("b", False))
action.connect("activate", window.activate_toggle)
action.connect("change-state", self.change_fullscreen_state)
window.add_action(action) 
# etc..

I think some of the other classes from GLib like GAction, GActionMap, and GSimpleAction might need some overrides too. That is, I assume we don't want Python applications directly using GLib.Variant? Or maybe we do? It seems to me the "pythonic" way is to make the GVariant based on the python type:

action = Gio.SimpleAction(state=False) 
action = Gio.SimpleAction(state='left')
Edited Mar 19, 2018 by Christoph Reiter
Assignee
Assign to
Time tracking