changeset 18510:f104e1d45d85

Changes to the test apps.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Fri, 13 Jul 2007 01:30:08 +0000
parents c96a0d4a84e2
children 7ee0e0597a26
files finch/libgnt/test/combo.c finch/libgnt/test/file.c finch/libgnt/test/key.c finch/libgnt/test/menu.c finch/libgnt/test/multiwin.c finch/libgnt/test/tv.c
diffstat 6 files changed, 70 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/finch/libgnt/test/combo.c	Fri Jul 13 01:27:31 2007 +0000
+++ b/finch/libgnt/test/combo.c	Fri Jul 13 01:30:08 2007 +0000
@@ -3,7 +3,9 @@
 #include <gntbutton.h>
 #include <gntcheckbox.h>
 #include <gntcombobox.h>
+#include <gntentry.h>
 #include <gntlabel.h>
+#include <gntslider.h>
 
 static void
 button_activated(GntWidget *b, GntComboBox *combo)
@@ -16,6 +18,16 @@
 	gnt_box_readjust(GNT_BOX(w->parent));
 }
 
+static void
+update_label(GntSlider *slider, int current_value, GntEntry *entry)
+{
+	char value[256];
+	g_snprintf(value, sizeof(value), "%d/%d", current_value, slider->max);
+	/*gnt_label_set_text(label, value);*/
+	/*gnt_widget_draw(GNT_WIDGET(label));*/
+	gnt_entry_set_text(entry, value);
+}
+
 int main()
 {
 	GntWidget *box, *combo, *button;
@@ -69,8 +81,19 @@
 
 	gnt_box_add_widget(GNT_BOX(box), gnt_check_box_new("check box"));
 
+	GntWidget *e = gnt_entry_new(NULL);
+	gnt_box_add_widget(GNT_BOX(box), e);
+
+	GntWidget *slider = gnt_slider_new(TRUE, 0, 100);
+	gnt_slider_set_value(GNT_SLIDER(slider), 50);
+	gnt_box_add_widget(GNT_BOX(box), slider);
+	g_signal_connect(G_OBJECT(slider), "changed", G_CALLBACK(update_label), e);
+	gnt_slider_reflect_label(GNT_SLIDER(slider), GNT_LABEL(l));
+
 	gnt_widget_show(box);
 
+	gnt_widget_show(gnt_file_sel_new());
+
 #ifdef STANDALONE
 	gnt_main();
 
--- a/finch/libgnt/test/file.c	Fri Jul 13 01:27:31 2007 +0000
+++ b/finch/libgnt/test/file.c	Fri Jul 13 01:30:08 2007 +0000
@@ -1,9 +1,16 @@
 #include "gnt.h"
 #include "gntfilesel.h"
 
+static void
+file_selected(GntFileSel *sel, const char *path, const char *filename)
+{
+	g_printerr("%s %s\n", path, filename);
+}
+
 int main()
 {
 	freopen(".error", "w", stderr);
+	fprintf(stdout, "\x1b]1;\x07\x1b]2;TEST\x07");
 	gnt_init();
 
 	GntWidget *w = gnt_file_sel_new();
@@ -12,6 +19,8 @@
 	gnt_file_sel_set_multi_select(GNT_FILE_SEL(w), TRUE);
 	gnt_widget_show(w);
 
+	g_signal_connect(G_OBJECT(w), "file_selected", G_CALLBACK(file_selected), NULL);
+
 	gnt_main();
 
 	gnt_quit();
--- a/finch/libgnt/test/key.c	Fri Jul 13 01:27:31 2007 +0000
+++ b/finch/libgnt/test/key.c	Fri Jul 13 01:30:08 2007 +0000
@@ -3,9 +3,16 @@
 int main()
 {
 	int ch;
-	initscr();
 
+	initscr();
 	noecho();
+	cbreak();
+	refresh();
+
+	WINDOW *win = newpad(20, 30);
+	box(win, 0, 0);
+	prefresh(win, 0, 0, 0, 0, 19, 29);
+	doupdate();
 
 	while ((ch = getch())) {
 		printw("%d ", ch);
--- a/finch/libgnt/test/menu.c	Fri Jul 13 01:27:31 2007 +0000
+++ b/finch/libgnt/test/menu.c	Fri Jul 13 01:30:08 2007 +0000
@@ -33,16 +33,23 @@
 	GntWidget *sub = gnt_menu_new(GNT_MENU_POPUP);
 	gnt_menuitem_set_submenu(GNT_MENU_ITEM(item), GNT_MENU(sub));
 
+	item = gnt_menuitem_new("Online Helpasd");
+	gnt_menuitem_set_trigger(GNT_MENU_ITEM(item), 'h');
+	gnt_menu_add_item(GNT_MENU(sub), GNT_MENU_ITEM(item));
+
 	item = gnt_menuitem_new("Online Help");
+	gnt_menuitem_set_trigger(GNT_MENU_ITEM(item), 'h');
 	gnt_menu_add_item(GNT_MENU(sub), GNT_MENU_ITEM(item));
 
 	item = gnt_menuitem_new("About");
+	gnt_menuitem_set_trigger(GNT_MENU_ITEM(item), 'a');
 	gnt_menu_add_item(GNT_MENU(sub), GNT_MENU_ITEM(item));
 
 	sub = gnt_menu_new(GNT_MENU_POPUP);
 	gnt_menuitem_set_submenu(GNT_MENU_ITEM(item), GNT_MENU(sub));
 
 	item = gnt_menuitem_new("Online Help");
+	gnt_menuitem_set_trigger(GNT_MENU_ITEM(item), 'O');
 	gnt_menu_add_item(GNT_MENU(sub), GNT_MENU_ITEM(item));
 	gnt_menuitem_set_callback(GNT_MENU_ITEM(item), dothis, NULL);
 
--- a/finch/libgnt/test/multiwin.c	Fri Jul 13 01:27:31 2007 +0000
+++ b/finch/libgnt/test/multiwin.c	Fri Jul 13 01:30:08 2007 +0000
@@ -62,6 +62,8 @@
 
 	gnt_tree_add_row_after(GNT_TREE(tree), "6", gnt_tree_create_row(GNT_TREE(tree), "6", " long text", "a2"), "4", NULL);
 
+	gnt_tree_add_row_after(GNT_TREE(tree), NULL, gnt_tree_create_separator(GNT_TREE(tree)), NULL, "c");
+
 	int i;
 	for (i = 110; i < 430; i++)
 	{
--- a/finch/libgnt/test/tv.c	Fri Jul 13 01:27:31 2007 +0000
+++ b/finch/libgnt/test/tv.c	Fri Jul 13 01:30:08 2007 +0000
@@ -23,6 +23,17 @@
 
 		return TRUE;
 	}
+    else if (strcmp(key, "\033" "e") == 0)
+    {
+        if (fork() == 0) {
+            endwin();
+            printf("%s\n", GNT_TEXT_VIEW(view)->string->str);
+            fflush(stdout);
+            getch();
+            refresh();
+            exit(0);
+        }
+    }
 	else if (key[0] == 27)
 	{
 		if (strcmp(key, GNT_KEY_UP) == 0)
@@ -37,6 +48,13 @@
 	return FALSE;
 }
 
+static void
+completion_cb(GntEntry *entry, const char *start, const char *end)
+{
+	if (start == entry->start)
+		gnt_widget_key_pressed(GNT_WIDGET(entry), ": ");
+}
+
 int main()
 {
 	GntWidget *hbox, *entry, *view;
@@ -58,6 +76,8 @@
 	gnt_widget_set_name(entry, "entry");
 	GNT_WIDGET_SET_FLAGS(entry, GNT_WIDGET_CAN_TAKE_FOCUS);
 
+	g_signal_connect(G_OBJECT(entry), "completion", G_CALLBACK(completion_cb), NULL);
+
 	gnt_entry_set_word_suggest(GNT_ENTRY(entry), TRUE);
 	gnt_entry_set_always_suggest(GNT_ENTRY(entry), FALSE);
 	gnt_entry_add_suggest(GNT_ENTRY(entry), "a");
@@ -81,6 +101,7 @@
 	gnt_widget_show(hbox);
 
 	gnt_entry_set_history_length(GNT_ENTRY(entry), -1);
+	gnt_text_view_attach_pager_widget(GNT_TEXT_VIEW(view), entry);
 	g_signal_connect_after(G_OBJECT(entry), "key_pressed", G_CALLBACK(key_pressed), view);
 
 	gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(view), "\n", GNT_TEXT_FLAG_NORMAL);