aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/dialogs/task-page.c
diff options
context:
space:
mode:
authorHans Petter Jansson <hpj@ximian.com>2003-12-18 10:41:53 +0800
committerHans Petter <hansp@src.gnome.org>2003-12-18 10:41:53 +0800
commite4a68478f7fed9fdf32feae4cca56fb1f4b71411 (patch)
treeccaf59a8b1d95a3be46e9241248185f490592535 /calendar/gui/dialogs/task-page.c
parent919563751e1cce6a0aa42f6ec8bd02f84ec7d67c (diff)
downloadgsoc2013-evolution-e4a68478f7fed9fdf32feae4cca56fb1f4b71411.tar
gsoc2013-evolution-e4a68478f7fed9fdf32feae4cca56fb1f4b71411.tar.gz
gsoc2013-evolution-e4a68478f7fed9fdf32feae4cca56fb1f4b71411.tar.bz2
gsoc2013-evolution-e4a68478f7fed9fdf32feae4cca56fb1f4b71411.tar.lz
gsoc2013-evolution-e4a68478f7fed9fdf32feae4cca56fb1f4b71411.tar.xz
gsoc2013-evolution-e4a68478f7fed9fdf32feae4cca56fb1f4b71411.tar.zst
gsoc2013-evolution-e4a68478f7fed9fdf32feae4cca56fb1f4b71411.zip
Add the concept of a source client, where the object lives currently. The
2003-12-17 Hans Petter Jansson <hpj@ximian.com> * gui/dialogs/comp-editor.c: Add the concept of a source client, where the object lives currently. The plain client is where it will be stored. (comp_editor_finalize): If we have a source client, disconnect from and unref it. (save_comp): Check if the object is being moved, and if so, remove it from the source client, and make the target client the new source. (comp_editor_append_page): Connect to client_changed signal. (real_set_e_cal): Change an old gtk_signal_disconnect_by_data() to the GLib equivalent, and don't cast ECal to GtkObject. If the source client is not set, make it equivalent to the target client. (page_client_changed_cb): Implement. Handles a client change. * gui/dialogs/comp-editor-page.c (comp_editor_page_class_init): Add a new signal, "client_changed", that notifies that the ECal client was changed from one of the editor pages. (comp_editor_page_set_e_cal): Fix two bugs in this function; if the same client is set twice, its ref count could drop to 0. Additionally, it was unreffing the new client instead of the old one. (comp_editor_page_notify_client_changed): Implement. * gui/dialogs/event-page.c (event_page_fill_widgets): Fill in the source menu. (get_widgets): Get the source menu. (source_changed_cb): Implement. Try to open a client for the new source, and if successful, notify of the change. Show a dialog on failure, and revert to last selected source. (init_widgets): Connect to source menu. (event_page_create_source_option_menu): Implement Glade helper. * gui/dialogs/task-page.c (task_page_fill_widgets): Fill in the source menu. (get_widgets): Get the source menu. (source_changed_cb): Implement, similar to the event page, but for tasks. (init_widgets): Connect to source menu. (task_page_construct): Fix a message booboo. (task_page_create_source_option_menu): Implement Glade helper. * gui/dialogs/event-page.glade: Add source menu widget. * gui/dialogs/task-page.glade: Add source menu widget. svn path=/trunk/; revision=23974
Diffstat (limited to 'calendar/gui/dialogs/task-page.c')
-rw-r--r--calendar/gui/dialogs/task-page.c68
1 files changed, 67 insertions, 1 deletions
diff --git a/calendar/gui/dialogs/task-page.c b/calendar/gui/dialogs/task-page.c
index 830e5a0bef..1ff2cd608d 100644
--- a/calendar/gui/dialogs/task-page.c
+++ b/calendar/gui/dialogs/task-page.c
@@ -31,10 +31,12 @@
#include <gtk/gtktogglebutton.h>
#include <gtk/gtkspinbutton.h>
#include <gtk/gtkoptionmenu.h>
+#include <gtk/gtkmessagedialog.h>
#include <libgnome/gnome-i18n.h>
#include <glade/glade.h>
#include <gal/widgets/e-categories.h>
#include <widgets/misc/e-dateedit.h>
+#include "widgets/misc/e-source-option-menu.h"
#include "e-util/e-dialog-widgets.h"
#include "e-util/e-categories-config.h"
#include "../e-timezone-entry.h"
@@ -68,6 +70,8 @@ struct _TaskPagePrivate {
GtkWidget *categories_btn;
GtkWidget *categories;
+ GtkWidget *source_selector;
+
gboolean updating;
};
@@ -256,6 +260,7 @@ task_page_fill_widgets (CompEditorPage *page, ECalComponent *comp)
const char *categories;
icaltimezone *zone, *default_zone;
char *location;
+ ESource *source;
tpage = TASK_PAGE (page);
priv = tpage->priv;
@@ -399,6 +404,9 @@ task_page_fill_widgets (CompEditorPage *page, ECalComponent *comp)
e_cal_component_get_categories (comp, &categories);
e_dialog_editable_set (priv->categories, categories);
+ /* Source */
+ source = e_cal_get_source (page->client);
+ e_source_option_menu_select (E_SOURCE_OPTION_MENU (priv->source_selector), source);
priv->updating = FALSE;
}
@@ -634,6 +642,8 @@ get_widgets (TaskPage *tpage)
priv->categories_btn = GW ("categories-button");
priv->categories = GW ("categories");
+ priv->source_selector = GW ("source");
+
#undef GW
return (priv->summary
@@ -772,6 +782,40 @@ field_changed_cb (GtkWidget *widget, gpointer data)
comp_editor_page_notify_changed (COMP_EDITOR_PAGE (tpage));
}
+static void
+source_changed_cb (GtkWidget *widget, ESource *source, gpointer data)
+{
+ TaskPage *epage;
+ TaskPagePrivate *priv;
+
+ epage = TASK_PAGE (data);
+ priv = epage->priv;
+
+ if (!priv->updating) {
+ ECal *client;
+
+ client = e_cal_new (source, CALOBJ_TYPE_TODO);
+ if (!client || !e_cal_open (client, FALSE, NULL)) {
+ GtkWidget *dialog;
+
+ if (client)
+ g_object_unref (client);
+
+ e_source_option_menu_select (E_SOURCE_OPTION_MENU (priv->source_selector),
+ e_cal_get_source (COMP_EDITOR_PAGE (epage)->client));
+
+ dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
+ GTK_MESSAGE_WARNING, GTK_BUTTONS_OK,
+ _("Unable to open tasks in '%s'."),
+ e_source_peek_name (source));
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ } else {
+ comp_editor_page_notify_client_changed (COMP_EDITOR_PAGE (epage), client);
+ }
+ }
+}
+
/* Hooks the widget signals */
static gboolean
init_widgets (TaskPage *tpage)
@@ -839,6 +883,9 @@ init_widgets (TaskPage *tpage)
g_signal_connect((priv->categories_btn), "clicked",
G_CALLBACK (categories_clicked_cb), tpage);
+ /* Source selector */
+ g_signal_connect((priv->source_selector), "source_selected",
+ G_CALLBACK (source_changed_cb), tpage);
/* Set the default timezone, so the timezone entry may be hidden. */
location = calendar_config_get_timezone ();
@@ -882,7 +929,7 @@ task_page_construct (TaskPage *tpage)
}
if (!init_widgets (tpage)) {
- g_message ("event_page_construct(): "
+ g_message ("task_page_construct(): "
"Could not initialize the widgets!");
return NULL;
}
@@ -924,3 +971,22 @@ task_page_create_date_edit (void)
return dedit;
}
+
+GtkWidget *task_page_create_source_option_menu (void);
+
+GtkWidget *
+task_page_create_source_option_menu (void)
+{
+ GtkWidget *menu;
+ GConfClient *gconf_client;
+ ESourceList *source_list;
+
+ gconf_client = gconf_client_get_default ();
+ source_list = e_source_list_new_for_gconf (gconf_client, "/apps/evolution/tasks/sources");
+
+ menu = e_source_option_menu_new (source_list);
+ g_object_unref (source_list);
+
+ gtk_widget_show (menu);
+ return menu;
+}