[virt-tools-list] [remote-viewer PATCH 2/7 v3] remote-viewer-connect: Changed response to gboolean
Lukas Venhoda
lvenhoda at redhat.com
Mon Jun 15 10:47:29 UTC 2015
remote_viewer_connect_dialog now returns TRUE and FALSE, instead of 0 and -1.
Added a doxygen style comment to document this in code also.
---
Changes since v2
- Changed return type from GtkResponseType to simpler gboolean
Changes since v1
- New patch
- Added some documentation about the return value of the connect dialog.
---
src/remote-viewer-connect.c | 19 +++++++++++++++----
src/remote-viewer-connect.h | 2 +-
src/remote-viewer.c | 2 +-
3 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/src/remote-viewer-connect.c b/src/remote-viewer-connect.c
index a459f6a..5c3b03f 100644
--- a/src/remote-viewer-connect.c
+++ b/src/remote-viewer-connect.c
@@ -91,7 +91,18 @@ make_label_bold(GtkLabel* label)
pango_attr_list_unref(attributes);
}
-gint
+/**
+* remote_viewer_connect_dialog
+*
+* @brief Opens connect dialog for remote viewer
+*
+* @param main_window Parent window of the dialog
+* @param uri For returning the uri of chosen server
+*
+* @return TRUE if Connect or ENTER is pressed
+* @return FALSE if Cancel is pressed or dialog is closed
+*/
+gboolean
remote_viewer_connect_dialog(GtkWindow *main_window, gchar **uri)
{
GtkWidget *dialog, *area, *box, *label, *entry, *recent;
@@ -99,7 +110,7 @@ remote_viewer_connect_dialog(GtkWindow *main_window, gchar **uri)
GtkWidget *alignment;
#endif
GtkRecentFilter *rfilter;
- gint retval;
+ gboolean retval;
/* Create the widgets */
dialog = gtk_dialog_new_with_buttons(_("Connection details"),
@@ -170,10 +181,10 @@ remote_viewer_connect_dialog(GtkWindow *main_window, gchar **uri)
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
*uri = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
g_strstrip(*uri);
- retval = 0;
+ retval = TRUE;
} else {
*uri = NULL;
- retval = -1;
+ retval = FALSE;
}
gtk_widget_destroy(dialog);
diff --git a/src/remote-viewer-connect.h b/src/remote-viewer-connect.h
index 86705d7..99779ef 100644
--- a/src/remote-viewer-connect.h
+++ b/src/remote-viewer-connect.h
@@ -23,7 +23,7 @@
#include <gtk/gtk.h>
-gint remote_viewer_connect_dialog(GtkWindow *main_window, gchar **uri);
+gboolean remote_viewer_connect_dialog(GtkWindow *main_window, gchar **uri);
#endif /* REMOTE_VIEWER_CONNECT_H */
diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index 76b12ae..04d7bf0 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -1098,7 +1098,7 @@ remote_viewer_start(VirtViewerApp *app, GError **err)
retry_dialog:
main_window = virt_viewer_app_get_main_window(app);
if (priv->open_recent_dialog) {
- if (remote_viewer_connect_dialog(virt_viewer_window_get_window(main_window), &guri) != 0) {
+ if (!remote_viewer_connect_dialog(virt_viewer_window_get_window(main_window), &guri)) {
g_set_error_literal(&error,
VIRT_VIEWER_ERROR, VIRT_VIEWER_ERROR_CANCELLED,
_("No connection was chosen"));
--
2.4.2
More information about the virt-tools-list
mailing list