gtk2 sam7fc telemetrie application
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.7KB

  1. /***************************************************************************
  2. * Copyright (C) 04/2008 by Olaf Rempel *
  3. * razzor@kopf-tisch.de *
  4. * *
  5. * This program is free software; you can redistribute it and/or modify *
  6. * it under the terms of the GNU General Public License as published by *
  7. * the Free Software Foundation; version 2 of the License *
  8. * *
  9. * This program is distributed in the hope that it will be useful, *
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  12. * GNU General Public License for more details. *
  13. * *
  14. * You should have received a copy of the GNU General Public License *
  15. * along with this program; if not, write to the *
  16. * Free Software Foundation, Inc., *
  17. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  18. ***************************************************************************/
  19. #include <gtk/gtk.h>
  20. #include "tdc_parser.h"
  21. static GtkWidget *button_connect;
  22. static int connect_status = STAT_DISCONNECTED;
  23. static void connect_button_update(int status)
  24. {
  25. connect_status = status;
  26. if (status == STAT_DISCONNECTED)
  27. gtk_button_set_label(GTK_BUTTON(button_connect), "Connect");
  28. else
  29. gtk_button_set_label(GTK_BUTTON(button_connect), "Disconnect");
  30. }
  31. static void connect_button_cb(GtkWidget *widget, gpointer data)
  32. {
  33. switch (connect_status) {
  34. case STAT_DISCONNECTED:
  35. tdcparser_connect("127.0.0.1:5000", connect_button_update);
  36. break;
  37. case STAT_CONNECTING:
  38. case STAT_CONNECTED:
  39. tdcparser_disconnect();
  40. break;
  41. }
  42. }
  43. gint gui_ctrltab_init(GtkNotebook *notebook)
  44. {
  45. GtkWidget *table = gtk_table_new(10, 10, FALSE);
  46. gtk_container_set_border_width(GTK_CONTAINER(table), 10);
  47. button_connect = gtk_button_new_with_label("Connect");
  48. gtk_table_attach(GTK_TABLE(table), button_connect, 0, 1, 0, 1, 0, 0, 10, 10);
  49. g_signal_connect(G_OBJECT(button_connect), "clicked", G_CALLBACK(connect_button_cb), NULL);
  50. /*
  51. * TODO:
  52. * - address field
  53. * - all_variable_refresh_timer
  54. * - graph_variable_refresh_timer
  55. * later:
  56. * - board select
  57. * - connection/protocol details/errors
  58. */
  59. GtkWidget *label = gtk_label_new(" Control ");
  60. return gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table, label);
  61. }