Merge lp:~mardy/unity-2d/default-apps into lp:unity-2d

Proposed by Alberto Mardegan
Status: Merged
Approved by: Florian Boucault
Approved revision: 686
Merged at revision: 697
Proposed branch: lp:~mardy/unity-2d/default-apps
Merge into: lp:unity-2d
Diff against target: 126 lines (+41/-4)
4 files modified
libunity-2d-private/src/giodefaultapplication.cpp (+31/-4)
libunity-2d-private/src/giodefaultapplication.h (+5/-0)
places/HomeButtonDefaultApplication.qml (+4/-0)
places/HomeShortcuts.qml (+1/-0)
To merge this branch: bzr merge lp:~mardy/unity-2d/default-apps
Reviewer Review Type Date Requested Status
Alberto Mardegan Pending
Florian Boucault Pending
Review via email: mp+73658@code.launchpad.net

This proposal supersedes a proposal from 2011-08-26.

Description of the change

[places] Use shotwell as default photo viewer

Extend GioDefaultApplication with a defaultDesktopFile property which can be
used to override the default application registered for the content-type.

To post a comment you must log in.
Revision history for this message
Alberto Mardegan (mardy) wrote : Posted in a previous version of this proposal

As I commented on the bug, I don't think this is how we should deal with the problem.

review: Disapprove
Revision history for this message
Florian Boucault (fboucault) wrote :

Looks great, I will test it later.

Revision history for this message
Florian Boucault (fboucault) wrote :

Fantastic!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libunity-2d-private/src/giodefaultapplication.cpp'
2--- libunity-2d-private/src/giodefaultapplication.cpp 2011-07-05 15:27:03 +0000
3+++ libunity-2d-private/src/giodefaultapplication.cpp 2011-09-01 12:37:25 +0000
4@@ -37,6 +37,7 @@
5 : QObject(parent),
6 m_contentType(""),
7 m_desktopFile(""),
8+ m_defaultDesktopFile(""),
9 m_mimeappsWatcher(new QFileSystemWatcher(this))
10 {
11 /* GIO does not have any signal to inform us of changes in default
12@@ -77,6 +78,11 @@
13 return m_contentType;
14 }
15
16+QString GioDefaultApplication::defaultDesktopFile() const
17+{
18+ return m_defaultDesktopFile;
19+}
20+
21 void GioDefaultApplication::setContentType(const QString& contentType)
22 {
23 if (contentType == m_contentType) {
24@@ -88,13 +94,34 @@
25 updateDesktopFile();
26 }
27
28+void GioDefaultApplication::setDefaultDesktopFile(
29+ const QString& defaultDesktopFile)
30+{
31+ if (defaultDesktopFile == m_defaultDesktopFile) {
32+ return;
33+ }
34+
35+ m_defaultDesktopFile = defaultDesktopFile;
36+ Q_EMIT defaultDesktopFileChanged();
37+ updateDesktopFile();
38+}
39+
40 void GioDefaultApplication::updateDesktopFile()
41 {
42 GObjectScopedPointer<GAppInfo> app_info;
43- QByteArray byte_array = m_contentType.toUtf8();
44- gchar *content_type = byte_array.data();
45-
46- app_info.reset(g_app_info_get_default_for_type(content_type, false));
47+
48+ if (!m_defaultDesktopFile.isEmpty()) {
49+ QByteArray byte_array = m_defaultDesktopFile.toUtf8();
50+ gchar *desktopFile = byte_array.data();
51+ app_info.reset((GAppInfo*)g_desktop_app_info_new(desktopFile));
52+ }
53+
54+ if (app_info.isNull()) {
55+ QByteArray byte_array = m_contentType.toUtf8();
56+ gchar *content_type = byte_array.data();
57+ app_info.reset(g_app_info_get_default_for_type(content_type, false));
58+ }
59+
60 if (!app_info.isNull()) {
61 m_desktopFile = QString::fromUtf8(g_desktop_app_info_get_filename((GDesktopAppInfo*)app_info.data()));
62 } else {
63
64=== modified file 'libunity-2d-private/src/giodefaultapplication.h'
65--- libunity-2d-private/src/giodefaultapplication.h 2011-07-26 16:06:48 +0000
66+++ libunity-2d-private/src/giodefaultapplication.h 2011-09-01 12:37:25 +0000
67@@ -35,6 +35,7 @@
68
69 Q_PROPERTY(QString desktopFile READ desktopFile NOTIFY desktopFileChanged)
70 Q_PROPERTY(QString contentType READ contentType WRITE setContentType NOTIFY contentTypeChanged)
71+ Q_PROPERTY(QString defaultDesktopFile READ defaultDesktopFile WRITE setDefaultDesktopFile NOTIFY defaultDesktopFileChanged)
72
73 public:
74 GioDefaultApplication(QObject* parent=0);
75@@ -42,13 +43,16 @@
76 /* getters */
77 QString desktopFile() const;
78 QString contentType() const;
79+ QString defaultDesktopFile() const;
80
81 /* setters */
82+ void setDefaultDesktopFile(const QString& defaultDesktopFile);
83 void setContentType(const QString& contentType);
84
85 Q_SIGNALS:
86 void desktopFileChanged();
87 void contentTypeChanged();
88+ void defaultDesktopFileChanged();
89
90 private:
91 Q_SLOT void updateDesktopFile();
92@@ -56,6 +60,7 @@
93
94 QString m_contentType;
95 QString m_desktopFile;
96+ QString m_defaultDesktopFile;
97 QFileSystemWatcher* m_mimeappsWatcher;
98 };
99
100
101=== modified file 'places/HomeButtonDefaultApplication.qml'
102--- places/HomeButtonDefaultApplication.qml 2011-08-10 00:10:39 +0000
103+++ places/HomeButtonDefaultApplication.qml 2011-09-01 12:37:25 +0000
104@@ -21,6 +21,10 @@
105
106 HomeButton {
107 property alias contentType: defaultApplication.contentType
108+ /* If the desktopFile property is set and points to an existing
109+ * application, the contentType property is ignored.
110+ */
111+ property alias desktopFile: defaultApplication.defaultDesktopFile
112
113 GioDefaultApplication {
114 id: defaultApplication
115
116=== modified file 'places/HomeShortcuts.qml'
117--- places/HomeShortcuts.qml 2011-08-31 10:57:31 +0000
118+++ places/HomeShortcuts.qml 2011-09-01 12:37:25 +0000
119@@ -85,6 +85,7 @@
120 HomeButtonDefaultApplication {
121 label: u2d.tr("View Photos")
122 contentType: "image/jpeg"
123+ desktopFile: "shotwell-viewer.desktop"
124 }
125
126 HomeButtonDefaultApplication {

Subscribers

People subscribed via source and target branches