~darkxst/ubuntu/saucy/gnome-shell/upstart_log

« back to all changes in this revision

Viewing changes to js/ui/dateMenu.js

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-05-31 12:01:12 UTC
  • mfrom: (1.1.49) (19.1.36 experimental)
  • Revision ID: package-import@ubuntu.com-20130531120112-ew91khxf051x9i2r
Tags: 3.8.2-1ubuntu1
* Merge with Debian (LP: #1185869, #1185721). Remaining changes:
  - debian/control.in:
    + Build-depend on libsystemd-login-dev & libsystemd-daemon-dev
    + Depend on gdm instead of gdm3
    + Don't recommend gnome-session-fallback
  - debian/patches/40_change-pam-name-to-match-gdm.patch:
  - debian/patches/revert-suspend-break.patch:
    + Disabled, not needed on Ubuntu
  - debian/patches/ubuntu-lightdm-user-switching.patch:
    + Allow user switching when using LightDM. Thanks Gerhard Stein
      for rebasing against gnome-shell 3.8!
  - debian/patches/ubuntu_lock_on_suspend.patch
    + Respect Ubuntu's lock-on-suspend setting.
      Disabled until it can be rewritten.
  - debian/patches/git_relock_screen_after_crash.patch:
    + Add Upstream fix for unlocked session after crash (LP: #1064584)
* Note that the new GNOME Classic mode (which requires installing
  gnome-shell-extensions) won't work until gnome-session 3.8 is
  available in Ubuntu

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
    cr.setDash([1, 3], 1); // Hard-code for now
33
33
    cr.setLineWidth(stippleWidth);
34
34
    cr.stroke();
 
35
    cr.$dispose();
35
36
};
36
37
 
37
38
const DateMenuButton = new Lang.Class({
83
84
                               }));
84
85
        vbox.add(this._calendar.actor);
85
86
 
86
 
        item = this.menu.addSettingsAction(_("Date and Time Settings"), 'gnome-datetime-panel.desktop');
 
87
        let separator = new PopupMenu.PopupSeparatorMenuItem();
 
88
        separator.setColumnWidths(1);
 
89
        vbox.add(separator.actor, {y_align: St.Align.END, expand: true, y_fill: false});
 
90
 
 
91
        this._openCalendarItem = new PopupMenu.PopupMenuItem(_("Open Calendar"));
 
92
        this._openCalendarItem.connect('activate', Lang.bind(this, this._onOpenCalendarActivate));
 
93
        this._openCalendarItem.actor.can_focus = false;
 
94
        vbox.add(this._openCalendarItem.actor, {y_align: St.Align.END, expand: true, y_fill: false});
 
95
 
 
96
        this._openClocksItem = new PopupMenu.PopupMenuItem(_("Open Clocks"));
 
97
        this._openClocksItem.connect('activate', Lang.bind(this, this._onOpenClocksActivate));
 
98
        this._openClocksItem.actor.can_focus = false;
 
99
        vbox.add(this._openClocksItem.actor, {y_align: St.Align.END, expand: true, y_fill: false});
 
100
 
 
101
        Shell.AppSystem.get_default().connect('installed-changed',
 
102
                                              Lang.bind(this, this._appInstalledChanged));
 
103
 
 
104
        item = this.menu.addSettingsAction(_("Date & Time Settings"), 'gnome-datetime-panel.desktop');
87
105
        if (item) {
88
 
            let separator = new PopupMenu.PopupSeparatorMenuItem();
89
 
            separator.setColumnWidths(1);
90
 
            vbox.add(separator.actor, {y_align: St.Align.END, expand: true, y_fill: false});
91
 
 
92
106
            item.actor.show_on_set_parent = false;
93
107
            item.actor.can_focus = false;
94
108
            item.actor.reparent(vbox);
108
122
        // Event list
109
123
        vbox.add(this._eventList.actor, { expand: true });
110
124
 
111
 
        this._openCalendarItem = new PopupMenu.PopupMenuItem(_("Open Calendar"));
112
 
        this._openCalendarItem.connect('activate', Lang.bind(this, this._onOpenCalendarActivate));
113
 
        this._openCalendarItem.actor.can_focus = false;
114
 
        vbox.add(this._openCalendarItem.actor, {y_align: St.Align.END, expand: true, y_fill: false});
115
 
 
116
 
        this._calendarSettings = new Gio.Settings({ schema: 'org.gnome.desktop.default-applications.office.calendar' });
117
 
        this._calendarSettings.connect('changed::exec',
118
 
                                       Lang.bind(this, this._calendarSettingsChanged));
119
 
        this._calendarSettingsChanged();
120
 
 
121
125
        // Whenever the menu is opened, select today
122
126
        this.menu.connect('open-state-changed', Lang.bind(this, function(menu, isOpen) {
123
127
            if (isOpen) {
151
155
        this._sessionUpdated();
152
156
    },
153
157
 
154
 
    _calendarSettingsChanged: function() {
155
 
        let exec = this._calendarSettings.get_string('exec');
156
 
        let fullExec = GLib.find_program_in_path(exec);
157
 
        this._openCalendarItem.actor.visible = fullExec != null;
 
158
    _appInstalledChanged: function() {
 
159
        this._calendarApp = undefined;
 
160
        this._updateEventsVisibility();
158
161
    },
159
162
 
160
 
    _setEventsVisibility: function(visible) {
161
 
        this._openCalendarItem.actor.visible = visible;
 
163
    _updateEventsVisibility: function() {
 
164
        let visible = this._eventSource.hasCalendars;
 
165
        this._openCalendarItem.actor.visible = visible &&
 
166
            (this._getCalendarApp() != null);
 
167
        this._openClocksItem.actor.visible = visible &&
 
168
            (this._getClockApp() != null);
162
169
        this._separator.visible = visible;
163
170
        if (visible) {
164
171
          let alignment = 0.25;
173
180
    },
174
181
 
175
182
    _setEventSource: function(eventSource) {
 
183
        if (this._eventSource)
 
184
            this._eventSource.destroy();
 
185
 
176
186
        this._calendar.setEventSource(eventSource);
177
187
        this._eventList.setEventSource(eventSource);
 
188
 
 
189
        this._eventSource = eventSource;
 
190
        this._eventSource.connect('notify::has-calendars', Lang.bind(this, function() {
 
191
            this._updateEventsVisibility();
 
192
        }));
178
193
    },
179
194
 
180
195
    _sessionUpdated: function() {
183
198
        if (showEvents) {
184
199
            eventSource = new Calendar.DBusEventSource();
185
200
        } else {
186
 
            eventSource = null;
 
201
            eventSource = new Calendar.EmptyEventSource();
187
202
        }
188
203
        this._setEventSource(eventSource);
189
 
        this._setEventsVisibility(showEvents);
 
204
        this._updateEventsVisibility();
190
205
 
191
206
        // This needs to be handled manually, as the code to
192
207
        // autohide separators doesn't work across the vbox
203
218
        this._date.set_text(displayDate.toLocaleFormat(dateFormat));
204
219
    },
205
220
 
 
221
    _getCalendarApp: function() {
 
222
        if (this._calendarApp !== undefined)
 
223
            return this._calendarApp;
 
224
 
 
225
        let apps = Gio.AppInfo.get_recommended_for_type('text/calendar');
 
226
        if (apps && (apps.length > 0))
 
227
            this._calendarApp = apps[0];
 
228
        else
 
229
            this._calendarApp = null;
 
230
        return this._calendarApp;
 
231
    },
 
232
 
 
233
    _getClockApp: function() {
 
234
        return Shell.AppSystem.get_default().lookup_app('gnome-clocks.desktop');
 
235
    },
 
236
 
206
237
    _onOpenCalendarActivate: function() {
207
238
        this.menu.close();
208
 
        let tool = this._calendarSettings.get_string('exec');
209
 
        if (tool.length == 0 || tool.substr(0, 9) == 'evolution') {
210
 
            // TODO: pass the selected day
211
 
            let app = Shell.AppSystem.get_default().lookup_app('evolution-calendar.desktop');
212
 
            app.activate();
213
 
        } else {
214
 
            let needTerm = this._calendarSettings.get_boolean('needs-term');
215
 
            if (needTerm) {
216
 
                let terminalSettings = new Gio.Settings({ schema: 'org.gnome.desktop.default-applications.terminal' });
217
 
                let term = terminalSettings.get_string('exec');
218
 
                let arg = terminalSettings.get_string('exec-arg');
219
 
                if (arg != '')
220
 
                    Util.spawn([term, arg, tool]);
221
 
                else
222
 
                    Util.spawn([term, tool]);
223
 
            } else {
224
 
                Util.spawnCommandLine(tool)
225
 
            }
226
 
        }
 
239
 
 
240
        let app = this._getCalendarApp();
 
241
        if (app.get_id() == 'evolution.desktop')
 
242
            app = Gio.DesktopAppInfo.new('evolution-calendar.desktop');
 
243
        app.launch([], global.create_app_launch_context());
 
244
    },
 
245
 
 
246
    _onOpenClocksActivate: function() {
 
247
        this.menu.close();
 
248
        let app = this._getClockApp();
 
249
        app.activate();
227
250
    }
228
251
});