-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use action parameters, improve layout
- Loading branch information
1 parent
c54824c
commit 74ac8fb
Showing
2 changed files
with
20 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,27 @@ | ||
import Gdk from "gi://Gdk"; | ||
import GLib from "gi://GLib"; | ||
import Gio from "gi://Gio"; | ||
|
||
const box_menu_parent = workbench.builder.get_object("box_menu_parent"); | ||
const label_emoji = workbench.builder.get_object("label_emoji"); | ||
const gesture_click = workbench.builder.get_object("gesture_click"); | ||
const popover_menu = workbench.builder.get_object("popover_menu"); | ||
|
||
gesture_click.connect("pressed", (_, __, x, y) => { | ||
const position = new Gdk.Rectangle(); | ||
position.x = x; | ||
position.y = y; | ||
gesture_click.connect("pressed", (_self, _n_press, x, y) => { | ||
const position = new Gdk.Rectangle({ x: x, y: y }); | ||
popover_menu.set_pointing_to(position); | ||
popover_menu.popup(); | ||
}); | ||
|
||
const mood_group = new Gio.SimpleActionGroup(); | ||
box_menu_parent.insert_action_group("mood", mood_group); | ||
|
||
const happy_action = new Gio.SimpleAction({ | ||
name: "happy", | ||
const emoji_action = new Gio.SimpleAction({ | ||
name: "emoji", | ||
parameter_type: new GLib.VariantType("s"), | ||
}); | ||
|
||
happy_action.connect("activate", () => { | ||
label_emoji.label = "😀"; | ||
emoji_action.connect("activate", (_action, parameter) => { | ||
label_emoji.label = parameter.deepUnpack().toString(); | ||
}); | ||
mood_group.add_action(happy_action); | ||
|
||
const start_struck_action = new Gio.SimpleAction({ | ||
name: "start-struck", | ||
}); | ||
|
||
start_struck_action.connect("activate", () => { | ||
label_emoji.label = "🤩"; | ||
}); | ||
mood_group.add_action(start_struck_action); | ||
|
||
const partying_action = new Gio.SimpleAction({ | ||
name: "partying", | ||
}); | ||
|
||
partying_action.connect("activate", () => { | ||
label_emoji.label = "🥳"; | ||
}); | ||
mood_group.add_action(partying_action); | ||
mood_group.add_action(emoji_action); |