~dcaro/clicompanion/fix-801906

« back to all changes in this revision

Viewing changes to clicompanionlib/view.py

  • Committer: duanedesign
  • Date: 2011-03-24 16:31:52 UTC
  • mfrom: (66.1.8 clicompanion)
  • Revision ID: duanedesign@gmail.com-20110324163152-zpr79z0oy9hw9glz
[MERGE] lp:~bdfhjk/clicompanion/bdfhjk Adds show/hide UI and hides tabs when not in use. fixes lp:739488 lp:740182

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
    ('TEXT', 0, 2),
62
62
    ('STRING', 0, 3),
63
63
    ]
 
64
 
64
65
FILTER = 0
65
66
NETBOOKMODE = 0
 
67
HIDEUI = 0
 
68
FULLSCREEN = 0
 
69
 
 
70
treeview = ''
 
71
expander = ''
 
72
scrolledwindow = ''
 
73
notebook = ''
 
74
menu_search_hbox = ''
 
75
button_box = ''
66
76
 
67
77
 
68
78
class MainWindow():
131
141
    def delete_event(self, widget,  data=None):
132
142
        gtk.main_quit()
133
143
        return False
 
144
        
 
145
    def key_clicked(self, widget, event):
 
146
        global HIDEUI
 
147
        global FULLSCREEN
 
148
        global treeview
 
149
        global expander
 
150
        global scrolledwindow
 
151
        global notebook
 
152
        global menu_search_hbox
 
153
        global button_box
 
154
        keyname = gtk.gdk.keyval_name(event.keyval).upper()
 
155
        #print keyname ##debug
 
156
        if keyname == "F12":
 
157
            HIDEUI = 1 - HIDEUI
 
158
        if HIDEUI == 1:
 
159
            treeview.hide_all()
 
160
            expander.hide_all()
 
161
            scrolledwindow.hide_all()
 
162
            menu_search_hbox.hide_all()
 
163
            button_box.hide_all()
 
164
        else:
 
165
            treeview.show_all()
 
166
            expander.show_all()
 
167
            scrolledwindow.show_all()
 
168
            menu_search_hbox.show_all()
 
169
            button_box.show_all()
 
170
        if keyname == "F11":
 
171
            FULLSCREEN = 1 - FULLSCREEN
 
172
        if FULLSCREEN == 1:
 
173
            pwin = button_box.get_window()
 
174
            pwin.fullscreen()
 
175
        else: 
 
176
            pwin = button_box.get_window()
 
177
            pwin.unfullscreen()
134
178
  
135
179
    def __init__(self):
136
180
        #import pdb  ##debug
160
204
                     "widget \"*.tab-close-button\" style \"tab-close-button-style\"");
161
205
        
162
206
        ## Create UI widgets
163
 
        window = gtk.Window(gtk.WINDOW_TOPLEVEL)
164
 
 
 
207
        window = gtk.Window(gtk.WINDOW_TOPLEVEL)        
 
208
        global treeview
 
209
        global expander
 
210
        global scrolledwindow
 
211
        global notebook
165
212
        treeview = gtk.TreeView()
166
213
        expander = gtk.Expander()
167
214
        scrolledwindow = gtk.ScrolledWindow()
168
215
        notebook = gtk.Notebook()
 
216
        notebook.set_show_tabs(0)
169
217
 
170
218
        ##attach the style to the widget
171
219
        notebook.set_name ("tab-close-button")
248
296
                if keyname == 'RETURN':
249
297
                    actions.run_command(self, notebook, self.liststore)
250
298
                    
 
299
                    
251
300
 
252
301
        selection = treeview.get_selection()
253
302
        #selection.set_mode(gtk.SELECTION_SINGLE)
265
314
        treeview.connect("drag_data_get", actions.drag_data_get_data)
266
315
        treeview.connect("drag_data_received", actions.drag_data_received_data)
267
316
        
 
317
        global menu_search_hbox
 
318
        
268
319
        ## The search section
269
320
        search_label = gtk.Label(_("Search:"))
270
321
        search_label.set_alignment(xalign=-1, yalign=0)
305
356
        ## create first tab
306
357
        notebook.append_page(gtk.Label(""), add_tab_button)
307
358
        
 
359
        global button_box
308
360
        ## buttons at bottom of main window [menus_buttons.py]
309
361
        button_box = bar.buttons(actions, 10, gtk.BUTTONBOX_END, notebook, self.liststore)
310
362
 
321
373
        ## signals
322
374
        expander.connect('notify::expanded', self.expanded_cb, window, self.search_box)
323
375
        window.connect("delete_event", self.delete_event)
 
376
        window.connect("key-press-event", self.key_clicked)
324
377
        add_tab_button.connect("clicked", tabs.add_tab, notebook)
325
378
        ## right click menu event capture
326
379
        treeview.connect ("button_press_event", bar.right_click, actions, treeview, notebook, self.liststore)