File: window_line_entry.c

package info (click to toggle)
tenace 0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 1,440 kB
  • ctags: 543
  • sloc: ansic: 5,303; sh: 3,683; makefile: 98
file content (69 lines) | stat: -rw-r--r-- 1,797 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
 *  tenace - bridge hand viewer and editor
 *  Copyright (C) 2005-2007 Christoph Berg <cb@df7cb.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; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  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.
 */

#include <assert.h>

#include "bridge.h"
#include "file.h"
#include "interface.h"
#include "support.h"
#include "window_board.h"
#include "window_card.h"

static GtkWidget *window_line_entry = NULL;
static GtkEntry *line_entry = NULL;

void board_set_from_line_entry(board *b)
{
	assert (window_line_entry);
	const char *line = gtk_entry_get_text(line_entry);
	board_clear(b);
	if (!board_parse_line(line, b, ' ', '.')) {
		board_statusbar(_("Parse error"));
	}
	card_window_update(b->dealt_cards);
	show_board(b, REDRAW_FULL);
}

void line_entry_set_from_board(board *b)
{
	if (!window_line_entry)
		return;

	GString *line = board_format_line(b, ' ', '.');
	gtk_entry_set_text(line_entry, line->str);
	g_string_free(line, TRUE);
}

void window_line_entry_init(board *b)
{
	if (!window_line_entry) {
		window_line_entry = create_window_line_entry ();
		line_entry = GTK_ENTRY(lookup_widget(window_line_entry, "line_entry"));
		gtk_widget_show (window_line_entry);
	}
	if (b)
		line_entry_set_from_board(b);
}

void window_line_entry_delete (board *b)
{
	if (window_line_entry) {
		gtk_widget_destroy (window_line_entry);
		window_line_entry = NULL;
		line_entry = NULL;
	}
}