diff options
author | JP Rosevear <jpr@helixcode.com> | 2000-10-21 05:04:47 +0800 |
---|---|---|
committer | JP Rosevear <jpr@src.gnome.org> | 2000-10-21 05:04:47 +0800 |
commit | e2e21e3f7650b33259ae9e60ac8b7f5b78dbb098 (patch) | |
tree | 088ece25751c05553fcdab95b759cff99a0280b2 /addressbook/conduit/address-conduit-control-applet.c | |
parent | 06ef60fa04a5b10f5238c9eb39ade9dc152fcb04 (diff) | |
download | gsoc2013-evolution-e2e21e3f7650b33259ae9e60ac8b7f5b78dbb098.tar gsoc2013-evolution-e2e21e3f7650b33259ae9e60ac8b7f5b78dbb098.tar.gz gsoc2013-evolution-e2e21e3f7650b33259ae9e60ac8b7f5b78dbb098.tar.bz2 gsoc2013-evolution-e2e21e3f7650b33259ae9e60ac8b7f5b78dbb098.tar.lz gsoc2013-evolution-e2e21e3f7650b33259ae9e60ac8b7f5b78dbb098.tar.xz gsoc2013-evolution-e2e21e3f7650b33259ae9e60ac8b7f5b78dbb098.tar.zst gsoc2013-evolution-e2e21e3f7650b33259ae9e60ac8b7f5b78dbb098.zip |
New structure of file - similar to calendar/todo conduits
2000-10-20 JP Rosevear <jpr@helixcode.com>
* conduit/address-conduit.h: New structure of file - similar
to calendar/todo conduits
* conduit/address-conduit.c: ditto
* conduit/address-conduit-config.h: Config stuff for conduit
* conduit/.cvsignore: Update
* conduit/Makefile.am: Build fixes
* conduit/address-conduit-control-applet.desktop: Renamed
to e-address-conduit-control-applet.desktop
* conduit/address.conduit.in: Renamed to e-address.conduit.in
svn path=/trunk/; revision=6081
Diffstat (limited to 'addressbook/conduit/address-conduit-control-applet.c')
-rw-r--r-- | addressbook/conduit/address-conduit-control-applet.c | 233 |
1 files changed, 94 insertions, 139 deletions
diff --git a/addressbook/conduit/address-conduit-control-applet.c b/addressbook/conduit/address-conduit-control-applet.c index 07a6e0042f..3cbdbf8976 100644 --- a/addressbook/conduit/address-conduit-control-applet.c +++ b/addressbook/conduit/address-conduit-control-applet.c @@ -1,7 +1,26 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* Control applet ("capplet") for the gnome-pilot address conduit, */ -/* based on */ -/* gpilotd control applet ('capplet') for use with the GNOME control center */ +/* Evolution addressbook - Address Conduit Capplet + * + * Copyright (C) 1998 Free Software Foundation + * Copyright (C) 2000 Helix Code, Inc. + * + * Authors: Eskil Heyn Olsen <deity@eskil.dk> + * JP Rosevear <jpr@helixcode.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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 <pwd.h> #include <sys/types.h> @@ -11,12 +30,17 @@ #include <config.h> #include <capplet-widget.h> -#include <libgpilotdCM/gnome-pilot-conduit-management.h> -#include <libgpilotdCM/gnome-pilot-conduit-config.h> #include <gpilotd/gnome-pilot-client.h> -#include "address-conduit.h" - +#define ADDR_CONFIG_LOAD 1 +#define ADDR_CONFIG_SAVE 1 +#define ADDR_CONFIG_DUPE 1 +#define ADDR_CONFIG_DESTROY 1 +#include <address-conduit-config.h> +#undef ADDR_CONFIG_LOAD +#undef ADDR_CONFIG_SAVE +#undef ADDR_CONFIG_DUPE +#undef ADDR_CONFIG_DESTROY /* tell changes callbacks to ignore changes or not */ static gboolean ignore_changes=FALSE; @@ -32,21 +56,20 @@ GtkWidget *dialogWindow=NULL; gboolean activated,org_activation_state; GnomePilotConduitManagement *conduit; GnomePilotConduitConfig *conduit_config; -AddressbookConduitCfg *origState = NULL; -AddressbookConduitCfg *curState = NULL; +EAddrConduitCfg *origState = NULL; +EAddrConduitCfg *curState = NULL; -static void doTrySettings(GtkWidget *widget, AddressbookConduitCfg *cfg); -static void doRevertSettings(GtkWidget *widget, AddressbookConduitCfg *cfg); -static void doSaveSettings(GtkWidget *widget, AddressbookConduitCfg *cfg); +static void doTrySettings(GtkWidget *widget, EAddrConduitCfg *c); +static void doRevertSettings(GtkWidget *widget, EAddrConduitCfg *c); +static void doSaveSettings(GtkWidget *widget, EAddrConduitCfg *c); -//static void readStateCfg (GtkWidget *w, AddressbookConduitCfg *c); -static void setStateCfg (GtkWidget *w, AddressbookConduitCfg *c); +static void setStateCfg (GtkWidget *w, EAddrConduitCfg *c); gint pilotId; -CORBA_Environment ev; static GnomePilotClient *gpc; + /* This array must be in the same order as enumerations in GnomePilotConduitSyncType as they are used as index. Custom type implies Disabled state. @@ -59,50 +82,10 @@ static gchar* sync_options[] ={ N_("Disabled"), N_("Merge To Pilot")}; #define SYNC_OPTIONS_COUNT 6 - - - -/* Saves the configuration data. */ -static void -addressbookconduit_save_configuration(AddressbookConduitCfg *c) -{ - gchar prefix[256]; - - g_snprintf(prefix,255,"/gnome-pilot.d/address-conduit/Pilot_%u/",c->pilotId); - - gnome_config_push_prefix(prefix); - gnome_config_set_bool ("open_secret", c->open_secret); - gnome_config_pop_prefix(); - - gnome_config_sync(); - gnome_config_drop_all(); -} - -/* Creates a duplicate of the configuration data */ -static AddressbookConduitCfg* -gcalconduit_dupe_configuration(AddressbookConduitCfg *c) { - AddressbookConduitCfg *retval; - g_return_val_if_fail(c!=NULL,NULL); - retval = g_new0(AddressbookConduitCfg,1); - retval->sync_type = c->sync_type; - retval->open_secret = c->open_secret; - retval->pilotId = c->pilotId; - return retval; -} - - static void -doTrySettings(GtkWidget *widget, AddressbookConduitCfg *c) +doTrySettings (GtkWidget *widget, EAddrConduitCfg *c) { - /* - readStateCfg (cfgStateWindow, curState); - if (activated) - gnome_pilot_conduit_config_enable (conduit_config, GnomePilotConduitSyncTypeCustom); - else - gnome_pilot_conduit_config_disable (conduit_config); - */ - - if (c->sync_type!=GnomePilotConduitSyncTypeCustom) + if (c->sync_type != GnomePilotConduitSyncTypeCustom) gnome_pilot_conduit_config_enable_with_first_sync (conduit_config, c->sync_type, c->sync_type, @@ -110,43 +93,42 @@ doTrySettings(GtkWidget *widget, AddressbookConduitCfg *c) else gnome_pilot_conduit_config_disable (conduit_config); - addressbookconduit_save_configuration (c); + addrconduit_save_configuration (c); } - static void -doSaveSettings(GtkWidget *widget, AddressbookConduitCfg *cfg) +doRevertSettings (GtkWidget *widget, EAddrConduitCfg *c) { - doTrySettings(widget, cfg); - addressbookconduit_save_configuration(cfg); + activated = org_activation_state; + *c = *origState; + setStateCfg (cfgStateWindow, c); + doTrySettings (widget, c); } - static void -doCancelSettings(GtkWidget *widget, AddressbookConduitCfg *c) +doSaveSettings (GtkWidget *widget, EAddrConduitCfg *c) { - doSaveSettings (widget, c); + *origState = *c; + doTrySettings (widget, c); } -static void -doRevertSettings(GtkWidget *widget, AddressbookConduitCfg *cfg) -{ - activated = org_activation_state; - setStateCfg (cfgStateWindow, curState); -} - static void -about_cb (GtkWidget *widget, gpointer data) +doHelp (GtkWidget *widget, gpointer data) { GtkWidget *about; - const gchar *authors[] = {_("Eskil Heyn Olsen <deity@eskil.dk>"),NULL}; + const gchar *authors[] = { + _("JP Rosevear <jpr@helixcode.com>"), + "", _("Original Author:"), + _("Eskil Heyn Olsen <deity@eskil.dk>"), + NULL}; - about = gnome_about_new (_("Gpilotd address conduit"), VERSION, - _("(C) 1998 the Free Software Foundation"), - authors, - _("Configuration utility for the address conduit.\n"), - _("gnome-unknown.xpm")); + about = gnome_about_new ( + _("Evolution Addressbook Conduit"), VERSION, + _("(C) 1998-2000 the Free Software Foundation and Helix Code"), + authors, + _("Configuration utility for the evolution addressbook conduit.\n"), + _("gnome-unknown.xpm")); gtk_widget_show (about); return; @@ -155,26 +137,16 @@ about_cb (GtkWidget *widget, gpointer data) /* called by the sync_type GtkOptionMenu */ static void -sync_action_selection(GtkMenuShell *widget, gpointer unused) +activate_sync_type (GtkMenuItem *widget, gpointer data) { - if (!ignore_changes) { - capplet_widget_state_changed(CAPPLET_WIDGET (capplet), TRUE); - } + curState->sync_type = GPOINTER_TO_INT (data); + if (!ignore_changes) + capplet_widget_state_changed (CAPPLET_WIDGET (capplet), TRUE); } -/* called by the sync_type GtkOptionMenu */ -static void -activate_sync_type(GtkMenuItem *widget, gpointer data) -{ - curState->sync_type = GPOINTER_TO_INT(data); - if(!ignore_changes) - capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE); -} - - -static GtkWidget -*createStateCfgWindow(void) +static GtkWidget * +createStateCfgWindow(void) { GtkWidget *vbox, *table; GtkWidget *label; @@ -205,10 +177,6 @@ static GtkWidget } gtk_option_menu_set_menu(GTK_OPTION_MENU(optionMenu),GTK_WIDGET(menu)); - gtk_signal_connect(GTK_OBJECT(menu), "selection-done", - GTK_SIGNAL_FUNC(sync_action_selection), - NULL); - gtk_box_pack_start(GTK_BOX(table), optionMenu, FALSE, FALSE, 0); return vbox; @@ -216,7 +184,7 @@ static GtkWidget static void -setStateCfg (GtkWidget *w, AddressbookConduitCfg *c) +setStateCfg (GtkWidget *w, EAddrConduitCfg *c) { GtkOptionMenu *optionMenu; GtkMenu *menu; @@ -232,21 +200,6 @@ setStateCfg (GtkWidget *w, AddressbookConduitCfg *c) ignore_changes = FALSE; } - -#if 0 -static void -readStateCfg (GtkWidget *w, AddressbookConduitCfg *c) -{ - /* - GtkWidget *button; - button = gtk_object_get_data(GTK_OBJECT(cfg), "conduit_on_off"); - g_assert(button!=NULL); - activated = GTK_TOGGLE_BUTTON(button)->active; - */ -} -#endif /* 0 */ - - static void pilot_capplet_setup(void) { @@ -270,10 +223,8 @@ pilot_capplet_setup(void) GTK_SIGNAL_FUNC(doRevertSettings), curState); gtk_signal_connect(GTK_OBJECT(capplet), "ok", GTK_SIGNAL_FUNC(doSaveSettings), curState); - gtk_signal_connect(GTK_OBJECT(capplet), "cancel", - GTK_SIGNAL_FUNC(doCancelSettings), curState); gtk_signal_connect(GTK_OBJECT(capplet), "help", - GTK_SIGNAL_FUNC(about_cb), NULL); + GTK_SIGNAL_FUNC(doHelp), NULL); setStateCfg (cfgStateWindow, curState); @@ -350,37 +301,41 @@ main (int argc, char *argv[]) G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING); - /* we're a capplet */ - gnome_capplet_init ("address conduit control applet", NULL, argc, argv, + /* Init capplet */ + gnome_capplet_init ("Evolution Address conduit control applet", + NULL, argc, argv, NULL, 0, NULL); - - gpc = gnome_pilot_client_new(); - gnome_pilot_client_connect_to_daemon(gpc); - pilotId = get_pilot_id_from_gpilotd(); - if(!pilotId) return -1; + /* Setup Client */ + gpc = gnome_pilot_client_new (); + gnome_pilot_client_connect_to_daemon (gpc); + pilotId = get_pilot_id_from_gpilotd (); + if (!pilotId) + return -1; - /* put all code to set things up in here */ - conduit_load_configuration (&origState, pilotId); + + /* Put all code to set things up in here */ + conduit = gnome_pilot_conduit_management_new ("e_address_conduit", GNOME_PILOT_CONDUIT_MGMT_ID); + if (conduit == NULL) + return -1; - conduit = gnome_pilot_conduit_management_new ("address_conduit", GNOME_PILOT_CONDUIT_MGMT_ID); - if (conduit == NULL) return -1; + addrconduit_load_configuration (&origState, pilotId); conduit_config = gnome_pilot_conduit_config_new (conduit, pilotId); - org_activation_state = gnome_pilot_conduit_config_is_enabled (conduit_config, - &origState->sync_type); - activated = org_activation_state; - - //gpilotd_conduit_mgmt_get_sync_type (conduit, pilotId, &origState->sync_type); + org_activation_state = activated = + gnome_pilot_conduit_config_is_enabled (conduit_config, + &origState->sync_type); - curState = gcalconduit_dupe_configuration(origState); + curState = addrconduit_dupe_configuration (origState); pilot_capplet_setup (); - - /* done setting up, now run main loop */ + /* Done setting up, now run main loop */ capplet_gtk_main(); - - gnome_pilot_conduit_management_destroy(conduit); + /* Clean up */ + gnome_pilot_conduit_management_destroy (conduit); + addrconduit_destroy_configuration (&origState); + addrconduit_destroy_configuration (&curState); + return 0; } |