/*************************************************************************** * Copyright (C) 04/2008 by Olaf Rempel * * razzor@kopf-tisch.de * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; version 2 of the License * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include #include "tdc_parser.h" static GtkWidget *button_connect; static int connect_status = STAT_DISCONNECTED; static void connect_button_update(int status) { connect_status = status; if (status == STAT_DISCONNECTED) gtk_button_set_label(GTK_BUTTON(button_connect), "Connect"); else gtk_button_set_label(GTK_BUTTON(button_connect), "Disconnect"); } static void connect_button_cb(GtkWidget *widget, gpointer data) { switch (connect_status) { case STAT_DISCONNECTED: tdcparser_connect("127.0.0.1:5000", connect_button_update); break; case STAT_CONNECTING: case STAT_CONNECTED: tdcparser_disconnect(); break; } } gint gui_ctrltab_init(GtkNotebook *notebook) { GtkWidget *table = gtk_table_new(10, 10, FALSE); gtk_container_set_border_width(GTK_CONTAINER(table), 10); button_connect = gtk_button_new_with_label("Connect"); gtk_table_attach(GTK_TABLE(table), button_connect, 0, 1, 0, 1, 0, 0, 10, 10); g_signal_connect(G_OBJECT(button_connect), "clicked", G_CALLBACK(connect_button_cb), NULL); /* * TODO: * - address field * - all_variable_refresh_timer * - graph_variable_refresh_timer * later: * - board select * - connection/protocol details/errors */ GtkWidget *label = gtk_label_new(" Control "); return gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table, label); }