]> icculus.org git repositories - duncan/yast2-web-wt.git/blob - src/YWebUI_builtins.cc
examples
[duncan/yast2-web-wt.git] / src / YWebUI_builtins.cc
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:         YWebUI_builtins.cc
14
15   Author:       Stefan Hundhammer <sh@suse.de>
16                 Stanislav Visnovsky <visnov@suse.de>
17
18 /-*/
19
20 #include <sys/stat.h>
21 #include <unistd.h>
22
23 #include <ycp/YCPTerm.h>
24 #define y2log_component "web-ui"
25 #include <ycp/y2log.h>
26
27 #include "YWebUI.h"
28 #include "YEvent.h"
29 #include "YUISymbols.h"
30
31 YCPString
32 YWebUI::glyph( const YCPSymbol & glyphSymbol )
33 {
34     string sym = glyphSymbol->symbol();
35     
36     return YCPString( sym );
37     
38     // FIXME:
39 #if 0
40     QChar unicodeChar;
41
42     // Hint: Use 'xfd' to view characters available in the Unicode font.
43
44     if      ( sym == YUIGlyph_ArrowLeft         )       unicodeChar = QChar( 0x2190 );
45     else if ( sym == YUIGlyph_ArrowRight        )       unicodeChar = QChar( 0x2192 );
46     else if ( sym == YUIGlyph_ArrowUp           )       unicodeChar = QChar( 0x2191 );
47     else if ( sym == YUIGlyph_ArrowDown         )       unicodeChar = QChar( 0x2193 );
48     else if ( sym == YUIGlyph_CheckMark         )       unicodeChar = QChar( 0x2714 );
49     else if ( sym == YUIGlyph_BulletArrowRight  )       unicodeChar = QChar( 0x279c );
50     else if ( sym == YUIGlyph_BulletCircle      )       unicodeChar = QChar( 0x274d );
51     else if ( sym == YUIGlyph_BulletSquare      )       unicodeChar = QChar( 0x274f );
52     else return YCPString( "" );
53
54     QString qstr( unicodeChar );
55
56     return YCPString( toUTF8( qstr ) );
57 #endif
58 }
59
60
61 YCPValue YWebUI::runPkgSelection( YWidget * packageSelector )
62 {
63     
64     y2milestone( "Running package selection..." );
65     return YCPVoid();
66 #if 0
67     _wm_close_blocked           = true;
68     _auto_activate_dialogs      = false;
69
70     YCPValue input = YCPVoid();
71
72     try
73     {
74         input = evaluateUserInput();
75     }
76     catch (const std::exception & e)
77     {
78         y2error( "Caught std::exception: %s", e.what() );
79         y2error( "This is a libzypp problem. Do not file a bug against the UI!" );
80     }
81     catch (...)
82     {
83         y2error( "Caught unspecified exception." );
84         y2error( "This is a libzypp problem. Do not file a bug against the UI!" );
85     }
86
87     _auto_activate_dialogs      = true;
88     _wm_close_blocked           = false;
89     y2milestone( "Package selection done - returning %s", input->toString().c_str() );
90
91     return input;
92 #endif
93 }
94
95
96 YCPValue YWebUI::askForExistingDirectory( const YCPString & startDir,
97                                          const YCPString & headline )
98 {
99     return YCPVoid();
100
101 #if 0
102     normalCursor();
103
104     QString dir_name =
105         QFileDialog::getExistingDirectory( fromUTF8( startDir->value() ),
106                                            _main_win,                           // parent
107                                            "dir_selector",                      // name
108                                            fromUTF8( headline->value() ) );     // caption
109     busyCursor();
110
111     if ( dir_name.isEmpty() )   // this includes dir_name.isNull()
112         return YCPVoid();       // nothing selected -> return 'nil'
113
114     return YCPString( toUTF8( dir_name ) );
115 #endif
116 }
117
118
119 YCPValue YWebUI::askForExistingFile( const YCPString & startWith,
120                                    const YCPString & filter,
121                                    const YCPString & headline )
122 {
123     return YCPVoid ();
124 #if 0
125     normalCursor();
126
127     QString file_name =
128         QFileDialog::getOpenFileName( fromUTF8( startWith->value() ),
129                                       fromUTF8( filter->value() ),
130                                       _main_win,                        // parent
131                                       "file_selector",                  // name
132                                       fromUTF8( headline->value() ) );  // caption
133     busyCursor();
134
135     if ( file_name.isEmpty() )  // this includes file_name.isNull()
136         return YCPVoid();       // nothing selected -> return 'nil'
137
138     return YCPString( toUTF8( file_name ) );
139 #endif
140 }
141
142
143 YCPValue YWebUI::askForSaveFileName( const YCPString & startWith,
144                                    const YCPString & filter,
145                                    const YCPString & headline )
146 {
147     return YCPVoid();
148 #if 0
149     normalCursor();
150
151     QString file_name = askForSaveFileName( fromUTF8( startWith->value() ),
152                                             fromUTF8( filter->value() ),
153                                             fromUTF8( headline->value() ) );
154     busyCursor();
155
156     if ( file_name.isEmpty() )          // this includes file_name.isNull()
157         return YCPVoid();               // nothing selected -> return 'nil'
158
159     return YCPString( toUTF8( file_name ) );
160 #endif
161 }
162
163
164
165
166 // EOF