def __init__(self, conf, ind): gtk.Frame.__init__(self) self.conf = conf self.ind = ind self.set_border_width(5) framebox = gtk.VBox(False, 0) framebox.set_border_width(5) framebox.set_spacing(10) self.add(framebox) BoxListControls = gtk.VBox(False,0) # ListStore self.view = View() self.app_menu = ui.Menu(self.new_item_menu) if ind in self.conf.drawer: self.view.add_list(self.conf.drawer[ind]) self.view.connect("row-activated", self.edit_item) scrolled = gtk.ScrolledWindow() scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled.add(self.view) frame = gtk.Frame() frame.add(scrolled) #~ # Add from menu button = Core.image_button(BarConf._('add from menu'), 'images/conf/add_app.png', 24) button.connect("clicked", self.popup_menu) BoxListControls.pack_start(button, False, False) ## Control buttons for list # Add Launcher button = Core.image_button(BarConf._('add custom launcher'), 'images/conf/add_custom.png', 24) button.connect("clicked", self.new_item_custom) BoxListControls.pack_start(button, False, False) # Remove button = Core.image_button(BarConf._('remove'), 'images/conf/remove.png', 24) button.connect("clicked", self.remove_item) BoxListControls.pack_end(button, False, False) box = gtk.HBox() box.pack_start(BoxListControls, False, False) box.pack_start(frame, True) framebox.pack_start(box, True)
def add_to_nbook(self): app_sort = [] for category in self.applications: app_sort.append(category) app_sort.sort() for category in app_sort: box = self.make_tab_box(category, self.applications[category][0]) for app in self.applications[category][1]: if DEBUG: txt_label = app.Name + '\n' + app.Exec else: txt_label = app.Name if app.Comment == '' or app.Comment == ' ': comment = '--' elif len(app.Comment) > 50: comment = app.Comment[:50] + '..' else: comment = app.Comment txt_label += '\n<small>' + comment + '</small>' button = Core.image_button(txt_label, app.Icon, 24) button.connect("button-release-event", self.executeAction, app) box.pack_start(button, False, False)
def __init__(self, box, conf, ind): self.conf = conf self.ind = ind BoxListControls = gtk.VBox(False, 0) # ListStore self.view = View() self.app_menu = ui.Menu(self.new_item_menu) if ind in self.conf.drawer: self.view.add_list(self.conf.drawer[ind]) self.view.connect("row-activated", self.edit_item) scrolled = gtk.ScrolledWindow() scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled.add(self.view) frame = gtk.Frame() frame.add(scrolled) #~ # Add from menu button = Core.image_button(BarConf._('add from menu'), 'images/conf/add_app.png', 24) button.connect("clicked", self.popup_menu) BoxListControls.pack_start(button, False, False) ## Control buttons for list # Add Launcher button = Core.image_button(BarConf._('add custom launcher'), 'images/conf/add_custom.png', 24) button.connect("clicked", self.new_item_custom) BoxListControls.pack_start(button, False, False) # Remove button = Core.image_button(BarConf._('remove'), 'images/conf/remove.png', 24) button.connect("clicked", self.remove_item) BoxListControls.pack_end(button, False, False) hbox = gtk.HBox() hbox.pack_start(BoxListControls, False, False) hbox.pack_start(frame, True) box.pack_start(hbox, True)
def create_session_button(self): for key in mail.keys(): label = (mail[key][1].ljust(80-len(mail[key][0]))+mail[key][0]).rjust(80) button = Core.image_button(label, 'mail-unread', int(self.plugin.settings['icon_size'])) button.connect("button-release-event", self.onClicked, self.plugin.settings['exec_cmd']) self.box.pack_start(button, False) self.buttons.append(button) self.box.show_all()
def create_drawer_button(self): for launcher in self.plugin.settings['launcher']: (cmd, icon, name) = launcher image = gtk.Image() Core.set_icon(icon, image, size=24) button = Core.image_button(name, image, 24) button.connect("button-release-event", self.onClicked, cmd) self.box.pack_start(button) self.buttons.append(button) self.set_size_request(200,-1) self.box.show_all()
def make_tab_box(self, label, icon): box = gtk.VBox() box.show() box.set_spacing(1) box.set_border_width(1) scrolled = gtk.ScrolledWindow() scrolled.show() scrolled.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) scrolled.add_with_viewport(box) ind = self.nbook.append_page(scrolled, None) if self.plugin.settings['show_label'] in ('False','false','0', 0): button = Core.image_button(None, icon, 24) else: button = Core.image_button(label, icon, 24) button.connect("button-release-event", self.mouse_over, ind) button.connect("enter-notify-event", self.mouse_over, ind) self.catbox.pack_start(button, False, False) return box
def restart(self): if self.nbook is not None: self.nbook.destroy() self.catbox.destroy() self.nbook = gtk.Notebook() self.nbook.set_show_tabs(False) self.nbook.set_border_width(0) self.nbook.show() self.catbox = gtk.VBox() self.catbox.show() self.catbox.set_spacing(1) self.catbox.set_border_width(1) self.catbox.show() self.mainbox.pack_start(self.catbox, False, False) self.mainbox.pack_start(self.nbook, False, False) self.create_menu() self.catbox.get_children()[0].set_relief(gtk.RELIEF_HALF) if self.entry: for child in self.entrybox.get_children(): child.destroy() self.entry = None if self.settings['run']: self.fl = FileListing(PATH) self.entry = gtk.Entry() self.entry.show() #~ self.entry.set_max_length(150) self.entry.set_width_chars(45) completion = gtk.EntryCompletion() self.entry.set_completion(completion) completion_model = self.create_completion_model() completion.set_model(completion_model) completion.set_text_column(0) self.entry.connect("activate", self.enter_callback) btn = Core.image_button(None, 'images/plugins/run.png', 24) btn.connect("clicked", self.enter_callback) btn.set_focus_on_click(False) self.entrybox.pack_start(self.entry, True, True) self.entrybox.pack_start(btn, False, False)
def create_drawer_button(self): if not self.plugin.index in self.bar.drawer: return for launcher in self.bar.drawer[self.plugin.index]: (cmd, icon, name) = launcher image = gtk.Image() Core.set_icon(icon, image, size=24) button = Core.image_button(name, image, 24) button.connect("button-release-event", self.onClicked, cmd) self.box.pack_start(button) self.buttons.append(button) self.set_size_request(200,-1) self.box.show_all()
def create_session_button(self): for action in ('lockscreen','logout','hibernate','suspend', 'reboot','shutdown'): if not self.plugin.settings[action] == '': if self.plugin.settings['show_label']: label = '<b>%s</b>\n<small>%s</small>' % (session[action][0], session[action][1]) button = Core.image_button(label, session[action][2], self.plugin.settings['icon_size']) else: button = gtk.Button() button.set_relief(gtk.RELIEF_NONE) img = gtk.Image() pixbuf = Core.get_pixbuf_icon(session[action][2], self.plugin.settings['icon_size']) img.set_from_pixbuf(pixbuf) button.add(img) button.connect("button-release-event", self.onClicked, self.plugin.settings[action]) self.box.pack_start(button, False) self.buttons.append(button) self.box.show_all()
def add_to_nbook(self): app_sort = [] for category in self.applications: app_sort.append(category) app_sort.sort() for category in app_sort: box = self.make_tab_box(category, self.applications[category][0]) for app in self.applications[category][1]: if DEBUG: txt_label = app[0] + '\n' + app[2] else: txt_label = app[0] if app[3] is not None: txt_label += '\n<small>' + app[3] + '</small>' button = Core.image_button(txt_label, app[1], 24) #~ button.set_tooltip_text(app.get_comment()) button.connect("button-release-event", self.executeAction, app) box.pack_start(button, False, False)
def __init__(self, plugin, bar): UI.PopupWindow.__init__(self, bar, plugin) self.connect ("key-press-event", self.on_key_press_event) box = gtk.HBox(False, 4) box.set_border_width(2) self.add(box) self.entry = gtk.Entry() self.entry.x_done = False self.entry.set_name("TextBox") self.entry.set_width_chars(25) self.entry.connect("button-press-event", self.manage_click) self.entry.connect("activate", self.go) box.pack_start(self.entry, True) btn = Core.image_button(None, 'images/plugins/searchbox.png', 24) btn.connect("clicked", self.go) btn.set_focus_on_click(False) box.pack_end(btn, False) box.show_all()
def __init__(self, plugin, bar): UI.PopupWindow.__init__(self, bar, plugin) self.connect("key-press-event", self.on_key_press_event) box = gtk.HBox(False, 4) box.set_border_width(2) self.add(box) self.entry = gtk.Entry() self.entry.x_done = False self.entry.set_name("TextBox") self.entry.set_width_chars(25) self.entry.connect("button-press-event", self.manage_click) self.entry.connect("activate", self.go) box.pack_start(self.entry, True) btn = Core.image_button(None, 'images/plugins/searchbox.png', 24) btn.connect("clicked", self.go) btn.set_focus_on_click(False) box.pack_end(btn, False) box.show_all()
def create_session_button(self): for action in ('lockscreen', 'logout', 'reboot', 'shutdown', 'hibernate', 'suspend'): if not self.plugin.settings[action] == '': if self.plugin.settings['show_label']: label = '<b>%s</b>\n<small>%s</small>' % ( session[action][0], session[action][1]) pixbuf = Core.get_pixbuf_icon( session[action][2], self.plugin.settings['icon_size']) if pixbuf == None: pixbuf = Core.pixbuf_from_file( 'images/plugins/session/' + session[action][2] + '.png', self.plugin.settings['icon_size'], self.plugin.settings['icon_size']) button = Core.image_button( label, pixbuf, self.plugin.settings['icon_size']) else: button = gtk.Button() button.set_relief(gtk.RELIEF_NONE) img = gtk.Image() pixbuf = Core.get_pixbuf_icon( session[action][2], self.plugin.settings['icon_size']) if pixbuf == None: pixbuf = Core.pixbuf_from_file( 'images/plugins/session/' + session[action][2] + '.png', self.plugin.settings['icon_size'], self.plugin.settings['icon_size']) img.set_from_pixbuf(pixbuf) button.add(img) button.connect("button-release-event", self.onClicked, self.plugin.settings[action]) self.box.pack_start(button, False) self.buttons.append(button) self.box.show_all()
class config(): def __init__(self, box, conf, ind): self.conf = conf self.ind = ind framebox = gtk.VBox(False, 0) framebox.set_border_width(5) framebox.set_spacing(10) box.pack_start(framebox) for key in settings: if not key in conf.launcher[ind]: conf.launcher[ind][key] = settings[key] self.settings = conf.launcher[ind] # make new array from string # because when you save the array, it looks like a string: [{'text':'\xd0\xa3\xd0\xa0\xd0\x90'}] # but when the load value, adeskbar takes it as a string type alarmlist_dict = {} alarmlist_str = self.settings['alarmlist'] settings['alarmlist'] = [] if str(alarmlist_str) != '[]': q = [] try: q = alarmlist_str[2:-2].split("}, {") except Exception, e: q.append(alarmlist_str[2:-2]) for a in q: paras = a[1:-1].split("', '") for line in paras: k, v = line.split("': '") alarmlist_dict[k] = v settings['alarmlist'].append(alarmlist_dict) alarmlist_dict = {} table = gtk.Table(4, 2, False) label = gtk.Label(_("Time :")) label.set_alignment(0, 0.5) self.time_format = gtk.Entry() self.time_format.set_width_chars(10) self.time_format.set_text(self.settings['time']) map = label.get_colormap() colour = map.alloc_color(self.settings['time_color']) self.time_color = gtk.ColorButton(colour) self.time_font = gtk.FontButton(self.settings['time_font']) table.attach(label, 0, 1, 0, 1) table.attach(self.time_format, 1, 2, 0, 1) table.attach(self.time_color, 2, 3, 0, 1) table.attach(self.time_font, 3, 4, 0, 1) label = gtk.Label(_("Date :")) label.set_alignment(0, 0.5) self.date_format = gtk.Entry() self.date_format.set_width_chars(10) self.date_format.set_text(self.settings['date']) colour = map.alloc_color(self.settings['date_color']) self.date_color = gtk.ColorButton(colour) self.date_font = gtk.FontButton(self.settings['date_font']) table.attach(label, 0, 1, 1, 2) table.attach(self.date_format, 1, 2, 1, 2) table.attach(self.date_color, 2, 3, 1, 2) table.attach(self.date_font, 3, 4, 1, 2) label = gtk.Label(_("Tooltip :")) label.set_alignment(0, 0.5) self.tooltip_format = gtk.Entry() self.tooltip_format.set_width_chars(10) self.tooltip_format.set_text(self.settings['tooltip']) table.attach(label, 0, 1, 2, 3) table.attach(self.tooltip_format, 1, 2, 2, 3) framebox.pack_start(table, True) text_timeformat = gtk.TextView() text_timeformat.set_wrap_mode(gtk.WRAP_WORD) text_timeformat.set_border_width(2) buffer = text_timeformat.get_buffer() buffer.set_text(INFO) sw = gtk.ScrolledWindow() sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.add(text_timeformat) expander = gtk.expander_new_with_mnemonic(_("_Info")) expander.add(sw) framebox.pack_start(expander, True) self.mouseover_checkbox = gtk.CheckButton(_('Show on mouseover')) self.mouseover_checkbox.set_active(int( conf.launcher[ind]['mouseover'])) framebox.pack_end(self.mouseover_checkbox, False, False) bBox = gtk.VBox(False, 0) bBox.set_spacing(10) bBox.set_border_width(4) BoxListControls = gtk.HBox(False, 0) # ListStore self.view = View(self) self.view.connect("row-activated", self.edit_item) index = 0 if settings['alarmlist'] != []: for alarm in settings['alarmlist']: date_d = alarm['date_d'] date_m = alarm['date_m'] date_y = alarm['date_y'] time_h = alarm['time_h'] time_m = alarm['time_m'] day1 = alarm['day1'] day2 = alarm['day2'] day3 = alarm['day3'] day4 = alarm['day4'] day5 = alarm['day5'] day6 = alarm['day6'] day7 = alarm['day7'] soundfile = alarm['soundfile'] cmd = alarm['cmd'] text = alarm['text'] notify = alarm['notify'] remind = alarm['remind'] index = alarm['index'] self.view.add_launcher(date_d, date_m, date_y, time_h, time_m, day1, day2, day3, day4, day5, day6, day7, soundfile, cmd, text, notify, remind, index) self.view.model.connect("row-deleted", self.view.row_deleted) scrolled = gtk.ScrolledWindow() scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled.add(self.view) scrolled.set_size_request(550, 100) frame = gtk.Frame() frame.add(scrolled) ## Control buttons for list # Add Launcher button = core.image_button(_('add new task'), './images/conf/add_custom.png', 24) button.connect("clicked", self.new_item_custom) BoxListControls.pack_start(button, False, False) # Remove button = core.image_button(_('remove'), './images/conf/remove.png', 24) button.connect("clicked", self.remove_item) BoxListControls.pack_start(button, False, False) bBox.pack_start(BoxListControls, False, False) bBox.pack_start(frame, False, False) framebox.pack_start(bBox, False, False)