Merge lp:~davidmhewitt/wingpanel-indicator-datetime/fix-1629692 into lp:~wingpanel-devs/wingpanel-indicator-datetime/trunk

Proposed by David Hewitt
Status: Merged
Approved by: Corentin Noël
Approved revision: 176
Merged at revision: 177
Proposed branch: lp:~davidmhewitt/wingpanel-indicator-datetime/fix-1629692
Merge into: lp:~wingpanel-devs/wingpanel-indicator-datetime/trunk
Diff against target: 28 lines (+8/-5)
1 file modified
src/Widgets/calendar/Calendar.vala (+8/-5)
To merge this branch: bzr merge lp:~davidmhewitt/wingpanel-indicator-datetime/fix-1629692
Reviewer Review Type Date Requested Status
David Hewitt Needs Resubmitting
Adam Bieńkowski (community) code Disapprove
Review via email: mp+315304@code.launchpad.net

Commit message

Resolve a hang when maya-calendar is not installed

Description of the change

Resolves the hang when maya-calendar is not installed. Must have been an issue with the SimpleCommand.run() function as no exceptions are thrown with it, it just hangs.

execute_command works as intended.

To post a comment you must log in.
Revision history for this message
Adam Bieńkowski (donadigo) wrote :

We should use GLib's AppInfo instead.

review: Disapprove (code)
Revision history for this message
David Hewitt (davidmhewitt) wrote :

> We should use GLib's AppInfo instead.

I agree. However, this would disable the functionality of launching the calendar on the date you double clicked on. Should this be removed to be more compatible with other calendar applications?

Revision history for this message
Adam Bieńkowski (donadigo) wrote :

> > We should use GLib's AppInfo instead.
>
> I agree. However, this would disable the functionality of launching the
> calendar on the date you double clicked on. Should this be removed to be more
> compatible with other calendar applications?

I'm not talking about other applications here. You can just use something like this:
var app_info = AppInfo.create_from_commandline ("maya-calendar", null, AppInfoCreateFlags.NONE);
app_info.launch_uris (`your arguments here`, null);

This is the native method of executing apps with GLib, rather than using the command line, and if maya doesn't exist handle the error just by using error ().

Revision history for this message
David Hewitt (davidmhewitt) wrote :

> > > We should use GLib's AppInfo instead.
> >
> > I agree. However, this would disable the functionality of launching the
> > calendar on the date you double clicked on. Should this be removed to be
> more
> > compatible with other calendar applications?
>
> I'm not talking about other applications here. You can just use something like
> this:
> var app_info = AppInfo.create_from_commandline ("maya-calendar", null,
> AppInfoCreateFlags.NONE);
> app_info.launch_uris (`your arguments here`, null);
>
> This is the native method of executing apps with GLib, rather than using the
> command line, and if maya doesn't exist handle the error just by using error
> ().

Thank you for the info. I've just tried the launch_uris method and while maya-calendar launches fine, it isn't possible to get it to open on the clicked date. I've tried splitting the arguments up in various ways to pass into launch_uris.

I would assume that the launch_uris method is ignoring things that aren't valid URIs and not passing them to maya-calendar. Something of the format of "--show-day 01/01/2017" isn't a valid URI and without doing some work on maya-calendar, we can't pass the date we want as a URI either.

Revision history for this message
Vishal Rao (vishalrao) wrote :

Is it not possible to do AppInfo.create_from_commandline ("maya-calendar --show-day 01/01/2017"...) then launch_uris (null, null) ?

Revision history for this message
Adam Bieńkowski (donadigo) wrote :

Yeah, probably that could work ^^

176. By David Hewitt

Switch to using AppInfo to launch maya

Revision history for this message
David Hewitt (davidmhewitt) wrote :

Thanks, not sure why I didn't think of that while I was trying all the combinations of launching with AppInfo. Should be ready to go now.

review: Needs Resubmitting

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Widgets/calendar/Calendar.vala'
2--- src/Widgets/calendar/Calendar.vala 2016-01-07 14:46:41 +0000
3+++ src/Widgets/calendar/Calendar.vala 2017-02-10 19:47:02 +0000
4@@ -69,10 +69,13 @@
5 selected_day= date.get_day_of_month ();
6
7 var parameter_string = @" --show-day $selected_day/$selected_month/$selected_year";
8- var command = CALENDAR_EXEC + parameter_string;
9-
10- var cmd = new Granite.Services.SimpleCommand ("/usr/bin", command);
11- cmd.run ();
12+ try {
13+ var appinfo = AppInfo.create_from_commandline (CALENDAR_EXEC + parameter_string, null, AppInfoCreateFlags.NONE);
14+ appinfo.launch_uris (null, null);
15+ } catch (GLib.Error e) {
16+ warning ("Unable to start calendar, error: %s", e.message);
17+ }
18+
19 }
20
21 public override bool draw (Cairo.Context cr) {
22@@ -97,4 +100,4 @@
23 return false;
24 }
25 }
26-}
27\ No newline at end of file
28+}

Subscribers

People subscribed via source and target branches