After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 651190 - [PATCH] Use user-defined calendar application in the Date Menu
[PATCH] Use user-defined calendar application in the Date Menu
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
3.0.x
Other Linux
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2011-05-26 20:37 UTC by Tassilo Horn
Modified: 2011-08-12 16:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Use user-defined calendar application for the date menu calendar button (1.58 KB, patch)
2011-05-26 20:38 UTC, Tassilo Horn
needs-work Details | Review
Uptated patch (3.71 KB, patch)
2011-06-28 09:43 UTC, Tassilo Horn
reviewed Details | Review
Updated patch (2) (3.72 KB, patch)
2011-08-11 09:33 UTC, Tassilo Horn
committed Details | Review

Description Tassilo Horn 2011-05-26 20:37:35 UTC
Use user-defined calendar application for the date menu calendar button
    
Use the existing setting
    
      org.gnome.desktop.default-applications.office.calendar.exec
    
as calendar application instead of the hard-coded evolution.  Evolution
is still the fallback if that setting is cleared (it defaults to
evolution).
Comment 1 Tassilo Horn 2011-05-26 20:38:29 UTC
Created attachment 188705 [details] [review]
Use user-defined calendar application for the date menu calendar button

Use the existing setting

  org.gnome.desktop.default-applications.office.calendar.exec

as calendar application instead of the hard-coded evolution.  Evolution
is still the fallback if that setting is cleared (it defaults to
evolution).
Comment 2 Dan Winship 2011-06-27 13:56:03 UTC
Comment on attachment 188705 [details] [review]
Use user-defined calendar application for the date menu calendar button

>+        let calendarSettings = new Gio.Settings({ schema: 'org.gnome.desktop.default-applications.office.calendar' });
>+	let tool = calendarSettings.get_string('exec');

watch out on spaces-vs-tabs. There should be no tabs in JS files.

>+	// Fall back to evolution (and call the right day)
>+	if (tool.length == 0 || tool == 'evolution') {
>+	    // TODO: pass the selected day
>+            Util.spawn(['evolution', '-c', 'calendar']);

arguably the schema is broken here and ought to default to "evolution -c calendar"...

>+	} else {
>+	    let toolArray = tool.split(' ');
>+	    let terminal = calendarSettings.get_boolean('needs-term');
>+	    if (terminal) {
>+		Util.spawn(['gnome-terminal', '-e'].concat(toolArray));
>+	    } else {
>+		Util.spawn(toolArray);

this is wrong in several ways. First, you can't just split on spaces, because there may be quoted strings in the command. But second, you don't want to split it into argv anyway, because you have to pass the command as a single argument to gnome-terminal. So you want to use Util.spawnCommandLine here.

However... it should also use org.gnome.desktop.default-applications.terminal rather than assuming gnome-terminal.
Comment 3 Tassilo Horn 2011-06-28 09:43:05 UTC
> arguably the schema is broken here and ought to default to "evolution -c
> calendar"...

Well, not my fault.  I kept that statement as-is. :-)

With regard to the other problems (TABs, usage of default terminal, spawning commands correctly) I've created a new version of the patch.

Thanks a ton of the comments. :-)

Tassilo
Comment 4 Tassilo Horn 2011-06-28 09:43:47 UTC
Created attachment 190843 [details] [review]
Uptated patch
Comment 5 Dan Winship 2011-08-03 14:48:05 UTC
Comment on attachment 190843 [details] [review]
Uptated patch

>+                Util.spawnCommandLine(term.concat(' ').concat(arg)
>+                                      .concat(' ').concat(tool));

ew. you can just do: term + ' ' + arg + ' ' + tool

however, I was wrong before, you want to do

    if (arg != '')
        Util.spawn([term, arg, tool]);
    else
        Util.spawn([term, tool]);

do you have a GNOME git account or do you need someone to commit this for you?
Comment 6 Tassilo Horn 2011-08-11 09:32:51 UTC
Hi Dan,

sorry for responding so late, I've been on a holiday trip. :-)

Here's an updated patch, and no, I don't have a gnome git account, so someone has to commit for me.
Comment 7 Tassilo Horn 2011-08-11 09:33:52 UTC
Created attachment 193616 [details] [review]
Updated patch (2)
Comment 8 Dan Winship 2011-08-12 16:50:44 UTC
I split the tabs-vs-spaces fixes out into a separate patch and then
committed. Thanks for the patches.