diff options
author | Christian Grothoff <christian@grothoff.org> | 2005-07-05 22:02:57 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2005-07-05 22:02:57 +0000 |
commit | cb8edf8bcc9030e4bb8f72ffee46de4a82e18c94 (patch) | |
tree | 6bb99b81fe7dd761e8ea1f145fafe5991dabde35 /src | |
parent | 23c3e30bb76d94ec32633296a3aeb7ec4958ec49 (diff) | |
download | gnunet-gtk-cb8edf8bcc9030e4bb8f72ffee46de4a82e18c94.tar.gz gnunet-gtk-cb8edf8bcc9030e4bb8f72ffee46de4a82e18c94.zip |
die gui message, die
Diffstat (limited to 'src')
-rw-r--r-- | src/common/helper.c | 73 | ||||
-rw-r--r-- | src/include/gnunetgtk_common.h | 10 | ||||
-rw-r--r-- | src/plugins/about/about.c | 1 | ||||
-rw-r--r-- | src/plugins/daemon/daemon.c | 11 | ||||
-rw-r--r-- | src/plugins/fs/download.c | 25 |
5 files changed, 32 insertions, 88 deletions
diff --git a/src/common/helper.c b/src/common/helper.c index bf2ae4a8..59c10bf8 100644 --- a/src/common/helper.c +++ b/src/common/helper.c | |||
@@ -1,5 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | (C) 2003, 2004, 2005 Christian Grothoff (and other contributing authors) | ||
3 | 4 | ||
4 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -144,78 +145,6 @@ deleteEvent(GtkWidget * widget, | |||
144 | return FALSE; | 145 | return FALSE; |
145 | } | 146 | } |
146 | 147 | ||
147 | /** | ||
148 | * A callback to destroy any widget given as second argument | ||
149 | */ | ||
150 | static void | ||
151 | destroyWidget(GtkWidget * dummy, | ||
152 | GtkWidget * widget) { | ||
153 | gtk_widget_destroy(widget); | ||
154 | } | ||
155 | |||
156 | /** | ||
157 | * Callback function for guiMessage() | ||
158 | * | ||
159 | * FIXME: use GLADE (or direct GTK functionality) here! | ||
160 | */ | ||
161 | static void doGuiMessage(void * args) { | ||
162 | const gchar * msg = args; | ||
163 | GtkWidget * window; | ||
164 | GtkWidget * label; | ||
165 | GtkWidget * box; | ||
166 | GtkWidget * button; | ||
167 | |||
168 | window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | ||
169 | gtk_container_set_border_width(GTK_CONTAINER(window), 10); | ||
170 | gtk_window_set_title(GTK_WINDOW(window), | ||
171 | _("Notification")); | ||
172 | gtk_signal_connect(GTK_OBJECT(window), | ||
173 | "delete_event", | ||
174 | GTK_SIGNAL_FUNC(deleteEvent), | ||
175 | NULL); | ||
176 | |||
177 | box = gtk_vbox_new(FALSE, 0); | ||
178 | gtk_container_add(GTK_CONTAINER(window), | ||
179 | box); | ||
180 | |||
181 | label = gtk_label_new(msg); | ||
182 | gtk_box_pack_start(GTK_BOX(box), | ||
183 | label, | ||
184 | FALSE, | ||
185 | FALSE, | ||
186 | 0); | ||
187 | |||
188 | button = gtk_button_new_with_label(_("Ok")); | ||
189 | gtk_signal_connect(GTK_OBJECT (button), | ||
190 | "clicked", | ||
191 | GTK_SIGNAL_FUNC(destroyWidget), | ||
192 | window); | ||
193 | gtk_box_pack_start(GTK_BOX(box), | ||
194 | button, | ||
195 | FALSE, | ||
196 | FALSE, | ||
197 | 0); | ||
198 | gtk_window_set_position(GTK_WINDOW(window), | ||
199 | GTK_WIN_POS_MOUSE); | ||
200 | gtk_widget_show_all(window); | ||
201 | gtk_widget_grab_focus(button); | ||
202 | } | ||
203 | |||
204 | /** | ||
205 | * Displays an informative message to the user in a fresh window | ||
206 | */ | ||
207 | void guiMessage(const char * format, | ||
208 | ...) { | ||
209 | va_list args; | ||
210 | gchar *note; | ||
211 | |||
212 | va_start(args, format); | ||
213 | note = g_strdup_vprintf(format, args); | ||
214 | va_end(args); | ||
215 | gtkSaveCall(&doGuiMessage, note); | ||
216 | free(note); | ||
217 | } | ||
218 | |||
219 | static void hideWindow(GtkWidget * widget, | 148 | static void hideWindow(GtkWidget * widget, |
220 | gpointer data) { | 149 | gpointer data) { |
221 | if (widget != NULL) | 150 | if (widget != NULL) |
diff --git a/src/include/gnunetgtk_common.h b/src/include/gnunetgtk_common.h index 7dd342fa..ee3e53c4 100644 --- a/src/include/gnunetgtk_common.h +++ b/src/include/gnunetgtk_common.h | |||
@@ -42,19 +42,13 @@ const char * getGladeFileName(void); | |||
42 | GladeXML * getMainXML(void); | 42 | GladeXML * getMainXML(void); |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * Displays an informative message to the user | ||
46 | * in a new popup window. | ||
47 | */ | ||
48 | void guiMessage(const char * format, | ||
49 | ...); | ||
50 | |||
51 | /** | ||
52 | * Appends a message to the info window | 45 | * Appends a message to the info window |
53 | * @param doPopup if YES, the info window will | 46 | * @param doPopup if YES, the info window will |
54 | * be opened | 47 | * be opened |
55 | */ | 48 | */ |
56 | void infoMessage(int doPopup, | 49 | void infoMessage(int doPopup, |
57 | const char * format, ...); | 50 | const char * format, |
51 | ...); | ||
58 | 52 | ||
59 | /** | 53 | /** |
60 | * Appends a log entry to the info window | 54 | * Appends a log entry to the info window |
diff --git a/src/plugins/about/about.c b/src/plugins/about/about.c index 0b05f3e2..74163aad 100644 --- a/src/plugins/about/about.c +++ b/src/plugins/about/about.c | |||
@@ -1,5 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | (C) 2005 Christian Grothoff (and other contributing authors) | ||
3 | 4 | ||
4 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
diff --git a/src/plugins/daemon/daemon.c b/src/plugins/daemon/daemon.c index e6b1d833..b366fdb5 100644 --- a/src/plugins/daemon/daemon.c +++ b/src/plugins/daemon/daemon.c | |||
@@ -122,7 +122,16 @@ void on_stopDaemon_clicked(GtkWidget * widget, | |||
122 | 122 | ||
123 | if (OK == checkGNUnetDaemonRunning() ) { | 123 | if (OK == checkGNUnetDaemonRunning() ) { |
124 | if (OK != stopGNUnetDaemon()) { | 124 | if (OK != stopGNUnetDaemon()) { |
125 | guiMessage(_("Error requesting shutdown by gnunetd.")); | 125 | GtkWidget * dialog; |
126 | |||
127 | dialog = gtk_message_dialog_new | ||
128 | (NULL, | ||
129 | GTK_DIALOG_MODAL, | ||
130 | GTK_MESSAGE_ERROR, | ||
131 | GTK_BUTTONS_CLOSE, | ||
132 | _("Error requesting shutdown of gnunetd.")); | ||
133 | gtk_dialog_run(GTK_DIALOG(dialog)); | ||
134 | gtk_widget_destroy(dialog); | ||
126 | } else { | 135 | } else { |
127 | addLogEntry(_("Terminating gnunetd...")); | 136 | addLogEntry(_("Terminating gnunetd...")); |
128 | } | 137 | } |
diff --git a/src/plugins/fs/download.c b/src/plugins/fs/download.c index 9947a2ef..b6679b05 100644 --- a/src/plugins/fs/download.c +++ b/src/plugins/fs/download.c | |||
@@ -168,12 +168,22 @@ static void initiateDownload(GtkTreeModel *model, | |||
168 | pfx[strlen(pfx)-1] = '\0'; | 168 | pfx[strlen(pfx)-1] = '\0'; |
169 | if (0 == STAT(pfx, | 169 | if (0 == STAT(pfx, |
170 | &sbuf)) { | 170 | &sbuf)) { |
171 | guiMessage(_("File '%s' exists in '%s',\n" | 171 | GtkWidget * dialog; |
172 | "will store download under its GNUnet URI '%s' instead.\n"), | 172 | |
173 | name, | 173 | dialog = gtk_message_dialog_new |
174 | fn, | 174 | (NULL, |
175 | &filename[strlen(ECRS_URI_PREFIX) + | 175 | GTK_DIALOG_MODAL, |
176 | strlen(ECRS_FILE_INFIX)]); | 176 | GTK_MESSAGE_WARNING, |
177 | GTK_BUTTONS_CLOSE, | ||
178 | _("File '%s' exists in '%s',\n" | ||
179 | "will store download under its" | ||
180 | " GNUnet URI '%s' instead.\n"), | ||
181 | name, | ||
182 | fn, | ||
183 | &filename[strlen(ECRS_URI_PREFIX) + | ||
184 | strlen(ECRS_FILE_INFIX)]); | ||
185 | gtk_dialog_run(GTK_DIALOG(dialog)); | ||
186 | gtk_widget_destroy(dialog); | ||
177 | strcpy(pfx, fn); | 187 | strcpy(pfx, fn); |
178 | strcat(pfx, | 188 | strcat(pfx, |
179 | DIR_SEPARATOR_STR); | 189 | DIR_SEPARATOR_STR); |
@@ -198,7 +208,8 @@ static void initiateDownload(GtkTreeModel *model, | |||
198 | DOWNLOAD_PROGRESS, 0, /* progress */ | 208 | DOWNLOAD_PROGRESS, 0, /* progress */ |
199 | DOWNLOAD_URISTRING, filename, | 209 | DOWNLOAD_URISTRING, filename, |
200 | DOWNLOAD_URI, ECRS_dupUri(uri), | 210 | DOWNLOAD_URI, ECRS_dupUri(uri), |
201 | DOWNLOAD_TREEPATH, list->rr, /* internal: row reference! */ | 211 | DOWNLOAD_TREEPATH, list->rr, |
212 | /* internal: row reference! */ | ||
202 | -1); | 213 | -1); |
203 | FREE(filename); | 214 | FREE(filename); |
204 | FREE(name); | 215 | FREE(name); |