[gnome-pilot] Remove gnome_message_box, and fix some bugs in restore code.
- From: Matthew Charles Davey <mcdavey src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-pilot] Remove gnome_message_box, and fix some bugs in restore code.
- Date: Tue, 25 Aug 2009 07:51:35 +0000 (UTC)
commit 7656481a18499bff9717cf91f782fb58b1e6d06b
Author: Matt Davey <mcdavey mrao cam ac uk>
Date: Tue Aug 25 08:48:29 2009 +0100
Remove gnome_message_box, and fix some bugs in restore code.
2009-08-25 Matt Davey <mcdavey mrao cam ac uk>
* Makefile.am: removed gpilot-fileman. Obsolete.
* applet/pilot.c: fix some bugs with restore feature, plus
remove gnome_message_box use.
* conduits/backup/backup_conduit.c: ditto.
* conduits/file/gpilot_install_file.c: remove gnome_message_box.
* gpilotd/gpilot-gui.c: ditto.
ChangeLog | 9 +
Makefile.am | 1 -
applet/pilot.c | 119 +++----
conduits/backup/backup_conduit.c | 8 +-
conduits/file/gpilot_install_file.c | 47 ++--
gpilot-fileman/.cvsignore | 11 -
gpilot-fileman/Makefile.am | 20 -
gpilot-fileman/OChangeLog | 57 ---
gpilot-fileman/fileman.c | 674 -----------------------------------
gpilot-fileman/gpilot-fileman.h | 38 --
gpilot-fileman/multifile.c | 415 ---------------------
gpilot-fileman/multifile.h | 56 ---
gpilot-fileman/pilotfunc.c | 284 ---------------
gpilot-fileman/preferences.c | 138 -------
gpilotd/gpilot-gui.c | 54 +--
15 files changed, 105 insertions(+), 1826 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index dd65273..0c33cf2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-08-25 Matt Davey <mcdavey mrao cam ac uk>
+ * Makefile.am: removed gpilot-fileman. Obsolete.
+ * applet/pilot.c: fix some bugs with restore feature, plus
+ remove gnome_message_box use.
+ * conduits/backup/backup_conduit.c: ditto.
+ * conduits/file/gpilot_install_file.c: remove gnome_message_box.
+ * gpilotd/gpilot-gui.c: ditto.
+
+
2009-08-20 Matt Davey <mcdavey mrao cam ac uk>
* gnome-pilot.doap: Added doap file. See http://live.gnome.org/Git/FAQ
* Makefile.am: Remove obsolete references to compiler-flags.m4,
diff --git a/Makefile.am b/Makefile.am
index 0e45b6f..c367da3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -23,7 +23,6 @@ changelogs = \
conduits/backup/OChangeLog \
conduits/OChangeLog \
conduits/file/OChangeLog \
- gpilot-fileman/OChangeLog \
gpilotd/OChangeLog \
idl/OChangeLog \
libgpilotdCM/OChangeLog \
diff --git a/applet/pilot.c b/applet/pilot.c
index 42c2867..2945ef9 100644
--- a/applet/pilot.c
+++ b/applet/pilot.c
@@ -31,7 +31,6 @@
#include <gtk/gtk.h>
#include <libgnome/gnome-util.h>
#include <libgnomeui/gnome-about.h>
-#include <libgnomeui/gnome-dialog.h>
#include <libgnomeui/gnome-dialog-util.h>
#include <libgnomeui/gnome-messagebox.h>
#include <panel-applet-gconf.h>
@@ -106,9 +105,7 @@ typedef struct {
#define PILOT_APPLET(x) ((PilotApplet*)(x))
-static void show_error_dialog (PilotApplet *self, gchar*,...);
-static void show_warning_dialog (PilotApplet *self, gchar*,...);
-static void show_message_dialog (PilotApplet *self, gchar*,...);
+static void show_dialog (PilotApplet *self, GtkMessageType type, gchar*,...);
static void cancel_cb (GtkButton* button, gpointer whatever);
static void save_properties (PilotApplet *self);
@@ -422,12 +419,14 @@ static void
handle_client_error (PilotApplet *self)
{
if (self->curstate == SYNCING) {
- show_warning_dialog (self, _("PDA is currently synchronizing.\nPlease wait for it to finish."));
+ show_dialog (self, GTK_MESSAGE_WARNING,
+ _("PDA is currently synchronizing.\nPlease wait for it to finish."));
} else {
self->curstate=INITIALISING;
gtk_tooltips_set_tip (self->tooltips, GTK_WIDGET (self->applet),_("Not connected. Please restart daemon."), NULL);
pilot_draw (self);
- show_error_dialog (self, _("Not connected to gpilotd.\nPlease restart daemon."));
+ show_dialog (self, GTK_MESSAGE_ERROR,
+ _("Not connected to gpilotd.\nPlease restart daemon."));
}
}
@@ -616,17 +615,10 @@ complete_restore (GnomePilotClient* client, const gchar *id,
PilotApplet *applet = user_data;
gtk_widget_destroy (applet->operationDialogWindow);
+ applet->operationDialogWindow = NULL;
}
static void
-cancel_restore (PilotApplet *self, GnomeDialog *w,gpointer data)
-{
- g_message (_("cancelling %d"),GPOINTER_TO_INT (data));
- gnome_pilot_client_remove_request (self->gpc,GPOINTER_TO_INT (data));
-}
-
-
-static void
restore_cb (BonoboUIComponent *uic, gpointer user_data, const gchar *verbname)
{
PilotApplet *applet = user_data;
@@ -637,7 +629,7 @@ restore_cb (BonoboUIComponent *uic, gpointer user_data, const gchar *verbname)
GtkWidget *dir_entry, *id_entry,*frame;
GtkWidget *device_menu, *menu_item,*menu;
GList *list;
- gchar *buf;
+ gchar *buf = NULL;
restore_properties restore_props;
@@ -651,7 +643,8 @@ restore_cb (BonoboUIComponent *uic, gpointer user_data, const gchar *verbname)
}
if (gnome_pilot_client_get_pilot_base_dir_by_name (applet->gpc,pilot_name,&buf) == GPILOTD_OK) {
- restore_props.backupdir = g_strdup_printf ("%s/backup/",buf);
+ /* XXX backup conduit allows user to modify the backup directory :( */
+ restore_props.backupdir = g_strdup_printf ("%s",buf);
g_free (buf);
} else {
handle_client_error (applet);
@@ -715,24 +708,31 @@ restore_cb (BonoboUIComponent *uic, gpointer user_data, const gchar *verbname)
gtk_widget_destroy (applet->restoreDialog);
if ( restore_props.backupdir == NULL ||
strlen (restore_props.backupdir)==0) {
- show_warning_dialog (applet, _("No directory to restore from."));
+ show_dialog (applet, GTK_MESSAGE_WARNING,
+ _("No directory to restore from."));
return;
}
/* FIXME: how do we specify which device to restore on? */
id = gnome_pilot_client_connect__completed_request (applet->gpc, complete_restore, applet);
- if (gnome_pilot_client_restore (applet->gpc,pilot_name,restore_props.backupdir,GNOME_Pilot_IMMEDIATE,0, &handle) == GPILOTD_OK) {
+ if (gnome_pilot_client_restore (applet->gpc,pilot_name,
+ restore_props.backupdir,
+ GNOME_Pilot_IMMEDIATE,0, &handle) == GPILOTD_OK) {
applet->operationDialogWindow =
- gnome_message_box_new (_("Press synchronize on the cradle to restore\n"
- " or cancel the operation."),
- GNOME_MESSAGE_BOX_GENERIC,
- GNOME_STOCK_BUTTON_CANCEL,
- NULL);
- gnome_dialog_button_connect (GNOME_DIALOG (applet->operationDialogWindow),0,
- (GCallback) cancel_restore ,GINT_TO_POINTER (handle));
- gnome_dialog_run_and_close (GNOME_DIALOG (applet->operationDialogWindow));
+ gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
+ GTK_MESSAGE_OTHER, GTK_BUTTONS_CANCEL, "%s",
+ _("Press synchronize on the cradle to restore\n"
+ " or cancel the operation."));
+ gint response = gtk_dialog_run(GTK_DIALOG (applet->operationDialogWindow));
+ if (applet->operationDialogWindow != NULL)
+ gtk_widget_destroy(applet->operationDialogWindow);
+ if (response == GTK_RESPONSE_CANCEL) {
+ g_message (_("cancelling %d"), handle);
+ gnome_pilot_client_remove_request (applet->gpc, handle);
+ }
} else {
- show_warning_dialog (applet,_("Restore request failed"));
+ show_dialog (applet, GTK_MESSAGE_WARNING,
+ _("Restore request failed"));
}
gtk_signal_disconnect (applet->gpc, id);
} else {
@@ -768,9 +768,15 @@ static void
restart_cb (BonoboUIComponent *uic, gpointer user_data, const gchar *verbname)
{
PilotApplet *applet = user_data;
+ GtkWidget *dialog;
if (applet->curstate == SYNCING) {
- if ( gnome_dialog_run_and_close (GNOME_DIALOG (gnome_question_dialog (_("PDA sync is currently in progress.\nAre you sure you want to restart daemon?"),NULL,NULL))) !=0 ) {
+ dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, "%s",
+ _("PDA sync is currently in progress.\nAre you sure you want to restart daemon?"));
+ gint response = gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
+ if (response != GTK_RESPONSE_YES) {
return;
}
if (applet->progressDialog!=NULL) {
@@ -796,7 +802,8 @@ log_cb (BonoboUIComponent *uic, gpointer user_data, const gchar *verbname)
gtk_widget_set_sensitive (applet->cancel_button,TRUE);
gtk_widget_show_all (applet->progressDialog);
} else {
- show_message_dialog (applet, _("There's no last sync on record."));
+ show_dialog (applet, GTK_MESSAGE_INFO,
+ _("There's no last sync on record."));
}
}
@@ -1051,51 +1058,24 @@ timeout (PilotApplet *self)
}
static void
-show_error_dialog (PilotApplet *self, gchar *mesg,...)
+show_dialog (PilotApplet *self, GtkMessageType type, gchar *mesg,...)
{
char *tmp;
va_list ap;
va_start (ap,mesg);
tmp = g_strdup_vprintf (mesg,ap);
- self->dialogWindow = gnome_message_box_new (tmp,GNOME_MESSAGE_BOX_ERROR,
- GNOME_STOCK_BUTTON_OK,NULL);
- gnome_dialog_run_and_close (GNOME_DIALOG (self->dialogWindow));
- g_free (tmp);
- va_end (ap);
-}
-static void
-show_warning_dialog (PilotApplet *self, gchar *mesg,...)
-{
- char *tmp;
- va_list ap;
+ self->dialogWindow = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL,
+ type, GTK_BUTTONS_OK, "%s", tmp);
- va_start (ap,mesg);
- tmp = g_strdup_vprintf (mesg,ap);
- self->dialogWindow = gnome_message_box_new (tmp,GNOME_MESSAGE_BOX_WARNING,
- GNOME_STOCK_BUTTON_OK,NULL);
- gnome_dialog_run_and_close (GNOME_DIALOG (self->dialogWindow));
+ gtk_dialog_run (GTK_DIALOG (self->dialogWindow));
+ gtk_widget_destroy (self->dialogWindow);
g_free (tmp);
va_end (ap);
}
-static void
-show_message_dialog (PilotApplet *self, char *mesg,...)
-{
- char *tmp;
- va_list ap;
-
- va_start (ap,mesg);
- tmp = g_strdup_vprintf (mesg,ap);
- self->dialogWindow = gnome_message_box_new (tmp,GNOME_MESSAGE_BOX_GENERIC,
- GNOME_STOCK_BUTTON_OK,NULL);
- gnome_dialog_run_and_close (GNOME_DIALOG (self->dialogWindow));
- g_free (tmp);
- va_end (ap);
-}
-
static void
load_properties (PilotApplet *self)
{
@@ -1132,9 +1112,11 @@ save_properties (PilotApplet *self)
}
static void
-activate_pilot_menu (PilotApplet *self, GtkMenuItem *widget, gpointer data)
+activate_pilot_menu (GtkMenuItem *widget, gpointer data)
{
- gtk_object_set_data (GTK_OBJECT (self->chooseDialog),"pilot",data);
+ PilotApplet *applet = PILOT_APPLET (data);
+ gtk_object_set_data (GTK_OBJECT (applet->chooseDialog),"pilot",
+ (gpointer)gtk_menu_item_get_label(widget));
}
static gchar*
@@ -1166,18 +1148,19 @@ pick_pilot (PilotApplet *self)
gtk_widget_show (menuItem);
gtk_signal_connect (GTK_OBJECT (menuItem),"activate",
GTK_SIGNAL_FUNC (activate_pilot_menu),
- tmp->data);
+ self);
gtk_menu_append (GTK_MENU (menu),menuItem);
tmp=tmp->next;
}
gtk_option_menu_set_menu (GTK_OPTION_MENU (optionMenu),menu);
gtk_option_menu_set_history (GTK_OPTION_MENU (optionMenu),0);
gtk_object_set_data (GTK_OBJECT (self->chooseDialog),"pilot",self->properties.pilot_ids->data);
- if (gnome_dialog_run_and_close (GNOME_DIALOG (self->chooseDialog))==0) {
+ if (gtk_dialog_run(GTK_DIALOG (self->chooseDialog))== 0) {
pilot=(gchar *)gtk_object_get_data (GTK_OBJECT (self->chooseDialog),"pilot");
} else {
pilot=NULL;
}
+ gtk_widget_hide(self->chooseDialog);
}
}
@@ -1190,7 +1173,8 @@ pilot_execute_program (PilotApplet *self, const gchar *str)
g_return_if_fail (str != NULL);
if (!g_spawn_command_line_async (str, NULL))
- show_warning_dialog (self, _("Execution of %s failed"),str);
+ show_dialog (self, GTK_MESSAGE_WARNING,
+ _("Execution of %s failed"),str);
}
static gint
@@ -1418,7 +1402,8 @@ pilot_applet_fill (PanelApplet *applet)
self->glade_file = g_concat_dir_and_file (GLADEDATADIR, "pilot-applet.glade");
}
if (!g_file_exists (self->glade_file)) {
- show_error_dialog (self, _("Cannot find pilot-applet.glade"));
+ show_dialog (self, GTK_MESSAGE_ERROR,
+ _("Cannot find pilot-applet.glade"));
return -1;
}
diff --git a/conduits/backup/backup_conduit.c b/conduits/backup/backup_conduit.c
index ec4b82e..b69a796 100644
--- a/conduits/backup/backup_conduit.c
+++ b/conduits/backup/backup_conduit.c
@@ -713,6 +713,7 @@ gnome_real_pilot_conduit_backup_restore (GnomePilotConduitBackup *conduit,
gpointer _cfg)
{
DIR *dir;
+ struct stat buf;
struct dirent *dirent;
file_db **db;
int dbcount = 0;
@@ -745,8 +746,11 @@ gnome_real_pilot_conduit_backup_restore (GnomePilotConduitBackup *conduit,
printf ("checking %s/%s\n", source, dirent->d_name);
#endif
- /* skip dotfiles. */
- if (dirent->d_name[0] == '.')
+ gchar *entryname = g_strdup_printf("%s/%s", source, dirent->d_name);
+ /* skip dotfiles and directories. */
+ lstat (entryname, &buf);
+ g_free(entryname);
+ if (dirent->d_name[0] == '.' || S_ISDIR (buf.st_mode))
continue;
db[dbcount] = g_new0 (file_db, 1);
diff --git a/conduits/file/gpilot_install_file.c b/conduits/file/gpilot_install_file.c
index 2fd0b01..564f7ad 100644
--- a/conduits/file/gpilot_install_file.c
+++ b/conduits/file/gpilot_install_file.c
@@ -20,7 +20,7 @@
*/
#include "config.h"
-#include <libgnomeui/gnome-dialog.h>
+#include <gtk/gtk.h>
#include <libgnomeui/gnome-messagebox.h>
#include <libgnomeui/gnome-ui-init.h>
#include <gpilotd/gnome-pilot-client.h>
@@ -54,20 +54,10 @@ gpilotd_request_completed (GnomePilotClient *gpc, gchar *pilot_id, gint handle,
{
g_message ("%s completed %d", pilot_id, handle);
handles = g_slist_remove (handles,GINT_TO_POINTER(handle));
- if (handles == NULL)
- gnome_dialog_close (GNOME_DIALOG (dialog));
-}
-
-static void
-cancel_install (GnomeDialog *w, GSList *list)
-{
- GSList *e;
-
- for (e=list;e;e = g_slist_next (e)) {
- gnome_pilot_client_remove_request (gpc,GPOINTER_TO_INT(e->data));
+ if (handles == NULL) {
+ gtk_widget_destroy (dialog);
+ dialog = NULL;
}
- g_slist_free (list);
-
}
static void
@@ -78,9 +68,11 @@ show_warning_dialog (gchar *mesg,...)
va_start (ap, mesg);
tmp = g_strdup_vprintf (mesg, ap);
- dialog = gnome_message_box_new (tmp, GNOME_MESSAGE_BOX_WARNING,
- GNOME_STOCK_BUTTON_OK, NULL);
- gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
+ dialog = gtk_message_dialog_new (NULL, 0,GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_OK, "%s", tmp);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ dialog = NULL;
g_free (tmp);
va_end (ap);
}
@@ -213,13 +205,20 @@ main (int argc, char *argv[])
g_free (info);
message = tmp;
}
- dialog = gnome_message_box_new (message,
- GNOME_MESSAGE_BOX_GENERIC,
- GNOME_STOCK_BUTTON_CANCEL,
- NULL);
- gnome_dialog_button_connect (GNOME_DIALOG (dialog),0,
- G_CALLBACK(cancel_install), handles);
- gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
+ dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL,
+ GTK_MESSAGE_OTHER, GTK_BUTTONS_CANCEL, "%s",
+ message);
+ gint response = gtk_dialog_run(GTK_DIALOG(dialog));
+ if (dialog != NULL) /* if not destroyed by callback */
+ gtk_widget_destroy(dialog);
+ if (response == GTK_RESPONSE_CANCEL) {
+ GSList *e;
+ for (e=handles;e;e = g_slist_next (e)) {
+ gnome_pilot_client_remove_request
+ (gpc,GPOINTER_TO_INT(e->data));
+ }
+ g_slist_free (handles);
+ }
g_free (message);
}
diff --git a/gpilotd/gpilot-gui.c b/gpilotd/gpilot-gui.c
index 32667c9..dd471d1 100644
--- a/gpilotd/gpilot-gui.c
+++ b/gpilotd/gpilot-gui.c
@@ -23,30 +23,21 @@
#include "gpilot-gui.h"
#include <string.h>
#include <stdlib.h>
-#include <libgnomeui/gnome-dialog-util.h>
+#include <gtk/gtk.h>
-static void gpilot_gui_run_dialog(gchar *type, gchar *mesg, va_list ap);
+static void gpilot_gui_run_dialog(GtkMessageType type, gchar *mesg, va_list ap);
static void
-gpilot_gui_run_dialog(gchar *type, gchar *mesg, va_list ap)
+gpilot_gui_run_dialog(GtkMessageType type, gchar *mesg, va_list ap)
{
char *tmp;
- GtkWidget *dialogWindow;
+ GtkWidget *dialog;
tmp = g_strdup_vprintf(mesg,ap);
-#if 0
- dialogWindow = gnome_message_box_new(tmp,type,GNOME_STOCK_BUTTON_OK,NULL);
- gnome_dialog_run_and_close(GNOME_DIALOG(dialogWindow));
-#endif
-
- if (strcmp(type,GNOME_MESSAGE_BOX_WARNING)==0) {
- gnome_warning_dialog(tmp);
- } else if (strcmp(type,GNOME_MESSAGE_BOX_ERROR)==0) {
- dialogWindow = gnome_message_box_new(tmp,type,GNOME_STOCK_BUTTON_OK,NULL);
- gnome_dialog_run(GNOME_DIALOG(dialogWindow));
- exit(-1);
- }
+ dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, type, GTK_BUTTONS_OK, "%s", tmp);
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
g_free(tmp);
va_end(ap);
}
@@ -57,7 +48,7 @@ gpilot_gui_warning_dialog (gchar *mesg, ...)
va_list args;
va_start (args, mesg);
- gpilot_gui_run_dialog (GNOME_MESSAGE_BOX_WARNING, mesg, args);
+ gpilot_gui_run_dialog (GTK_MESSAGE_WARNING, mesg, args);
va_end (args);
}
@@ -67,24 +58,10 @@ gpilot_gui_error_dialog (gchar *mesg, ...)
va_list args;
va_start (args, mesg);
- gpilot_gui_run_dialog (GNOME_MESSAGE_BOX_ERROR, mesg, args);
+ gpilot_gui_run_dialog (GTK_MESSAGE_ERROR, mesg, args);
va_end (args);
}
-static void
-gpilot_gui_restore_callback (gint reply,
- gpointer data)
-{
- gboolean *result = (gboolean*)data;
- if (reply == 0 /* YES */) {
- (*result) = TRUE;
- } else if (reply == 1 /* NO */) {
- (*result) = FALSE;
- } else {
- g_assert_not_reached ();
- }
-}
-
GPilotPilot*
gpilot_gui_restore (GPilotContext *context,
GPilotPilot *pilot)
@@ -93,20 +70,19 @@ gpilot_gui_restore (GPilotContext *context,
GtkWidget *d;
if (pilot) {
- gboolean q_result = FALSE;
+ gint response;
char *tmp;
tmp = g_strdup_printf ("Restore %s' pilot with id %d\n"
"and name `%s'",
pilot->pilot_username,
pilot->pilot_id,
pilot->name);
- d = gnome_question_dialog_modal (tmp,
- gpilot_gui_restore_callback,
- GINT_TO_POINTER (&q_result));
- gnome_dialog_run (GNOME_DIALOG (d));
+ d = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_YES_NO, "%s", tmp);
+ response = gtk_dialog_run (GTK_DIALOG (d));
g_free (tmp);
-
- if (q_result == TRUE) {
+ gtk_widget_destroy(d);
+ if (response == GTK_RESPONSE_YES) {
result = pilot;
} else {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]