Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 4 additions & 26 deletions src/Indicator.vala
Original file line number Diff line number Diff line change
Expand Up @@ -52,28 +52,6 @@ public class DateTime.Indicator : Wingpanel.Indicator {
panel_label = new Widgets.PanelLabel () {
tooltip_markup = Granite.TOOLTIP_SECONDARY_TEXT_MARKUP.printf (_("Middle-click to open Calendar"))
};

panel_label.button_press_event.connect ((e) => {
if (e.button == Gdk.BUTTON_MIDDLE) {
var command = "io.elementary.calendar --show-day %s".printf (new GLib.DateTime.now_local ().format ("%F"));
try {
var appinfo = AppInfo.create_from_commandline (command, null, AppInfoCreateFlags.NONE);
appinfo.launch_uris (null, null);
} catch (GLib.Error e) {
var dialog = new Granite.MessageDialog.with_image_from_icon_name (
_("Unable To Launch Calendar"),
_("The program \"io.elementary.calendar\" may not be installed"),
"dialog-error"
);
dialog.show_error_details (e.message);
dialog.run ();
dialog.destroy ();
}
return Gdk.EVENT_STOP;
}

return Gdk.EVENT_PROPAGATE;
});
}

return panel_label;
Expand Down Expand Up @@ -107,9 +85,9 @@ public class DateTime.Indicator : Wingpanel.Indicator {
component_listbox.set_sort_func (sort_function);

var scrolled_window = new Gtk.ScrolledWindow (null, null) {
hscrollbar_policy = Gtk.PolicyType.NEVER
hscrollbar_policy = Gtk.PolicyType.NEVER,
child = component_listbox
};
scrolled_window.add (component_listbox);

var settings_button = new Gtk.ModelButton () {
text = _("Date & Time Settings…")
Expand Down Expand Up @@ -157,8 +135,8 @@ public class DateTime.Indicator : Wingpanel.Indicator {
"dialog-error"
);
dialog.show_error_details (e.message);
dialog.run ();
dialog.destroy ();
dialog.response.connect ((_dialog, response) => _dialog.destroy ());
dialog.present ();
Comment thread
leolost2605 marked this conversation as resolved.
}
close ();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Services/TimeManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ interface FDO.Accounts : Object {
public abstract string find_user_by_name (string username) throws GLib.Error;
}

public class DateTime.Services.TimeManager : Gtk.Calendar {
public class DateTime.Services.TimeManager : Object {
private static TimeManager? instance = null;

public signal void minute_changed ();
Expand Down
24 changes: 24 additions & 0 deletions src/Widgets/PanelLabel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class DateTime.Widgets.PanelLabel : Gtk.Box {
public bool clock_show_seconds { get; set; }
public bool clock_show_weekday { get; set; }

private Gtk.GestureMultiPress gesture_click;

construct {
date_label = new Gtk.Label (null) {
margin_end = 12
Expand Down Expand Up @@ -57,6 +59,11 @@ public class DateTime.Widgets.PanelLabel : Gtk.Box {
time_manager = Services.TimeManager.get_default ();
time_manager.minute_changed.connect (update_labels);
time_manager.notify["is-12h"].connect (update_labels);

gesture_click = new Gtk.GestureMultiPress (this) {
button = Gdk.BUTTON_MIDDLE
};
gesture_click.pressed.connect (on_pressed);
}

private void update_labels () {
Expand All @@ -72,4 +79,21 @@ public class DateTime.Widgets.PanelLabel : Gtk.Box {
string time_format = Granite.DateTime.get_default_time_format (time_manager.is_12h, clock_show_seconds);
time_label.label = GLib.Markup.printf_escaped ("<span font_features='tnum'>%s</span>", time_manager.format (time_format));
}

private void on_pressed () {
var command = "io.elementary.calendar --show-day %s".printf (new GLib.DateTime.now_local ().format ("%F"));
try {
var appinfo = AppInfo.create_from_commandline (command, null, AppInfoCreateFlags.NONE);
appinfo.launch_uris (null, null);
} catch (GLib.Error e) {
var dialog = new Granite.MessageDialog.with_image_from_icon_name (
_("Unable To Launch Calendar"),
_("The program \"io.elementary.calendar\" may not be installed"),
"dialog-error"
);
dialog.show_error_details (e.message);
dialog.response.connect ((_dialog, response) => _dialog.destroy ());
dialog.present ();
Comment thread
leolost2605 marked this conversation as resolved.
}
}
}
8 changes: 4 additions & 4 deletions src/Widgets/calendar/Grid.vala
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ namespace DateTime.Widgets {
};

var week_sep_revealer = new Gtk.Revealer () {
transition_type = Gtk.RevealerTransitionType.SLIDE_LEFT
transition_type = Gtk.RevealerTransitionType.SLIDE_LEFT,
child = week_sep
};
week_sep_revealer.add (week_sep);

hexpand = true;
attach (week_sep_revealer, 1, 1, 1, 6);
Expand Down Expand Up @@ -255,9 +255,9 @@ namespace DateTime.Widgets {
week_label.get_style_context ().add_class (Granite.STYLE_CLASS_H4_LABEL);

week_labels[c] = new Gtk.Revealer () {
transition_type = Gtk.RevealerTransitionType.SLIDE_LEFT
transition_type = Gtk.RevealerTransitionType.SLIDE_LEFT,
child = week_label
};
week_labels[c].add (week_label);
week_labels[c].show_all ();

DateTime.Indicator.settings.bind ("show-weeks", week_labels[c], "reveal-child", GLib.SettingsBindFlags.DEFAULT);
Expand Down
20 changes: 13 additions & 7 deletions src/Widgets/calendar/GridDay.vala
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public class DateTime.Widgets.GridDay : Gtk.EventBox {
private Gtk.Label label;
private bool valid_grab = false;

private Gtk.GestureMultiPress click_gesture;
private Gtk.EventControllerKey key_controller;

public GridDay (GLib.DateTime date) {
Object (date: date);
}
Expand Down Expand Up @@ -76,8 +79,12 @@ public class DateTime.Widgets.GridDay : Gtk.EventBox {
show_all ();

// Signals and handlers
button_press_event.connect (on_button_press);
key_press_event.connect (on_key_press);
click_gesture = new Gtk.GestureMultiPress (this);
click_gesture.pressed.connect (on_button_press);

key_controller = new Gtk.EventControllerKey (this);
key_controller.key_pressed.connect (on_key_press);

bind_property ("date", label, "label", GLib.BindingFlags.SYNC_CREATE, (binding, from_value, ref to_value) => {
unowned var new_date = (GLib.DateTime) from_value.get_boxed ();
to_value.take_string (new_date.get_day_of_month ().to_string ());
Expand Down Expand Up @@ -150,17 +157,16 @@ public class DateTime.Widgets.GridDay : Gtk.EventBox {
event_box.sensitive = sens;
}

private bool on_button_press (Gdk.EventButton event) {
if (event.type == Gdk.EventType.2BUTTON_PRESS && event.button == Gdk.BUTTON_PRIMARY) {
private void on_button_press (int n_press) {
if (n_press == 2) {
on_event_add (date);
}
valid_grab = true;
grab_focus ();
return false;
}

private bool on_key_press (Gdk.EventKey event) {
if (event.keyval == Gdk.keyval_from_name ("Return") ) {
private bool on_key_press (uint keyval) {
if (keyval == Gdk.keyval_from_name ("Return") ) {
on_event_add (date);
return true;
}
Expand Down