3
#include <glib/gi18n-lib.h>
7
#include "gnome-settings-daemon/gnome-settings-plugin.h"
8
#include "gsd-ubuntuone.h"
9
#include "gsd-ubuntuone-ui.h"
11
#ifdef REGISTER_PLUGIN
12
GNOME_SETTINGS_PLUGIN_REGISTER (GsdUbuntuOne, gsd_ubuntuone)
14
G_DEFINE_TYPE (GsdUbuntuOne, gsd_ubuntuone, G_TYPE_OBJECT);
15
G_DEFINE_TYPE (GnomeSettingsPlugin, gnome_settings_plugin, G_TYPE_OBJECT);
18
#define NO_SPACE _("Your Ubuntu One storage is full. Follow the link below to upgrade your subscription.")
19
#define NO_SPACE_SHARE _("There is no available space on the folder:\n\"%s\" shared by %s")
20
#define NO_SPACE_TITLE _("Out of space")
21
#define UPGRADE_SUBSCRIPTION _("Upgrade Subscription")
23
static void dialog_closed_callback (GtkDialog *dialog,
27
GsdUbuntuOne *plugin = GSD_UBUNTUONE (user_data);
28
g_debug ("dialog closed %d", response_id);
29
gtk_widget_destroy (GTK_WIDGET (plugin->out_of_space_dialog));
30
plugin->out_of_space_dialog = NULL;
34
show_out_of_space_dialog (GsdUbuntuOne *plugin,
37
gboolean show_upgrade_link)
41
GtkLinkButton *upgrade_link;
42
GtkResponseType result;
44
if (plugin->out_of_space_dialog != NULL) {
45
gtk_widget_destroy (GTK_WIDGET (plugin->out_of_space_dialog));
46
plugin->out_of_space_dialog = NULL;
49
builder = gtk_builder_new ();
50
if (!gtk_builder_add_from_string (builder, gsd_ubuntuone_ui, -1, &error)) {
51
g_warning ("Couldn't load builder file: %s", error->message);
54
g_debug ("builder succeeded!");
55
g_debug ("notification: %s - %s", title, body);
57
plugin->out_of_space_dialog = GTK_DIALOG (gtk_builder_get_object (builder, "out_of_space_dialog"));
59
gtk_window_set_skip_taskbar_hint (GTK_WINDOW (plugin->out_of_space_dialog), FALSE);
61
upgrade_link = GTK_LINK_BUTTON (gtk_builder_get_object (builder, "upgrade_link"));
62
gtk_builder_connect_signals (builder, NULL);
63
g_object_unref (builder);
65
gtk_window_set_title (GTK_WINDOW (plugin->out_of_space_dialog), title);
66
g_object_set (plugin->out_of_space_dialog, "text", body, NULL);
67
if (!show_upgrade_link) {
68
gtk_widget_hide (GTK_WIDGET (upgrade_link));
71
gtk_button_set_label (GTK_BUTTON (upgrade_link), UPGRADE_SUBSCRIPTION);
73
g_signal_connect (G_OBJECT (plugin->out_of_space_dialog), "response",
74
G_CALLBACK (dialog_closed_callback), plugin);
75
gtk_widget_show (GTK_WIDGET (plugin->out_of_space_dialog));
80
quota_exceeded_callback (SyncdaemonDaemon *daemon,
81
GHashTable *file_info,
85
GsdUbuntuOne *plugin = GSD_UBUNTUONE (user_data);
86
volume_type = g_hash_table_lookup (file_info, "type");
87
if (volume_type != NULL && strcmp (volume_type, "Share") == 0) {
88
gchar * other_visible_name, * path, * message;
89
other_visible_name = g_hash_table_lookup (file_info, "other_visible_name");
90
path = g_hash_table_lookup (file_info, "path");
91
message = g_strdup_printf (NO_SPACE_SHARE, path, other_visible_name);
92
show_out_of_space_dialog (plugin, NO_SPACE_TITLE, message, FALSE);
95
show_out_of_space_dialog (plugin, NO_SPACE_TITLE, NO_SPACE, TRUE);
100
delayed_syncdaemon_start (gpointer data)
102
GsdUbuntuOne *plugin;
103
plugin = GSD_UBUNTUONE (data);
104
g_debug ("Performing delayed syncdaemon init");
106
plugin->syncdaemon = syncdaemon_daemon_new ();
107
plugin->out_of_space_dialog = NULL;
108
g_signal_connect (G_OBJECT (plugin->syncdaemon), "quota_exceeded",
109
G_CALLBACK (quota_exceeded_callback), plugin);
114
gsd_ubuntuone_init (GsdUbuntuOne *plugin)
119
gsd_ubuntuone_activate (GnomeSettingsPlugin *gsp_object)
121
GsdUbuntuOne *plugin = GSD_UBUNTUONE (gsp_object);
122
g_timeout_add (DELAYED_START_TIMEOUT, delayed_syncdaemon_start, plugin);
126
gsd_ubuntuone_dispose (GObject *object)
128
GsdUbuntuOne *plugin = GSD_UBUNTUONE (object);
129
GsdUbuntuOneClass *klass = GSD_UBUNTUONE_GET_CLASS (object);
130
GObjectClass *parent_class = G_OBJECT_CLASS (klass);
132
if (plugin->syncdaemon)
133
g_object_unref (plugin->syncdaemon);
135
parent_class->dispose (object);
139
gsd_ubuntuone_class_init (GsdUbuntuOneClass *klass)
141
GObjectClass *g_class = G_OBJECT_CLASS (klass);
142
GnomeSettingsPluginClass *gsp_class = GNOME_SETTINGS_PLUGIN_CLASS (klass);
144
g_class->dispose = gsd_ubuntuone_dispose;
145
gsp_class->activate = gsd_ubuntuone_activate;