Merge lp:~voldyman/maya/contractor-fix into lp:~elementary-apps/maya/trunk

Proposed by Akshay Shekher
Status: Merged
Approved by: Corentin Noël
Approved revision: 470
Merged at revision: 468
Proposed branch: lp:~voldyman/maya/contractor-fix
Merge into: lp:~elementary-apps/maya/trunk
Diff against target: 140 lines (+37/-70)
3 files modified
CMakeLists.txt (+0/-1)
Maya/Services/Contractor.vala (+0/-27)
Maya/View/Widgets/ContractorButtonWithMenu.vala (+37/-42)
To merge this branch: bzr merge lp:~voldyman/maya/contractor-fix
Reviewer Review Type Date Requested Status
Corentin Noël Approve
Review via email: mp+174409@code.launchpad.net

Commit message

now using the new Contractor API from granite.

Description of the change

now using the new Contractor API from granite.

To post a comment you must log in.
Revision history for this message
Corentin Noël (tintou) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2013-06-09 23:29:58 +0000
+++ CMakeLists.txt 2013-07-12 13:28:00 +0000
@@ -86,7 +86,6 @@
86 Maya/Application.vala86 Maya/Application.vala
87 Maya/Model/CalendarModel.vala87 Maya/Model/CalendarModel.vala
88 Maya/Model/SourceManager.vala88 Maya/Model/SourceManager.vala
89 Maya/Services/Contractor.vala
90 Maya/Services/Dexter.vala89 Maya/Services/Dexter.vala
91 Maya/Settings/MayaSettings.vala90 Maya/Settings/MayaSettings.vala
92 Maya/Settings/SavedState.vala91 Maya/Settings/SavedState.vala
9392
=== removed file 'Maya/Services/Contractor.vala'
--- Maya/Services/Contractor.vala 2012-03-18 03:12:54 +0000
+++ Maya/Services/Contractor.vala 1970-01-01 00:00:00 +0000
@@ -1,27 +0,0 @@
1//
2// Copyright (C) 2011-2012 Jaap Broekhuizen <jaapz.b@gmail.com>
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16//
17
18namespace Maya.Services {
19
20 [DBus (name = "org.elementary.contractor")]
21 public interface Contractor : Object
22 {
23 public abstract GLib.HashTable<string,string>[] GetServicesByLocation (string strlocation, string? file_mime="text/calendar") throws IOError;
24 }
25
26}
27
280
=== modified file 'Maya/View/Widgets/ContractorButtonWithMenu.vala'
--- Maya/View/Widgets/ContractorButtonWithMenu.vala 2013-02-17 17:04:21 +0000
+++ Maya/View/Widgets/ContractorButtonWithMenu.vala 2013-07-12 13:28:00 +0000
@@ -17,55 +17,50 @@
1717
18namespace Maya.View.Widgets {18namespace Maya.View.Widgets {
1919
20 public class ContractorMenuItem : Gtk.MenuItem {
21 private Granite.Services.Contract contract;
22
23 public ContractorMenuItem (Granite.Services.Contract cont) {
24 this.contract = cont;
25
26 label = cont.get_display_name ();
27 }
28
29 public override void activate () {
30 /* creates a .ics file */
31 Util.save_temp_selected_calendars ();
32
33 string file_path = GLib.Environment.get_tmp_dir () + "/calendar.ics";
34 File cal_file = File.new_for_path(file_path);
35
36 try {
37 contract.execute_with_file (cal_file);
38 } catch (Error err) {
39 warning (err.message);
40 }
41 }
42 }
43
20 public class ContractorButtonWithMenu : Granite.Widgets.ToolButtonWithMenu {44 public class ContractorButtonWithMenu : Granite.Widgets.ToolButtonWithMenu {
2145
22 private Maya.Services.Contractor contract;
23 private HashTable<string,string>[] services;
24 private Gtk.FileChooserDialog filechooser;46 private Gtk.FileChooserDialog filechooser;
2547
26 public ContractorButtonWithMenu (string tooltiptext) {48 public ContractorButtonWithMenu (string tooltiptext) {
2749
28 base (new Gtk.Image.from_icon_name ("document-export", Gtk.IconSize.MENU), tooltiptext, new Gtk.Menu());50 base (new Gtk.Image.from_icon_name ("document-export", Gtk.IconSize.MENU), tooltiptext, new Gtk.Menu());
2951 var contracts = Granite.Services.ContractorProxy.get_contracts_by_mime ("text/calender");
30 // try to connect52
31 try {53 for (int i = 0; i < contracts.size; i++) {
32 contract = Bus.get_proxy_sync (BusType.SESSION,54 var contract = contracts.get (i);
33 "org.elementary.contractor",55 Gtk.MenuItem menu_item;
34 "/org/elementary/contractor");56
3557 menu_item = new ContractorMenuItem (contract);
36 // get the list and parse it into the menu58 menu.append (menu_item);
37 services = contract.GetServicesByLocation (GLib.Environment.get_tmp_dir () + "/calendar.ics");59 }
38 foreach (HashTable<string,string> service in services) {60 Gtk.MenuItem item = new Gtk.MenuItem.with_label(_("Export Calendar..."));
39 Gtk.MenuItem item = new Gtk.MenuItem.with_label(service.lookup ("Description"));61 item.activate.connect (savecal);
40 item.activate.connect (activate_contract);62 menu.append (item);
41 menu.append (item);63
42 }
43 Gtk.MenuItem item = new Gtk.MenuItem.with_label(_("Export Calendar..."));
44 item.activate.connect (savecal);
45 menu.append (item);
46 } catch (IOError e) {
47 stderr.printf ("%s\n", e.message);
48 }
49
50 }
51
52 private void activate_contract () {
53 /* creates a .ics file */
54 Util.save_temp_selected_calendars ();
55 Gtk.MenuItem menuitem = (Gtk.MenuItem) menu.get_active();
56 string app_menu = menuitem.get_label();
57
58 foreach (HashTable<string,string> service in services) {
59 if (app_menu == service.lookup ("Description")) {
60 try {
61 GLib.Process.spawn_command_line_async (service.lookup ("Exec"));
62 } catch (SpawnError e) {
63 warning (e.message);
64 }
65
66 break;
67 }
68 }
69 }64 }
7065
71 private void savecal () {66 private void savecal () {

Subscribers

People subscribed via source and target branches