1 /* wconfig_start.cc
2 * This file belongs to Worker, a file manager for UN*X/X11.
3 * Copyright (C) 2006-2014 Ralf Hoffmann.
4 * You can contact me at: ralf@boomerangsworld.de
5 * or http://www.boomerangsworld.de/worker
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include "wconfig_start.hh"
23 #include "wconfig.h"
24 #include "worker.h"
25 #include "worker_locale.h"
26 #include "aguix/stringgadget.h"
27 #include "aguix/cyclebutton.h"
28
StartPanel(AWindow & basewin,WConfig & baseconfig)29 StartPanel::StartPanel( AWindow &basewin, WConfig &baseconfig ) : WConfigPanel( basewin, baseconfig )
30 {
31 }
32
~StartPanel()33 StartPanel::~StartPanel()
34 {
35 }
36
create()37 int StartPanel::create()
38 {
39 Panel::create();
40
41 AContainer *ac1 = setContainer( new AContainer( this, 1, 3 ), true );
42 ac1->setBorderWidth( 5 );
43 ac1->setMinSpace( 10 );
44 ac1->setMaxSpace( 10 );
45
46 addMultiLineText( catalog.getLocale( 681 ),
47 *ac1,
48 0, 0,
49 NULL, NULL );
50
51 AContainer *ac1_1 = ac1->add( new AContainer( this, 2, 2 ), 0, 1 );
52 ac1_1->setBorderWidth( 0 );
53 ac1_1->setMinSpace( 5 );
54 ac1_1->setMaxSpace( 5 );
55
56 ac1_1->add( new Text( _aguix, 0, 0, catalog.getLocale( 46 ) ),
57 0, 0, AContainer::CO_FIX );
58
59 sg1 = (StringGadget*)ac1_1->add( new StringGadget( _aguix, 0, 0, 100, _baseconfig.getStartDir( 0 ), 0 ),
60 1, 0, AContainer::CO_INCW );
61
62 ac1_1->add( new Text( _aguix, 0, 0, catalog.getLocale( 47 ) ),
63 0, 1, AContainer::CO_FIX );
64
65 sg2 = (StringGadget*)ac1_1->add( new StringGadget( _aguix, 0, 0, 100, _baseconfig.getStartDir( 1 ), 0 ),
66 1, 1, AContainer::CO_INCW );
67
68 AContainer *ac1_2 = ac1->add( new AContainer( this, 2, 2 ), 0, 2 );
69 ac1_2->setBorderWidth( 0 );
70 ac1_2->setMinSpace( 5 );
71 ac1_2->setMaxSpace( 5 );
72
73 ac1_2->add( new Text( _aguix, 0, 0, catalog.getLocale( 1064 ) ),
74 0, 0, AContainer::CO_FIX );
75
76 m_restore_paths_cycb = ac1_2->addWidget( new CycleButton( _aguix, 0, 0, 50, 0 ),
77 1, 0, AContainer::CO_INCW );
78
79 m_restore_paths_cycb->addOption( catalog.getLocale( 1065 ) );
80 m_restore_paths_cycb->addOption( catalog.getLocale( 1066 ) );
81 m_restore_paths_cycb->addOption( catalog.getLocale( 1067 ) );
82
83 switch ( _baseconfig.getRestoreTabsMode() ) {
84 case WConfig::RESTORE_TABS_ALWAYS:
85 m_restore_paths_cycb->setOption( 1 );
86 break;
87 case WConfig::RESTORE_TABS_ASK:
88 m_restore_paths_cycb->setOption( 2 );
89 break;
90 case WConfig::RESTORE_TABS_NEVER:
91 default:
92 m_restore_paths_cycb->setOption( 0 );
93 break;
94 }
95 m_restore_paths_cycb->resize( m_restore_paths_cycb->getMaxSize(),
96 m_restore_paths_cycb->getHeight() );
97
98 ac1_2->add( new Text( _aguix, 0, 0, catalog.getLocale( 1068 ) ),
99 0, 1, AContainer::CO_FIX );
100
101 m_store_paths_cycb = ac1_2->addWidget( new CycleButton( _aguix, 0, 0, 50, 0 ),
102 1, 1, AContainer::CO_INCW );
103
104 m_store_paths_cycb->addOption( catalog.getLocale( 1069 ) );
105 m_store_paths_cycb->addOption( catalog.getLocale( 1070 ) );
106 m_store_paths_cycb->addOption( catalog.getLocale( 1071 ) );
107 m_store_paths_cycb->addOption( catalog.getLocale( 1072 ) );
108
109 switch ( _baseconfig.getStoreTabsMode() ) {
110 case WConfig::STORE_TABS_ALWAYS:
111 m_store_paths_cycb->setOption( 1 );
112 break;
113 case WConfig::STORE_TABS_AS_EXIT_STATE:
114 m_store_paths_cycb->setOption( 2 );
115 break;
116 case WConfig::STORE_TABS_ASK:
117 m_store_paths_cycb->setOption( 3 );
118 break;
119 case WConfig::STORE_TABS_NEVER:
120 default:
121 m_store_paths_cycb->setOption( 0 );
122 break;
123 }
124 m_store_paths_cycb->resize( m_store_paths_cycb->getMaxSize(),
125 m_store_paths_cycb->getHeight() );
126 ac1_2->readLimits();
127
128 contMaximize( true );
129 return 0;
130 }
131
saveValues()132 int StartPanel::saveValues()
133 {
134 _baseconfig.setStartDir( 0, sg1->getText() );
135 _baseconfig.setStartDir( 1, sg2->getText() );
136
137 switch ( m_restore_paths_cycb->getSelectedOption() ) {
138 case 1:
139 _baseconfig.setRestoreTabsMode( WConfig::RESTORE_TABS_ALWAYS );
140 break;
141 case 2:
142 _baseconfig.setRestoreTabsMode( WConfig::RESTORE_TABS_ASK );
143 break;
144 default:
145 _baseconfig.setRestoreTabsMode( WConfig::RESTORE_TABS_NEVER );
146 break;
147 }
148
149 switch ( m_store_paths_cycb->getSelectedOption() ) {
150 case 1:
151 _baseconfig.setStoreTabsMode( WConfig::STORE_TABS_ALWAYS );
152 break;
153 case 2:
154 _baseconfig.setStoreTabsMode( WConfig::STORE_TABS_AS_EXIT_STATE );
155 break;
156 case 3:
157 _baseconfig.setStoreTabsMode( WConfig::STORE_TABS_ASK );
158 break;
159 default:
160 _baseconfig.setStoreTabsMode( WConfig::STORE_TABS_NEVER );
161 break;
162 }
163
164 return 0;
165 }
166