Do you think we'll need to support other response codes besides OK and CANCEL in the future? If not, I think it might be simpler to just use a boolean return value. But this is OK too On Thu, 2015-06-11 at 16:28 +0200, Lukas Venhoda wrote: > remote_viewer_connect_dialog now return meaningful GTK_RESPONSE_OK > and GTK_RESPONSE_CANCEL, instead of "magical" 0 and -1. > > Added a doxygen style comment to document this in code also. > --- > 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..3927d19 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 GTK_RESPONSE_OK if Connect or ENTER is pressed > +* @return GTK_RESPONSE_CANCEL if Cancel is pressed or dialog is closed > +*/ > +GtkResponseType > 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; > + GtkResponseType 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 = GTK_RESPONSE_OK; > } else { > *uri = NULL; > - retval = -1; > + retval = GTK_RESPONSE_CANCEL; > } > gtk_widget_destroy(dialog); > > diff --git a/src/remote-viewer-connect.h b/src/remote-viewer-connect.h > index 86705d7..f095f57 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); > +GtkResponseType 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..ca8a3aa 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) != GTK_RESPONSE_OK) { > g_set_error_literal(&error, > VIRT_VIEWER_ERROR, VIRT_VIEWER_ERROR_CANCELLED, > _("No connection was chosen")); > -- > 2.4.2 > > _______________________________________________ > virt-tools-list mailing list > virt-tools-list@xxxxxxxxxx > https://www.redhat.com/mailman/listinfo/virt-tools-list _______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list