diff options
author | Milan Crha <mcrha@redhat.com> | 2010-02-04 19:55:42 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2010-02-04 19:55:42 +0800 |
commit | 9a8fa88b6a3fe12409ff0358bed45187c9c743a5 (patch) | |
tree | 2686e65a6fa77973efac264c3ce14c388906f650 /plugins/google-account-setup | |
parent | caee31bac657c69b3dd8ec2d9ebfebd4510a6608 (diff) | |
download | gsoc2013-evolution-9a8fa88b6a3fe12409ff0358bed45187c9c743a5.tar gsoc2013-evolution-9a8fa88b6a3fe12409ff0358bed45187c9c743a5.tar.gz gsoc2013-evolution-9a8fa88b6a3fe12409ff0358bed45187c9c743a5.tar.bz2 gsoc2013-evolution-9a8fa88b6a3fe12409ff0358bed45187c9c743a5.tar.lz gsoc2013-evolution-9a8fa88b6a3fe12409ff0358bed45187c9c743a5.tar.xz 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/google-account-setup')
-rw-r--r-- | plugins/google-account-setup/google-source.c | 145 | ||||
-rw-r--r-- | plugins/google-account-setup/org-gnome-evolution-google.eplug.xml | 4 |
2 files changed, 11 insertions, 138 deletions
diff --git a/plugins/google-account-setup/google-source.c b/plugins/google-account-setup/google-source.c index 9452422902..26b80f0ec8 100644 --- a/plugins/google-account-setup/google-source.c +++ b/plugins/google-account-setup/google-source.c @@ -34,6 +34,7 @@ #include <e-util/e-config.h> #include <e-util/e-plugin.h> +#include <e-util/e-plugin-util.h> #include <calendar/gui/e-cal-config.h> #include <calendar/gui/e-cal-event.h> @@ -303,85 +304,6 @@ user_changed (GtkEntry *editable, ESource *source) init_combo_values (GTK_COMBO_BOX (g_object_get_data (G_OBJECT (editable), "CalendarCombo")), _("Default"), NULL); } -static gchar * -get_refresh_minutes (GtkWidget *spin, GtkWidget *combobox) -{ - gint setting = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin)); - switch (gtk_combo_box_get_active (GTK_COMBO_BOX (combobox))) { - case 0: - /* minutes */ - break; - case 1: - /* hours */ - setting *= 60; - break; - case 2: - /* days */ - setting *= 1440; - break; - case 3: - /* weeks - is this *really* necessary? */ - setting *= 10080; - break; - default: - g_warning ("Time unit out of range"); - break; - } - - return g_strdup_printf ("%d", setting); -} - -static void -spin_changed (GtkSpinButton *spin, ECalConfigTargetSource *t) -{ - gchar *refresh_str; - GtkWidget *combobox; - - combobox = g_object_get_data (G_OBJECT(spin), "combobox"); - - refresh_str = get_refresh_minutes ((GtkWidget *)spin, combobox); - e_source_set_property (t->source, "refresh", refresh_str); - g_free (refresh_str); -} - -static void -combobox_changed (GtkComboBox *combobox, ECalConfigTargetSource *t) -{ - gchar *refresh_str; - GtkWidget *spin; - - spin = g_object_get_data (G_OBJECT(combobox), "spin"); - - refresh_str = get_refresh_minutes (spin, (GtkWidget *)combobox); - e_source_set_property (t->source, "refresh", refresh_str); - g_free (refresh_str); -} - -static void -set_refresh_time (ESource *source, GtkWidget *spin, GtkWidget *combobox) -{ - gint time; - gint item_num = 0; - const gchar *refresh_str = e_source_get_property (source, "refresh"); - time = refresh_str ? atoi (refresh_str) : 30; - - if (time && !(time % 10080)) { - /* weeks */ - item_num = 3; - time /= 10080; - } else if (time && !(time % 1440)) { - /* days */ - item_num = 2; - time /= 1440; - } else if (time && !(time % 60)) { - /* hours */ - item_num = 1; - time /= 60; - } - gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), item_num); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), time); -} - enum { COL_COLOR = 0, /* GDK_TYPE_COLOR */ COL_TITLE, /* G_TYPE_STRING */ @@ -656,7 +578,6 @@ plugin_google (EPlugin *epl, EUri *euri; GtkWidget *parent; GtkWidget *widget; - GtkWidget *luser; GtkWidget *user; GtkWidget *label; GtkWidget *combo; @@ -666,7 +587,7 @@ plugin_google (EPlugin *epl, GtkCellRenderer *renderer; GtkListStore *store; - GtkWidget *combobox, *spin, *hbox; + GtkWidget *hbox; source = t->source; group = e_source_peek_group (source); @@ -695,70 +616,22 @@ plugin_google (EPlugin *epl, /* Build up the UI */ parent = data->parent; - row = GTK_TABLE (parent)->nrows; - - luser = gtk_label_new_with_mnemonic (_("User_name:")); - gtk_widget_show (luser); - gtk_misc_set_alignment (GTK_MISC (luser), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (parent), - luser, 0, 1, - row + 1, row + 2, - GTK_FILL, 0, 0, 0); - user = gtk_entry_new (); - gtk_widget_show (user); + user = e_plugin_util_add_entry (parent, _("User_name:"), NULL, NULL); gtk_entry_set_text (GTK_ENTRY (user), username ? username : ""); - gtk_table_attach (GTK_TABLE (parent), user, - 1, 2, row + 1, row + 2, - GTK_EXPAND | GTK_FILL, 0, 0, 0); - - gtk_label_set_mnemonic_widget (GTK_LABEL (luser), user); - - label = gtk_label_new_with_mnemonic (_("Re_fresh:")); - gtk_widget_show (label); - gtk_misc_set_alignment (GTK_MISC(label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (parent), - label, - 0, 1, - row + 2, row + 3, - GTK_EXPAND | GTK_FILL, 0, 0, 0); - - hbox = gtk_hbox_new (FALSE, 6); - gtk_widget_show (hbox); - - spin = gtk_spin_button_new_with_range (1, 100, 1); - gtk_label_set_mnemonic_widget (GTK_LABEL(label), spin); - gtk_widget_show (spin); - gtk_box_pack_start (GTK_BOX(hbox), spin, FALSE, TRUE, 0); - - if (!e_source_get_property (source, "refresh")) - e_source_set_property (source, "refresh", "30"); - - combobox = gtk_combo_box_new_text (); - gtk_widget_show (combobox); - gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("minutes")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("hours")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("days")); - gtk_combo_box_append_text (GTK_COMBO_BOX (combobox), _("weeks")); - set_refresh_time (source, spin, combobox); - gtk_box_pack_start (GTK_BOX (hbox), combobox, FALSE, TRUE, 0); - - g_object_set_data (G_OBJECT (combobox), "spin", spin); - g_signal_connect (G_OBJECT (combobox), "changed", G_CALLBACK (combobox_changed), t); - g_object_set_data (G_OBJECT (spin), "combobox", combobox); - g_signal_connect (G_OBJECT (spin), "value-changed", G_CALLBACK (spin_changed), t); - - gtk_table_attach (GTK_TABLE (parent), hbox, 1, 2, row + 2, row + 3, GTK_EXPAND | GTK_FILL, 0, 0, 0); - g_signal_connect (G_OBJECT (user), "changed", G_CALLBACK (user_changed), source); + e_plugin_util_add_refresh (parent, _("Re_fresh:"), source, "refresh"); + + row = GTK_TABLE (parent)->nrows; + label = gtk_label_new_with_mnemonic (_("Cal_endar:")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (parent), label, 0, 1, row + 3, row + 4, GTK_FILL | GTK_EXPAND, 0, 0, 0); + gtk_table_attach (GTK_TABLE (parent), label, 0, 1, row, row + 1, GTK_FILL | GTK_EXPAND, 0, 0, 0); store = gtk_list_store_new ( NUM_COLUMNS, @@ -798,7 +671,7 @@ plugin_google (EPlugin *epl, gtk_widget_set_sensitive (label, username && *username); gtk_widget_show_all (hbox); - gtk_table_attach (GTK_TABLE (parent), hbox, 1, 2, row + 3, row + 4, GTK_FILL | GTK_EXPAND, 0, 0, 0); + gtk_table_attach (GTK_TABLE (parent), hbox, 1, 2, row, row + 1, GTK_FILL | GTK_EXPAND, 0, 0, 0); return widget; } diff --git a/plugins/google-account-setup/org-gnome-evolution-google.eplug.xml b/plugins/google-account-setup/org-gnome-evolution-google.eplug.xml index afccbd3fb7..8eefe3dfce 100644 --- a/plugins/google-account-setup/org-gnome-evolution-google.eplug.xml +++ b/plugins/google-account-setup/org-gnome-evolution-google.eplug.xml @@ -8,7 +8,7 @@ <hook class="org.gnome.evolution.calendar.config:1.0"> <group target="source" id="org.gnome.evolution.calendar.calendarProperties"> - <item type="item_table" path="00.general/00.source/15.google" factory="plugin_google"/> + <item type="item_table" path="00.general/00.source/99.google" factory="plugin_google"/> </group> </hook> <hook class="org.gnome.evolution.calendar.events:1.0"> @@ -17,7 +17,7 @@ <hook class="org.gnome.evolution.addressbook.config:1.0"> <group target="source" id="com.novell.evolution.addressbook.config.accountEditor"> - <item type="item" path="00.general/10.display/00.google" factory="plugin_google_contacts"/> + <item type="item" path="00.general/10.display/99.google" factory="plugin_google_contacts"/> </group> </hook> </e-plugin> |