1 /* todo
2 * implement cget
3 */
4
5 /*
6 History:
7 2013-07: added commands, options, commands
8 2011-04: Begin of developement
9 */
10
11 /**
12 \page page_spinner gnocl::spinner
13 \htmlinclude spinnner.html
14 **/
15
16 #include "gnocl.h"
17
18 static GnoclOption spinnerOptions[] =
19 {
20 /* widget specific options */
21 { "-active", GNOCL_BOOL, "active" },
22
23 /* general options */
24 { "-name", GNOCL_STRING, "name" },
25 { "-visible", GNOCL_BOOL, "visible" },
26 { "-tooltip", GNOCL_OBJ, "", gnoclOptTooltip },
27 { NULL },
28 };
29
30 /**
31 \brief
32 **/
configure(Tcl_Interp * interp,GtkSpinner * spinner,GnoclOption options[])33 static int configure ( Tcl_Interp *interp, GtkSpinner *spinner, GnoclOption options[] )
34 {
35 return TCL_OK;
36 }
37
38 static const char *cmds[] =
39 {
40 "delete", "configure", "class", "start", "stop",
41 NULL
42 };
43
44 /**
45 \brief
46 **/
spinnerFunc(ClientData data,Tcl_Interp * interp,int objc,Tcl_Obj * const objv[])47 int spinnerFunc ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] )
48 {
49
50
51 enum cmdIdx
52 {
53 DeleteIdx, ConfigureIdx, ClassIdx, ParentIdx, StartIdx, StopIdx
54 };
55
56 GtkSpinner *spinner = GTK_SPINNER ( data );
57
58 int idx;
59
60 if ( Tcl_GetIndexFromObj ( interp, objv[1], cmds, "command", TCL_EXACT, &idx ) != TCL_OK )
61 {
62 return TCL_ERROR;
63 }
64
65 switch ( idx )
66 {
67 case StopIdx:
68 {
69 gtk_spinner_stop ( spinner );
70 }
71 break;
72 case ClassIdx:
73 {
74 Tcl_SetObjResult ( interp, Tcl_NewStringObj ( "spinner", -1 ) );
75 }
76 break;
77 case DeleteIdx:
78 {
79 return gnoclDelete ( interp, GTK_WIDGET ( spinner ), objc, objv );
80 }
81 case ConfigureIdx:
82 {
83 int ret = TCL_ERROR;
84
85 if ( gnoclParseAndSetOptions ( interp, objc - 1, objv + 1,
86 spinnerOptions, G_OBJECT ( spinner ) ) == TCL_OK )
87 {
88 ret = configure ( interp, spinner, spinnerOptions );
89 }
90
91 gnoclClearOptions ( spinnerOptions );
92
93 return ret;
94 }
95
96 break;
97 }
98
99 return TCL_OK;
100 }
101
102 /**
103 \brief
104 **/
gnoclSpinnerCmd(ClientData data,Tcl_Interp * interp,int objc,Tcl_Obj * const objv[])105 int gnoclSpinnerCmd ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] )
106 {
107 if ( gnoclGetCmdsAndOpts ( interp, cmds, spinnerOptions, objv, objc ) == TCL_OK )
108 {
109 return TCL_OK;
110 }
111
112
113 int ret;
114 GtkWidget *spinner;
115
116
117 if ( gnoclParseOptions ( interp, objc, objv, spinnerOptions ) != TCL_OK )
118 {
119 gnoclClearOptions ( spinnerOptions );
120 return TCL_ERROR;
121 }
122
123 spinner = gtk_spinner_new ();
124
125 ret = gnoclSetOptions ( interp, spinnerOptions, G_OBJECT ( spinner ), -1 );
126
127 gnoclClearOptions ( spinnerOptions );
128
129 if ( ret != TCL_OK )
130 {
131 gtk_widget_destroy ( GTK_WIDGET ( spinner ) );
132 return TCL_ERROR;
133 }
134
135 /* TODO: if not -visible == 0 */
136 gtk_widget_show ( GTK_WIDGET ( spinner ) );
137
138 return gnoclRegisterWidget ( interp, GTK_WIDGET ( spinner ), spinnerFunc );
139 }
140