[gnome-pilot] Initialise gtk in gpilotd. Remove gnome_program_init. Some other cleanups. 2010-07-31 Matt Davey <



commit 0914839927a83a3835d0920195b99c355ed9656b
Author: Matt Davey <mcdavey mrao cam ac uk>
Date:   Sat Jul 31 14:40:37 2010 +0100

    Initialise gtk in gpilotd.  Remove gnome_program_init.  Some other cleanups.
    2010-07-31 Matt Davey <mcdavey mrao cam ac uk>
    
       applet/pilot.c: Add Halton to Authors credits; Add more consistent state-change
          messages to console output.
       conduits/file/gpilot_install_file.c: remove gnome_program_init
       configure.ac: remove libgnome requirement (still included via gnome-panel)
       gpilotd/gpilotd.c: Add gtk_init for dialogs (gpilotd-ui)
       gpilotd/manager.c: Improve error message.
       utils/gpilotd-client.c: remove gnome_program_init and a CORBA function call.
       utils/gpilotdcm-client.c: remove gnome_program_init
       help/C/gnome-pilot.xml: fix a typo.

 applet/pilot.c                      |   30 +++++++++++++++++++++++-------
 conduits/file/gpilot_install_file.c |   16 ++++++----------
 configure.ac                        |    2 --
 gpilotd/gpilotd.c                   |    2 ++
 gpilotd/manager.c                   |    2 +-
 help/C/gnome-pilot.xml              |    2 +-
 utils/gpilotd-client.c              |   21 +++++++++------------
 utils/gpilotdcm-client.c            |   14 +++++---------
 8 files changed, 47 insertions(+), 42 deletions(-)
---
diff --git a/applet/pilot.c b/applet/pilot.c
index 61ce647..40fbb3e 100644
--- a/applet/pilot.c
+++ b/applet/pilot.c
@@ -148,7 +148,7 @@ gpilotd_connect_cb (GnomePilotClient *client,
 {
 	GdkColormap *colormap;
 	gchar *buf;
-	GError *error;
+	GError *error = NULL;
 	PilotApplet *applet = PILOT_APPLET (user_data);
 
 	gtk_tooltips_set_tip (applet->tooltips, GTK_WIDGET(applet->applet),
@@ -159,6 +159,8 @@ gpilotd_connect_cb (GnomePilotClient *client,
 		return;
 	}
 	applet->curstate = SYNCING;
+	g_message ("state = SYNCING");
+
 	pilot_draw (applet);
 
 	if (applet->properties.popups == FALSE) return;
@@ -211,6 +213,8 @@ gpilotd_disconnect_cb (GnomePilotClient *client,
 			("Ready to synchronize"), NULL);
 
 	applet->curstate = WAITING;
+	g_message ("state = READY");
+
 	pilot_draw (applet);
 	if (applet->properties.popups && applet->progressDialog!=NULL) {
 		gpilot_applet_progress_stop (applet->c_progress);
@@ -280,6 +284,11 @@ gpilotd_request_completed (GnomePilotClient *client,
 {
 	PilotApplet *applet = PILOT_APPLET (user_data);
 
+
+	/* could happen, if gpilotd-client is used, for example */
+	if (applet->operationDialogWindow == NULL)
+	    return;
+
 	gtk_dialog_response (GTK_DIALOG (applet->operationDialogWindow), GTK_RESPONSE_CLOSE);
 	if (applet->properties.popups && applet->progressDialog !=NULL) {
 		gchar *txt=g_strdup_printf (_("Request %ld has been completed\n"),handle);
@@ -438,6 +447,7 @@ handle_client_error (PilotApplet *self)
 		    _("PDA is currently synchronizing.\nPlease wait for it to finish."));
 	} else {
 		self->curstate=INITIALISING;
+		g_message ("state = INITIALISING");
 		gtk_tooltips_set_tip (self->tooltips, GTK_WIDGET (self->applet),_("Not connected. Please restart daemon."), NULL);	
 		pilot_draw (self);
 		show_dialog (self, GTK_MESSAGE_ERROR,
@@ -458,6 +468,7 @@ about_cb(BonoboUIComponent *uic, PilotApplet *pilot, const gchar *verbname)
 				  "Chris Toshok <toshok ximian com>",
 				  "Frank Belew <frb ximian com>",
 				  "Matt Davey <mcdavey mrao cam ac uk>",
+				  "Halton Huo <haltonhuo gnome org>",
 				  NULL};
 
 	gtk_window_set_default_icon_from_file (
@@ -524,7 +535,7 @@ properties_cb (BonoboUIComponent *uic, gpointer user_data, const gchar *verbname
 	PilotApplet *self = user_data;
 	GtkWidget *button, *entry, *dialog;
 	GtkBuilder *ui;
-	GError *error;
+	GError *error = NULL;
 
 	gtk_window_set_default_icon_from_file (GNOME_ICONDIR "/sync_icon.png", &error);
 	ui = load_ui (self->ui_file,"PropertiesDialog");
@@ -802,6 +813,8 @@ restart_cb (BonoboUIComponent *uic, gpointer user_data, const gchar *verbname)
 		}
 	}
 	applet->curstate = INITIALISING;
+	g_message ("state = INITIALISING");
+
 	gnome_pilot_client_restart_daemon (applet->gpc);
 	gtk_tooltips_set_tip (applet->tooltips, GTK_WIDGET (applet->applet),
 			      _("Trying to connect to the GnomePilot Daemon"), NULL);
@@ -890,6 +903,7 @@ gpilotd_daemon_pause (GnomePilotClient *client,
 		if (applet->curstate == WAITING) {
 			applet->curstate = PAUSED;
 			gtk_tooltips_set_tip (applet->tooltips, GTK_WIDGET (applet->applet),_("Daemon paused..."), NULL);
+			g_message ("state = PAUSED");
 		}
 		else
 			handle_client_error (applet);
@@ -897,13 +911,12 @@ gpilotd_daemon_pause (GnomePilotClient *client,
 	else {
 		applet->curstate = WAITING;
 		gtk_tooltips_set_tip (applet->tooltips, GTK_WIDGET (applet->applet), _("Ready to synchronize"), NULL);
+		g_message ("state = READY");
 	}
 
 	install_popup_menu (applet, on_off);
 
 	pilot_draw (applet);
-	
-	g_message ("paused");
 }
 
 static void 
@@ -1005,17 +1018,16 @@ static gboolean
 timeout (PilotApplet *self)
 {
 	if (self->curstate == INITIALISING) {
-		g_message ("state = INITIALISING");
 		pilot_draw (self);
 		
 		if (gnome_pilot_client_connect_to_daemon (self->gpc) == GPILOTD_OK) {
 			self->curstate = CONNECTING_TO_DAEMON;
+			g_message ("state = CONNECTING_TO_DAEMON");
 			pilot_draw (self);
 		} 
 	}
 	
 	if (self->curstate == CONNECTING_TO_DAEMON) {
-		g_message ("state = CONNECTING_TO_DAEMON");
 		
 		if (self->properties.pilot_ids) {
 			GList *tmp =self->properties.pilot_ids;
@@ -1038,7 +1050,8 @@ timeout (PilotApplet *self)
 				pilot_execute_program (self, GPILOTD_DRUID);
 			}
 
-			self->curstate=INITIALISING;
+			self->curstate = INITIALISING;
+			g_message ("state = INITIALISING");
 			pilot_draw (self);
 			/* FIXME: add gpilot_monitor_state_change () */
 		} else {
@@ -1048,6 +1061,7 @@ timeout (PilotApplet *self)
 					      NULL);
 			
 			self->curstate = WAITING;
+			g_message ("state = READY");
 			pilot_draw (self);
 		}
 	} 
@@ -1057,6 +1071,7 @@ timeout (PilotApplet *self)
 		/* this will happen once a sec */
 		if (gnome_pilot_client_noop (self->gpc) == GPILOTD_ERR_NOT_CONNECTED) {
 			self->curstate = INITIALISING;
+			g_message ("state = INITIALISING");
 		}
 		break;
 	case SYNCING: 
@@ -1376,6 +1391,7 @@ create_pilot_widgets (GtkWidget *widget, PilotApplet *self)
 	self->c_progress = GPILOT_APPLET_PROGRESS (gpilot_applet_progress_new ()); 
 
 	self->curstate = INITIALISING; 
+	g_message ("state = INITIALISING");
 
 	/*	for (i = 0; i < sizeof (pixmaps)/sizeof (pixmaps[0]); i++) 
 		pixmaps[i] = gnome_program_locate_file(
diff --git a/conduits/file/gpilot_install_file.c b/conduits/file/gpilot_install_file.c
index 67d9fb9..653ad5e 100644
--- a/conduits/file/gpilot_install_file.c
+++ b/conduits/file/gpilot_install_file.c
@@ -22,7 +22,6 @@
 #include "config.h"
 #include <gtk/gtk.h>
 #include <glib/gi18n-lib.h>
-#include <libgnome/gnome-init.h>
 
 #include <gpilotd/gnome-pilot-client.h>
 
@@ -79,31 +78,28 @@ main (int argc, char *argv[])
 {
 	int err, i;
 	GNOME_Pilot_Survival survive;
+	GError *error;
 	GList *pilots = NULL;
 	GOptionContext *option_context;
-	GnomeProgram *program;
         
 	bindtextdomain (PACKAGE, GNOMELOCALEDIR);
 	textdomain (PACKAGE);
 	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 
 	if (argc<2) {
-		g_message ("usage : %s [--now|--later] [FILE]", argv[0]);
+		g_message ("usage : %s [--now|--later] [--pilot PDA] [FILE ...]", argv[0]);
 		exit (1);
 	}
 
 	option_context = g_option_context_new (PACKAGE);
 	g_option_context_add_main_entries (option_context, options, NULL);
-	program = gnome_program_init(PACKAGE, VERSION, LIBGNOME_MODULE,
-	                            argc, argv,
-				    GNOME_PARAM_GOPTION_CONTEXT, option_context,
-				    GNOME_PARAM_NONE);
-
-	if (program == NULL) {
-		g_error (_("Error initializing gpilotd"));
+	if (!g_option_context_parse(option_context, &argc, &argv, &error)) {
+		g_error (_("Error parsing commandline arguments: %s"), error->message);
 		exit (1);
 	}
 
+	gtk_init (&argc, &argv);
+
 	gpc = GNOME_PILOT_CLIENT (gnome_pilot_client_new ());
 	gtk_object_ref (GTK_OBJECT (gpc));
 	gtk_object_sink (GTK_OBJECT (gpc));
diff --git a/configure.ac b/configure.ac
index 0052ff2..0a48e4c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -134,7 +134,6 @@ dnl ******************************
 dnl Library Checks
 dnl ******************************
 LIBXML_REQUIRED="libxml-2.0"
-LIBGNOME_REQUIRED="libgnome-2.0 >= 2.0.0"
 LIBGTK_REQUIRED="gtk+-2.0 >= 2.13.0"
 DBUS_GLIB_REQUIRED="dbus-glib-1 >= 0.74"
 LIBPANELAPPLET_REQUIRED="libpanelapplet-2.0 >= 2.0.6"
@@ -143,7 +142,6 @@ GCONF_REQUIRED="gconf-2.0"
 PKG_CHECK_MODULES(GNOME_PILOT, 
 [
 	$LIBXML_REQUIRED
-	$LIBGNOME_REQUIRED
 	$LIBGTK_REQUIRED
 	$DBUS_GLIB_REQUIRED
 ])
diff --git a/gpilotd/gpilotd.c b/gpilotd/gpilotd.c
index 2eb8ae2..07cdc5c 100644
--- a/gpilotd/gpilotd.c
+++ b/gpilotd/gpilotd.c
@@ -254,6 +254,8 @@ main (int argc, char *argv[])
                 goto out;
         }
 
+	gtk_init (&argc, &argv);
+
         loop = g_main_loop_new (NULL, FALSE);
 
 	signal (SIGTERM, sig_term_handler);
diff --git a/gpilotd/manager.c b/gpilotd/manager.c
index b7958e6..7a45317 100644
--- a/gpilotd/manager.c
+++ b/gpilotd/manager.c
@@ -814,7 +814,7 @@ run_conduit_sync_foreach (GPilotRequest *req,
 	if (conduit==NULL) {
 		/* FIXME: remove the bloody request, or the user will get this
 		   message every time */
-		g_warning (_("Conduit %s requested, but not found"),
+		g_warning (_("Conduit %s requested, but not found.  Is it enabled?"),
 			   req->parameters.conduit.name);
 	} else {
 		if (GNOME_IS_PILOT_CONDUIT_BACKUP (conduit)) {
diff --git a/help/C/gnome-pilot.xml b/help/C/gnome-pilot.xml
index b8f142a..751f5aa 100644
--- a/help/C/gnome-pilot.xml
+++ b/help/C/gnome-pilot.xml
@@ -445,7 +445,7 @@
           <para>
             Pause the GNOME Pilot daemon
             <application>gpilotd</application>. If the daemon is paused, this item
-            will read <guilabel>Continute</guilabel>.
+            will read <guilabel>Continue</guilabel>.
           </para>
         </listitem>
       </varlistentry>
diff --git a/utils/gpilotd-client.c b/utils/gpilotd-client.c
index 0ee08c6..dd1aecd 100644
--- a/utils/gpilotd-client.c
+++ b/utils/gpilotd-client.c
@@ -6,7 +6,6 @@
 #include <config.h>
 
 #include <glib/gi18n.h>
-#include <libgnome/gnome-init.h>
 
 #include <gpilotd/gnome-pilot-client.h>
 
@@ -45,7 +44,7 @@ static GOptionEntry options[] = {
 	{"install",'\0', 0, G_OPTION_ARG_STRING, &arg_install, N_("Install file"), N_("FILE")},
 	{"restore", '\0', 0, G_OPTION_ARG_STRING, &arg_restore, N_("Restore directory"), N_("DIRECTORY")},
 	{"conduit", '\0', 0, G_OPTION_ARG_STRING, &arg_conduit, N_("Run conduit"), N_("CONDUIT")},
-	{"userid", '\0', 0, G_OPTION_ARG_STRING, &arg_username, N_("Username to set"), N_("USERNAME")},
+	{"username", '\0', 0, G_OPTION_ARG_STRING, &arg_username, N_("Username to set"), N_("USERNAME")},
 	{"monitor", 'm', 0, G_OPTION_ARG_NONE, &arg_monitor, N_("Monitor all PDAs"), NULL},
 	{"listpilots", '\0', 0, G_OPTION_ARG_STRING, &arg_list_by_login, N_("list PDAs by login (all for all pilots)"), N_("LOGIN")},
 	{"pilot", '\0', 0, G_OPTION_ARG_STRING, &arg_pilot, N_("Specify PDA to operate on (defaults to MyPDA)"), N_("PILOTNAME")},
@@ -332,7 +331,7 @@ revive (char *rest)
 
 	g_message ("Reviving %d to %s from %s",arg_id,arg_cradle,arg_restore);
 	user.userID = arg_id;
-	user.username = CORBA_string_dup (arg_username);
+	user.username = g_strdup (arg_username);
 	err = gnome_pilot_client_set_user_info (gpc,
 					       arg_cradle,
 					       user,
@@ -393,7 +392,7 @@ set_user (void)
 		g_warning ("Please set a pilotid using --pilotid");
 		abort = TRUE;
 	}	if (arg_username==NULL) {
-		g_warning ("Please set a username using --userid");
+		g_warning ("Please set a username using --username");
 		abort = TRUE;
 	}
 	if (arg_cradle==NULL) {
@@ -404,7 +403,7 @@ set_user (void)
 	if (!abort) {
 		g_message ("Setting userid/name %d/%s on %s",arg_id,arg_username,arg_cradle);
 		user.userID = arg_id;
-		user.username = CORBA_string_dup (arg_username);
+		user.username = g_strdup (arg_username);
 		err = gnome_pilot_client_set_user_info (gpc,
 						       arg_cradle,
 						       user,
@@ -449,7 +448,7 @@ get_system_info (void)
 int
 main (int argc, char *argv[]) {
 	GOptionContext *option_context;
-	GnomeProgram *program;
+	GError *error = NULL;
 
 	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 	bindtextdomain (PACKAGE, GNOMELOCALEDIR);
@@ -462,16 +461,14 @@ main (int argc, char *argv[]) {
 
 	option_context = g_option_context_new (PACKAGE);
 	g_option_context_add_main_entries (option_context, options, NULL);
-	program = gnome_program_init(PACKAGE, VERSION, LIBGNOME_MODULE,
-	                            argc, argv,
-				    GNOME_PARAM_GOPTION_CONTEXT, option_context,
-				    GNOME_PARAM_NONE);
 
-	if (program == NULL) {
-		g_error (_("Error initializing gpilotd-client"));
+	if (!g_option_context_parse(option_context, &argc, &argv, &error)) {
+		g_error (_("Error parsing commandline arguments: %s"), error->message);
 		exit (1);
 	}
 
+	gtk_init (&argc, &argv);
+
 	g_message (_("\nBEWARE!!\nThis is a tool for certain parts of the gnome-pilot package.\nUnless you know what you're doing, don't use this tool."));
 
 	if (arg_pilot==NULL) arg_pilot = g_strdup ("MyPilot");
diff --git a/utils/gpilotdcm-client.c b/utils/gpilotdcm-client.c
index 863f5a1..46533ad 100644
--- a/utils/gpilotdcm-client.c
+++ b/utils/gpilotdcm-client.c
@@ -6,7 +6,6 @@
 #include <config.h>
 
 #include <glib/gi18n.h>
-#include <libgnome/gnome-init.h>
 
 #include <libgpilotdCM/gnome-pilot-conduit-management.h>
 #include <libgpilotdCM/gnome-pilot-conduit-config.h>
@@ -96,7 +95,7 @@ main (int argc, char *argv[]) {
 	GList *conduits = NULL,*it;
 	const gchar* const *ll;
 	GOptionContext *option_context;
-	GnomeProgram *program;
+	GError *error;
 	
 	bindtextdomain (PACKAGE, GNOMELOCALEDIR);
 	textdomain (PACKAGE);
@@ -104,16 +103,13 @@ main (int argc, char *argv[]) {
 
 	option_context = g_option_context_new (PACKAGE);
 	g_option_context_add_main_entries (option_context, options, NULL);
-	program = gnome_program_init(PACKAGE, VERSION, LIBGNOME_MODULE,
-	                            argc, argv,
-				    GNOME_PARAM_GOPTION_CONTEXT, option_context,
-				    GNOME_PARAM_NONE);
-
-	if (program == NULL) {
-		g_error (_("Error initializing gpilotdcm-client"));
+	if (!g_option_context_parse(option_context, &argc, &argv, &error)) {
+		g_error (_("Error parsing commandline arguments: %s"), error->message);
 		exit (1);
 	}
 
+	gtk_init (&argc, &argv);
+
 	g_print (_("\nBEWARE!!\nThis is a tool for certain parts of the gnome-pilot package.\nUnless you know what you're doing, don't use this tool."));
 
 	gnome_pilot_conduit_management_get_conduits (&conduits, GNOME_PILOT_CONDUIT_MGMT_ID);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]