/* Control applet ("capplet") for the gnome-pilot todo conduit, */ /* based on */ /* gpilotd control applet ('capplet') for use with the GNOME control center */ /* $Id$ */ #include #include #include #include #include #include #include #include #include #include "todo-conduit.h" /* tell changes callbacks to ignore changes or not */ static gboolean ignore_changes=FALSE; /* capplet widget */ static GtkWidget *capplet=NULL; /* host/device/pilot configuration windows */ GtkWidget *cfgOptionsWindow=NULL; GtkWidget *cfgStateWindow=NULL; GtkWidget *dialogWindow=NULL; gboolean activated,org_activation_state; GnomePilotConduitMgmt *conduit; static void doTrySettings(GtkWidget *widget, ConduitCfg *conduitCfg); static void doRevertSettings(GtkWidget *widget, ConduitCfg *conduitCfg); static void doSaveSettings(GtkWidget *widget, ConduitCfg *conduitCfg); static void readStateCfg(GtkWidget *w); static void setStateCfg(GtkWidget *w); gint pilotId; CORBA_Environment ev; static void doTrySettings(GtkWidget *widget, ConduitCfg *conduitCfg) { readStateCfg(cfgStateWindow); if(activated) gpilotd_conduit_mgmt_enable(conduit,pilotId,GnomePilotConduitSyncTypeSynchronize); else gpilotd_conduit_mgmt_disable(conduit,pilotId); } static void doSaveSettings(GtkWidget *widget, ConduitCfg *conduitCfg) { doTrySettings(widget, conduitCfg); save_configuration(NULL); } static void doRevertSettings(GtkWidget *widget, ConduitCfg *conduitCfg) { activated = org_activation_state; setStateCfg(cfgStateWindow); } static void insert_dir_callback (GtkEditable *editable, const gchar *text, gint len, gint *position, void *data) { gint i; gchar *curname; curname = gtk_entry_get_text(GTK_ENTRY(editable)); if (*curname == '\0' && len > 0) { if (isspace(text[0])) { gtk_signal_emit_stop_by_name(GTK_OBJECT(editable), "insert_text"); return; } } else { for (i=0; i"),NULL}; about = gnome_about_new(_("Gpilotd todo conduit"), VERSION, _("(C) 1998 the Free Software Foundation"), authors, _("Configuration utility for the todo conduit.\n"), _("gnome-unknown.xpm")); gtk_widget_show (about); return; } static void toggled_cb(GtkWidget *widget, gpointer data) { gtk_widget_set_sensitive(cfgOptionsWindow,GTK_TOGGLE_BUTTON(widget)->active); capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE); } static GtkWidget *createStateCfgWindow(void) { GtkWidget *vbox, *table; GtkWidget *entry, *label; GtkWidget *button; vbox = gtk_vbox_new(FALSE, GNOME_PAD); table = gtk_table_new(2, 2, FALSE); gtk_table_set_row_spacings(GTK_TABLE(table), 4); gtk_table_set_col_spacings(GTK_TABLE(table), 10); gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, GNOME_PAD); label = gtk_label_new(_("Enabled")); gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1,2); button = gtk_check_button_new(); gtk_object_set_data(GTK_OBJECT(vbox), "conduit_on_off", button); gtk_signal_connect(GTK_OBJECT(button), "toggled", GTK_SIGNAL_FUNC(toggled_cb), NULL); gtk_table_attach_defaults(GTK_TABLE(table), button, 1, 2, 1,2); return vbox; } static void setStateCfg(GtkWidget *cfg) { GtkWidget *button; gchar num[40]; button = gtk_object_get_data(GTK_OBJECT(cfg), "conduit_on_off"); g_assert(button!=NULL); ignore_changes = TRUE; gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),activated); gtk_widget_set_sensitive(cfgOptionsWindow,GTK_TOGGLE_BUTTON(button)->active); ignore_changes = FALSE; } static void readStateCfg(GtkWidget *cfg) { GtkWidget *button; button = gtk_object_get_data(GTK_OBJECT(cfg), "conduit_on_off"); g_assert(button!=NULL); activated = GTK_TOGGLE_BUTTON(button)->active; } static void pilot_capplet_setup(void) { GtkWidget *frame, *table; capplet = capplet_widget_new(); table = gtk_table_new(1, 2, FALSE); gtk_container_border_width(GTK_CONTAINER(table), GNOME_PAD); gtk_container_add(GTK_CONTAINER(capplet), table); frame = gtk_frame_new(_("Conduit state")); gtk_container_border_width(GTK_CONTAINER(frame), GNOME_PAD_SMALL); gtk_table_attach_defaults(GTK_TABLE(table), frame, 0, 1, 0, 1); cfgStateWindow = createStateCfgWindow(); gtk_container_add(GTK_CONTAINER(frame), cfgStateWindow); gtk_signal_connect(GTK_OBJECT(capplet), "try", GTK_SIGNAL_FUNC(doTrySettings), NULL); gtk_signal_connect(GTK_OBJECT(capplet), "revert", GTK_SIGNAL_FUNC(doRevertSettings), NULL); gtk_signal_connect(GTK_OBJECT(capplet), "ok", GTK_SIGNAL_FUNC(doSaveSettings), NULL); gtk_signal_connect(GTK_OBJECT(capplet), "help", GTK_SIGNAL_FUNC(about_cb), NULL); setStateCfg(cfgStateWindow); gtk_widget_show_all(capplet); } void run_error_dialog(gchar *mesg,...) { char tmp[80]; va_list ap; va_start(ap,mesg); vsnprintf(tmp,79,mesg,ap); dialogWindow = gnome_message_box_new(mesg,GNOME_MESSAGE_BOX_ERROR,GNOME_STOCK_BUTTON_OK,NULL); gnome_dialog_run_and_close(GNOME_DIALOG(dialogWindow)); va_end(ap); } gint get_pilot_id_from_gpilotd() { gint *pilots; int i; i=0; gpilotd_get_pilot_ids(&pilots); if(pilots) { while(pilots[i]!=-1) { g_message("pilot %d = \"%d\"",i,pilots[i]); i++; } if(i==0) { run_error_dialog(_("No pilot configured, please choose the\n'Pilot Link Properties' capplet first.")); return -1; } else { if(i==1) return pilots[0]; else { g_message("too many pilots..."); return pilots[0]; } } } else { run_error_dialog(_("No pilot configured, please choose the\n'Pilot Link Properties' capplet first.")); return -1; } } int main( int argc, char *argv[] ) { /* we're a capplet */ gnome_capplet_init ("todo conduit control applet", NULL, argc, argv, NULL, 0, NULL); /* put all code to set things up in here */ conduit = gpilotd_conduit_mgmt_new("todo_conduit"); /* get pilot name from gpilotd */ /* 1. initialize the gpilotd connection */ if (gpilotd_init(&argc,argv)!=0) { run_error_dialog(_("Cannot initialze the GnomePilot Daemon")); g_error(_("Cannot initialze the GnomePilot Daemon")); return -1; } /* 2 connect to gpilotd */ if (gpilotd_connect()!=0) { run_error_dialog(_("Cannot connect to the GnomePilot Daemon")); g_error(_("Cannot connect to the GnomePilot Daemon")); return -1; } pilotId = get_pilot_id_from_gpilotd(); if(!pilotId) return -1; org_activation_state = activated = gpilotd_conduit_mgmt_is_enabled(conduit,pilotId); pilot_capplet_setup(); /* done setting up, now run main loop */ capplet_gtk_main(); return 0; } an>2-4/+7 * - Resolve LATEST_LINK conflictpav2009-06-011-0/+2 * Nodoka is the new Fedora default theme for Gnome. This port install the enginemiwi2009-05-316-0/+108 * Theme pack for the SLiM X login application.miwi2009-05-236-0/+257 * update audacious to 2.0.1oliver2009-05-211-1/+2 * Update to 2.18.2.kwm2009-05-202-4/+4 * Update to 2.26.2.marcus2009-05-192-4/+4 * - Update to 0.90.3miwi2009-05-174-11/+10 * Update KDE ports to 4.2.3makc2009-05-101-3/+3 * - Re-roll tarballtabthorpe2009-05-072-5/+5 * - Update to 2.0.3miwi2009-05-054-17/+13 * Update to 0.62.9makc2009-05-042-5/+4 * Connect kde4-windeco-dekorator to buildmakc2009-05-041-0/+1 * Add new port x11-themes/kde4-windeco-dekorator.makc2009-05-044-0/+38 * Presenting GNOME 2.26.1 for FreeBSD.kwm2009-04-246-10/+12 * - Mark all kde4 ports MAKE_JOBS_UNSAFEmiwi2009-04-171-1/+1 * - Make it fetchable againgarga2009-04-141-1/+2 * Presenting GNOME 2.26 for FreeBSD. Seemarcus2009-04-106-95/+174 * 2009-03-26 www/drupal4-attachment: Drupal 4.7.x is end-of-life since 200802. ...miwi2009-04-056-469/+0 * The KDE FreeBSD team is proud to announce the release of KDE 4.2.2miwi2009-04-023-4/+5 * Here are new Linux Fedora 8 infrastructure ports.bsam2009-04-013-6/+5 * Finish repocopies of new linux-f8 infrastructure ports:bsam2009-04-011-1/+3 * - Mark BROKEN: does not fetchpav2009-03-312-0/+4 * Remove MAKE_JOBS_SAFE, port has no build target.ehaupt2009-03-302-2/+0 * Mark MAKE_JOBS_SAFEehaupt2009-03-272-0/+3 * bump PORTREVISION after cmake updatemakc2009-03-257-2/+7 * - Fix clearlooks-themes slave port for people with gtk-engines2 installedpav2009-03-231-4/+4 * - udpate to 0.4.1dinoex2009-03-2011-16/+22 * - mark DEPRECATEDdinoex2009-03-201-0/+2 * Release these ports into wild. I don't have time for these ports anymore. I ammezz2009-03-191-1/+1 * Update to 2.24.1.marcus2009-03-183-4/+7 * - Update to 0.16.8.0.3gahr2009-03-103-9/+7 * - Reset farrokhi@freebsd.org due to long period of inactivity.miwi2009-03-105-5/+5 * Update KDE to 4.2.1.makc2009-03-092-3/+30 * - Bump PORTREVISION after claws-mail updatemiwi2009-03-071-0/+1 * - Update to 20090225miwi2009-03-063-24/+30 * update Xfce to 4.6oliver2009-03-038-1706/+7 * - cleanupdinoex2009-02-271-1/+0 * Update to 2.0.0makc2009-02-223-12/+5 * Update to 0.61.1makc2009-02-223-8/+4 * Update to 1.2.2 (backported from KDE4)makc2009-02-224-7/+41 * Use my @FreeBSD.org email for the rest of my portsmakc2009-02-211-1/+1 * The KDE FreeBSD team is proud to announce the release of KDE 4.2.0miwi2009-02-093-11990/+566 * - Update to 1.0.7beat2009-02-084-10/+8 * 2009-01-19 games/emacs-chess: has been broken for more than 6 monthsmiwi2009-02-046-118/+0