コード例 #1
0
ファイル: dialogs.c プロジェクト: jagsmani/iio-oscilloscope
G_MODULE_EXPORT gint cb_connect(GtkButton *button, Dialogs *data)
{
	/* Connect Dialog */
	gint ret;

	connect_fillin(data);

	do {
		ret = gtk_dialog_run(GTK_DIALOG(data->connect));
		if (ret == GTK_RESPONSE_APPLY)
			connect_fillin(data);
	} while (ret == GTK_RESPONSE_APPLY);

	switch(ret) {
		case GTK_RESPONSE_CANCEL:
		case GTK_RESPONSE_DELETE_EVENT:
			break;
		case GTK_RESPONSE_OK:
			break;
		default:
			printf("unknown response (%i) in %s(%s)\n", ret, __FILE__, __func__);
			break;
	}
	gtk_widget_hide(data->connect);

	return ret;
}
コード例 #2
0
ファイル: dialogs.c プロジェクト: lrmodesgh/iio-oscilloscope
static gint fru_connect_dialog(Dialogs *data, bool load_profile)
{
    /* Connect Dialog */
    gint ret;
    struct iio_context *ctx;
    const char *name = NULL;
    bool has_context = false;

    /* Preload the device list and FRU info only if we can use the local
     * backend */
    ctx = get_context_from_osc();
    if (ctx)
        name = iio_context_get_name(ctx);
    if (name && !strcmp(name, "local"))
        has_context = connect_fillin(data);

    while (true) {
        gtk_widget_set_sensitive(data->ok_btn, has_context);

        ret = gtk_dialog_run(GTK_DIALOG(data->connect));
        switch (ret) {
        case GTK_RESPONSE_APPLY:
            widget_set_cursor(data->connect, GDK_WATCH);
            has_context = connect_fillin(data);
            widget_use_parent_cursor(data->connect);
            continue;
        case GTK_RESPONSE_OK:
            ctx = get_context(data);
            widget_set_cursor(data->connect, GDK_WATCH);
            widget_use_parent_cursor(data->connect);
            if (!ctx)
                continue;

            application_reload(ctx, load_profile);
            break;
        default:
            printf("unknown response (%i) in %s(%s)\n", ret, __FILE__, __func__);
        case GTK_RESPONSE_CANCEL:
        case GTK_RESPONSE_DELETE_EVENT:
            break;
        }

        gtk_widget_hide(data->connect);
        return ret;
    }
}