Merge lp:~chipaca/ubuntuone-client/nautilus-ppage into lp:ubuntuone-client

Proposed by John Lenton on 2010-08-11
Status: Rejected
Rejected by: John Lenton on 2010-09-08
Proposed branch: lp:~chipaca/ubuntuone-client/nautilus-ppage
Merge into: lp:ubuntuone-client
Diff against target: 167 lines (+138/-0)
1 file modified
nautilus/ubuntuone-nautilus.c (+138/-0)
To merge this branch: bzr merge lp:~chipaca/ubuntuone-client/nautilus-ppage
Reviewer Review Type Date Requested Status
Rodrigo Moya (community) 2010-08-11 Needs Fixing on 2010-08-11
Review via email: mp+32295@code.launchpad.net

Description of the change

these are not the property pages you are looking for.

To post a comment you must log in.
Rodrigo Moya (rodrigo-moya) wrote :

yay! But a few things:

ubuntuone-nautilus.c is too crowded, so could you move the property page creation/code to its own file, like location-widget.c does?

If the data is not editable, why not just use a label? See the 'Audio' property page for MP3's, it has sections (in bold) and then the different data in labels, with nice italic strings for the "field" names. Something like that would look much better.

Also, the 'Ubuntu One' page shows for every folder/file, whether it's a UDF/inside a UDF or not.

review: Needs Fixing

Unmerged revisions

627. By John Lenton on 2010-08-11

second half of the ppage work

626. By John Lenton on 2010-08-11

whee, a page provider

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nautilus/ubuntuone-nautilus.c'
2--- nautilus/ubuntuone-nautilus.c 2010-08-06 23:31:50 +0000
3+++ nautilus/ubuntuone-nautilus.c 2010-08-11 07:07:44 +0000
4@@ -31,6 +31,7 @@
5 #include <libnautilus-extension/nautilus-info-provider.h>
6 #include <libnautilus-extension/nautilus-menu-provider.h>
7 #include <libnautilus-extension/nautilus-location-widget-provider.h>
8+#include <libnautilus-extension/nautilus-property-page-provider.h>
9 #include <libsyncdaemon/libsyncdaemon.h>
10 #include "ubuntuone-nautilus.h"
11 #include "location-widget.h"
12@@ -585,6 +586,132 @@
13 iface->get_background_items = ubuntuone_nautilus_get_bg_menu_items;
14 }
15
16+static void ubuntuone_nautilus_put_label_and_value (GtkWidget *box, const char *label, const char *value) {
17+ GtkWidget *widget;
18+
19+ widget = gtk_label_new (g_markup_printf_escaped ("<b>%s:</b>", label));
20+ gtk_label_set_use_markup (GTK_LABEL (widget), TRUE);
21+ gtk_misc_set_alignment (GTK_MISC (widget), 0., 0.5);
22+ gtk_box_pack_start (GTK_BOX (box), widget, FALSE, FALSE, 2);
23+
24+ widget = gtk_entry_new ();
25+ gtk_entry_set_text (GTK_ENTRY (widget), value);
26+ gtk_entry_set_editable (GTK_ENTRY (widget), FALSE);
27+ gtk_misc_set_alignment (GTK_MISC (widget), 0.5, 0.5);
28+ gtk_box_pack_start (GTK_BOX (box), widget, FALSE, FALSE, 0);
29+}
30+
31+typedef struct _PPdata {
32+ UbuntuOneNautilus *uon;
33+ GtkWidget *props;
34+ GtkWidget *spinner;
35+ gchar *path;
36+} _PPdata;
37+
38+static void ubuntuone_nautilus_got_metainfo_for_ppage (SyncdaemonFilesystemInterface *interface,
39+ gboolean success,
40+ SyncdaemonMetadata *metadata,
41+ gpointer user_data) {
42+ _PPdata *data = (_PPdata *) user_data;
43+ gchar *public_url;
44+
45+ /* kill the spinner */
46+ gtk_spinner_stop (GTK_SPINNER (data->spinner));
47+ gtk_widget_destroy (data->spinner);
48+
49+ if (success) {
50+ if (data->uon && data->uon->public) {
51+ public_url = g_hash_table_lookup (data->uon->public, data->path);
52+ if (!public_url)
53+ public_url = _("(not published)");
54+ } else {
55+ public_url = _("(information not yet available)");
56+ }
57+
58+ gtk_box_pack_start (GTK_BOX (data->props), gtk_label_new (_("Ubuntu One data->props")), FALSE, FALSE, 4);
59+ gtk_box_pack_start (GTK_BOX (data->props), gtk_hseparator_new (), FALSE, FALSE, 0);
60+
61+ ubuntuone_nautilus_put_label_and_value (data->props, _("Public URL"), public_url);
62+ ubuntuone_nautilus_put_label_and_value (data->props, _("Currently synchronized"), syncdaemon_metadata_get_is_synced (metadata) ? _("Yes") : _("No"));
63+
64+ gtk_box_pack_start (GTK_BOX (data->props), gtk_hseparator_new (), FALSE, FALSE, 0);
65+
66+ ubuntuone_nautilus_put_label_and_value (data->props, _("Local hash"), syncdaemon_metadata_get_local_hash (metadata));
67+ ubuntuone_nautilus_put_label_and_value (data->props, _("Server hash"), syncdaemon_metadata_get_server_hash (metadata));
68+ ubuntuone_nautilus_put_label_and_value (data->props, _("Share ID"), syncdaemon_metadata_get_share_id (metadata));
69+ ubuntuone_nautilus_put_label_and_value (data->props, _("Node ID"), syncdaemon_metadata_get_node_id (metadata));
70+ } else {
71+ gtk_box_pack_start (GTK_BOX (data->props), gtk_label_new (_("No information available")), TRUE, FALSE, 0);
72+ }
73+
74+ g_free (data->path);
75+ g_free (data);
76+ gtk_widget_show_all (data->props);
77+}
78+
79+static GList * ubuntuone_nautilus_get_ppages (NautilusPropertyPageProvider *provider, GList *files) {
80+ GList *pages;
81+ NautilusPropertyPage *page;
82+ NautilusFileInfo *file;
83+ SyncdaemonFilesystemInterface *interface;
84+ UbuntuOneNautilus * uon;
85+ gchar *uri, *filename;
86+ _PPdata *data;
87+
88+ if (!files)
89+ return NULL;
90+
91+ /* for now, only support single files */
92+ if (files->next)
93+ return NULL;
94+
95+ file = NAUTILUS_FILE_INFO (files->data);
96+
97+ uon = UBUNTUONE_NAUTILUS(provider);
98+ interface = (SyncdaemonFilesystemInterface *) syncdaemon_daemon_get_filesystem_interface (uon->syncdaemon);
99+ if (!interface)
100+ return NULL;
101+
102+ uri = nautilus_file_info_get_uri (file);
103+ if (!uri) {
104+ g_warning ("no URI in file?");
105+ return NULL;
106+ }
107+ filename = g_filename_from_uri (uri, NULL, NULL);
108+ if (!filename) {
109+ g_warning ("no filename from URI?");
110+ return NULL;
111+ }
112+ g_free (uri);
113+
114+ /* OK, it looks like we're doing this thing */
115+ data = g_new0 (struct _PPdata, 1);
116+ data->path = filename;
117+ data->props = gtk_vbox_new (FALSE, 8);
118+ data->spinner = gtk_spinner_new ();
119+ data->uon = uon;
120+ gtk_spinner_start (GTK_SPINNER (data->spinner));
121+ gtk_box_pack_start (GTK_BOX (data->props), data->spinner, TRUE, FALSE, 0);
122+ gtk_widget_show_all (data->props);
123+
124+ page = nautilus_property_page_new ("ubuntuone-ppage",
125+ gtk_label_new("Ubuntu One"),
126+ data->props);
127+
128+ syncdaemon_filesystem_interface_get_metadata_async (interface,
129+ filename,
130+ nautilus_file_info_is_directory (file),
131+ (SyncdaemonGotMetadataFunc) ubuntuone_nautilus_got_metainfo_for_ppage,
132+ data);
133+
134+ return g_list_append (NULL, page);
135+}
136+
137+static void
138+ubuntuone_nautilus_ppage_provider_iface_init (NautilusPropertyPageProviderIface *iface) {
139+ iface->get_pages = ubuntuone_nautilus_get_ppages;
140+}
141+
142 /* GType and nautilus module stuff */
143 static GType un_type = 0;
144
145@@ -722,6 +849,12 @@
146 NULL
147 };
148
149+ static const GInterfaceInfo ppage_provider_iface_info = {
150+ (GInterfaceInitFunc) ubuntuone_nautilus_ppage_provider_iface_init,
151+ NULL,
152+ NULL
153+ };
154+
155 un_type = g_type_module_register_type (module,
156 G_TYPE_OBJECT,
157 "UbuntuOneNautilus",
158@@ -742,6 +875,11 @@
159 un_type,
160 NAUTILUS_TYPE_MENU_PROVIDER,
161 &menu_provider_iface_info);
162+
163+ g_type_module_add_interface (module,
164+ un_type,
165+ NAUTILUS_TYPE_PROPERTY_PAGE_PROVIDER,
166+ &ppage_provider_iface_info);
167 }
168
169

Subscribers

People subscribed via source and target branches