Merge lp:~jeremywootten/pantheon-terminal/fix-1208140 into lp:~elementary-apps/pantheon-terminal/trunk

Proposed by Jeremy Wootten
Status: Merged
Merged at revision: 525
Proposed branch: lp:~jeremywootten/pantheon-terminal/fix-1208140
Merge into: lp:~elementary-apps/pantheon-terminal/trunk
Diff against target: 142 lines (+59/-8)
5 files modified
CMakeLists.txt (+1/-0)
data/open-pantheon-terminal-here.desktop (+11/-0)
src/PantheonTerminal.vala (+34/-8)
src/PantheonTerminalWindow.vala (+12/-0)
src/config.vala.cmake (+1/-0)
To merge this branch: bzr merge lp:~jeremywootten/pantheon-terminal/fix-1208140
Reviewer Review Type Date Requested Status
Cody Garver (community) Needs Fixing
Sergey "Shnatsel" Davidoff (community) Needs Fixing
David Gomes (community) Needs Fixing
Akshay Shekher (community) Needs Fixing
Review via email: mp+179597@code.launchpad.net

Commit message

Fixed bug #1208140, moved -d to -w, steps necessary taken to fix #1033456 in Files.

Description of the change

1/. Implements the command line option to open terminal at a specified location.

2/. The short option has been changed from -d to -w to avoid conflict with the debug option.

3/. Repeat use of the option opens the location in a new tab on the (last) existing window instead of opening a new window.

4/. This was implemented as part of fixing bug #1033456 in pantheon-files - implementing an "Open Terminal here" option in the context menu. That bug-fix is dependent on this one.

Note: working_directory has been changed from a static to an instance variable in order to permit repeated use of the option. Consequential changes are made to PantheonTerminalWindow.

To post a comment you must log in.
Revision history for this message
David Gomes (davidgomes) wrote :

Why the variable extra_entries?

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

If I include the -w option entry into "entries" then it only works as
expected for the first terminal window, any subsequent window is opened at
the same directory regardless of what directory you specify after -w. This
is because "entries" is parsed in main in a static context so the working
directory it sets must be static.

"extra_entries" is parsed in _command_line and sets an instance variable
"working_directory" so you can repeatedly run the command
"pantheon-terminal -w [directory_path]" and each window opens at the
specified directory.

Is there a better way of doing this?

On 15 August 2013 17:49, David Gomes <email address hidden> wrote:

> Why the variable extra_entries?
> --
>
> https://code.launchpad.net/~jeremywootten/pantheon-terminal/fix-1208140/+merge/179597
> You are the owner of lp:~jeremywootten/pantheon-terminal/fix-1208140.
>

--
Jeremy Wootten
GPG Key ID CB585BCD
Key Fingerprint 37C0 3C2A A6D4 E45B BA7C 4328 2DF2 1882 CB58 5BCD

Revision history for this message
Akshay Shekher (voldyman) wrote :

good work jeremy, one thing is missing

--help doesn't show --working-directly/-w option.

review: Needs Fixing
503. By Jeremy Wootten

Revised desktop file - only a single one needed

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

The latest revision fixes this problem (and removes the need for the
separate variable "extra-entries")

On 16 August 2013 13:09, Akshay Shekher <email address hidden> wrote:

> Review: Needs Fixing
>
> good work jeremy, one thing is missing
>
> --help doesn't show --working-directly/-w option.
> --
>
> https://code.launchpad.net/~jeremywootten/pantheon-terminal/fix-1208140/+merge/179597
> You are the owner of lp:~jeremywootten/pantheon-terminal/fix-1208140.
>

--
Jeremy Wootten
GPG Key ID CB585BCD
Key Fingerprint 37C0 3C2A A6D4 E45B BA7C 4328 2DF2 1882 CB58 5BCD

Revision history for this message
David Gomes (davidgomes) wrote :

>Name=Pantheon Terminal
Pantheon Terminal is installed under the name of Terminal on purpose.

review: Needs Fixing
504. By Jeremy Wootten

Correct name in desktop file, correct formatting, remove unnecessary changes

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

OK, fixed that.

On 23 August 2013 19:06, David Gomes <email address hidden> wrote:

> Review: Needs Fixing
>
> >Name=Pantheon Terminal
> Pantheon Terminal is installed under the name of Terminal on purpose.
> --
>
> https://code.launchpad.net/~jeremywootten/pantheon-terminal/fix-1208140/+merge/179597
> You are the owner of lp:~jeremywootten/pantheon-terminal/fix-1208140.
>

--
Jeremy Wootten
GPG Key ID CB585BCD
Key Fingerprint 37C0 3C2A A6D4 E45B BA7C 4328 2DF2 1882 CB58 5BCD

Revision history for this message
Cody Garver (codygarver) wrote :

Conflicts diff lines 161, 165, 168

review: Needs Fixing
505. By Jeremy Wootten

Merged changes from trunk revision 507

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

Sorry - now merged trunk up to revision 507 and resolved conflicts.

On 24 August 2013 08:00, Cody Garver <email address hidden> wrote:

> Review: Needs Fixing
>
> Conflicts diff lines 161, 165, 168
> --
>
> https://code.launchpad.net/~jeremywootten/pantheon-terminal/fix-1208140/+merge/179597
> You are the owner of lp:~jeremywootten/pantheon-terminal/fix-1208140.
>

--
Jeremy Wootten
GPG Key ID CB585BCD
Key Fingerprint 37C0 3C2A A6D4 E45B BA7C 4328 2DF2 1882 CB58 5BCD

Revision history for this message
Sergey "Shnatsel" Davidoff (shnatsel) wrote :

It's better to make a new .desktop file called "Open Terminal Here" with "NoDisplay=True" key instead of changing the existing .desktop file. This will make "Terminal" show up in app launchers (e.g. Slingshot) and "Open Terminal Here" in Open With menus.

So I'm adding my name to the long list of "Needs Fixing" reviewers :D
But thanks for tackling this issue!

review: Needs Fixing
Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

Thanks for the advice, I will do that.

On 27 August 2013 15:26, Sergey "Shnatsel" Davidoff <email address hidden>wrote:

> Review: Needs Fixing
>
> It's better to make a new .desktop file called "Open Terminal Here" with
> "NoDisplay=True" key instead of changing the existing .desktop file. This
> will make "Terminal" show up in app launchers (e.g. Slingshot) and "Open
> Terminal Here" in Open With menus.
>
> So I'm adding my name to the long list of "Needs Fixing" reviewers :D
> But thanks for tackling this issue!
> --
>
> https://code.launchpad.net/~jeremywootten/pantheon-terminal/fix-1208140/+merge/179597
> You are the owner of lp:~jeremywootten/pantheon-terminal/fix-1208140.
>

--
Jeremy Wootten
GPG Key ID CB585BCD
Key Fingerprint 37C0 3C2A A6D4 E45B BA7C 4328 2DF2 1882 CB58 5BCD

506. By Jeremy Wootten

Use separate open-terminal-here.desktop file

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

I have uploaded a revision with a separate open-terminal-here.desktop file
as recommended. I was not quite sure how many keys needed to be repeated
in this file, but it works anyway.

You need to update the ~/.local/share/applications/mimeapps.list file to
stop the Terminal option appearing, of course, if you have already used
that option.

On 27 August 2013 15:26, Sergey "Shnatsel" Davidoff <email address hidden>wrote:

> Review: Needs Fixing
>
> It's better to make a new .desktop file called "Open Terminal Here" with
> "NoDisplay=True" key instead of changing the existing .desktop file. This
> will make "Terminal" show up in app launchers (e.g. Slingshot) and "Open
> Terminal Here" in Open With menus.
>
> So I'm adding my name to the long list of "Needs Fixing" reviewers :D
> But thanks for tackling this issue!
> --
>
> https://code.launchpad.net/~jeremywootten/pantheon-terminal/fix-1208140/+merge/179597
> You are the owner of lp:~jeremywootten/pantheon-terminal/fix-1208140.
>

--
Jeremy Wootten
GPG Key ID CB585BCD
Key Fingerprint 37C0 3C2A A6D4 E45B BA7C 4328 2DF2 1882 CB58 5BCD

Revision history for this message
Sergey "Shnatsel" Davidoff (shnatsel) wrote :

Thanks! The keys in the open-terminal-here.desktop file are fine. I'd prefer to change the name to "open-pantheon-terminal-here.desktop" because the current name can cause collisions with some other terminal emulator which does the same thing.

Also, I get text conflicts in src/PantheonTerminalWindow.vala now, so I can't test the result of the merge.

507. By Jeremy Wootten

Rename open-terminal-here.desktop to open-pantheon-terminal-here.desktop

508. By Jeremy Wootten

merged changes from trunk revision 514

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

I have now renamed the desktop file and merged changes from trunk.

On 2 September 2013 09:22, Sergey "Shnatsel" Davidoff <email address hidden>wrote:

> Thanks! The keys in the open-terminal-here.desktop file are fine. I'd
> prefer to change the name to "open-pantheon-terminal-here.desktop" because
> the current name can cause collisions with some other terminal emulator
> which does the same thing.
>
> Also, I get text conflicts in src/PantheonTerminalWindow.vala now, so I
> can't test the result of the merge.
> --
>
> https://code.launchpad.net/~jeremywootten/pantheon-terminal/fix-1208140/+merge/179597
> You are the owner of lp:~jeremywootten/pantheon-terminal/fix-1208140.
>

--
Jeremy Wootten
GPG Key ID CB585BCD
Key Fingerprint 37C0 3C2A A6D4 E45B BA7C 4328 2DF2 1882 CB58 5BCD

Revision history for this message
Sergey "Shnatsel" Davidoff (shnatsel) wrote :

"open-pantheon-terminal-here.desktop" doesn't show up in the list of apps to open a folder with, not even as a recommended application in the "Other application..." dialog.
I've added "inode/directory" mimetype to the "open-pantheon-terminal-here.desktop" (why is it not in there?) and ran "sudo update-mime-database /usr/share/mime/" and restarted pantheon-files but that didn't help. What am I missing?

Revision history for this message
Julián Unrrein (junrrein) wrote :

I have the same issue Shnatsel is talking about.

Revision history for this message
Julián Unrrein (junrrein) wrote :

@Shnatsel

It seems that you also need to add an "inode/directory=open-pantheon-terminal-here.desktop" entry to /usr/share/applications/mimeinfo.cache. Running "sudo update-mime-database ..." didn't change the file for me.

Unfortunately, doing this doesn't make Terminal show up as a default application.

Revision history for this message
Victor Martinez (victored) wrote :

Time to write a contract file for Pantheon Terminal? :)
On Sep 15, 2013 3:52 PM, "Julián Unrrein" <email address hidden> wrote:

> @Shnatsel
>
> It seems that you also need to add an
> "inode/directory=open-pantheon-terminal-here.desktop" entry to
> /usr/share/applications/mimeinfo.cache. Running "sudo update-mime-database
> ..." didn't change the file for me.
>
> Unfortunately, doing this doesn't make Terminal show up as a default
> application.
> --
>
> https://code.launchpad.net/~jeremywootten/pantheon-terminal/fix-1208140/+merge/179597
> Your team elementary Apps team is subscribed to branch
> lp:pantheon-terminal.
>

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

I'll look into this. It may need a change to the install script.

On 15 September 2013 22:52, Julián Unrrein <email address hidden> wrote:

> @Shnatsel
>
> It seems that you also need to add an
> "inode/directory=open-pantheon-terminal-here.desktop" entry to
> /usr/share/applications/mimeinfo.cache. Running "sudo update-mime-database
> ..." didn't change the file for me.
>
> Unfortunately, doing this doesn't make Terminal show up as a default
> application.
> --
>
> https://code.launchpad.net/~jeremywootten/pantheon-terminal/fix-1208140/+merge/179597
> You are the owner of lp:~jeremywootten/pantheon-terminal/fix-1208140.
>

--
Jeremy Wootten
GPG Key ID CB585BCD
Key Fingerprint 37C0 3C2A A6D4 E45B BA7C 4328 2DF2 1882 CB58 5BCD

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

You need to run "sudo update-desktop-database". We have added a new
desktop file, not created a new mime type.

I need to find out how to get cmake to do this automatically on
installation - or is this done by the deb package anyway?

You are right - the mime-type should now be "inode/directory" - I will
change it.

On 15 September 2013 22:04, Sergey "Shnatsel" Davidoff
<email address hidden>wrote:

> "open-pantheon-terminal-here.desktop" doesn't show up in the list of apps
> to open a folder with, not even as a recommended application in the "Other
> application..." dialog.
> I've added "inode/directory" mimetype to the
> "open-pantheon-terminal-here.desktop" (why is it not in there?) and ran
> "sudo update-mime-database /usr/share/mime/" and restarted pantheon-files
> but that didn't help. What am I missing?
> --
>
> https://code.launchpad.net/~jeremywootten/pantheon-terminal/fix-1208140/+merge/179597
> You are the owner of lp:~jeremywootten/pantheon-terminal/fix-1208140.
>

--
Jeremy Wootten
GPG Key ID CB585BCD
Key Fingerprint 37C0 3C2A A6D4 E45B BA7C 4328 2DF2 1882 CB58 5BCD

Revision history for this message
Sergey "Shnatsel" Davidoff (shnatsel) wrote :

It should be done automatically on installation of .deb package, but I'm not 100% sure.
And I believe both mimetypes should be present in the "invisible" .desktop file.

509. By Jeremy Wootten

change MimeType to inode/directory; run update-desktop-database during install

510. By Jeremy Wootten

Merge changes from trunk up to revision 519

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

update-desktop-database complained about the presence of
"x-directory/normal" in the desktop file so I took it out but I can put it
back if you like.

I have just uploaded a new version which runs update-desktop-database
during make install. Does this fix the problem you were having?

On 17 September 2013 19:45, Sergey "Shnatsel" Davidoff
<email address hidden>wrote:

> It should be done automatically on installation of .deb package, but I'm
> not 100% sure.
> And I believe both mimetypes should be present in the "invisible" .desktop
> file.
> --
>
> https://code.launchpad.net/~jeremywootten/pantheon-terminal/fix-1208140/+merge/179597
> You are the owner of lp:~jeremywootten/pantheon-terminal/fix-1208140.
>

--
Jeremy Wootten
GPG Key ID CB585BCD
Key Fingerprint 37C0 3C2A A6D4 E45B BA7C 4328 2DF2 1882 CB58 5BCD

Revision history for this message
Cody Garver (codygarver) wrote :

Remove update-desktop-database and restore "x-directory/normal".

The general rule is to not duplicate utilities already run by the packaging.

We ignore the warnings about "x-directory/normal" because there is no known alternative to its functionality.

review: Needs Fixing
511. By Jeremy Wootten

Remove update-desktop-database from CMakeLists.txt; Add x-directory/normal back to .desktop file.

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

OK, done

On 19 September 2013 13:37, Cody Garver <email address hidden> wrote:

> Review: Needs Fixing
>
> Remove update-desktop-database and restore "x-directory/normal".
>
> The general rule is to not duplicate utilities already run by the
> packaging.
>
> We ignore the warnings about "x-directory/normal" because there is no
> known alternative to its functionality.
> --
>
> https://code.launchpad.net/~jeremywootten/pantheon-terminal/fix-1208140/+merge/179597
> You are the owner of lp:~jeremywootten/pantheon-terminal/fix-1208140.
>

--
Jeremy Wootten
GPG Key ID CB585BCD
Key Fingerprint 37C0 3C2A A6D4 E45B BA7C 4328 2DF2 1882 CB58 5BCD

Revision history for this message
Cody Garver (codygarver) wrote :

-d does not work for me

>$ pantheon-terminal -d ~/Downloads

review: Needs Fixing
Revision history for this message
Cody Garver (codygarver) wrote :

-w works

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

The option was changed to -w so that it did not clash with the -d (debug)
option of Granite.Application

On 21 September 2013 11:35, Cody Garver <email address hidden> wrote:

> -w works
> --
>
> https://code.launchpad.net/~jeremywootten/pantheon-terminal/fix-1208140/+merge/179597
> You are the owner of lp:~jeremywootten/pantheon-terminal/fix-1208140.
>

--
Jeremy Wootten
GPG Key ID CB585BCD
Key Fingerprint 37C0 3C2A A6D4 E45B BA7C 4328 2DF2 1882 CB58 5BCD

512. By Jeremy Wootten

Pass unrecognized options to Granite.Application

Revision history for this message
Jeremy Wootten (jeremywootten) wrote :

I have now fixed it so that unrecognised options are correctly passed onto
Granite.Application, so pantheon-terminal -d will run with the "debug"
option.

On 21 September 2013 11:34, Cody Garver <email address hidden> wrote:

> Review: Needs Fixing
>
> -d does not work for me
>
> >$ pantheon-terminal -d ~/Downloads
> --
>
> https://code.launchpad.net/~jeremywootten/pantheon-terminal/fix-1208140/+merge/179597
> You are the owner of lp:~jeremywootten/pantheon-terminal/fix-1208140.
>

--
Jeremy Wootten
GPG Key ID CB585BCD
Key Fingerprint 37C0 3C2A A6D4 E45B BA7C 4328 2DF2 1882 CB58 5BCD

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2013-09-16 06:44:53 +0000
3+++ CMakeLists.txt 2013-09-22 06:55:21 +0000
4@@ -78,3 +78,4 @@
5
6 install (TARGETS pantheon-terminal RUNTIME DESTINATION bin)
7 install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/pantheon-terminal.desktop DESTINATION share/applications)
8+install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/open-pantheon-terminal-here.desktop DESTINATION share/applications)
9
10=== added file 'data/open-pantheon-terminal-here.desktop'
11--- data/open-pantheon-terminal-here.desktop 1970-01-01 00:00:00 +0000
12+++ data/open-pantheon-terminal-here.desktop 2013-09-22 06:55:21 +0000
13@@ -0,0 +1,11 @@
14+[Desktop Entry]
15+Name=Open Terminal Here
16+TryExec=pantheon-terminal
17+Exec=pantheon-terminal -w %u
18+Icon=utilities-terminal
19+Type=Application
20+StartupNotify=true
21+X-GNOME-Gettext-Domain=pantheon-terminal
22+NoDisplay=True;
23+MimeType=inode/directory;x-directory/normal
24+
25
26=== modified file 'src/PantheonTerminal.vala'
27--- src/PantheonTerminal.vala 2013-06-16 16:31:02 +0000
28+++ src/PantheonTerminal.vala 2013-09-22 06:55:21 +0000
29@@ -34,7 +34,6 @@
30 private static string app_cmd_name;
31 private static string app_shell_name;
32 public static string? working_directory = null;
33-
34 /* command_e (-e) is used for running commands independently (not inside a shell) */
35 [CCode (array_length = false, array_null_terminated = true)]
36 static string[]? command_e = null;
37@@ -118,6 +117,17 @@
38 new_window_with_programs (command_e);
39 return 0;
40 }
41+ if (PantheonTerminalApp.working_directory != null) {
42+ uint n_windows = windows.length ();
43+ if (n_windows < 1)
44+ new_window_with_working_directory (PantheonTerminalApp.working_directory);
45+ else {
46+ unowned PantheonTerminalWindow win = windows.nth_data (n_windows -1);
47+ win.add_tab_with_working_directory (PantheonTerminalApp.working_directory);
48+ win.present ();
49+ }
50+ return 0;
51+ }
52 new_window ();
53 return 0;
54 }
55@@ -146,6 +156,14 @@
56 return window;
57 }
58
59+ public PantheonTerminalWindow new_window_with_working_directory (string location) {
60+ var window = new PantheonTerminalWindow.with_working_directory (this, location, false);
61+ window.show ();
62+ windows.append (window);
63+ add_window (window);
64+ return window;
65+ }
66+
67 public void new_window_with_programs (string[] programs) {
68 PantheonTerminalWindow? window;
69 window = get_last_window ();
70@@ -174,24 +192,32 @@
71 { "shell", 's', 0, OptionArg.STRING, ref app_shell_name, N_("Set shell at launch"), "" },
72 { "version", 'v', 0, OptionArg.NONE, out print_version, N_("Print version info and exit"), null },
73 { "execute" , 'e', 0, OptionArg.STRING_ARRAY, ref command_e, N_("Run a program in terminal"), "" },
74- { "working-directory", 'd', 0, OptionArg.STRING, ref working_directory, N_("Set shell working directory"), "" },
75+ { "working-directory", 'w', 0, OptionArg.STRING, ref working_directory, N_("Set shell working directory"), "" },
76 { null }
77 };
78
79 public static int main (string[] args) {
80 app_cmd_name = "Pantheon Terminal";
81-
82+
83 var context = new OptionContext ("Terminal");
84 context.add_main_entries (entries, Constants.GETTEXT_PACKAGE);
85-
86+
87 try {
88 context.parse(ref args);
89- } catch (Error e) {
90- warning (e.message);
91+ } catch (Error e) {}
92+
93+ string[] copy = {};
94+ foreach (string s in args)
95+ copy += s;
96+
97+ if (working_directory != null) {
98+ /* Recreating -w option so that is passed to instance */
99+ copy += "-w";
100+ copy += working_directory;
101 }
102-
103+
104 var app = new PantheonTerminalApp ();
105- return app.run (args);
106+ return app.run (copy);
107 }
108 }
109 } // Namespace
110
111=== modified file 'src/PantheonTerminalWindow.vala'
112--- src/PantheonTerminalWindow.vala 2013-09-19 01:26:44 +0000
113+++ src/PantheonTerminalWindow.vala 2013-09-22 06:55:21 +0000
114@@ -94,6 +94,18 @@
115 init (should_recreate_tabs, false);
116 }
117
118+ public PantheonTerminalWindow.with_working_directory (Granite.Application app, string location,
119+ bool should_recreate_tabs = true) {
120+ this.app = app as PantheonTerminalApp;
121+ set_application (app);
122+ init (should_recreate_tabs, false);
123+ new_tab (location);
124+ }
125+
126+ public void add_tab_with_working_directory (string location) {
127+ new_tab (location);
128+ }
129+
130 private void init (bool recreate_tabs=true, bool restore_pos = true) {
131 this.icon_name = "utilities-terminal";
132
133
134=== modified file 'src/config.vala.cmake'
135--- src/config.vala.cmake 2013-03-04 17:26:46 +0000
136+++ src/config.vala.cmake 2013-09-22 06:55:21 +0000
137@@ -13,4 +13,5 @@
138 public const string GENERIC = N_("Terminal");
139 public const string NEW_WINDOW = N_("New Window");
140 public const string NEW_ROOT_WINDOW = N_("New Root Window");
141+public const string OPEN_HERE = N_("Open Terminal Here");
142 }

Subscribers

People subscribed via source and target branches