forked from blackfiveimaging/library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tabui.cpp
87 lines (65 loc) · 1.59 KB
/
tabui.cpp
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <iostream>
#include <gtk/gtk.h>
#include "config.h"
#include "miscwidgets/uitab.h"
#include "miscwidgets/progressspinner.h"
#include "gettext.h"
#define _(x) gettext(x)
using namespace std;
class UITab;
class TestUI
{
public:
TestUI();
~TestUI();
GtkWidget *window;
GtkWidget *notebook;
protected:
friend class UITab;
};
TestUI::TestUI() : notebook(NULL)
{
window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(window),600,450);
gtk_window_set_title (GTK_WINDOW (window), _("TestUI"));
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
(GtkSignalFunc) gtk_main_quit, NULL);
gtk_widget_show(window);
GtkWidget *hbox=gtk_hbox_new(FALSE,0);
gtk_container_add(GTK_CONTAINER(window),hbox);
gtk_widget_show(hbox);
notebook=gtk_notebook_new();
gtk_notebook_set_scrollable(GTK_NOTEBOOK(notebook),true);
gtk_box_pack_start(GTK_BOX(hbox),notebook,TRUE,TRUE,0);
gtk_widget_show(GTK_WIDGET(notebook));
}
TestUI::~TestUI()
{
}
gboolean timeoutfunc(gpointer userdata)
{
ProgressSpinner *s=(ProgressSpinner *)userdata;
s->DoProgress(0,0);
return(TRUE);
}
int main(int argc,char **argv)
{
gtk_init(&argc,&argv);
try
{
TestUI ui;
ProgressSpinner spinner;
new UITab(ui.notebook,"Tab 1");
(new UITab(ui.notebook))->AddTabWidget(spinner.GetWidget());
(new UITab(ui.notebook))->SetTabText("Tab 2");
(new UITab(ui.notebook))->AddTabButton(gtk_button_new_with_label("Hi!"));
new UITab(ui.notebook);
g_timeout_add(100,timeoutfunc,&spinner);
gtk_main();
}
catch(const char *err)
{
cerr << "Error: " << err << endl;
}
return(0);
}