Skip to content

Commit 6769bd2

Browse files
committed
PanelLabel: GTK4 prep
1 parent 0c9de35 commit 6769bd2

2 files changed

Lines changed: 23 additions & 22 deletions

File tree

src/Indicator.vala

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,28 +52,6 @@ public class DateTime.Indicator : Wingpanel.Indicator {
5252
panel_label = new Widgets.PanelLabel () {
5353
tooltip_markup = Granite.TOOLTIP_SECONDARY_TEXT_MARKUP.printf (_("Middle-click to open Calendar"))
5454
};
55-
56-
panel_label.button_press_event.connect ((e) => {
57-
if (e.button == Gdk.BUTTON_MIDDLE) {
58-
var command = "io.elementary.calendar --show-day %s".printf (new GLib.DateTime.now_local ().format ("%F"));
59-
try {
60-
var appinfo = AppInfo.create_from_commandline (command, null, AppInfoCreateFlags.NONE);
61-
appinfo.launch_uris (null, null);
62-
} catch (GLib.Error e) {
63-
var dialog = new Granite.MessageDialog.with_image_from_icon_name (
64-
_("Unable To Launch Calendar"),
65-
_("The program \"io.elementary.calendar\" may not be installed"),
66-
"dialog-error"
67-
);
68-
dialog.show_error_details (e.message);
69-
dialog.run ();
70-
dialog.destroy ();
71-
}
72-
return Gdk.EVENT_STOP;
73-
}
74-
75-
return Gdk.EVENT_PROPAGATE;
76-
});
7755
}
7856

7957
return panel_label;

src/Widgets/PanelLabel.vala

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public class DateTime.Widgets.PanelLabel : Gtk.Box {
2626
public bool clock_show_seconds { get; set; }
2727
public bool clock_show_weekday { get; set; }
2828

29+
private Gtk.GestureMultiPress gesture_click;
30+
2931
construct {
3032
date_label = new Gtk.Label (null) {
3133
margin_end = 12
@@ -57,6 +59,11 @@ public class DateTime.Widgets.PanelLabel : Gtk.Box {
5759
time_manager = Services.TimeManager.get_default ();
5860
time_manager.minute_changed.connect (update_labels);
5961
time_manager.notify["is-12h"].connect (update_labels);
62+
63+
gesture_click = new Gtk.GestureMultiPress (this) {
64+
button = Gdk.BUTTON_MIDDLE
65+
};
66+
gesture_click.pressed.connect (on_pressed);
6067
}
6168

6269
private void update_labels () {
@@ -72,4 +79,20 @@ public class DateTime.Widgets.PanelLabel : Gtk.Box {
7279
string time_format = Granite.DateTime.get_default_time_format (time_manager.is_12h, clock_show_seconds);
7380
time_label.label = GLib.Markup.printf_escaped ("<span font_features='tnum'>%s</span>", time_manager.format (time_format));
7481
}
82+
83+
private void on_pressed () {
84+
var command = "io.elementary.calendar --show-day %s".printf (new GLib.DateTime.now_local ().format ("%F"));
85+
try {
86+
var appinfo = AppInfo.create_from_commandline (command, null, AppInfoCreateFlags.NONE);
87+
appinfo.launch_uris (null, null);
88+
} catch (GLib.Error e) {
89+
var dialog = new Granite.MessageDialog.with_image_from_icon_name (
90+
_("Unable To Launch Calendar"),
91+
_("The program \"io.elementary.calendar\" may not be installed"),
92+
"dialog-error"
93+
);
94+
dialog.show_error_details (e.message);
95+
dialog.present ();
96+
}
97+
}
7598
}

0 commit comments

Comments
 (0)