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
=== modified file 'libunity-2d-private/src/giodefaultapplication.cpp'
--- libunity-2d-private/src/giodefaultapplication.cpp 2011-07-05 15:27:03 +0000
+++ libunity-2d-private/src/giodefaultapplication.cpp 2011-09-01 12:37:25 +0000
@@ -37,6 +37,7 @@
37 : QObject(parent),37 : QObject(parent),
38 m_contentType(""),38 m_contentType(""),
39 m_desktopFile(""),39 m_desktopFile(""),
40 m_defaultDesktopFile(""),
40 m_mimeappsWatcher(new QFileSystemWatcher(this))41 m_mimeappsWatcher(new QFileSystemWatcher(this))
41{42{
42 /* GIO does not have any signal to inform us of changes in default43 /* GIO does not have any signal to inform us of changes in default
@@ -77,6 +78,11 @@
77 return m_contentType;78 return m_contentType;
78}79}
7980
81QString GioDefaultApplication::defaultDesktopFile() const
82{
83 return m_defaultDesktopFile;
84}
85
80void GioDefaultApplication::setContentType(const QString& contentType)86void GioDefaultApplication::setContentType(const QString& contentType)
81{87{
82 if (contentType == m_contentType) {88 if (contentType == m_contentType) {
@@ -88,13 +94,34 @@
88 updateDesktopFile();94 updateDesktopFile();
89}95}
9096
97void GioDefaultApplication::setDefaultDesktopFile(
98 const QString& defaultDesktopFile)
99{
100 if (defaultDesktopFile == m_defaultDesktopFile) {
101 return;
102 }
103
104 m_defaultDesktopFile = defaultDesktopFile;
105 Q_EMIT defaultDesktopFileChanged();
106 updateDesktopFile();
107}
108
91void GioDefaultApplication::updateDesktopFile()109void GioDefaultApplication::updateDesktopFile()
92{110{
93 GObjectScopedPointer<GAppInfo> app_info;111 GObjectScopedPointer<GAppInfo> app_info;
94 QByteArray byte_array = m_contentType.toUtf8();112
95 gchar *content_type = byte_array.data();113 if (!m_defaultDesktopFile.isEmpty()) {
96114 QByteArray byte_array = m_defaultDesktopFile.toUtf8();
97 app_info.reset(g_app_info_get_default_for_type(content_type, false));115 gchar *desktopFile = byte_array.data();
116 app_info.reset((GAppInfo*)g_desktop_app_info_new(desktopFile));
117 }
118
119 if (app_info.isNull()) {
120 QByteArray byte_array = m_contentType.toUtf8();
121 gchar *content_type = byte_array.data();
122 app_info.reset(g_app_info_get_default_for_type(content_type, false));
123 }
124
98 if (!app_info.isNull()) {125 if (!app_info.isNull()) {
99 m_desktopFile = QString::fromUtf8(g_desktop_app_info_get_filename((GDesktopAppInfo*)app_info.data()));126 m_desktopFile = QString::fromUtf8(g_desktop_app_info_get_filename((GDesktopAppInfo*)app_info.data()));
100 } else {127 } else {
101128
=== modified file 'libunity-2d-private/src/giodefaultapplication.h'
--- libunity-2d-private/src/giodefaultapplication.h 2011-07-26 16:06:48 +0000
+++ libunity-2d-private/src/giodefaultapplication.h 2011-09-01 12:37:25 +0000
@@ -35,6 +35,7 @@
3535
36 Q_PROPERTY(QString desktopFile READ desktopFile NOTIFY desktopFileChanged)36 Q_PROPERTY(QString desktopFile READ desktopFile NOTIFY desktopFileChanged)
37 Q_PROPERTY(QString contentType READ contentType WRITE setContentType NOTIFY contentTypeChanged)37 Q_PROPERTY(QString contentType READ contentType WRITE setContentType NOTIFY contentTypeChanged)
38 Q_PROPERTY(QString defaultDesktopFile READ defaultDesktopFile WRITE setDefaultDesktopFile NOTIFY defaultDesktopFileChanged)
3839
39public:40public:
40 GioDefaultApplication(QObject* parent=0);41 GioDefaultApplication(QObject* parent=0);
@@ -42,13 +43,16 @@
42 /* getters */43 /* getters */
43 QString desktopFile() const;44 QString desktopFile() const;
44 QString contentType() const;45 QString contentType() const;
46 QString defaultDesktopFile() const;
4547
46 /* setters */48 /* setters */
49 void setDefaultDesktopFile(const QString& defaultDesktopFile);
47 void setContentType(const QString& contentType);50 void setContentType(const QString& contentType);
4851
49Q_SIGNALS:52Q_SIGNALS:
50 void desktopFileChanged();53 void desktopFileChanged();
51 void contentTypeChanged();54 void contentTypeChanged();
55 void defaultDesktopFileChanged();
5256
53private:57private:
54 Q_SLOT void updateDesktopFile();58 Q_SLOT void updateDesktopFile();
@@ -56,6 +60,7 @@
5660
57 QString m_contentType;61 QString m_contentType;
58 QString m_desktopFile;62 QString m_desktopFile;
63 QString m_defaultDesktopFile;
59 QFileSystemWatcher* m_mimeappsWatcher;64 QFileSystemWatcher* m_mimeappsWatcher;
60};65};
6166
6267
=== modified file 'places/HomeButtonDefaultApplication.qml'
--- places/HomeButtonDefaultApplication.qml 2011-08-10 00:10:39 +0000
+++ places/HomeButtonDefaultApplication.qml 2011-09-01 12:37:25 +0000
@@ -21,6 +21,10 @@
2121
22HomeButton {22HomeButton {
23 property alias contentType: defaultApplication.contentType23 property alias contentType: defaultApplication.contentType
24 /* If the desktopFile property is set and points to an existing
25 * application, the contentType property is ignored.
26 */
27 property alias desktopFile: defaultApplication.defaultDesktopFile
2428
25 GioDefaultApplication {29 GioDefaultApplication {
26 id: defaultApplication30 id: defaultApplication
2731
=== modified file 'places/HomeShortcuts.qml'
--- places/HomeShortcuts.qml 2011-08-31 10:57:31 +0000
+++ places/HomeShortcuts.qml 2011-09-01 12:37:25 +0000
@@ -85,6 +85,7 @@
85 HomeButtonDefaultApplication {85 HomeButtonDefaultApplication {
86 label: u2d.tr("View Photos")86 label: u2d.tr("View Photos")
87 contentType: "image/jpeg"87 contentType: "image/jpeg"
88 desktopFile: "shotwell-viewer.desktop"
88 }89 }
8990
90 HomeButtonDefaultApplication {91 HomeButtonDefaultApplication {

Subscribers

People subscribed via source and target branches