~ubuntu-branches/ubuntu/vivid/gnome-maps/vivid

« back to all changes in this revision

Viewing changes to src/application.js

  • Committer: Package Import Robot
  • Author(s): Andreas Henriksson
  • Date: 2014-09-22 23:04:28 UTC
  • mfrom: (1.1.3) (2.1.3 experimental)
  • Revision ID: package-import@ubuntu.com-20140922230428-zvgvmk5pea6eavcz
Tags: 3.14.0-1
* New upstream release.
* Drop debian/patches/gjs-readwrite-flags.patch, fixed upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 
35
35
const Main = imports.main;
36
36
const Format = imports.format;
 
37
const Geoclue = imports.geoclue;
 
38
const GeocodeService = imports.geocodeService;
37
39
const MainWindow = imports.mainWindow;
 
40
const Notification = imports.notification;
 
41
const NotificationManager = imports.notificationManager;
38
42
const Utils = imports.utils;
39
43
const Path = imports.path;
40
44
const Settings = imports.settings;
 
45
const PlaceStore = imports.placeStore;
 
46
const RouteService = imports.routeService;
41
47
 
42
48
// used globally
43
49
let application = null;
44
50
let settings = null;
 
51
let placeStore = null;
 
52
let notificationManager = null;
 
53
let routeService = null;
 
54
let geoclue = null;
 
55
let geocodeService = null;
45
56
 
46
57
const Application = new Lang.Class({
47
58
    Name: 'Application',
61
72
        this._mainWindow.window.destroy();
62
73
    },
63
74
 
 
75
    _initPlaceStore: function() {
 
76
        placeStore = new PlaceStore.PlaceStore();
 
77
        try {
 
78
            placeStore.load();
 
79
        } catch (e) {
 
80
            log('Failed to parse Maps places file, ' +
 
81
                'subsequent writes will overwrite the file!');
 
82
        }
 
83
    },
 
84
 
64
85
    _initAppMenu: function() {
65
86
        let builder = new Gtk.Builder();
66
87
        builder.add_from_resource('/org/gnome/maps/app-menu.ui');
78
99
        Utils.loadStyleSheet(Gio.file_new_for_uri('resource:///org/gnome/maps/application.css'));
79
100
 
80
101
        application = this;
81
 
        settings = new Settings.Settings('org.gnome.maps');
 
102
        this._initServices();
82
103
 
83
104
        Utils.initActions(this, [{
84
105
            properties: { name: 'quit' },
85
106
            signalHandlers: { activate: this._onQuitActivate }
86
107
        }], this);
87
108
 
 
109
        this._initPlaceStore();
88
110
        this._initAppMenu();
89
111
    },
90
112
 
 
113
    _initServices: function() {
 
114
        settings       = new Settings.Settings('org.gnome.maps');
 
115
        routeService   = new RouteService.GraphHopper();
 
116
        geoclue        = new Geoclue.Geoclue();
 
117
        geocodeService = new GeocodeService.GeocodeService();
 
118
    },
 
119
 
91
120
    _createWindow: function() {
92
121
        if (this._mainWindow)
93
122
            return;
94
123
 
95
 
        this._mainWindow = new MainWindow.MainWindow(this);
 
124
        Gtk.IconTheme.get_default().append_search_path(Path.ICONS_DIR);
 
125
        let overlay = new Gtk.Overlay({ visible: true, can_focus: true });
 
126
        notificationManager = new NotificationManager.NotificationManager(overlay);
 
127
        this._mainWindow = new MainWindow.MainWindow(this, overlay);
96
128
        this._mainWindow.window.connect('destroy', this._onWindowDestroy.bind(this));
97
129
    },
98
130
 
 
131
    vfunc_dbus_register: function(connection, path) {
 
132
        this.parent(connection, path);
 
133
        return true;
 
134
    },
 
135
 
 
136
    vfunc_dbus_unregister: function(connection, path) {
 
137
        this.parent(connection, path);
 
138
    },
 
139
 
99
140
    vfunc_activate: function() {
100
141
        this._createWindow();
101
142
        this._mainWindow.window.present();