aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/default-source/default-source.c
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2010-02-04 19:55:42 +0800
committerMilan Crha <mcrha@redhat.com>2010-02-04 19:55:42 +0800
commit9a8fa88b6a3fe12409ff0358bed45187c9c743a5 (patch)
tree2686e65a6fa77973efac264c3ce14c388906f650 /plugins/default-source/default-source.c
parentcaee31bac657c69b3dd8ec2d9ebfebd4510a6608 (diff)
downloadgsoc2013-evolution-9a8fa88b6a3fe12409ff0358bed45187c9c743a5.tar.gz
gsoc2013-evolution-9a8fa88b6a3fe12409ff0358bed45187c9c743a5.tar.zst
gsoc2013-evolution-9a8fa88b6a3fe12409ff0358bed45187c9c743a5.zip
Move some ESource-plugin common code to e-plugin-util.h/.c
Diffstat (limited to 'plugins/default-source/default-source.c')
-rw-r--r--plugins/default-source/default-source.c67
1 files changed, 6 insertions, 61 deletions
diff --git a/plugins/default-source/default-source.c b/plugins/default-source/default-source.c
index 1d8a7e0299..db8423aec6 100644
--- a/plugins/default-source/default-source.c
+++ b/plugins/default-source/default-source.c
@@ -22,12 +22,12 @@
#include <gtk/gtk.h>
#include <e-util/e-config.h>
+#include <e-util/e-plugin-util.h>
#include <calendar/gui/e-cal-config.h>
#include <libedataserver/e-source.h>
#include <addressbook/gui/widgets/eab-config.h>
#include <libebook/e-book.h>
#include <libecal/e-cal.h>
-#include <libedataserver/e-source.h>
#include <glib/gi18n.h>
#include <string.h>
@@ -62,71 +62,30 @@ commit_default_book (EPlugin *epl, EConfigTarget *target)
}
-static void
-default_source_changed (GtkWidget *check_box, ESource *source)
-{
-
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_box)))
- e_source_set_property (source, "default", "true");
- else
- e_source_set_property (source, "default", NULL);
-}
-
-static void
-autocomplete_book_changed (GtkWidget *check_box, ESource *source)
-{
-
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_box)))
- e_source_set_property (source, "completion", "true");
- else
- e_source_set_property (source, "completion", NULL);
-}
-
GtkWidget *
org_gnome_default_book (EPlugin *epl, EConfigHookItemFactoryData *data)
{
- GtkWidget *widget;
- ESource *source;
EABConfigTargetSource *book_target;
if (data->old)
return data->old;
- widget = gtk_check_button_new_with_mnemonic (_("Mark as _default address book"));
+
book_target = (EABConfigTargetSource *) data->target;
- source = book_target->source;
- if (e_source_get_property (source, "default"))
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
- else
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
- gtk_container_add (GTK_CONTAINER (data->parent), widget);
-
- g_signal_connect (GTK_TOGGLE_BUTTON (widget), "toggled", G_CALLBACK (default_source_changed), source);
- gtk_widget_show (widget);
- return widget;
+ return e_plugin_util_add_check (data->parent, _("Mark as _default address book"), book_target->source, "default", "true", NULL);
}
GtkWidget *
org_gnome_autocomplete_book (EPlugin *epl, EConfigHookItemFactoryData *data)
{
- GtkWidget *widget;
- ESource *source;
EABConfigTargetSource *book_target;
if (data->old)
return data->old;
- widget = gtk_check_button_new_with_mnemonic (_("A_utocomplete with this address book"));
book_target = (EABConfigTargetSource *) data->target;
- source = book_target->source;
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), e_source_get_property (source, "completion") && g_str_equal (e_source_get_property (source, "completion"), "true"));
- gtk_container_add (GTK_CONTAINER (data->parent), widget);
-
- g_signal_connect (GTK_TOGGLE_BUTTON (widget), "toggled", G_CALLBACK (autocomplete_book_changed), source);
- gtk_widget_show (widget);
-
- return widget;
+ return e_plugin_util_add_check (data->parent, _("A_utocomplete with this address book"), book_target->source, "completion", "true", NULL);
}
static const gchar *
@@ -149,26 +108,12 @@ GtkWidget *org_gnome_default_cal (EPlugin *epl, EConfigHookItemFactoryData *data
GtkWidget *
org_gnome_default_cal (EPlugin *epl, EConfigHookItemFactoryData *data)
{
- GtkWidget *widget;
- ESource *source;
ECalConfigTargetSource *cal_target;
- gint i;
if (data->old)
return data->old;
- cal_target = (ECalConfigTargetSource *) data->target;
- source = cal_target->source;
- widget = gtk_check_button_new_with_mnemonic (get_calendar_option_caption (cal_target->source_type));
- if (e_source_get_property (source, "default"))
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
- else
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
-
- i = ((GtkTable *)data->parent)->nrows;
- gtk_table_attach((GtkTable *)data->parent, widget, 1, 2, i, i+1, GTK_EXPAND | GTK_FILL, 0, 0, 0);
+ cal_target = (ECalConfigTargetSource *) data->target;
- g_signal_connect (GTK_TOGGLE_BUTTON (widget), "toggled", G_CALLBACK (default_source_changed), source);
- gtk_widget_show (widget);
- return widget;
+ return e_plugin_util_add_check (data->parent, get_calendar_option_caption (cal_target->source_type), cal_target->source, "default", "true", NULL);
}