Browse Source

initial commit

master
Olaf Rempel 11 years ago
commit
329a0ebf46
6 changed files with 176 additions and 0 deletions
  1. +3
    -0
      .gitignore
  2. +24
    -0
      Makefile
  3. +26
    -0
      control_tab.c
  4. +37
    -0
      graph_tab.c
  5. +32
    -0
      gtdc.c
  6. +54
    -0
      variable_tab.c

+ 3
- 0
.gitignore View File

@@ -0,0 +1,3 @@
*.o
*.d
gtdc

+ 24
- 0
Makefile View File

@@ -0,0 +1,24 @@
TARGET = gtdc

CFLAGS = -Wall -O2 -MD -MP -MF $(*F).d
LDFLAGS = $(shell pkg-config --libs gtk+-2.0 gtkdatabox)
CFLAGS += $(shell pkg-config --cflags gtk+-2.0 gtkdatabox)

# ------

SRC := $(wildcard *.c)

all: $(TARGET)

$(TARGET): $(SRC:.c=.o)
@echo " Linking file: $@"
@$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) > /dev/null

%.o: %.c
@echo " Building file: $<"
@$(CC) -c $(CFLAGS) $< -o $@

clean:
rm -rf $(TARGET) *.o *.d

-include $(shell find -name *.d 2> /dev/null)

+ 26
- 0
control_tab.c View File

@@ -0,0 +1,26 @@
#include <gtk/gtk.h>

static gboolean connected = FALSE;

static void connect_cb(GtkWidget *widget, gpointer data)
{
connected = !connected;

if (connected)
gtk_button_set_label(GTK_BUTTON(widget), "Disconnect");
else
gtk_button_set_label(GTK_BUTTON(widget), "Connect");
}

gint control_tab_init(GtkNotebook *notebook)
{
GtkWidget *table = gtk_table_new(10, 10, FALSE);
gtk_container_set_border_width(GTK_CONTAINER(table), 10);

GtkWidget *button = gtk_button_new_with_label("Connect");
gtk_table_attach(GTK_TABLE(table), button, 0, 1, 0, 1, 0, 0, 10, 10);
g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(connect_cb), NULL);

GtkWidget *label = gtk_label_new(" Control ");
return gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table, label);
}

+ 37
- 0
graph_tab.c View File

@@ -0,0 +1,37 @@
#include <gtk/gtk.h>
#include <gtkdatabox.h>

gint graph_tab_init(GtkNotebook *notebook)
{
GtkWidget *table = gtk_table_new(3, 3, FALSE);
GtkWidget *box = gtk_databox_new();
gtk_table_attach(GTK_TABLE(table), box, 1, 2, 1, 2,
GTK_FILL | GTK_EXPAND | GTK_SHRINK,
GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0);

GtkWidget *scrollbar = gtk_hscrollbar_new(gtk_databox_get_hadjustment(GTK_DATABOX(box)));
gtk_table_attach(GTK_TABLE(table), scrollbar, 1, 2, 2, 3,
GTK_FILL | GTK_EXPAND | GTK_SHRINK,
GTK_FILL, 0, 0);

scrollbar = gtk_vscrollbar_new(gtk_databox_get_vadjustment(GTK_DATABOX(box)));
gtk_table_attach(GTK_TABLE(table), scrollbar, 2, 3, 1, 2,
GTK_FILL,
GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0);

GtkWidget *ruler = gtk_hruler_new();
gtk_table_attach(GTK_TABLE(table), ruler, 1, 2, 0, 1,
GTK_FILL | GTK_EXPAND | GTK_SHRINK,
GTK_FILL, 0, 0);
gtk_databox_set_hruler(GTK_DATABOX(box), GTK_RULER(ruler));

ruler = gtk_vruler_new();
gtk_table_attach (GTK_TABLE (table), ruler, 0, 1, 1, 2,
GTK_FILL,
GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 0);
gtk_databox_set_vruler(GTK_DATABOX(box), GTK_RULER(ruler));


GtkWidget *label = gtk_label_new(" Graph ");
return gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table, label);
}

+ 32
- 0
gtdc.c View File

@@ -0,0 +1,32 @@
#include <stdio.h>
#include <gtk/gtk.h>

gint control_tab_init(GtkNotebook *notebook);
gint variable_tab_init(GtkNotebook *notebook);
gint graph_tab_init(GtkNotebook *notebook);

int main(int argc, char *argv[])
{
gtk_init (&argc, &argv);

GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), " gTDC v0.1 ");
gtk_window_set_default_size(GTK_WINDOW(window), 800, 600);
gtk_container_set_border_width(GTK_CONTAINER(window), 10);

g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(gtk_main_quit), NULL);

GtkWidget *notebook = gtk_notebook_new();
gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_TOP);
gtk_container_add(GTK_CONTAINER(window), notebook);

control_tab_init(GTK_NOTEBOOK(notebook));
variable_tab_init(GTK_NOTEBOOK(notebook));
graph_tab_init(GTK_NOTEBOOK(notebook));

gtk_widget_show_all(window);
gtk_main();

return 0;
}

+ 54
- 0
variable_tab.c View File

@@ -0,0 +1,54 @@
#include <gtk/gtk.h>

enum {
COL_GRAPH = 0,
COL_VALUE,
COL_TYPE,
COL_NAME,
};

gint variable_tab_init(GtkNotebook *notebook)
{
/* graph, value, type, name */
GtkListStore *list_store = gtk_list_store_new(1,
G_TYPE_BOOLEAN, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING);

GtkWidget *view = gtk_tree_view_new();
gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(list_store));
g_object_unref(list_store);

GtkTreeViewColumn *col;
GtkCellRenderer *renderer;

col = gtk_tree_view_column_new();
gtk_tree_view_column_set_title(col, "Graph");
gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
renderer = gtk_cell_renderer_toggle_new();
gtk_tree_view_column_pack_start(col, renderer, TRUE);
gtk_tree_view_column_add_attribute(col, renderer, "active", COL_GRAPH);

col = gtk_tree_view_column_new();
gtk_tree_view_column_set_title(col, "Value");
gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
renderer = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(col, renderer, TRUE);
gtk_tree_view_column_add_attribute(col, renderer, "text", COL_VALUE);

col = gtk_tree_view_column_new();
gtk_tree_view_column_set_title(col, "Type");
gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
renderer = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(col, renderer, TRUE);
gtk_tree_view_column_add_attribute(col, renderer, "text", COL_TYPE);

col = gtk_tree_view_column_new();
gtk_tree_view_column_set_title(col, "Name");
gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
renderer = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(col, renderer, TRUE);
gtk_tree_view_column_add_attribute(col, renderer, "text", COL_NAME);

GtkWidget *label = gtk_label_new(" Variables ");
return gtk_notebook_append_page(GTK_NOTEBOOK(notebook), view, label);
}

Loading…
Cancel
Save