2
* UbuntuOne Nautilus plugin
4
* Authors: Rodrigo Moya <rodrigo.moya@canonical.com>
6
* Copyright 2009-2010 Canonical Ltd.
8
* This program is free software: you can redistribute it and/or modify it
9
* under the terms of the GNU General Public License version 3, as published
10
* by the Free Software Foundation.
12
* This program is distributed in the hope that it will be useful, but
13
* WITHOUT ANY WARRANTY; without even the implied warranties of
14
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15
* PURPOSE. See the GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License along
18
* with this program. If not, see <http://www.gnu.org/licenses/>.
26
#include <glib/gi18n-lib.h>
27
#include <libsyncdaemon/libsyncdaemon.h>
28
#include "share-dialog.h"
29
#include "u1-contacts-picker.h"
31
G_DEFINE_TYPE(ShareDialog, share_dialog, GTK_TYPE_DIALOG)
34
share_dialog_finalize (GObject *object)
36
ShareDialog *dialog = SHARE_DIALOG (object);
38
if (dialog->path != NULL)
39
g_free (dialog->path);
41
G_OBJECT_CLASS (share_dialog_parent_class)->finalize (object);
45
share_dialog_class_init (ShareDialogClass *klass)
47
GObjectClass *object_class = G_OBJECT_CLASS (klass);
49
object_class->finalize = share_dialog_finalize;
53
picker_selection_changed_cb (U1ContactsPicker *picker, gpointer user_data)
56
GtkWidget * dialog = (GtkWidget *) user_data;
58
selection = u1_contacts_picker_get_selected_emails (picker);
59
if (selection != NULL) {
60
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT, TRUE);
61
u1_contacts_picker_free_selection_list (selection);
63
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT, FALSE);
67
dialog_response_cb (GtkDialog *gtk_dialog,
71
ShareDialog *dialog = SHARE_DIALOG (gtk_dialog);
74
case GTK_RESPONSE_ACCEPT: {
76
SyncdaemonSharesInterface *interface;
77
gboolean allow_mods = FALSE;
79
emails = u1_contacts_picker_get_selected_emails (U1_CONTACTS_PICKER (dialog->user_picker));
81
ubuntuone_show_error_dialog (dialog->uon,
83
_("You need to select at least one contact to share this folder with"));
88
allow_mods = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->allow_mods));
90
interface = SYNCDAEMON_SHARES_INTERFACE (syncdaemon_daemon_get_shares_interface (dialog->uon->syncdaemon));
91
if (interface != NULL) {
92
syncdaemon_shares_interface_create (interface,
95
g_path_get_basename (dialog->path),
99
u1_contacts_picker_free_selection_list (emails);
102
gtk_widget_destroy (GTK_WIDGET (dialog));
108
share_dialog_init (ShareDialog *dialog)
110
GtkWidget *area, *table;
112
gtk_window_set_title (GTK_WINDOW (dialog), _("Share on Ubuntu One"));
113
gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
114
gtk_dialog_add_buttons (GTK_DIALOG (dialog),
115
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
116
(_("Share")), GTK_RESPONSE_ACCEPT,
118
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
119
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT, FALSE);
120
gtk_window_set_icon_name (GTK_WINDOW (dialog), "ubuntuone");
121
g_signal_connect (G_OBJECT (dialog), "response",
122
G_CALLBACK (dialog_response_cb), NULL);
124
area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
126
table = gtk_table_new (3, 2, FALSE);
127
gtk_table_set_row_spacings (GTK_TABLE (table), 12);
128
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
129
gtk_container_set_border_width (GTK_CONTAINER (table), 7);
130
gtk_widget_show (table);
131
gtk_container_add (GTK_CONTAINER (area), table);
133
dialog->user_picker = u1_contacts_picker_new ();
134
g_signal_connect (G_OBJECT (dialog->user_picker), "selection-changed",
135
G_CALLBACK (picker_selection_changed_cb), dialog);
136
gtk_table_attach (GTK_TABLE (table), dialog->user_picker, 0, 2, 0, 2,
137
GTK_FILL | GTK_EXPAND | GTK_SHRINK,
138
GTK_FILL | GTK_EXPAND | GTK_SHRINK, 3, 3);
139
gtk_widget_show (dialog->user_picker);
141
dialog->allow_mods = gtk_check_button_new_with_mnemonic (_("_Allow Modification"));
142
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->allow_mods), TRUE); /* Default to RW */
143
gtk_table_attach (GTK_TABLE (table), dialog->allow_mods, 0, 2, 2, 3, GTK_FILL, GTK_FILL, 3, 3);
144
gtk_widget_show (dialog->allow_mods);
146
gtk_widget_set_size_request (GTK_WIDGET (dialog), 500, 450);
150
share_dialog_new (GtkWidget *parent, UbuntuOneNautilus *uon, const gchar *path)
154
dialog = (ShareDialog *) g_object_new (TYPE_SHARE_DIALOG, NULL);
156
dialog->path = g_strdup (path);
157
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
159
return (GtkWidget *) dialog;