remote-viewer-connect: Changed response to gboolean

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.
This commit is contained in:
Lukas Venhoda 2015-06-15 12:47:29 +02:00 committed by Pavel Grunt
parent f4018a8dbe
commit e7dcc5a497
3 changed files with 17 additions and 6 deletions

View File

@ -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);

View File

@ -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 */

View File

@ -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"));