1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
4 * Copyright (C) 2001 JP Rosevear
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
29 #include <libgnome/gnome-i18n.h>
30 #include "e-source-option-menu.h"
31 #include "e-pilot-settings.h"
33 struct _EPilotSettingsPrivate
42 static void class_init (EPilotSettingsClass *klass);
43 static void init (EPilotSettings *ps);
45 static GObjectClass *parent_class = NULL;
49 e_pilot_settings_get_type (void)
51 static GType type = 0;
54 static GTypeInfo info = {
55 sizeof (EPilotSettingsClass),
57 (GBaseFinalizeFunc) NULL,
58 (GClassInitFunc) class_init,
60 sizeof (EPilotSettings),
62 (GInstanceInitFunc) init
64 type = g_type_register_static (GTK_TYPE_TABLE, "EPilotSettings", &info, 0);
71 class_init (EPilotSettingsClass *klass)
73 GObjectClass *object_class;
75 object_class = G_OBJECT_CLASS (klass);
77 parent_class = g_type_class_ref (GTK_TYPE_TABLE);
81 init (EPilotSettings *ps)
83 EPilotSettingsPrivate *priv;
85 priv = g_new0 (EPilotSettingsPrivate, 1);
92 build_ui (EPilotSettings *ps, ESourceList *source_list)
94 EPilotSettingsPrivate *priv;
99 gtk_table_resize (GTK_TABLE (ps), 2, 2);
100 gtk_container_set_border_width (GTK_CONTAINER (ps), 4);
101 gtk_table_set_col_spacings (GTK_TABLE (ps), 6);
103 lbl = gtk_label_new (_("Sync with:"));
104 gtk_misc_set_alignment (GTK_MISC (lbl), 0.0, 0.5);
105 priv->source = e_source_option_menu_new (source_list);
106 gtk_table_attach_defaults (GTK_TABLE (ps), lbl, 0, 1, 0, 1);
107 gtk_table_attach_defaults (GTK_TABLE (ps), priv->source, 1, 2, 0, 1);
108 gtk_widget_show (lbl);
109 gtk_widget_show (priv->source);
111 lbl = gtk_label_new (_("Sync Private Records:"));
112 gtk_misc_set_alignment (GTK_MISC (lbl), 0.0, 0.5);
113 priv->secret = gtk_check_button_new ();
114 gtk_table_attach_defaults (GTK_TABLE (ps), lbl, 0, 1, 1, 2);
115 gtk_table_attach_defaults (GTK_TABLE (ps), priv->secret, 1, 2, 1, 2);
116 gtk_widget_show (lbl);
117 gtk_widget_show (priv->secret);
120 lbl = gtk_label_new (_("Sync Categories:"));
121 gtk_misc_set_alignment (GTK_MISC (lbl), 0.0, 0.5);
122 priv->cat = gtk_check_button_new ();
123 gtk_table_attach_defaults (GTK_TABLE (ps), lbl, 0, 1, 2, 3);
124 gtk_table_attach_defaults (GTK_TABLE (ps), priv->cat, 1, 2, 2, 3);
125 gtk_widget_show (lbl);
126 gtk_widget_show (priv->cat);
133 e_pilot_settings_new (ESourceList *source_list)
136 EPilotSettingsPrivate *priv;
138 ps = g_object_new (E_TYPE_PILOT_SETTINGS, NULL);
141 build_ui (ps, source_list);
143 return GTK_WIDGET (ps);
147 e_pilot_settings_get_source (EPilotSettings *ps)
149 EPilotSettingsPrivate *priv;
151 g_return_val_if_fail (ps != NULL, FALSE);
152 g_return_val_if_fail (E_IS_PILOT_SETTINGS (ps), FALSE);
156 return e_source_option_menu_peek_selected (E_SOURCE_OPTION_MENU (priv->source));
160 e_pilot_settings_set_source (EPilotSettings *ps, ESource *source)
162 EPilotSettingsPrivate *priv;
164 g_return_if_fail (ps != NULL);
165 g_return_if_fail (E_IS_PILOT_SETTINGS (ps));
169 e_source_option_menu_select (E_SOURCE_OPTION_MENU (priv->source), source);
173 e_pilot_settings_get_secret (EPilotSettings *ps)
175 EPilotSettingsPrivate *priv;
177 g_return_val_if_fail (ps != NULL, FALSE);
178 g_return_val_if_fail (E_IS_PILOT_SETTINGS (ps), FALSE);
182 return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->secret));
186 e_pilot_settings_set_secret (EPilotSettings *ps, gboolean secret)
188 EPilotSettingsPrivate *priv;
190 g_return_if_fail (ps != NULL);
191 g_return_if_fail (E_IS_PILOT_SETTINGS (ps));
195 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->secret),