aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/dialogs
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/gui/dialogs')
-rw-r--r--calendar/gui/dialogs/Makefile.am2
-rw-r--r--calendar/gui/dialogs/copy-source-dialog.c78
-rw-r--r--calendar/gui/dialogs/select-source-dialog.c94
-rw-r--r--calendar/gui/dialogs/select-source-dialog.h30
4 files changed, 135 insertions, 69 deletions
diff --git a/calendar/gui/dialogs/Makefile.am b/calendar/gui/dialogs/Makefile.am
index fc4e3f3ac1..dfe84f1a3c 100644
--- a/calendar/gui/dialogs/Makefile.am
+++ b/calendar/gui/dialogs/Makefile.am
@@ -72,6 +72,8 @@ libcal_dialogs_la_SOURCES = \
save-comp.h \
schedule-page.c \
schedule-page.h \
+ select-source-dialog.c \
+ select-source-dialog.h \
send-comp.c \
send-comp.h \
task-editor.c \
diff --git a/calendar/gui/dialogs/copy-source-dialog.c b/calendar/gui/dialogs/copy-source-dialog.c
index 936ed6e66a..11768525c3 100644
--- a/calendar/gui/dialogs/copy-source-dialog.c
+++ b/calendar/gui/dialogs/copy-source-dialog.c
@@ -18,44 +18,19 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
-#include <gtk/gtkbox.h>
-#include <gtk/gtkdialog.h>
-#include <gtk/gtklabel.h>
#include <gtk/gtkmessagedialog.h>
-#include <gtk/gtkstock.h>
#include <bonobo/bonobo-i18n.h>
-#include <widgets/misc/e-source-option-menu.h>
#include "copy-source-dialog.h"
+#include "select-source-dialog.h"
#include "common/authentication.h"
typedef struct {
- GtkWidget *dialog;
- GtkWidget *selector;
- ESourceList *source_list;
- GConfClient *conf_client;
ESource *orig_source;
ECalSourceType obj_type;
ESource *selected_source;
} CopySourceDialogData;
static void
-source_selected_cb (ESourceOptionMenu *menu, ESource *selected_source, gpointer user_data)
-{
- CopySourceDialogData *csdd = user_data;
-
- csdd->selected_source = selected_source;
- if (selected_source) {
- if (selected_source != csdd->orig_source)
- gtk_dialog_set_response_sensitive (GTK_DIALOG (csdd->dialog), GTK_RESPONSE_OK, TRUE);
- else {
- gtk_dialog_set_response_sensitive (GTK_DIALOG (csdd->dialog), GTK_RESPONSE_OK, FALSE);
- csdd->selected_source = NULL;
- }
- } else
- gtk_dialog_set_response_sensitive (GTK_DIALOG (csdd->dialog), GTK_RESPONSE_OK, FALSE);
-}
-
-static void
show_error (GtkWindow *parent, const char *msg)
{
GtkWidget *dialog;
@@ -80,7 +55,7 @@ copy_source (CopySourceDialogData *csdd)
/* open the source */
source_client = auth_new_cal_from_source (csdd->orig_source, csdd->obj_type);
if (!e_cal_open (source_client, TRUE, NULL)) {
- show_error (GTK_WINDOW (csdd->dialog), _("Could not open source"));
+ show_error (NULL, _("Could not open source"));
g_object_unref (source_client);
return FALSE;
}
@@ -88,7 +63,7 @@ copy_source (CopySourceDialogData *csdd)
/* open the destination */
dest_client = auth_new_cal_from_source (csdd->selected_source, csdd->obj_type);
if (!e_cal_open (dest_client, FALSE, NULL)) {
- show_error (GTK_WINDOW (csdd->dialog), _("Could not open destination"));
+ show_error (NULL, _("Could not open destination"));
g_object_unref (dest_client);
g_object_unref (source_client);
return FALSE;
@@ -97,7 +72,7 @@ copy_source (CopySourceDialogData *csdd)
/* check if the destination is read only */
e_cal_is_read_only (dest_client, &read_only, NULL);
if (read_only) {
- show_error (GTK_WINDOW (csdd->dialog), _("Destination is read only"));
+ show_error (NULL, _("Destination is read only"));
} else {
if (e_cal_get_object_list (source_client, "#t", &obj_list, NULL)) {
GList *l;
@@ -138,55 +113,20 @@ copy_source_dialog (GtkWindow *parent, ESource *source, ECalSourceType obj_type)
{
CopySourceDialogData csdd;
gboolean result = FALSE;
- const char *gconf_key;
- GtkWidget *label;
- gchar *label_text;
g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
- if (obj_type == E_CAL_SOURCE_TYPE_EVENT)
- gconf_key = "/apps/evolution/calendar/sources";
- else if (obj_type == E_CAL_SOURCE_TYPE_TODO)
- gconf_key = "/apps/evolution/tasks/sources";
- else
- return FALSE;
-
csdd.orig_source = source;
csdd.selected_source = NULL;
csdd.obj_type = obj_type;
- /* create the dialog */
- csdd.dialog = gtk_dialog_new_with_buttons (_("Copy"), parent, 0,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_OK,
- NULL);
- gtk_dialog_set_response_sensitive (GTK_DIALOG (csdd.dialog), GTK_RESPONSE_OK, FALSE);
-
- label_text = g_strdup_printf (_("Select destination %s"),
- obj_type == E_CAL_SOURCE_TYPE_EVENT ?
- _("calendar") : _("task list"));
- label = gtk_label_new (label_text);
- g_free (label_text);
-
- gtk_widget_show (label);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (csdd.dialog)->vbox), label, FALSE, FALSE, 6);
-
- csdd.conf_client = gconf_client_get_default ();
- csdd.source_list = e_source_list_new_for_gconf (csdd.conf_client, gconf_key);
- csdd.selector = e_source_option_menu_new (csdd.source_list);
- g_signal_connect (G_OBJECT (csdd.selector), "source_selected",
- G_CALLBACK (source_selected_cb), &csdd);
- gtk_widget_show (csdd.selector);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (csdd.dialog)->vbox), csdd.selector, FALSE, FALSE, 6);
-
- if (gtk_dialog_run (GTK_DIALOG (csdd.dialog)) == GTK_RESPONSE_OK) {
+ csdd.selected_source = select_source_dialog (parent, obj_type);
+ if (csdd.selected_source) {
result = copy_source (&csdd);
- }
- /* free memory */
- g_object_unref (csdd.conf_client);
- g_object_unref (csdd.source_list);
- gtk_widget_destroy (csdd.dialog);
+ /* free memory */
+ g_object_unref (csdd.selected_source);
+ }
return result;
}
diff --git a/calendar/gui/dialogs/select-source-dialog.c b/calendar/gui/dialogs/select-source-dialog.c
new file mode 100644
index 0000000000..978b151d86
--- /dev/null
+++ b/calendar/gui/dialogs/select-source-dialog.c
@@ -0,0 +1,94 @@
+/* Evolution calendar - Select source dialog
+ *
+ * Copyright (C) 2004 Novell, Inc.
+ *
+ * Author: Rodrigo Moya <rodrigo@ximian.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <bonobo/bonobo-i18n.h>
+#include <gtk/gtkbox.h>
+#include <gtk/gtkdialog.h>
+#include <gtk/gtklabel.h>
+#include <gtk/gtkstock.h>
+#include "widgets/misc/e-source-option-menu.h"
+#include "select-source-dialog.h"
+
+static void
+source_selected_cb (ESourceOptionMenu *menu, ESource *selected_source, gpointer user_data)
+{
+ ESource **our_selection = user_data;
+
+ if (*our_selection)
+ g_object_unref (*our_selection);
+ *our_selection = g_object_ref (selected_source);
+}
+
+/**
+ * select_source_dialog
+ *
+ * Implements dialog for allowing user to select a destination source.
+ */
+ESource *
+select_source_dialog (GtkWindow *parent, ECalSourceType obj_type)
+{
+ GtkWidget *dialog, *label, *source_selector;
+ ESourceList *source_list;
+ ESource *selected_source = NULL;
+ const char *gconf_key;
+ char *label_text;
+ GConfClient *conf_client;
+
+ if (obj_type == E_CAL_SOURCE_TYPE_EVENT)
+ gconf_key = "/apps/evolution/calendar/sources";
+ else if (obj_type == E_CAL_SOURCE_TYPE_TODO)
+ gconf_key = "/apps/evolution/tasks/sources";
+ else
+ return NULL;
+
+ /* create the dialog */
+ dialog = gtk_dialog_new_with_buttons (_("Select source"), parent, 0,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK, GTK_RESPONSE_OK,
+ NULL);
+ /* gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE); */
+
+ label_text = g_strdup_printf (_("Select destination %s"),
+ obj_type == E_CAL_SOURCE_TYPE_EVENT ?
+ _("calendar") : _("task list"));
+ label = gtk_label_new (label_text);
+ g_free (label_text);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), label, FALSE, FALSE, 6);
+
+ conf_client = gconf_client_get_default ();
+ source_list = e_source_list_new_for_gconf (conf_client, gconf_key);
+ source_selector = e_source_option_menu_new (source_list);
+ g_signal_connect (G_OBJECT (source_selector), "source_selected",
+ G_CALLBACK (source_selected_cb), &selected_source);
+ gtk_widget_show (source_selector);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), source_selector, FALSE, FALSE, 6);
+
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_OK) {
+ if (selected_source)
+ g_object_unref (selected_source);
+ }
+
+ g_object_unref (conf_client);
+ g_object_unref (source_list);
+ gtk_widget_destroy (dialog);
+
+ return selected_source;
+}
diff --git a/calendar/gui/dialogs/select-source-dialog.h b/calendar/gui/dialogs/select-source-dialog.h
new file mode 100644
index 0000000000..d0656395bb
--- /dev/null
+++ b/calendar/gui/dialogs/select-source-dialog.h
@@ -0,0 +1,30 @@
+/* Evolution calendar - Select source dialog
+ *
+ * Copyright (C) 2004 Novell, Inc.
+ *
+ * Author: Rodrigo Moya <rodrigo@ximian.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef SELECT_SOURCE_DIALOG_H
+#define SELECT_SOURCE_DIALOG_H
+
+#include <gtk/gtkwindow.h>
+#include <libedataserver/e-source.h>
+#include <libecal/e-cal.h>
+
+ESource *select_source_dialog (GtkWindow *parent, ECalSourceType type);
+
+#endif