2
This file is part of LoggerOuter.
4
LoggerOuter is free software: you can redistribute it and/or modify it under the
5
terms of the GNU Lesser General Public License as published by the Free Software
6
Foundation, either version 3 of the License, or (at your option) any later
9
LoggerOuter is distributed in the hope that it will be useful, but WITHOUT
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
12
License for more details.
14
You should have received a copy of the GNU Lessel General Public License
15
along with LoggerOuter. If not, see <https://www.gnu.org/licenses/>.
18
public class LO.ActionButton : Gtk.Button {
19
// This whole class is cursed. :-)
22
Gtk.Label widget_label;
30
string[]? argv = null;
31
string[] envp = Environ.get ();
34
GLib.Shell.parse_argv (exec_action, out argv);
36
GLib.Process.spawn_async (null, argv, envp,
37
GLib.SpawnFlags.DO_NOT_REAP_CHILD | GLib.SpawnFlags.SEARCH_PATH_FROM_ENVP ,
40
} catch (GLib.SpawnError e) {
41
prensent_dialog ("ERROR: %s\n", e.message);
42
} catch (GLib.ShellError e) {
43
prensent_dialog ("ERROR: %s\n", e.message);
49
public ActionButton (ActionEntry action) {
50
this.box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) {
54
if (action.icon != null) {
55
this.icon = new Gtk.Image () {
63
if (!action.icon_is_path) {
64
icon.icon_name = action.icon;
66
_icon_name = strip_prelude_of_path (action.icon);
67
this.icon.set_from_file (_icon_name);
72
if (action.text != null) {
73
_button_text = action.text;
75
_button_text = action.group;
78
this.exec_action = action.exec;
80
this.widget_label = new Gtk.Label (_button_text) {
83
halign = Gtk.Align.CENTER,
84
valign = Gtk.Align.CENTER,
87
box.append (widget_label);
88
this.set_child (this.box);
90
this.clicked.connect (() => {
91
var timer = new LO.Timer (this._button_text, 15, (e) => {
92
if (e == LO.Timer.ExitCode.OK) {
96
timer.set_transient_for (app.get_active_window ());
103
this.focusable = true;