def build_combobox(combobox, model, col=0): combobox.set_model(model) renderer = gtk.CellRendererText() combobox.pack_start(renderer, True) combobox.add_attribute(renderer, 'text', col)
def OnMenuItemClick(self, menuItem=None): """ Called when the user clicks on this extension's menu item. Parameters: menuItem -- reserved for GTK callbacks. Don't use it explicitly. """ username = self.api.get_config_value("fsUsername") password = self.api.get_config_value("fsPassword") if not self.freeSound.loggedIn: self.showSearch = True self.LoginDetails() return xmlString = pkg_resources.resource_string(__name__, "FreesoundSearch.ui") gtkBuilder = gtk.Builder() gtkBuilder.add_from_string(xmlString) signals = { "on_buttonFind_clicked": self.OnFind, "on_buttonClose_clicked": self.OnClose, "on_spinbuttonResults_value_changed": self.OnChangeResults, "on_destroy": self.OnDestroy, "on_buttonDelete_clicked": self.OnDelete, "on_buttonCopy_clicked": self.OnCopy } gtkBuilder.connect_signals(signals) self.entryFind = gtkBuilder.get_object("entryFind") self.buttonFind = gtkBuilder.get_object("buttonFind") self.scrollResults = gtkBuilder.get_object("scrolledwindowResults") self.statusbar = gtkBuilder.get_object("statusbar") self.imageHeader = gtkBuilder.get_object("imageHeader") self.eventBoxHeader = gtkBuilder.get_object("eventboxHeader") self.checkDescriptions = gtkBuilder.get_object( "checkbuttonDescriptions") self.checkTags = gtkBuilder.get_object("checkbuttonTags") self.checkFilenames = gtkBuilder.get_object("checkbuttonFilenames") self.checkUsernames = gtkBuilder.get_object("checkbuttonUsernames") self.spinResults = gtkBuilder.get_object("spinbuttonResults") self.window = gtkBuilder.get_object("FreesoundSearchWindow") self.treeHistory = gtkBuilder.get_object("treeviewHistory") self.vboxResults = gtk.VBox(spacing=6) self.clipboard = gtk.Clipboard() # load the history dict from the extension data self.sampleHistory = self.api.get_data_file(EXTENSION_DATA_NAME, "sampleHistory") if not self.sampleHistory: self.sampleHistory = {} # create a model for the used samples history and hook it to the GUI self.sampleHistoryModel = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING) # populate the model using the history dictionary for author in self.sampleHistory: parent = self.sampleHistoryModel.append(None, [author, None]) for id in self.sampleHistory[author]: self.sampleHistoryModel.append( parent, [id, self.sampleHistory[author][id]]) # hook up the model to the GUI self.treeHistory.set_model(self.sampleHistoryModel) self.treeHistory.get_selection().set_mode(gtk.SELECTION_SINGLE) # create the columns with their respective renderers and add them # these strings are not displayed, so they're not marked as translatable self.treeHistory.append_column( gtk.TreeViewColumn("Author-ID", gtk.CellRendererText(), text=0)) renderer = gtk.CellRendererText() #renderer.set_property("wrap-width", -1) #renderer.set_property("wrap-mode", pango.WRAP_WORD) #renderer.ellipsize = pango.ELLIPSIZE_END self.treeHistory.append_column( gtk.TreeViewColumn("Description", renderer, text=1)) # set up other widget properties self.eventBoxHeader.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#ffffff")) self.spinResults.set_value(self.maxResults) self.entryFind.set_activates_default(True) self.entryFind.grab_focus() self.buttonFind.set_flags(gtk.CAN_DEFAULT) self.buttonFind.grab_default() self.scrollResults.add_with_viewport(self.vboxResults) self.api.set_window_icon(self.window) self.imageHeader.set_from_file( pkg_resources.resource_filename(__name__, "images/banner.png")) self.window.show_all() # set up the result fetching thread searchThread = SearchFreesoundThread(self.api, self.vboxResults, self.statusbar, username, password, self.searchQueue, self.sampleHistory, self.sampleHistoryModel, self.ToggleFindButton) searchThread.setDaemon(True) # thread exits when Jokosher exits searchThread.start()
def initialize(self): if not IP.initialize(self): return False # glade gf = os.path.join(self.locations['glade'], 'importcsv.glade') # try to open the glade file try: self.gtk = gtk.glade.XML(gf) except: log.info("Glade-file %s can not be loaded.", gf) return False # open gtk window self.gtk.get_widget('d_import').set_transient_for( self.widgets['window']) # simple string lists self.tv_csv = self.gtk.get_widget('tv_csv') self.tv_assigned = self.gtk.get_widget('tv_assigned') self.tv_griffith = self.gtk.get_widget('tv_griffith') # 1st list self.ls_csv = gtk.ListStore(str) self.tv_csv.set_model(self.ls_csv) renderer = gtk.CellRendererText() column = gtk.TreeViewColumn("none", renderer, text=0) self.tv_csv.append_column(column) # 2nd list self.ls_griffith = gtk.ListStore(str, str) self.tv_griffith.set_model(self.ls_griffith) renderer = gtk.CellRendererText() column = gtk.TreeViewColumn("none", renderer, text=0) column.set_visible(False) self.tv_griffith.append_column(column) column = gtk.TreeViewColumn("none", renderer, text=1) self.tv_griffith.append_column(column) self.set_griffith_fields() # 3rd list self.ls_assigned = gtk.ListStore(str, str, str) self.tv_assigned.set_model(self.ls_assigned) renderer = gtk.CellRendererText() column = gtk.TreeViewColumn("none", renderer, text=0) self.tv_assigned.append_column(column) # add the columns for internal information handling and hide them column = gtk.TreeViewColumn("none", renderer, text=1) column.set_visible(False) self.tv_assigned.append_column(column) column = gtk.TreeViewColumn("none", renderer, text=2) column.set_visible(False) self.tv_assigned.append_column(column) # hide tabs self.nb_pages = self.gtk.get_widget('nb_pages') self.nb_pages.get_nth_page(1).hide() self.nb_pages.connect("switch-page", self._on_page_changed) # Events # Buttons self.b_cancel = self.gtk.get_widget("b_cancel") self.b_cancel.connect("clicked", self._clicked) self.b_next = self.gtk.get_widget("b_next") self.b_next.connect("clicked", self._clicked) self.b_back = self.gtk.get_widget("b_back") self.b_back.connect("clicked", self._clicked) self.b_add = self.gtk.get_widget("b_add") self.b_add.connect("clicked", self._clicked) self.b_del = self.gtk.get_widget("b_del") self.b_del.connect("clicked", self._clicked) # Treeviews self.tv_griffith.connect("row_activated", self._on_row_activated) self.tv_griffith.connect("cursor_changed", self._on_cursor_changed) self.tv_csv.connect("row_activated", self._on_row_activated) self.tv_csv.connect("cursor_changed", self._on_cursor_changed) self.tv_assigned.connect("cursor_changed", self._on_cursor_changed) self.gtk.get_widget('e_lineterminator').set_active(0) self.selected_griffith = None self.selected_csv = None self.current_csv_row = 0 self.csv_header = None return True
def gen_layer_widget(self, layers, layers_avail, window, tooltip=""): hbox = gtk.HBox(False, 6) layer_tv = gtk.TreeView() layer_tv.set_rules_hint(True) layer_tv.set_headers_visible(False) tree_selection = layer_tv.get_selection() tree_selection.set_mode(gtk.SELECTION_SINGLE) # Allow enable drag and drop of rows including row move dnd_internal_target = '' dnd_targets = [(dnd_internal_target, gtk.TARGET_SAME_WIDGET, 0)] layer_tv.enable_model_drag_source(gtk.gdk.BUTTON1_MASK, dnd_targets, gtk.gdk.ACTION_MOVE) layer_tv.enable_model_drag_dest(dnd_targets, gtk.gdk.ACTION_MOVE) layer_tv.connect("drag_data_get", self.drag_data_get_cb) layer_tv.connect("drag_data_received", self.drag_data_received_cb) col0 = gtk.TreeViewColumn('Path') cell0 = gtk.CellRendererText() cell0.set_padding(5, 2) col0.pack_start(cell0, True) col0.set_cell_data_func(cell0, self.draw_layer_path_cb) layer_tv.append_column(col0) scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) scroll.set_shadow_type(gtk.SHADOW_IN) scroll.add(layer_tv) table_layer = gtk.Table(2, 10, False) hbox.pack_start(table_layer, expand=True, fill=True) table_layer.attach(scroll, 0, 10, 0, 1) layer_store = gtk.ListStore(gobject.TYPE_STRING) for layer in layers: layer_store.append([layer]) col1 = gtk.TreeViewColumn('Enabled') layer_tv.append_column(col1) cell1 = CellRendererPixbufActivatable() cell1.set_fixed_size(-1, 35) cell1.connect("clicked", self.del_cell_clicked_cb, layer_store) col1.pack_start(cell1, True) col1.set_cell_data_func(cell1, self.draw_delete_button_cb, layer_tv) add_button = gtk.Button() add_button.set_relief(gtk.RELIEF_NONE) box = gtk.HBox(False, 6) box.show() add_button.add(box) add_button.connect("enter-notify-event", self.add_hover_cb) add_button.connect("leave-notify-event", self.add_leave_cb) self.im = gtk.Image() self.im.set_from_file(hic.ICON_INDI_ADD_FILE) self.im.show() box.pack_start(self.im, expand=False, fill=False, padding=6) lbl = gtk.Label("Add layer") lbl.set_alignment(0.0, 0.5) lbl.show() box.pack_start(lbl, expand=True, fill=True, padding=6) add_button.connect("clicked", self.layer_widget_add_clicked_cb, layer_store, window) table_layer.attach(add_button, 0, 10, 1, 2, gtk.EXPAND | gtk.FILL, 0, 0, 6) layer_tv.set_model(layer_store) hbox.show_all() return hbox, layer_store
def create_build_gui(self): vbox = gtk.VBox(False, 12) vbox.set_border_width(6) vbox.show() hbox = gtk.HBox(False, 12) hbox.show() vbox.pack_start(hbox, expand=False, fill=False) label = gtk.Label("Machine:") label.show() hbox.pack_start(label, expand=False, fill=False, padding=6) self.machine_combo = gtk.combo_box_new_text() self.machine_combo.show() self.machine_combo.set_tooltip_text( "Selects the architecture of the target board for which you would like to build an image." ) hbox.pack_start(self.machine_combo, expand=False, fill=False, padding=6) label = gtk.Label("Base image:") label.show() hbox.pack_start(label, expand=False, fill=False, padding=6) self.image_combo = gtk.ComboBox() self.image_combo.show() self.image_combo.set_tooltip_text( "Selects the image on which to base the created image") image_combo_cell = gtk.CellRendererText() self.image_combo.pack_start(image_combo_cell, True) self.image_combo.add_attribute(image_combo_cell, 'text', self.model.COL_NAME) hbox.pack_start(self.image_combo, expand=False, fill=False, padding=6) self.progress = gtk.ProgressBar() self.progress.set_size_request(250, -1) hbox.pack_end(self.progress, expand=False, fill=False, padding=6) ins = gtk.Notebook() vbox.pack_start(ins, expand=True, fill=True) ins.set_show_tabs(True) label = gtk.Label("Packages") label.show() ins.append_page(self.pkgsaz(), tab_label=label) label = gtk.Label("Package Collections") label.show() ins.append_page(self.tasks(), tab_label=label) ins.set_current_page(0) ins.show_all() hbox = gtk.HBox(False, 1) hbox.show() label = gtk.Label("Estimated image contents:") self.model.connect("contents-changed", self.update_package_count_cb, label) label.set_property("xalign", 0.00) label.show() hbox.pack_start(label, expand=False, fill=False, padding=6) info = gtk.Button("?") info.set_tooltip_text("What does this mean?") info.show() info.connect("clicked", self.info_button_clicked_cb) hbox.pack_start(info, expand=False, fill=False, padding=6) vbox.pack_start(hbox, expand=False, fill=False, padding=6) con = self.contents() con.show() vbox.pack_start(con, expand=True, fill=True) bbox = gtk.HButtonBox() bbox.set_spacing(12) bbox.set_layout(gtk.BUTTONBOX_END) bbox.show() vbox.pack_start(bbox, expand=False, fill=False) reset = gtk.Button("Reset") reset.connect("clicked", self.reset_clicked_cb) reset.show() bbox.add(reset) bake = gtk.Button("Bake") bake.connect("clicked", self.bake_clicked_cb) bake.show() bbox.add(bake) return vbox
def __init__(self, helper): gtk.VBox.__init__(self) # ftp params ff = gtk.Table(2,4) ff.set_row_spacings(2); ff.set_col_spacings(5); ff.attach(gtk.Label('Host'),0,1,0,1,False,False); ff.attach(gtk.Label('User'),0,1,1,2,False,False); ff.attach(gtk.Label('Pass'),2,3,1,2,False,False); #ff.attach(gtk.Label('Filter'),0,1,3,4,False,False); self.url = gtk.Entry() self.url.set_size_request(10,-1) self.user = gtk.Entry() self.user.set_size_request(10,-1) self.pasw = gtk.Entry() self.pasw.set_size_request(10,-1) self.pasw.set_visibility(False) self.filt = gtk.Entry() self.filt.set_size_request(10,-1) ff.attach(self.url,1,4,0,1); ff.attach(self.user,1,2,1,2); ff.attach(self.pasw,3,4,1,2); #ff.attach(self.filt,1,2,3,4); self.pack_start(ff, False, False) # buttons #b = gtk.HBox(False) i=gtk.Image() i.set_from_stock('gtk-home',gtk.ICON_SIZE_BUTTON) #b.pack_start(i) #b.pack_start(gtk.Label('Connect')) btn_connect = gtk.Button() btn_connect.add(i) btn_connect.set_tooltip_text("Connect to FTP server") btn_connect.connect("clicked", helper.on_connect) #b = gtk.HBox(False) i=gtk.Image() i.set_from_stock('gtk-refresh',gtk.ICON_SIZE_BUTTON) #b.pack_start(i) #b.pack_start(gtk.Label('Refresh')) btn_refresh = gtk.Button() btn_refresh.add(i) btn_refresh.set_tooltip_text("Refresh remote directory list") btn_refresh.connect("clicked", helper.on_refresh) i=gtk.Image() i.set_from_stock('gtk-go-up',gtk.ICON_SIZE_BUTTON) btn_parent = gtk.Button() btn_parent.add(i) btn_parent.set_tooltip_text("Go up to parent directory") btn_parent.connect("clicked", helper.on_parent) #list for combo box (Active/Passive FTP) self.list = gtk.ListStore(int, str) iter = self.list.append( (False, "Active FTP",) ) self.list.set(iter) iter = self.list.append( (True, "Passive FTP",) ) self.list.set(iter) # save as button for adding new file i=gtk.Image() i.set_from_stock('gtk-save-as',gtk.ICON_SIZE_BUTTON) btn_save_as = gtk.Button() btn_save_as.add(i) btn_save_as.set_tooltip_text("Save new file to FTP server") btn_save_as.connect("clicked", helper.on_save_as) #Combo box self.combo_pasv_mode = gtk.ComboBox() cell = gtk.CellRendererText() self.combo_pasv_mode.pack_start(cell, True) self.combo_pasv_mode.add_attribute(cell, 'text', 1) self.combo_pasv_mode.set_model(self.list) self.combo_pasv_mode.set_active(True) #default: passive mode=True #pack buttons and combo box (active/passive FTP) on same row buttonsAndCombo=gtk.HBox(False) buttonsAndCombo.pack_start(btn_connect,False,False) buttonsAndCombo.pack_start(btn_refresh,False,False) buttonsAndCombo.pack_start(btn_parent,False,False) buttonsAndCombo.pack_start(btn_save_as,False,False) buttonsAndCombo.pack_start(self.combo_pasv_mode,False,False) self.pack_start(buttonsAndCombo,False,False) #location label self.location = gtk.Label(helper.ftp_cwd) self.location.set_ellipsize(pango.ELLIPSIZE_MIDDLE) self.location.set_line_wrap(True) self.location.set_justify(gtk.JUSTIFY_LEFT) self.location.set_alignment(0,0.5) self.pack_start(self.location, False, False) # add a treeview sw = gtk.ScrolledWindow() sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.set_shadow_type(gtk.SHADOW_IN) self.browser_model = gtk.ListStore(gtk.gdk.Pixbuf, str, str) self.browser = gtk.TreeView(self.browser_model) self.browser.set_headers_visible(True) sw.add(self.browser) self.pack_start(sw) self.dir_icon = self.browser.render_icon('gtk-directory', gtk.ICON_SIZE_MENU) self.file_icon = self.browser.render_icon('gtk-file', gtk.ICON_SIZE_MENU) # add columns to the treeview col = gtk.TreeViewColumn() render_pixbuf = gtk.CellRendererPixbuf() col.pack_start(render_pixbuf, expand=False) col.add_attribute(render_pixbuf, 'pixbuf', 0) self.browser.append_column(col) col = gtk.TreeViewColumn('Filename') render_text = gtk.CellRendererText() col.pack_start(render_text, expand=True) col.add_attribute(render_text, 'text', 1) self.browser.append_column(col) # connect stuff self.browser.connect("row-activated",helper.on_list_row_activated) self.show_all()
def __init__(self, callback, args=None): gtk.Alignment.__init__(self, xalign=0.5, yalign=0.5, xscale=0.0, yscale=1.0) self.dialog = extension.get_default('dialog') Avatar = extension.get_default('avatar') NiceBar = extension.get_default('nice bar') self.liststore = gtk.ListStore(gobject.TYPE_STRING, gtk.gdk.Pixbuf) completion = gtk.EntryCompletion() completion.set_model(self.liststore) pixbufcell = gtk.CellRendererPixbuf() completion.pack_start(pixbufcell) completion.add_attribute(pixbufcell, 'pixbuf', 1) completion.set_text_column(0) completion.set_inline_selection(True) self.pixbuf = utils.safe_gtk_pixbuf_load(gui.theme.image_theme.user) self.cmb_account = gtk.ComboBoxEntry(self.liststore, 0) self.cmb_account.set_tooltip_text(_('Account')) self.cmb_account.get_children()[0].set_completion(completion) self.cmb_account.get_children()[0].connect('key-press-event', self._on_account_key_press) self.cmb_account.connect('changed', self._on_account_changed) self.cmb_account.connect('key-release-event', self._on_account_key_release) self.btn_status = StatusButton.StatusButton() self.btn_status.set_tooltip_text(_('Status')) self.btn_status.set_status(e3.status.ONLINE) self.btn_status.set_size_request(34, -1) self.txt_password = gtk.Entry() self.txt_password.set_tooltip_text(_('Password')) self.txt_password.set_visibility(False) self.txt_password.connect('key-press-event', self._on_password_key_press) self.txt_password.connect('changed', self._on_password_changed) self.txt_password.set_sensitive(False) pix_account = utils.safe_gtk_pixbuf_load(gui.theme.image_theme.user) pix_password = utils.safe_gtk_pixbuf_load(gui.theme.image_theme.password) self.avatar = Avatar() self.remember_account = gtk.CheckButton(_('Remember me')) self.remember_password = gtk.CheckButton(_('Remember password')) self.auto_login = gtk.CheckButton(_('Auto-login')) self.remember_account.connect('toggled', self._on_remember_account_toggled) self.remember_password.connect('toggled', self._on_remember_password_toggled) self.auto_login.connect('toggled', self._on_auto_login_toggled) self.remember_account.set_sensitive(False) self.remember_password.set_sensitive(False) self.auto_login.set_sensitive(False) self.forget_me = gtk.Button() self.forget_me.set_tooltip_text(_('Delete user')) forget_img = gtk.image_new_from_stock(gtk.STOCK_CANCEL, gtk.ICON_SIZE_MENU) self.forget_me.set_image(forget_img) self.forget_me.set_relief(gtk.RELIEF_NONE) self.forget_me.set_border_width(0) self.forget_me.set_size_request(34, -1) self.forget_me.connect('clicked', self._on_forget_me_clicked) self.forget_me.set_sensitive(False) hboxremember = gtk.HBox(spacing=2) hboxremember.pack_start(self.remember_account, False) vbox_remember = gtk.VBox(spacing=4) vbox_remember.set_border_width(8) vbox_remember.pack_start(hboxremember) vbox_remember.pack_start(self.remember_password) vbox_remember.pack_start(self.auto_login) vbox_remember.pack_start(gtk.Label()) self.b_connect = gtk.Button(stock=gtk.STOCK_CONNECT) self.b_connect.set_sensitive(False) self.b_cancel = gtk.Button(stock=gtk.STOCK_CANCEL) self.b_cancel.connect('clicked', self._on_cancel_clicked) vbuttonbox = gtk.VButtonBox() vbuttonbox.set_spacing(8) vbuttonbox.pack_start(self.b_connect) vbuttonbox.pack_start(self.b_cancel) vbox_content = gtk.VBox() hbox_account = gtk.HBox(spacing=6) img_accountpix = gtk.Image() img_accountpix.set_from_pixbuf(utils.scale_nicely(pix_account)) hbox_account.pack_start(img_accountpix, False) hbox_account.pack_start(self.cmb_account) hbox_account.pack_start(self.forget_me, False) hbox_password = gtk.HBox(spacing=6) img_password = gtk.Image() img_password.set_from_pixbuf(utils.scale_nicely(pix_password)) hbox_password.pack_start(img_password, False) hbox_password.pack_start(self.txt_password) hbox_password.pack_start(self.btn_status, False) session_combo_store = gtk.ListStore(gtk.gdk.Pixbuf, str) crp = gtk.CellRendererPixbuf() crt = gtk.CellRendererText() crp.set_property("xalign", 0) crt.set_property("xalign", 0) self.session_combo = gtk.ComboBox() self.session_combo.set_tooltip_text(_('Choose your network')) self.session_combo.set_model(session_combo_store) self.session_combo.pack_start(crp) self.session_combo.pack_start(crt) self.session_combo.add_attribute(crp, "pixbuf", 0) self.session_combo.add_attribute(crt, "text", 1) self.b_preferences = gtk.Button() self.b_preferences.set_tooltip_text(_('Preferences')) self.img_preferences = gtk.image_new_from_stock(gtk.STOCK_PREFERENCES, gtk.ICON_SIZE_MENU) self.img_preferences.set_sensitive(False) self.b_preferences.set_image(self.img_preferences) self.b_preferences.set_relief(gtk.RELIEF_NONE) self.b_preferences.connect('enter-notify-event', self._on_preferences_enter) self.b_preferences.connect('leave-notify-event', self._on_preferences_leave) self.b_preferences.connect('clicked', self._on_preferences_selected) self.b_preferences.set_size_request(34, -1) img_sessionpix = gtk.image_new_from_stock(gtk.STOCK_CONNECT, gtk.ICON_SIZE_MENU) img_sessionpix.set_size_request(20, -1) img_sessionpix.set_sensitive(False) hbox_session = gtk.HBox(spacing=6) hbox_session.pack_start(img_sessionpix, False) hbox_session.pack_start(self.session_combo) hbox_session.pack_start(self.b_preferences, False) vbox_entries = gtk.VBox(spacing=12) vbox_entries.set_border_width(8) vbox_entries.pack_start(hbox_account) vbox_entries.pack_start(hbox_password) vbox_entries.pack_start(hbox_session) self.nicebar = NiceBar() th_pix = utils.safe_gtk_pixbuf_load(gui.theme.image_theme.throbber, None, animated=True) self.throbber = gtk.image_new_from_animation(th_pix) self.label_timer = gtk.Label() self.label_timer.set_markup(_('<b>Connection error!\n </b>')) al_label_timer = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0, yscale=0.0) al_throbber = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.1, yscale=0.1) al_vbox_entries = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.2, yscale=0.0) al_vbox_remember = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0, yscale=0.2) al_button = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.2) al_account = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0, yscale=0.3) al_label_timer.add(self.label_timer) al_throbber.add(self.throbber) al_vbox_entries.add(vbox_entries) al_vbox_remember.add(vbox_remember) al_button.add(vbuttonbox) al_account.add(self.avatar) vbox = gtk.VBox() vbox_top = gtk.VBox() vbox_far_bottom = gtk.VBox() vbox_bottom = gtk.VBox(False) vbox_content.pack_start(gtk.Label(""), True, True) vbox_content.pack_start(al_account, True, False) vbox_content.pack_start(gtk.Label(""), True, True) vbox_content.pack_start(al_vbox_entries, False) vbox_content.pack_start(al_vbox_remember, True, False) vbox_bottom.set_size_request(-1, 100) vbox_bottom.pack_start(al_label_timer, True, False) vbox_bottom.pack_start(al_throbber, False) vbox_bottom.pack_start(gtk.Label(""), True, True) vbox_bottom.pack_start(al_button) vbox_content.pack_start(vbox_bottom) vbox_content.pack_start(gtk.Label(""), True, True) vbox.pack_start(self.nicebar, False) vbox.pack_start(vbox_top) vbox.pack_start(vbox_content) vbox.pack_start(vbox_far_bottom) self.add(vbox) vbox.show_all()
def run_network_dialog(wallet, parent): image = gtk.Image() image.set_from_stock(gtk.STOCK_NETWORK, gtk.ICON_SIZE_DIALOG) interface = wallet.interface if parent: if interface.is_connected: status = "Connected to %s:%d\n%d blocks" % ( interface.host, interface.port, wallet.verifier.height) else: status = "Not connected" else: import random status = "Please choose a server.\nSelect cancel if you are offline." server = interface.server plist, servers_list = interface.get_servers_list() dialog = gtk.MessageDialog( parent, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, status) dialog.set_title("Server") dialog.set_image(image) image.show() vbox = dialog.vbox host_box = gtk.HBox() host_label = gtk.Label('Connect to:') host_label.set_size_request(100, -1) host_label.show() host_box.pack_start(host_label, False, False, 10) host_entry = gtk.Entry() host_entry.set_size_request(200, -1) host_entry.set_text(server) host_entry.show() host_box.pack_start(host_entry, False, False, 10) add_help_button( host_box, 'The name and port number of your Electrum server, separated by a colon. Example: "ecdsa.org:50000". If no port number is provided, port 50000 will be tried. Some servers allow you to connect through http (port 80) or https (port 443)' ) host_box.show() p_box = gtk.HBox(False, 10) p_box.show() p_label = gtk.Label('Protocol:') p_label.set_size_request(100, -1) p_label.show() p_box.pack_start(p_label, False, False, 10) radio1 = gtk.RadioButton(None, "tcp") p_box.pack_start(radio1, True, True, 0) radio1.show() radio2 = gtk.RadioButton(radio1, "http") p_box.pack_start(radio2, True, True, 0) radio2.show() def current_line(): return unicode(host_entry.get_text()).split(':') def set_button(protocol): if protocol == 't': radio1.set_active(1) elif protocol == 'h': radio2.set_active(1) def set_protocol(protocol): host = current_line()[0] pp = plist[host] if protocol not in pp.keys(): protocol = pp.keys()[0] set_button(protocol) port = pp[protocol] host_entry.set_text(host + ':' + port + ':' + protocol) radio1.connect("toggled", lambda x, y: set_protocol('t'), "radio button 1") radio2.connect("toggled", lambda x, y: set_protocol('h'), "radio button 1") server_list = gtk.ListStore(str) for host in plist.keys(): server_list.append([host]) treeview = gtk.TreeView(model=server_list) treeview.show() if wallet.interface.servers: label = 'Active Servers' else: label = 'Default Servers' tvcolumn = gtk.TreeViewColumn(label) treeview.append_column(tvcolumn) cell = gtk.CellRendererText() tvcolumn.pack_start(cell, False) tvcolumn.add_attribute(cell, 'text', 0) scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scroll.add(treeview) scroll.show() vbox.pack_start(host_box, False, False, 5) vbox.pack_start(p_box, True, True, 0) vbox.pack_start(scroll) def my_treeview_cb(treeview): path, view_column = treeview.get_cursor() host = server_list.get_value(server_list.get_iter(path), 0) pp = plist[host] if 't' in pp.keys(): protocol = 't' else: protocol = pp.keys()[0] port = pp[protocol] host_entry.set_text(host + ':' + port + ':' + protocol) set_button(protocol) treeview.connect('cursor-changed', my_treeview_cb) dialog.show() r = dialog.run() server = host_entry.get_text() dialog.destroy() if r == gtk.RESPONSE_CANCEL: return False try: interface.set_server(server) except: show_message("error:" + server) return False if parent: wallet.config.set_key("server", server, True) return True
def create_history_tab(self): self.history_list = gtk.ListStore(str, str, str, str, 'gboolean', str, str, str, str) treeview = gtk.TreeView(model=self.history_list) self.history_treeview = treeview treeview.set_tooltip_column(7) treeview.show() treeview.connect('key-press-event', self.treeview_key_press) treeview.connect('button-press-event', self.treeview_button_press) tvcolumn = gtk.TreeViewColumn('') treeview.append_column(tvcolumn) cell = gtk.CellRendererPixbuf() tvcolumn.pack_start(cell, False) tvcolumn.set_attributes(cell, stock_id=1) tvcolumn = gtk.TreeViewColumn('Date') treeview.append_column(tvcolumn) cell = gtk.CellRendererText() tvcolumn.pack_start(cell, False) tvcolumn.add_attribute(cell, 'text', 2) tvcolumn = gtk.TreeViewColumn('Description') treeview.append_column(tvcolumn) cell = gtk.CellRendererText() cell.set_property('foreground', 'grey') cell.set_property('family', MONOSPACE_FONT) cell.set_property('editable', True) def edited_cb(cell, path, new_text, h_list): tx = h_list.get_value(h_list.get_iter(path), 0) self.wallet.labels[tx] = new_text self.wallet.save() self.update_history_tab() cell.connect('edited', edited_cb, self.history_list) def editing_started(cell, entry, path, h_list): tx = h_list.get_value(h_list.get_iter(path), 0) if not self.wallet.labels.get(tx): entry.set_text('') cell.connect('editing-started', editing_started, self.history_list) tvcolumn.set_expand(True) tvcolumn.pack_start(cell, True) tvcolumn.set_attributes(cell, text=3, foreground_set=4) tvcolumn = gtk.TreeViewColumn('Amount') treeview.append_column(tvcolumn) cell = gtk.CellRendererText() cell.set_alignment(1, 0.5) cell.set_property('family', MONOSPACE_FONT) tvcolumn.pack_start(cell, False) tvcolumn.add_attribute(cell, 'text', 5) tvcolumn = gtk.TreeViewColumn('Balance') treeview.append_column(tvcolumn) cell = gtk.CellRendererText() cell.set_alignment(1, 0.5) cell.set_property('family', MONOSPACE_FONT) tvcolumn.pack_start(cell, False) tvcolumn.add_attribute(cell, 'text', 6) tvcolumn = gtk.TreeViewColumn('Tooltip') treeview.append_column(tvcolumn) cell = gtk.CellRendererText() tvcolumn.pack_start(cell, False) tvcolumn.add_attribute(cell, 'text', 7) tvcolumn.set_visible(False) scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) scroll.add(treeview) self.add_tab(scroll, 'History') self.update_history_tab()
def __init__(self): # Create the temporary directory self.tmp_dir = tempfile.mkdtemp("pdfshuffler") os.chmod(self.tmp_dir, 0700) icon_theme = gtk.icon_theme_get_default() try: gtk.window_set_default_icon( icon_theme.load_icon("pdfshuffler", 64, 0)) except: print( _("Can't load icon. Application is not installed correctly.")) # Import the user interface file, trying different possible locations ui_path = '/usr/share/pdfshuffler/pdfshuffler.ui' if not os.path.exists(ui_path): ui_path = '/usr/local/share/pdfshuffler/pdfshuffler.ui' if not os.path.exists(ui_path): parent_dir = os.path.dirname( \ os.path.dirname(os.path.realpath(__file__))) ui_path = os.path.join(parent_dir, 'data', 'pdfshuffler.ui') if not os.path.exists(ui_path): head, tail = os.path.split(parent_dir) while tail != 'lib' and tail != '': head, tail = os.path.split(head) if tail == 'lib': ui_path = os.path.join(head, 'share', 'pdfshuffler', \ 'pdfshuffler.ui') self.uiXML = gtk.Builder() self.uiXML.add_from_file(ui_path) self.uiXML.connect_signals(self) # Create the main window, and attach delete_event signal to terminating # the application self.window = self.uiXML.get_object('main_window') self.window.set_title(APPNAME) self.window.set_border_width(0) self.window.move(self.prefs['window x'], self.prefs['window y']) self.window.set_default_size(self.prefs['window width'], self.prefs['window height']) self.window.connect('delete_event', self.close_application) # Create a scrolled window to hold the thumbnails-container self.sw = self.uiXML.get_object('scrolledwindow') self.sw.drag_dest_set( gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP | gtk.DEST_DEFAULT_MOTION, self.TARGETS_SW, gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE) self.sw.connect('drag_data_received', self.sw_dnd_received_data) self.sw.connect('button_press_event', self.sw_button_press_event) self.sw.connect('scroll_event', self.sw_scroll_event) # Create an alignment to keep the thumbnails center-aligned align = gtk.Alignment(0.5, 0.5, 0, 0) self.sw.add_with_viewport(align) # Create ListStore model and IconView self.model = gtk.ListStore( str, # 0.Text descriptor gobject.TYPE_PYOBJECT, # 1.Cached page image int, # 2.Document number int, # 3.Page number float, # 4.Scale str, # 5.Document filename int, # 6.Rotation angle float, # 7.Crop left float, # 8.Crop right float, # 9.Crop top float, # 10.Crop bottom int, # 11.Page width int, # 12.Page height float) # 13.Resampling factor self.zoom_set(self.prefs['initial zoom level']) self.iv_col_width = self.prefs['initial thumbnail size'] self.iconview = gtk.IconView(self.model) self.iconview.set_item_width(self.iv_col_width + 12) self.cellthmb = CellRendererImage() self.iconview.pack_start(self.cellthmb, False) self.iconview.set_attributes(self.cellthmb, image=1, scale=4, rotation=6, cropL=7, cropR=8, cropT=9, cropB=10, width=11, height=12, resample=13) self.celltxt = gtk.CellRendererText() self.celltxt.set_property('width', self.iv_col_width) self.celltxt.set_property('wrap-width', self.iv_col_width) self.celltxt.set_property('alignment', pango.ALIGN_CENTER) self.iconview.pack_start(self.celltxt, False) self.iconview.set_attributes(self.celltxt, text=0) self.iconview.set_selection_mode(gtk.SELECTION_MULTIPLE) self.iconview.enable_model_drag_source( gtk.gdk.BUTTON1_MASK, self.TARGETS_IV, gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE) self.iconview.enable_model_drag_dest(self.TARGETS_IV, gtk.gdk.ACTION_DEFAULT) self.iconview.connect('drag_begin', self.iv_drag_begin) self.iconview.connect('drag_data_get', self.iv_dnd_get_data) self.iconview.connect('drag_data_received', self.iv_dnd_received_data) self.iconview.connect('drag_data_delete', self.iv_dnd_data_delete) self.iconview.connect('drag_motion', self.iv_dnd_motion) self.iconview.connect('drag_leave', self.iv_dnd_leave_end) self.iconview.connect('drag_end', self.iv_dnd_leave_end) self.iconview.connect('button_press_event', self.iv_button_press_event) align.add(self.iconview) # Progress bar self.progress_bar = self.uiXML.get_object('progressbar') self.progress_bar_timeout_id = 0 # Define window callback function and show window self.window.connect('size_allocate', self.on_window_size_request) # resize self.window.connect('key_press_event', self.on_keypress_event) # keypress self.window.show_all() self.progress_bar.hide_all() # Change iconview color background style = self.sw.get_style().copy() for state in (gtk.STATE_NORMAL, gtk.STATE_PRELIGHT, gtk.STATE_ACTIVE): style.base[state] = style.bg[gtk.STATE_NORMAL] self.iconview.set_style(style) # Creating the popup menu self.popup = gtk.Menu() popup_rotate_right = gtk.ImageMenuItem(_('_Rotate Right')) popup_rotate_left = gtk.ImageMenuItem(_('Rotate _Left')) popup_crop = gtk.MenuItem(_('C_rop...')) popup_delete = gtk.ImageMenuItem(gtk.STOCK_DELETE) popup_saveselection = gtk.MenuItem(_('_Export selection...')) #popup_keep_password = gtk.MenuItem(_('_Export selection...')) popup_rotate_right.connect('activate', self.rotate_page_right) popup_rotate_left.connect('activate', self.rotate_page_left) popup_crop.connect('activate', self.crop_page_dialog) popup_delete.connect('activate', self.clear_selected) popup_saveselection.connect('activate', self.choose_export_pdf_name, True) #popup_keep_password.c popup_rotate_right.show() popup_rotate_left.show() popup_crop.show() popup_delete.show() popup_saveselection.show() self.popup.append(popup_rotate_right) self.popup.append(popup_rotate_left) self.popup.append(popup_crop) self.popup.append(popup_delete) self.popup.append(popup_saveselection) # Initializing variables self.export_directory = os.getenv('HOME') self.import_directory = self.export_directory self.nfile = 0 self.iv_auto_scroll_direction = 0 self.iv_auto_scroll_timer = None self.pdfqueue = [] gobject.type_register(PDF_Renderer) gobject.signal_new( 'update_thumbnail', PDF_Renderer, gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, [gobject.TYPE_INT, gobject.TYPE_PYOBJECT, gobject.TYPE_FLOAT]) self.rendering_thread = 0 self.set_unsaved(False) # Importing documents passed as command line arguments for filename in sys.argv[1:]: self.add_pdf_pages(filename)
def make_address_list(self, is_recv): liststore = self.recv_list if is_recv else self.addressbook_list treeview = gtk.TreeView(model=liststore) treeview.connect('key-press-event', self.treeview_key_press) treeview.connect('button-press-event', self.treeview_button_press) treeview.show() if not is_recv: self.contacts_treeview = treeview tvcolumn = gtk.TreeViewColumn('Address') treeview.append_column(tvcolumn) cell = gtk.CellRendererText() cell.set_property('family', MONOSPACE_FONT) tvcolumn.pack_start(cell, True) tvcolumn.add_attribute(cell, 'text', 0) tvcolumn = gtk.TreeViewColumn('Label') tvcolumn.set_expand(True) treeview.append_column(tvcolumn) cell = gtk.CellRendererText() cell.set_property('editable', True) def edited_cb2(cell, path, new_text, liststore): address = liststore.get_value(liststore.get_iter(path), 0) self.wallet.labels[address] = new_text self.wallet.save() self.update_receiving_tab() self.update_sending_tab() self.update_history_tab() cell.connect('edited', edited_cb2, liststore) tvcolumn.pack_start(cell, True) tvcolumn.add_attribute(cell, 'text', 1) tvcolumn = gtk.TreeViewColumn('Tx') treeview.append_column(tvcolumn) cell = gtk.CellRendererText() tvcolumn.pack_start(cell, True) tvcolumn.add_attribute(cell, 'text', 2) scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scroll.add(treeview) hbox = gtk.HBox() if not is_recv: button = gtk.Button("New") button.connect("clicked", self.newaddress_dialog) button.show() hbox.pack_start(button, False) def showqrcode(w, treeview, liststore): path, col = treeview.get_cursor() if not path: return address = liststore.get_value(liststore.get_iter(path), 0) qr = pyqrnative.QRCode(4, pyqrnative.QRErrorCorrectLevel.H) qr.addData(address) qr.make() boxsize = 7 size = qr.getModuleCount() * boxsize def area_expose_cb(area, event): style = area.get_style() k = qr.getModuleCount() for r in range(k): for c in range(k): gc = style.black_gc if qr.isDark(r, c) else style.white_gc area.window.draw_rectangle(gc, True, c * boxsize, r * boxsize, boxsize, boxsize) area = gtk.DrawingArea() area.set_size_request(size, size) area.connect("expose-event", area_expose_cb) area.show() dialog = gtk.Dialog(address, parent=self.window, flags=gtk.DIALOG_MODAL | gtk.DIALOG_NO_SEPARATOR, buttons=("ok", 1)) dialog.vbox.add(area) dialog.run() dialog.destroy() button = gtk.Button("QR") button.connect("clicked", showqrcode, treeview, liststore) button.show() hbox.pack_start(button, False) button = gtk.Button("Copy to clipboard") def copy2clipboard(w, treeview, liststore): import platform path, col = treeview.get_cursor() if path: address = liststore.get_value(liststore.get_iter(path), 0) if platform.system() == 'Windows': from Tkinter import Tk r = Tk() r.withdraw() r.clipboard_clear() r.clipboard_append(address) r.destroy() else: c = gtk.clipboard_get() c.set_text(address) button.connect("clicked", copy2clipboard, treeview, liststore) button.show() hbox.pack_start(button, False) if not is_recv: button = gtk.Button("Pay to") def payto(w, treeview, liststore): path, col = treeview.get_cursor() if path: address = liststore.get_value(liststore.get_iter(path), 0) self.payto_entry.set_text(address) self.notebook.set_current_page(1) self.amount_entry.grab_focus() button.connect("clicked", payto, treeview, liststore) button.show() hbox.pack_start(button, False) vbox = gtk.VBox() vbox.pack_start(scroll, True) vbox.pack_start(hbox, False) return vbox
def __init__(self, get_popup, parent_name, parent_tree, dispatcher): """ Initialize """ # initialize the treeview CommonTreeView.__init__(self) # save the dependency popup callback self.get_popup = get_popup # parents name we are building the dependency tree for, and some history self.parent_tree = parent_tree self.parent_name = parent_name self.dispatch = dispatcher # setup the model self.model = DependsTree(self.populate_info) # setup the column column = gtk.TreeViewColumn(_("Dependencies")) pixbuf = gtk.CellRendererPixbuf() column.pack_start(pixbuf, expand=False) column.add_attribute(pixbuf, "pixbuf", 1) text = gtk.CellRendererText() column.pack_start(text, expand=True) column.add_attribute(text, "text", self.model.column["depend"]) self.append_column(column) # Setup the Package Name Column self._name_column = gtk.TreeViewColumn(_("Package")) self.append_column(self._name_column) text_name = gtk.CellRendererText() self._name_column.pack_start(text_name, expand=False) self._name_column.add_attribute(text_name, "text", self.model.column["name"]) #self._name_column.set_cell_data_func(text_name, self.cell_data_func, None) self._name_column.set_resizable(True) self._name_column.set_min_width(10) # Setup the Installed Column self._installed_column = gtk.TreeViewColumn(_("Installed")) self.append_column(self._installed_column) text_installed = gtk.CellRendererText() self._installed_column.pack_start(text_installed, expand=False) self._installed_column.add_attribute(text_installed, "text", self.model.column["installed"]) #self._installed_column.set_cell_data_func(text_installed, self.cell_data_func, None) self._installed_column.set_resizable(True) self._installed_column.set_min_width(10) #self._installed_column.set_sort_column_id(self.model.column["installed"]) # Setup the Latest Column self._latest_column = gtk.TreeViewColumn(_("Recommended")) self.append_column(self._latest_column) text_latest = gtk.CellRendererText() self._latest_column.pack_start(text_latest, expand=False) self._latest_column.add_attribute(text_latest, "text", self.model.column["latest"]) #self._latest_column.set_cell_data_func(text_latest, self.cell_data_func, None) self._latest_column.set_resizable(True) self._latest_column.set_min_width(10) #self._latest_column.set_sort_column_id(self.model.column["latest"]) # Setup the keyword Column self._keyword_column = gtk.TreeViewColumn(_("Keywords")) self.append_column(self._keyword_column) text_keyword = gtk.CellRendererText() self._keyword_column.pack_start(text_keyword, expand=False) self._keyword_column.add_attribute(text_keyword, "text", self.model.column["keyword"]) #self._keyword_column.set_cell_data_func(text_keyword, self.cell_data_func, None) self._keyword_column.set_resizable(True) self._keyword_column.set_min_width(10) #self._keyword_column.set_sort_column_id(self.model.column["keyword"]) # Setup the required USE flags Column self._required_use_column = gtk.TreeViewColumn(_("Required USE")) self.append_column(self._required_use_column) text_use = gtk.CellRendererText() self._required_use_column.pack_start(text_use, expand=False) self._required_use_column.add_attribute( text_use, "text", self.model.column["required_use"]) #self._required_use_column.set_cell_data_func(text_use, self.cell_data_func, None) self._required_use_column.set_resizable(True) self._required_use_column.set_min_width(12) #self._required_use_column.set_sort_column_id(self.model.column["required_use"]) self._last_selected = None self.connect("cursor-changed", self._clicked) self.connect("test-expand-row", self.expand_row) self.connect("button_press_event", self.on_button_press) # make it easier to read across columns self.set_rules_hint(True) # create popup menu for rmb-click arch = "~" + portage_lib.get_arch() menu = gtk.Menu() menuitems = {} menuitems["emerge --oneshot"] = gtk.MenuItem(_("Emerge")) menuitems["emerge --oneshot"].connect("activate", self.emerge) menuitems["pretend-emerge"] = gtk.MenuItem(_("Pretend Emerge")) menuitems["pretend-emerge"].connect("activate", self.emerge, True, None) menuitems["sudo-emerge --oneshot"] = gtk.MenuItem(_("Sudo Emerge")) menuitems["sudo-emerge --oneshot"].connect("activate", self.emerge, None, True) menuitems["Advanced emerge dialog"] = gtk.MenuItem( _("Advanced Emerge")) menuitems["Advanced emerge dialog"].connect("activate", self.adv_emerge) #menuitems["unmerge"] = gtk.MenuItem(_("Unmerge")) #menuitems["unmerge"].connect("activate", self.unmerge) #menuitems["sudo-unmerge"] = gtk.MenuItem(_("Sudo Unmerge")) #menuitems["sudo-unmerge"].connect("activate", self.unmerge, True) menuitems["add-keyword"] = gtk.MenuItem( _("Append with %s to package.keywords") % arch) menuitems["add-keyword"].connect("activate", self.add_keyword) #menuitems["deselect_all"] = gtk.MenuItem(_("De-Select all")) #menuitems["deselect_all"].connect("activate", self.deselect_all) #menuitems["select_all"] = gtk.MenuItem(_("Select all")) #menuitems["select_all"].connect("activate", self.select_all) for item in menuitems.values(): menu.append(item) item.show() self.popup_menu = menu self.popup_menuitems = menuitems self.dopopup = None self.event = None self.event_src = None self.toggle = None self._depend_changed = None self.dep_window = { "window": None, "notebook": None, 'tree': [] } #, 'depth': 0} debug.dprint("DependsView: Depends view initialized")
def __init__(self, *args, **kwargs): super(WinCSV, self).__init__(*args, **kwargs) self.dialog = gtk.Dialog(parent=self.parent, flags=gtk.DIALOG_DESTROY_WITH_PARENT) self.dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT) self.dialog.set_icon(TRYTON_ICON) self.dialog.connect('response', self.response) dialog_vbox = gtk.VBox() self.add_header(dialog_vbox) hbox_mapping = gtk.HBox(True) dialog_vbox.pack_start(hbox_mapping, True, True, 0) frame_fields = gtk.Frame() frame_fields.set_shadow_type(gtk.SHADOW_NONE) viewport_fields = gtk.Viewport() scrolledwindow_fields = gtk.ScrolledWindow() scrolledwindow_fields.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) viewport_fields.add(scrolledwindow_fields) frame_fields.add(viewport_fields) label_all_fields = gtk.Label(_('<b>All fields</b>')) label_all_fields.set_use_markup(True) frame_fields.set_label_widget(label_all_fields) hbox_mapping.pack_start(frame_fields, True, True, 0) vbox_buttons = gtk.VBox(False, 10) vbox_buttons.set_border_width(5) hbox_mapping.pack_start(vbox_buttons, False, True, 0) button_add = gtk.Button(_('_Add'), stock=None, use_underline=True) button_add.set_alignment(0.0, 0.0) img_button = gtk.Image() img_button.set_from_stock('tryton-list-add', gtk.ICON_SIZE_BUTTON) button_add.set_image(img_button) button_add.connect_after('clicked', self.sig_sel) vbox_buttons.pack_start(button_add, False, False, 0) button_remove = gtk.Button(_('_Remove'), stock=None, use_underline=True) button_remove.set_alignment(0.0, 0.0) img_button = gtk.Image() img_button.set_from_stock('tryton-list-remove', gtk.ICON_SIZE_BUTTON) button_remove.set_image(img_button) button_remove.connect_after('clicked', self.sig_unsel) vbox_buttons.pack_start(button_remove, False, False, 0) button_remove_all = gtk.Button(_('_Clear'), stock=None, use_underline=True) button_remove_all.set_alignment(0.0, 0.0) img_button = gtk.Image() img_button.set_from_stock('tryton-clear', gtk.ICON_SIZE_BUTTON) button_remove_all.set_image(img_button) button_remove_all.connect_after('clicked', self.sig_unsel_all) vbox_buttons.pack_start(button_remove_all, False, False, 0) hseparator_buttons = gtk.HSeparator() vbox_buttons.pack_start(hseparator_buttons, False, False, 3) self.add_buttons(vbox_buttons) frame_fields_selected = gtk.Frame() frame_fields_selected.set_shadow_type(gtk.SHADOW_NONE) viewport_fields_selected = gtk.Viewport() scrolledwindow_fields_selected = gtk.ScrolledWindow() scrolledwindow_fields_selected.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) viewport_fields_selected.add(scrolledwindow_fields_selected) frame_fields_selected.add(viewport_fields_selected) label_fields_selected = gtk.Label(_('<b>Fields selected</b>')) label_fields_selected.set_use_markup(True) frame_fields_selected.set_label_widget(label_fields_selected) hbox_mapping.pack_start(frame_fields_selected, True, True, 0) frame_csv_param = gtk.Frame() frame_csv_param.set_shadow_type(gtk.SHADOW_ETCHED_OUT) dialog_vbox.pack_start(frame_csv_param, False, True, 0) alignment_csv_param = gtk.Alignment(0.5, 0.5, 1, 1) alignment_csv_param.set_padding(7, 7, 7, 7) frame_csv_param.add(alignment_csv_param) vbox_csv_param = gtk.VBox() alignment_csv_param.add(vbox_csv_param) self.add_chooser(vbox_csv_param) expander_csv = gtk.Expander() vbox_csv_param.pack_start(expander_csv, False, True, 0) label_csv_param = gtk.Label(_('CSV Parameters')) expander_csv.set_label_widget(label_csv_param) table = gtk.Table(2, 4, False) table.set_border_width(8) table.set_row_spacings(9) table.set_col_spacings(8) expander_csv.add(table) label_csv_delimiter = gtk.Label(_('Delimiter:')) label_csv_delimiter.set_alignment(1, 0.5) table.attach(label_csv_delimiter, 0, 1, 0, 1) self.csv_delimiter = gtk.Entry() self.csv_delimiter.set_max_length(1) if os.name == 'nt' and ',' == locale.localeconv()['decimal_point']: delimiter = ';' else: delimiter = ',' self.csv_delimiter.set_text(delimiter) self.csv_delimiter.set_width_chars(1) label_csv_delimiter.set_mnemonic_widget(self.csv_delimiter) table.attach(self.csv_delimiter, 1, 2, 0, 1) label_csv_quotechar = gtk.Label(_("Quote char:")) label_csv_quotechar.set_alignment(1, 0.5) table.attach(label_csv_quotechar, 2, 3, 0, 1) self.csv_quotechar = gtk.Entry() self.csv_quotechar.set_text("\"") self.csv_quotechar.set_width_chars(1) label_csv_quotechar.set_mnemonic_widget(self.csv_quotechar) table.attach(self.csv_quotechar, 3, 4, 0, 1) label_csv_enc = gtk.Label(_("Encoding:")) label_csv_enc.set_alignment(1, 0.5) table.attach(label_csv_enc, 0, 1, 1, 2) if hasattr(gtk, 'ComboBoxText'): self.csv_enc = gtk.ComboBoxText() else: self.csv_enc = gtk.combo_box_new_text() for i, encoding in enumerate(encodings): self.csv_enc.append_text(encoding) if ((os.name == 'nt' and encoding == 'cp1252') or (os.name != 'nt' and encoding == 'utf_8')): self.csv_enc.set_active(i) label_csv_enc.set_mnemonic_widget(self.csv_enc) table.attach(self.csv_enc, 1, 2, 1, 2) self.add_csv_header_param(table) button_cancel = gtk.Button("gtk-cancel", stock="gtk-cancel") self.dialog.add_action_widget(button_cancel, gtk.RESPONSE_CANCEL) button_ok = gtk.Button("gtk-ok", stock="gtk-ok") self.dialog.add_action_widget(button_ok, gtk.RESPONSE_OK) self.dialog.vbox.pack_start(dialog_vbox) self.view1 = gtk.TreeView() self.view1.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.view1.connect('row-expanded', self.on_row_expanded) scrolledwindow_fields.add(self.view1) self.view2 = gtk.TreeView() self.view2.get_selection().set_mode(gtk.SELECTION_MULTIPLE) scrolledwindow_fields_selected.add(self.view2) self.view1.set_headers_visible(False) self.view2.set_headers_visible(False) cell = gtk.CellRendererText() column = gtk.TreeViewColumn(_('Field name'), cell, text=0) self.view1.append_column(column) cell = gtk.CellRendererText() column = gtk.TreeViewColumn(_('Field name'), cell, text=0) self.view2.append_column(column) self.model1 = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING) self.model2 = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) self.model_populate(self._get_fields(self.model)) self.view1.set_model(self.model1) self.view1.connect('row-activated', self.sig_sel) self.view2.set_model(self.model2) self.view2.connect('row-activated', self.sig_unsel) sensible_allocation = self.sensible_widget.get_allocation() self.dialog.set_default_size(int(sensible_allocation.width * 0.9), int(sensible_allocation.height * 0.9)) self.dialog.show_all() center_window(self.dialog, self.parent, self.sensible_widget) self.register() if sys.platform != 'darwin': self.view2.drag_source_set( gtk.gdk.BUTTON1_MASK | gtk.gdk.BUTTON3_MASK, [ gtk.TargetEntry.new('EXPORT_TREE', gtk.TARGET_SAME_WIDGET, 0) ], gtk.gdk.ACTION_MOVE) self.view2.drag_dest_set(gtk.DEST_DEFAULT_ALL, [ gtk.TargetEntry.new('EXPORT_TREE', gtk.TARGET_SAME_WIDGET, 0) ], gtk.gdk.ACTION_MOVE) self.view2.connect('drag-begin', self.drag_begin) self.view2.connect('drag-motion', self.drag_motion) self.view2.connect('drag-drop', self.drag_drop) self.view2.connect("drag-data-get", self.drag_data_get) self.view2.connect('drag-data-received', self.drag_data_received) self.view2.connect('drag-data-delete', self.drag_data_delete)
def create_main_window(self): """Creates the main window with all it's widgets""" # Creamos una ventana self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_title("Naufrago!") self.window.set_icon_from_file("Viking_Longship.svg") self.window.connect("delete_event", self.delete_event) self.window.set_border_width(5) # Grosor del borde de la ventana self.window.move(self.x, self.y) self.window.resize(self.w, self.h) #self.window.set_size_request(600, 400) # Dimensionamiento estático de la ventana ######################## # PARTE 1 (feeds tree) # ######################## # Creación del VBox. self.vbox = gtk.VBox(False, 0) # Creación del menubar self.create_ui(self.window) self.vbox.pack_start(self.ui.get_widget('/Menubar'), expand=False) # Creación del HPaned. self.hpaned = gtk.HPaned() # Creación del Tree izquierdo para los feeds self.treestore = self.populate_feeds() # Propaga los feeds del usuario # Create the TreeView using treestore self.treeview = gtk.TreeView(self.treestore) # Control de eventos de ratón y teclado del tree. self.treeview.connect("button_press_event", self.tree_button_press_event) self.treeview.connect("key_press_event", self.tree_key_press_event) self.treeview.connect("row-activated", self.tree_row_activated) self.treeselection = self.treeview.get_selection() self.treeselection.connect("changed", self.tree_row_selection) self.tvcolumn = gtk.TreeViewColumn('Feeds') # Add tvcolumn to treeview self.treeview.append_column(self.tvcolumn) # CellRenderers para Iconos y Texto self.cellpb = gtk.CellRendererPixbuf() self.cell = gtk.CellRendererText() # Añadimos las cells a la tvcolumn self.tvcolumn.pack_start(self.cellpb, False) self.tvcolumn.pack_start(self.cell, True) if gtk.gtk_version[1] < 2: self.tvcolumn.set_cell_data_func(self.cellpb, self.make_pb) else: self.tvcolumn.set_attributes(self.cellpb, stock_id=1) self.tvcolumn.set_attributes(self.cell, text=0) # Allow sorting on the column self.tvcolumn.set_sort_column_id(0) # Allow drag and drop reordering of rows self.treeview.set_reorderable(True) self.treeview_setup_dnd(self.treeview) self.scrolled_window1 = gtk.ScrolledWindow() self.scrolled_window1.add_with_viewport(self.treeview) self.scrolled_window1.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.scrolled_window1.set_size_request( 175, 50) # Sets an acceptable tree sizing self.hpaned.add1(self.scrolled_window1) ######################## # PARTE 2 (entry list) # ######################## # Creación del VPaned self.vpaned = gtk.VPaned() # Creación de los 2 elementos restantes: la lista y el browser. # Create a liststore # Campos: fecha, flag_importante, titulo, font-style, id_entry/articulo self.liststore = gtk.ListStore(str, bool, str, str, int) # create the TreeView using liststore self.treeview2 = gtk.TreeView(self.liststore) self.treeview2.set_rules_hint(True) # differentiate rows... self.treeview2.connect("button_press_event", self.tree2_button_press_event) self.treeselection2 = self.treeview2.get_selection() self.treeselection2.connect("changed", self.list_row_selection) # Create CellRenderers to render the data self.cellt = gtk.CellRendererToggle() self.cellt.set_property('activatable', True) self.cellt.connect('toggled', self.toggle_importante, self.liststore) # toggle signal capture self.celldate = gtk.CellRendererText() self.celltitle = gtk.CellRendererText() # Create the TreeViewColumns to display the data self.image = gtk.Image() self.image.set_from_stock(gtk.STOCK_MEDIA_RECORD, gtk.ICON_SIZE_MENU) # Record icon self.image.show() # Sin esto, no aparece!!! :S self.tvcolumn_important = gtk.TreeViewColumn(None, self.cellt) self.tvcolumn_important.set_widget(self.image) ###self.tvcolumn_important = gtk.TreeViewColumn('') self.tvcolumn_fecha = gtk.TreeViewColumn('Fecha', self.celldate, text=0, font=3) self.tvcolumn_titulo = gtk.TreeViewColumn('Título', self.celltitle, text=2, font=3) # Append data to the liststore ###self.liststore = self.populate_entries(None) # Propaga las entradas de cada feed # (...) # Add columns to treeview self.treeview2.append_column(self.tvcolumn_important) self.treeview2.append_column(self.tvcolumn_fecha) self.treeview2.append_column(self.tvcolumn_titulo) # Add the cells to the columns ###self.tvcolumn_important.pack_start(self.cellt, False) # En este caso, no necesitamos lo siguiente (definimos su cell al crear self.tvcolumn_titulo) ###self.tvcolumn_fecha.pack_start(self.celldate, True) ###self.tvcolumn_titulo.pack_start(self.celltitle, True) self.tvcolumn_important.add_attribute(self.cellt, "active", 1) # Y esto tampoco! ###self.tvcolumn_fecha.set_attributes(self.celldate, text=0) ###self.tvcolumn_titulo.set_attributes(self.celltitle, text=2) # ORIG # make treeview searchable self.treeview2.set_search_column(2) # Allow sorting on the column self.tvcolumn_fecha.set_sort_column_id(0) self.tvcolumn_titulo.set_sort_column_id(2) self.scrolled_window2 = gtk.ScrolledWindow() self.scrolled_window2.add_with_viewport(self.treeview2) self.scrolled_window2.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.scrolled_window2.set_size_request( 300, 100) # Sets an acceptable list sizing self.vpaned.add1(self.scrolled_window2) ########### # PARTE 3 # ########### self.button2 = gtk.Button("Button 2") #self.button2.connect("clicked", self.callback, "button 2") self.vpaned.add2(self.button2) self.hpaned.add2(self.vpaned) self.vbox.pack_start(self.hpaned, True, True, 0) self.window.add(self.vbox) # Create TrayIcon self.create_trayicon() self.window.show_all()
def __init__(self, w3af): super(VulnAddDialog, self).__init__("Add new vulnerability", None, gtk.MESSAGE_QUESTION, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_ADD, gtk.RESPONSE_OK)) self.set_icon_from_file(W3AF_ICON) self.w3af = w3af # Main hbox hbox = gtk.HBox() hbox.show() image = gtk.Image() image.set_from_stock(gtk.STOCK_DIALOG_QUESTION, gtk.ICON_SIZE_DIALOG) image.set_padding(20, 20) image.show() hbox.pack_start(image) # Vbox with all the information for the right section of the dialog vbox = gtk.VBox() # Add a label align = gtk.Alignment() align.set_padding(10, 0, 0, 10) label = gtk.Label('Choose the vulnerability template to use:') align.add(label) vbox.pack_start(align) template_long_names = get_template_long_names() template_names = get_template_names() self.vuln_template = None # A list store with the following columns: # * Long template name (show) # * Template name (code internals) liststore = gtk.ListStore(str, str) self.combobox = gtk.ComboBox(liststore) cell = gtk.CellRendererText() self.combobox.pack_start(cell, True) self.combobox.add_attribute(cell, 'text', 0) self.combobox.connect("changed", self._changed_combo) for i, long_name in enumerate(template_long_names): liststore.append((long_name, template_names[i])) vbox.pack_start(self.combobox, False, False) vbox.pack_start(gtk.Label()) # the Cancel button but = self.action_area.get_children()[1] but.connect("clicked", lambda x: self.destroy()) self.connect("delete-event", lambda x, y: self.destroy()) # the Ok button self.ok_but = self.action_area.get_children()[0] self.ok_but.connect("clicked", self._ok) self.ok_but.set_sensitive(False) hbox.pack_start(vbox) self.vbox.pack_start(hbox) self.show_all()
def __init__(self): oofGUI.MainPage.__init__( self, name="Solver", ordering=240, tip="Find solutions for static and time-dependent problems.") mainbox = gtk.VBox(spacing=2) self.gtk.add(mainbox) align = gtk.Alignment(xalign=0.5) mainbox.pack_start(align, expand=0, fill=0) centerbox = gtk.HBox(spacing=3) align.add(centerbox) self.meshwidget = whowidget.WhoWidget(ooflib.engine.mesh.meshes, scope=self) switchboard.requestCallbackMain(self.meshwidget, self.meshCB) label = gtk.Label("Microstructure=") label.set_alignment(1.0, 0.5) centerbox.pack_start(label, expand=0, fill=0) centerbox.pack_start(self.meshwidget.gtk[0], expand=0, fill=0) label = gtk.Label("Skeleton=") label.set_alignment(1.0, 0.5) centerbox.pack_start(label, expand=0, fill=0) centerbox.pack_start(self.meshwidget.gtk[1], expand=0, fill=0) label = gtk.Label("Mesh=") label.set_alignment(1.0, 0.5) centerbox.pack_start(label, expand=0, fill=0) centerbox.pack_start(self.meshwidget.gtk[2], expand=0, fill=0) mainvpane = gtk.VPaned() gtklogger.setWidgetName(mainvpane, 'VPane') mainbox.pack_start(mainvpane, expand=1, fill=1) gtklogger.connect_passive(mainvpane, 'notify::position') # Subproblem pane ## TODO 3.1: Make it possible to reorder the subproblems by ## drag and drop. subprobframe = gtk.Frame('Solvers') gtklogger.setWidgetName(subprobframe, "Subproblems") subprobframe.set_shadow_type(gtk.SHADOW_IN) mainvpane.pack1(subprobframe, resize=1, shrink=0) subpvbox = gtk.VBox() # contains scrolled list and buttons subpvbox.set_border_width(3) subprobframe.add(subpvbox) innerframe = gtk.Frame() innerframe.set_shadow_type(gtk.SHADOW_IN) subpvbox.pack_start(innerframe, expand=1, fill=1) self.subpScroll = gtk.ScrolledWindow() gtklogger.logScrollBars(self.subpScroll, "SubproblemScroll") self.subpScroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) innerframe.add(self.subpScroll) self.subprobList = gtk.ListStore(gobject.TYPE_PYOBJECT) self.subpListView = gtk.TreeView(self.subprobList) gtklogger.setWidgetName(self.subpListView, "SubproblemList") self.subpScroll.add(self.subpListView) gtklogger.adoptGObject(self.subprobList, self.subpListView, access_method=self.subpListView.get_model) # Catch selection changes gtklogger.adoptGObject(self.subpListView.get_selection(), self.subpListView, access_method=self.subpListView.get_selection) self.subpselsig = gtklogger.connect(self.subpListView.get_selection(), 'changed', self.subpSelectCB) # Catch double clicks or returns gtklogger.connect(self.subpListView, 'row-activated', self.subpActivateRowCB) # Order number in the first column ordercell = gtk.CellRendererText() ordercol = gtk.TreeViewColumn("Order") ordercol.set_resizable(False) ordercol.pack_start(ordercell, expand=False) ordercol.set_cell_data_func(ordercell, self.renderSubproblemOrder) self.subpListView.append_column(ordercol) # Checkbox in the second column solvecell = gtk.CellRendererToggle() solvecol = gtk.TreeViewColumn("Solve?") solvecol.pack_start(solvecell, expand=False) solvecol.set_cell_data_func(solvecell, self.renderSolveCell) self.subpListView.append_column(solvecol) gtklogger.adoptGObject(solvecell, self.subpListView, access_function=gtklogger.findCellRenderer, access_kwargs={ 'col': 1, 'rend': 0 }) gtklogger.connect(solvecell, 'toggled', self.solvecellCB) # Subproblem name in the third column namecell = gtk.CellRendererText() namecol = gtk.TreeViewColumn("Subproblem") namecol.set_resizable(True) namecol.pack_start(namecell, expand=True) namecol.set_cell_data_func(namecell, self.renderSubproblemName) self.subpListView.append_column(namecol) # Solver in the fourth column solvercell = gtk.CellRendererText() solvercol = gtk.TreeViewColumn("Solver") solvercol.set_resizable(True) solvercol.pack_start(solvercell, expand=True) solvercol.set_cell_data_func(solvercell, self.renderSubproblemSolver) self.subpListView.append_column(solvercol) # Buttons at the bottom of the subproblem pane subpbbox = gtk.HBox(homogeneous=True) subpvbox.pack_start(subpbbox, expand=0, fill=0) # Set Solver self.setSolverButton = gtkutils.StockButton(gtk.STOCK_ADD, "Set...") gtklogger.setWidgetName(self.setSolverButton, "Set") gtklogger.connect(self.setSolverButton, 'clicked', self.setSolverCB) subpbbox.pack_start(self.setSolverButton, expand=0, fill=1) tooltips.set_tooltip_text( self.setSolverButton, "Assign a solver to the selected subproblem.") # Copy Solver self.copySolverButton = gtkutils.StockButton(gtk.STOCK_COPY, "Copy...") gtklogger.setWidgetName(self.copySolverButton, "Copy") gtklogger.connect(self.copySolverButton, 'clicked', self.copySolverCB) subpbbox.pack_start(self.copySolverButton, expand=0, fill=1) tooltips.set_tooltip_text( self.copySolverButton, "Copy the selected solver to another subproblem," " possibly in another mesh.") # Copy All Solvers self.copyAllSolversButton = gtkutils.StockButton( gtk.STOCK_COPY, "Copy All...") gtklogger.setWidgetName(self.copyAllSolversButton, "CopyAll") gtklogger.connect(self.copyAllSolversButton, 'clicked', self.copyAllSolversCB) subpbbox.pack_start(self.copyAllSolversButton, expand=0, fill=1) tooltips.set_tooltip_text( self.copyAllSolversButton, "Copy all solvers to identically named subproblems in another mesh." ) # Remove Solver self.removeSolverButton = gtkutils.StockButton(gtk.STOCK_REMOVE, "Remove") gtklogger.setWidgetName(self.removeSolverButton, "Remove") gtklogger.connect(self.removeSolverButton, 'clicked', self.removeSolverCB) subpbbox.pack_start(self.removeSolverButton, expand=0, fill=1) tooltips.set_tooltip_text( self.removeSolverButton, "Delete the solver from the selected subproblem.") # Remove all solvers self.removeAllSolversButton = gtkutils.StockButton( gtk.STOCK_CLEAR, "Remove All") gtklogger.setWidgetName(self.removeAllSolversButton, "RemoveAll") gtklogger.connect(self.removeAllSolversButton, 'clicked', self.removeAllSolversCB) subpbbox.pack_start(self.removeAllSolversButton, expand=0, fill=1) tooltips.set_tooltip_text(self.removeAllSolversButton, "Remove the solver from all subproblems.") # Second row of buttons at the bottom of the subproblem pane subpbbox = gtk.HBox(homogeneous=True) subpvbox.pack_start(subpbbox, expand=0, fill=0) # Solve this subproblem first self.firstButton = gtkutils.StockButton(gtk.STOCK_GOTO_FIRST, "First", align=0.0) gtklogger.setWidgetName(self.firstButton, "First") gtklogger.connect(self.firstButton, 'clicked', self.firstButtonCB) subpbbox.pack_start(self.firstButton, expand=0, fill=1) tooltips.set_tooltip_text( self.firstButton, "Solve the selected subproblem first when iterating" " over subproblems.") # Solve this subproblem earlier self.earlierButton = gtkutils.StockButton(gtk.STOCK_GO_BACK, "Earlier", align=0.0) gtklogger.setWidgetName(self.earlierButton, "Earlier") gtklogger.connect(self.earlierButton, 'clicked', self.earlierButtonCB) subpbbox.pack_start(self.earlierButton, expand=0, fill=1) tooltips.set_tooltip_text( self.earlierButton, "Solve the selected subproblem before the one above it" " in the list when iterating over subproblems.") # Solve this subproblem later self.laterButton = gtkutils.StockButton(gtk.STOCK_GO_FORWARD, "Later", reverse=True, align=1.0) gtklogger.setWidgetName(self.laterButton, "Later") gtklogger.connect(self.laterButton, 'clicked', self.laterButtonCB) subpbbox.pack_start(self.laterButton, expand=0, fill=1) tooltips.set_tooltip_text( self.laterButton, "Solve the selected subproblem after the next one in the" " list when iterating over subproblems.") # Solve this subproblem last self.lastButton = gtkutils.StockButton(gtk.STOCK_GOTO_LAST, "Last", reverse=True, align=1.0) gtklogger.setWidgetName(self.lastButton, "Last") gtklogger.connect(self.lastButton, 'clicked', self.lastButtonCB) subpbbox.pack_start(self.lastButton, expand=0, fill=1) tooltips.set_tooltip_text( self.lastButton, "Solve the selected subproblem last when iterating" " over subproblems.") # Field Initializers initframe = gtk.Frame('Initialization') gtklogger.setWidgetName(initframe, "FieldInit") initframe.set_shadow_type(gtk.SHADOW_IN) mainvpane.pack2(initframe, resize=1, shrink=0) ivbox = gtk.VBox() ivbox.set_border_width(3) initframe.add(ivbox) self.initscroll = gtk.ScrolledWindow() gtklogger.logScrollBars(self.initscroll, "Scroll") self.initscroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.initscroll.set_shadow_type(gtk.SHADOW_IN) ivbox.pack_start(self.initscroll, expand=1, fill=1) # The ListStore just contains the defined Fields. The # TreeView displays their names and initializers. self.initlist = gtk.ListStore(gobject.TYPE_PYOBJECT) self.initview = gtk.TreeView(self.initlist) gtklogger.setWidgetName(self.initview, 'Initializers') self.initscroll.add(self.initview) self.initview.set_headers_clickable(False) fieldnamecell = gtk.CellRendererText() fieldnamecol = gtk.TreeViewColumn('Field or BC') self.initview.append_column(fieldnamecol) fieldnamecol.pack_start(fieldnamecell, expand=False) fieldnamecol.set_cell_data_func(fieldnamecell, self.renderFieldName) fieldinitcell = gtk.CellRendererText() fieldinitcol = gtk.TreeViewColumn('Initializer') self.initview.append_column(fieldinitcol) fieldinitcol.pack_start(fieldinitcell, expand=True) fieldinitcol.set_cell_data_func(fieldinitcell, self.renderFieldInit) selection = self.initview.get_selection() gtklogger.adoptGObject(selection, self.initview, access_method=self.initview.get_selection) self.initselsignal = gtklogger.connect(selection, 'changed', self.initSelectCB) gtklogger.connect(self.initview, 'row-activated', self.initActivateRowCB) bbox = gtk.HBox(homogeneous=True) ivbox.pack_start(bbox, expand=0, fill=0) # Set button self.fieldinitbutton = gtkutils.StockButton(gtk.STOCK_ADD, 'Set...') gtklogger.setWidgetName(self.fieldinitbutton, "Set") gtklogger.connect(self.fieldinitbutton, 'clicked', self.fieldinitbuttonCB) tooltips.set_tooltip_text(self.fieldinitbutton, 'Initialized the selected field.') bbox.pack_start(self.fieldinitbutton, expand=0, fill=1) # Copy button self.copyinitbutton = gtkutils.StockButton(gtk.STOCK_COPY, "Copy All...") gtklogger.setWidgetName(self.copyinitbutton, 'CopyInit') gtklogger.connect(self.copyinitbutton, 'clicked', self.copyinitCB) bbox.pack_start(self.copyinitbutton, expand=0, fill=1) tooltips.set_tooltip_text( self.copyinitbutton, "Copy field initializers from the current mesh to another mesh.") # Clear Initializer button self.clearinitbutton = gtkutils.StockButton(gtk.STOCK_REMOVE, "Clear") gtklogger.setWidgetName(self.clearinitbutton, "Clear") gtklogger.connect(self.clearinitbutton, 'clicked', self.clearinitCB) bbox.pack_start(self.clearinitbutton, expand=0, fill=1) tooltips.set_tooltip_text( self.clearinitbutton, "Remove the selected field initializer from the current mesh.") # Clear All Initializers button self.clearallinitsbutton = gtkutils.StockButton( gtk.STOCK_CLEAR, "Clear All") gtklogger.setWidgetName(self.clearallinitsbutton, 'ClearAll') gtklogger.connect(self.clearallinitsbutton, 'clicked', self.clearallinitsCB) bbox.pack_start(self.clearallinitsbutton, expand=0, fill=1) tooltips.set_tooltip_text( self.clearallinitsbutton, "Remove the field initializers from the current mesh.") # Second row of buttons in the Field Initialization pane bbox = gtk.HBox(homogeneous=True) ivbox.pack_start(bbox, expand=0, fill=1) # Apply button self.applyinitbutton = gtkutils.StockButton(gtk.STOCK_APPLY, "Apply") gtklogger.setWidgetName(self.applyinitbutton, "Apply") gtklogger.connect(self.applyinitbutton, 'clicked', self.applyinitCB) tooltips.set_tooltip_text( self.applyinitbutton, "Apply initializers to all fields at the current time.") bbox.pack_start(self.applyinitbutton, expand=0, fill=1) # Apply At button self.applyinitattimebutton = gtkutils.StockButton( gtk.STOCK_APPLY, "Apply at time...") gtklogger.setWidgetName(self.applyinitattimebutton, "ApplyAt") gtklogger.connect(self.applyinitattimebutton, 'clicked', self.applyinitatCB) tooltips.set_tooltip_text( self.applyinitattimebutton, "Reset the current time and apply all field initializers.") bbox.pack_start(self.applyinitattimebutton, expand=0, fill=1) # Table containing status, time entries and Solve button table = gtk.Table(rows=2, columns=4) mainbox.pack_start(table, expand=0, fill=1) # The start time isn't set directly by the user, except by # applying field initializers at a given time. It's displayed # in a desensitized gtk.Entry. label = gtk.Label('current time=') label.set_alignment(1.0, 0.5) table.attach(label, 0, 1, 0, 1, xpadding=3, xoptions=~gtk.EXPAND) self.currentTimeEntry = gtk.Entry() self.currentTimeEntry.set_sensitive(False) # never sensitive table.attach(self.currentTimeEntry, 1, 2, 0, 1, xpadding=3) # End time is set by the user. label = gtk.Label('end time=') label.set_alignment(1.0, 0.5) table.attach(label, 0, 1, 1, 2, xpadding=3, xoptions=~gtk.EXPAND) self.endtimeEntry = gtk.Entry() gtklogger.setWidgetName(self.endtimeEntry, 'end') gtklogger.connect(self.endtimeEntry, 'changed', self.timeChangeCB) table.attach(self.endtimeEntry, 1, 2, 1, 2, xpadding=3) statusFrame = gtk.Frame("Status") statusFrame.set_shadow_type(gtk.SHADOW_IN) vbox = gtk.VBox() statusFrame.add(vbox) self.statusLabel = gtk.Label() self.statusLabel.set_alignment(0.5, 0.5) table.attach(statusFrame, 2, 3, 0, 3, xpadding=3) vbox.pack_start(self.statusLabel, expand=0, fill=0) align = gtk.Alignment(xalign=0.5) vbox.pack_start(align, expand=0, fill=0, padding=3) self.statusDetailButton = gtk.Button("Details...") gtklogger.setWidgetName(self.statusDetailButton, 'status') gtklogger.connect(self.statusDetailButton, 'clicked', self.statusCB) align.add(self.statusDetailButton) solveFrame0 = gtk.Frame() solveFrame0.set_shadow_type(gtk.SHADOW_OUT) solveFrame1 = gtk.Frame() solveFrame1.set_shadow_type(gtk.SHADOW_IN) solveFrame0.add(solveFrame1) table.attach(solveFrame0, 3, 4, 0, 3, xpadding=3, xoptions=~gtk.EXPAND) self.solveButton = gtkutils.StockButton(gtk.STOCK_EXECUTE, '<b>Solve</b>', markup=True) self.solveButton.set_border_width(4) gtklogger.setWidgetName(self.solveButton, 'solve') gtklogger.connect(self.solveButton, 'clicked', self.solveCB) solveFrame1.add(self.solveButton) switchboard.requestCallbackMain("field defined", self.defineFldCB) switchboard.requestCallbackMain("field initializer set", self.initFldCB) switchboard.requestCallbackMain("subproblem changed", self.subproblemsChangedCB) switchboard.requestCallbackMain("mesh changed", self.subproblemsChangedCB) switchboard.requestCallbackMain("subproblem solvability changed", self.subpSolverChangedCB) switchboard.requestCallbackMain("subproblem solver changed", self.subpSolverChangedCB) switchboard.requestCallbackMain("subproblem solvers changed", self.subpSolversChangedCB), switchboard.requestCallbackMain("subproblems reordered", self.subproblemsChangedCB), switchboard.requestCallbackMain(("new who", "SubProblem"), self.subproblemsChangedCB) switchboard.requestCallbackMain(("rename who", "SubProblem"), self.subproblemsChangedCB) switchboard.requestCallbackMain(("remove who", "SubProblem"), self.subproblemsChangedCB) switchboard.requestCallbackMain("time changed", self.meshTimeChangedCB) switchboard.requestCallbackMain("mesh solved", self.meshSolvedCB) switchboard.requestCallbackMain("mesh status changed", self.statusChangedCB) switchboard.requestCallbackMain("made reservation", self.reservationCB) switchboard.requestCallbackMain("cancelled reservation", self.reservationCB)
def __init__(self, mainUI, feedback): """Constructor for a new game dialog. 'mainUI' is the main UI. 'feedback' is the object to feedback events with. """ self.__mainUI = mainUI self.feedback = feedback # Load the UI self.__gui = gtkui.loadUIFile('network_game.ui') self.__gui.connect_signals(self) # Selected profile self.__profile = None self.profileModel = gtk.ListStore(gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT, str) # Translators: Server Combo Box: Not connected to a server self.profileModel.set(self.profileModel.append(), 0, None, 1, self._set_profile, 2, _('Disconnected')) self.profileModelSuffixCount = 0 self.profileModel.set(self.profileModel.append(), 1, None) self.profileModelSuffixCount += 1 # Translators: Server Combo Box: Add new profile self.profileModel.set(self.profileModel.append(), 0, None, 1, self._new_profile, 2, _('New profile...')) self.profileModelSuffixCount += 1 widget = self.__gui.get_object('server_combo') widget.set_model(self.profileModel) widget.set_active(0) widget.set_row_separator_func(self._is_profile_model_separator) cell = gtk.CellRendererText() widget.pack_start(cell, False) widget.add_attribute(cell, 'text', 2) # room object, index, name, num players, description, font weight, font style, icon_name self.roomModel = gtk.TreeStore(gobject.TYPE_PYOBJECT, int, str, str, str, int, int, str) self.firstNonChessIter = None self.roomIters = {} view = self.__gui.get_object('room_list') view.set_model(self.roomModel) cell = gtk.CellRendererText() column = gtk.TreeViewColumn('', cell) column.add_attribute(cell, 'text', 3) view.append_column(column) cell = gtk.CellRendererPixbuf() column = gtk.TreeViewColumn('', cell) column.add_attribute(cell, 'icon-name', 7) view.append_column(column) cell = gtk.CellRendererText() column = gtk.TreeViewColumn('', cell) column.add_attribute(cell, 'text', 2) column.add_attribute(cell, 'weight', 5) column.add_attribute(cell, 'style', 6) view.append_column(column) cell = gtk.CellRendererText() column = gtk.TreeViewColumn('', cell) column.add_attribute(cell, 'text', 4) #view.append_column(column) view.connect('row-activated', self._on_room_changed) # player, name, icon self.playerModel = gtk.ListStore(gobject.TYPE_PYOBJECT, str, str) view = self.__gui.get_object('player_list') view.set_model(self.playerModel) cell = gtk.CellRendererPixbuf() column = gtk.TreeViewColumn('', cell) column.add_attribute(cell, 'icon-name', 2) view.append_column(column) cell = gtk.CellRendererText() column = gtk.TreeViewColumn('', cell) column.add_attribute(cell, 'text', 1) view.append_column(column) # table, number, seats, description, seat model, can connect self.tableModel = gtk.ListStore(gobject.TYPE_PYOBJECT, str, str, str, gobject.TYPE_PYOBJECT, gobject.TYPE_BOOLEAN) self.tableIters = {} view = self.__gui.get_object('table_list') view.get_selection().connect('changed', self._on_table_selected) view.set_model(self.tableModel) cell = gtk.CellRendererText() # Translators: Available GGZ Tables: Table name column title column = gtk.TreeViewColumn(_('Table'), cell) column.add_attribute(cell, 'text', 1) view.append_column(column) cell = gtk.CellRendererText() # Translators: Available GGZ Tables: Seat status column title column = gtk.TreeViewColumn(_('Seats'), cell) column.add_attribute(cell, 'text', 2) view.append_column(column) cell = gtk.CellRendererText() # Translators: Available GGZ Tables: Table description column title column = gtk.TreeViewColumn(_('Description'), cell) column.add_attribute(cell, 'text', 3) view.append_column(column) view = self.__gui.get_object('seat_list') cell = gtk.CellRendererText() # Translators: Current GGZ Table: Seat name column title column = gtk.TreeViewColumn(_('Seat'), cell) column.add_attribute(cell, 'text', 2) view.append_column(column) # Translators: Current GGZ Table: Player name column title column = gtk.TreeViewColumn(_('Player'), cell) column.add_attribute(cell, 'text', 3) column.add_attribute(cell, 'style', 4) view.append_column(column) self.__loadThrobber() # Create styles for the buffer buffer = self.__gui.get_object('chat_textview').get_buffer() buffer.create_tag('motd', family='Monospace', foreground='red') buffer.create_tag('chat', family='Monospace') #buffer.create_tag('output', family='Monospace', weight = pango.WEIGHT_BOLD) #buffer.create_tag('move', family='Monospace', foreground = 'blue') buffer.create_tag('info', family='Monospace', foreground='gray') #buffer.create_tag('error', family='Monospace', foreground = 'red') buffer.create_mark('end', buffer.get_end_iter()) mainUI.setTooltipStyle(self.__gui.get_object('info_panel')) self.__addProfileDialog = GtkNetworkAddDialog( self, self.__gui.get_object('network_game_dialog'))
def new(self): self.config = Config() # Add controles self.tblGeneral = self.get_widget("tblGeneral") self.btnFColor = self.get_widget("btnFColor") self.btnBColor = self.get_widget("btnBColor") self.btnFont = self.get_widget("btnFont") self.lblFont = self.get_widget("lblFont") self.treeCmd = self.get_widget("treeCommands") self.treeCustom = self.get_widget("treeCustom") self.dlgColor = None self.capture_keys = False self.tblGeneral.rows = 0 self.addParam(_("Word separator"), "self.config.WORD_SEPARATORS", str) self.addParam(_(u"Buffer size"), "self.config.BUFFER_LINES", int, 1, 1000000) self.addParam(_("Transparency"), "self.config.TRANSPARENCY", int, 0, 100) self.addParam(_("Logs path"), "self.config.LOG_PATH", str) self.addParam(_("Open local console on startup"), "self.config.STARTUP_LOCAL", bool) self.addParam(_(u"Paste on right click"), "self.config.PASTE_ON_RIGHT_CLICK", bool) self.addParam(_(u"Copy selection to clipboard"), "self.config.AUTO_COPY_SELECTION", bool) self.addParam(_("Confirm on close console"), "self.config.CONFIRM_ON_CLOSE_TAB", bool) self.addParam( _("Close console"), "self.config.AUTO_CLOSE_TAB", list, [_("Never"), _("Always"), _(u"Only on clean exit")]) self.addParam(_("Confirm on exit"), "self.config.CONFIRM_ON_EXIT", bool) if len(self.config.FONT_COLOR) == 0: self.get_widget("chkDefaultColors").set_active(True) self.btnFColor.set_sensitive(False) self.btnBColor.set_sensitive(False) fcolor = "#FFFFFF" bcolor = "#000000" else: self.get_widget("chkDefaultColors").set_active(False) self.btnFColor.set_sensitive(True) self.btnBColor.set_sensitive(True) fcolor = self.config.FONT_COLOR bcolor = self.config.BACK_COLOR self.btnFColor.set_color(gtk.gdk.Color(fcolor)) self.btnBColor.set_color(gtk.gdk.Color(bcolor)) self.btnFColor.selected_color = fcolor self.btnBColor.selected_color = bcolor # Fuente if len(self.config.FONT) == 0 or self.config.FONT == 'monospace': self.config.FONT = 'monospace' else: self.chkDefaultFont.set_active(False) self.btnFont.selected_font = pango.FontDescription(self.config.FONT) self.btnFont.set_label(self.btnFont.selected_font.to_string()) self.btnFont.get_child().modify_font(self.btnFont.selected_font) # commandos self.treeModel = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING) self.treeCmd.set_model(self.treeModel) column = gtk.TreeViewColumn(_(u"Action"), gtk.CellRendererText(), text=0) column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) column.set_expand(True) self.treeCmd.append_column(column) renderer = gtk.CellRendererText() renderer.set_property("editable", True) renderer.connect('edited', self.on_edited, self.treeModel, 1) renderer.connect('editing-started', self.on_editing_started, self.treeModel, 1) column = gtk.TreeViewColumn(_("Atajo"), renderer, text=1) column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE) column.set_expand(False) self.treeCmd.append_column(column) self.treeModel2 = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING) self.treeCustom.set_model(self.treeModel2) renderer = MultilineCellRenderer() renderer.set_property("editable", True) renderer.connect('edited', self.on_edited, self.treeModel2, 0) column = gtk.TreeViewColumn(_("Comando"), renderer, text=0) column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) column.set_expand(True) self.treeCustom.append_column(column) renderer = gtk.CellRendererText() renderer.set_property("editable", True) renderer.connect('edited', self.on_edited, self.treeModel2, 1) renderer.connect('editing-started', self.on_editing_started, self.treeModel2, 1) column = gtk.TreeViewColumn(_("Atajo"), renderer, text=1) column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE) column.set_expand(False) self.treeCustom.append_column(column) slist = sorted(self.config.shortcuts.iteritems(), key=lambda (k, v): (v, k)) for s in slist: if type(s[1]) == list: self.treeModel.append(None, [s[1][0], s[0]]) for s in slist: if type(s[1]) != list: self.treeModel2.append(None, [s[1], s[0]]) self.treeModel2.append(None, ['', ''])
def __init__(self): #Set the Glade file self.gladefile = "/usr/lib/linuxmint/mint-debian-installer/mint-debian-installer.glade" self.wTree = gtk.glade.XML(self.gladefile,"main_window") self.wTree.get_widget("main_window").connect("destroy", gtk.main_quit) self.wTree.get_widget("main_window").set_icon_from_file("/usr/lib/linuxmint/mint-debian-installer/icon.png") self.wTree.get_widget("main_window").set_title(_("Installer")) self.wTree.get_widget("button_forward_1").connect('clicked', self.next_page) self.wTree.get_widget("button_forward_2").connect('clicked', self.validate_partition) self.wTree.get_widget("button_forward_3").connect('clicked', self.validate_names) self.wTree.get_widget("button_forward_4").connect('clicked', self.last_page) self.wTree.get_widget("button_apply").connect('clicked', self.performInstall) self.wTree.get_widget("button_back_2").connect('clicked', self.prev_page) self.wTree.get_widget("button_back_3").connect('clicked', self.prev_page) self.wTree.get_widget("button_back_4").connect('clicked', self.prev_page) self.wTree.get_widget("button_back_5").connect('clicked', self.prev_page) self.wTree.get_widget("button_quit_1").connect('clicked', gtk.main_quit) self.wTree.get_widget("button_quit_2").connect('clicked', gtk.main_quit) self.wTree.get_widget("button_quit_3").connect('clicked', gtk.main_quit) self.wTree.get_widget("button_quit_4").connect('clicked', gtk.main_quit) self.wTree.get_widget("button_quit_5").connect('clicked', gtk.main_quit) self.wTree.get_widget("menu_quit").connect('activate', gtk.main_quit) self.wTree.get_widget("menu_about").connect('activate', self.open_about) self.wTree.get_widget("check_grub").set_active(True) self.tree = self.wTree.get_widget("treeview_hard_disks") self.column = gtk.TreeViewColumn(_("Disk")) self.tree.append_column(self.column) self.renderer = gtk.CellRendererText() self.column.pack_start(self.renderer, True) self.column.add_attribute(self.renderer, 'text', 0) self.model = gtk.ListStore(str) # Find hard-drives hdd_descriptions = [] inxi = commands.getoutput("inxi -D -c 0") parts = inxi.split(":") for part in parts: if "/dev/" in part: hdd = part[:-1].strip() self.model.append([hdd]) self.tree.set_model(self.model) self.tree.show() self.tree = self.wTree.get_widget("treeview_partitions") self.renderer = gtk.CellRendererText() self.column1 = gtk.TreeViewColumn(_("Partition")) self.column1.pack_start(self.renderer, True) self.column1.add_attribute(self.renderer, 'text', 0) self.tree.append_column(self.column1) self.column2 = gtk.TreeViewColumn(_("Size")) self.column2.pack_start(self.renderer, True) self.column2.add_attribute(self.renderer, 'text', 1) self.tree.append_column(self.column2) self.column3 = gtk.TreeViewColumn(_("Type")) self.column3.pack_start(self.renderer, True) self.column3.add_attribute(self.renderer, 'text', 2) self.tree.append_column(self.column3) self.model = gtk.ListStore(str, str, str, str) partitions = commands.getoutput("fdisk -l") partitions = partitions.split("\n") for partition in partitions: if "/dev/" in partition: parts = partition.split() if len(parts) >= 6: if "/dev/" in parts[0]: # Partition device = parts[0] bootable = False x = 1 if parts[1] == "*": bootable = True x = x + 1 start = parts[x] end = parts[x+1] blocks = parts[x+2] try: if blocks[-1:] == "+": blocks = blocks[:-1] blocks = int(blocks) / 1024 / 1024 blocks = str(blocks) + _("GB") except Exception, detail: print detail pass code_type = (parts[x+3]).strip() str_type = "" for subpart in parts[x+4:]: str_type = str_type + subpart + " " self.model.append([device, blocks, str_type, code_type])
def __init__(self): gtk.Window.__init__(self) self.set_title('PDF Quench %s' % VERSION) self.set_default_size(900, 800) self.connect('delete_event', self.__on_delete_window) vbox = gtk.VBox() self.add(vbox) # toolbar toolbar = gtk.Toolbar() buttons = ( (gtk.ToolButton(gtk.STOCK_OPEN), self.__open_btn_clicked, 'Open'), (gtk.ToolButton(gtk.STOCK_SAVE), self.__save_btn_clicked, 'Save'), (gtk.ToolButton(gtk.STOCK_ZOOM_IN), self.__on_zoom_in_btn_clicked, 'Zoom In'), (gtk.ToolButton(gtk.STOCK_ZOOM_OUT), self.__on_zoom_out_btn_clicked, 'Zoom Out'), ) for button, callback, tooltip in buttons: button.set_tooltip_text(tooltip) button.connect_after('clicked', callback) toolbar.insert(button, -1) vbox.pack_start(toolbar, expand=False, fill=False, padding=0) # main component paned = gtk.HPaned() paned.set_position(100) vbox.pack_start(paned, expand=True, fill=True, padding=0) self.__pages_model = gtk.ListStore(str, object) self.__pages_view = gtk.TreeView(self.__pages_model) self.__pages_view.set_enable_search(False) self.__pages_view.get_selection().set_mode(gtk.SELECTION_SINGLE) self.__pages_view.get_selection().connect_after( 'changed', self.__on_page_selected) # columns column = gtk.TreeViewColumn() column.set_title('Pages') column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE) renderer = gtk.CellRendererText() column.pack_start(renderer, False) column.add_attribute(renderer, 'text', 0) column.set_cell_data_func(renderer, self.__render_page_number) self.__pages_view.append_column(column) sw = gtk.ScrolledWindow() sw.add(self.__pages_view) paned.add1(sw) self.__zoom_level = DEFAULT_ZOOM_LEVEL self.__canvas = goocanvas.Canvas() self.__canvas.set_data('scale', ZOOM_LEVELS[self.__zoom_level]) self.__canvas.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse('#F0F0F0')) self.__dragging = False frame = gtk.Frame() frame.set_shadow_type(gtk.SHADOW_ETCHED_OUT) frame.set_border_width(10) paned.add2(frame) sw = gtk.ScrolledWindow() sw.add(self.__canvas) frame.add(sw) accels = gtk.AccelGroup() accels.connect_group(ord('o'), gtk.gdk.CONTROL_MASK, gtk.ACCEL_LOCKED, self.__on_ctrl_o_pressed) accels.connect_group(ord('O'), gtk.gdk.CONTROL_MASK, gtk.ACCEL_LOCKED, self.__on_ctrl_o_pressed) accels.connect_group(ord('s'), gtk.gdk.CONTROL_MASK, gtk.ACCEL_LOCKED, self.__on_ctrl_s_pressed) accels.connect_group(ord('S'), gtk.gdk.CONTROL_MASK, gtk.ACCEL_LOCKED, self.__on_ctrl_s_pressed) accels.connect_group(ord('+'), 0, gtk.ACCEL_LOCKED, self.__on_zoom_in_pressed) accels.connect_group(ord('-'), 0, gtk.ACCEL_LOCKED, self.__on_zoom_out_pressed) self.add_accel_group(accels) self.__current_page = None self.__pdf_filename = None self.__pdf_document = None self.__n_pages = None self.__pdf_view = None self.__default_crop = CropSetting() self.__odd_crop = CropSetting(self.__default_crop) self.__even_crop = CropSetting(self.__default_crop)
def _add_columns(self): cell_favorite = CellRendererFavorite(self.tree_view) cell_favorite.connect('clicked', self.__favorite_clicked_cb) column = gtk.TreeViewColumn() column.props.sizing = gtk.TREE_VIEW_COLUMN_FIXED column.props.fixed_width = cell_favorite.props.width column.pack_start(cell_favorite) column.set_cell_data_func(cell_favorite, self.__favorite_set_data_cb) self.tree_view.append_column(column) self.cell_icon = CellRendererActivityIcon(self.tree_view) column = gtk.TreeViewColumn() column.props.sizing = gtk.TREE_VIEW_COLUMN_FIXED column.props.fixed_width = self.cell_icon.props.width column.pack_start(self.cell_icon) column.add_attribute(self.cell_icon, 'file-name', ListModel.COLUMN_ICON) column.add_attribute(self.cell_icon, 'xo-color', ListModel.COLUMN_ICON_COLOR) self.tree_view.append_column(column) self.cell_title = gtk.CellRendererText() self.cell_title.props.ellipsize = pango.ELLIPSIZE_MIDDLE self.cell_title.props.ellipsize_set = True self._title_column = gtk.TreeViewColumn() self._title_column.props.sizing = gtk.TREE_VIEW_COLUMN_FIXED self._title_column.props.expand = True self._title_column.props.clickable = True self._title_column.pack_start(self.cell_title) self._title_column.add_attribute(self.cell_title, 'markup', ListModel.COLUMN_TITLE) self.tree_view.append_column(self._title_column) buddies_column = gtk.TreeViewColumn() buddies_column.props.sizing = gtk.TREE_VIEW_COLUMN_FIXED self.tree_view.append_column(buddies_column) for column_index in [ ListModel.COLUMN_BUDDY_1, ListModel.COLUMN_BUDDY_2, ListModel.COLUMN_BUDDY_3 ]: cell_icon = CellRendererBuddy(self.tree_view, column_index=column_index) buddies_column.pack_start(cell_icon) buddies_column.props.fixed_width += cell_icon.props.width buddies_column.add_attribute(cell_icon, 'buddy', column_index) buddies_column.set_cell_data_func(cell_icon, self.__buddies_set_data_cb) cell_progress = gtk.CellRendererProgress() cell_progress.props.ypad = style.GRID_CELL_SIZE / 4 buddies_column.pack_start(cell_progress) buddies_column.add_attribute(cell_progress, 'value', ListModel.COLUMN_PROGRESS) buddies_column.set_cell_data_func(cell_progress, self.__progress_data_cb) cell_text = gtk.CellRendererText() cell_text.props.xalign = 1 # Measure the required width for a date in the form of "10 hours, 10 # minutes ago" timestamp = time.time() - 10 * 60 - 10 * 60 * 60 date = util.timestamp_to_elapsed_string(timestamp) date_width = self._get_width_for_string(date) self.sort_column = gtk.TreeViewColumn() self.sort_column.props.sizing = gtk.TREE_VIEW_COLUMN_FIXED self.sort_column.props.fixed_width = date_width self.sort_column.set_alignment(1) self.sort_column.props.resizable = True self.sort_column.props.clickable = True self.sort_column.pack_start(cell_text) self.sort_column.add_attribute(cell_text, 'text', ListModel.COLUMN_TIMESTAMP) self.tree_view.append_column(self.sort_column)
def __init__(self, prefs): melddoc.MeldDoc.__init__(self, prefs) gnomeglade.Component.__init__(self, paths.ui_dir("vcview.ui"), "vcview") actions = ( ("VcCompare", gtk.STOCK_DIALOG_INFO, _("_Compare"), None, _("Compare selected files"), self.on_button_diff_clicked), ("VcCommit", "vc-commit-24", _("Co_mmit..."), None, _("Commit changes to version control"), self.on_button_commit_clicked), ("VcUpdate", "vc-update-24", _("_Update"), None, _("Update working copy from version control"), self.on_button_update_clicked), ("VcPush", "vc-push-24", _("_Push"), None, _("Push local changes to remote"), self.on_button_push_clicked), ("VcAdd", "vc-add-24", _("_Add"), None, _("Add to version control"), self.on_button_add_clicked), ("VcRemove", "vc-remove-24", _("_Remove"), None, _("Remove from version control"), self.on_button_remove_clicked), ("VcResolved", "vc-resolve-24", _("Mar_k as Resolved"), None, _("Mark as resolved in version control"), self.on_button_resolved_clicked), ("VcRevert", gtk.STOCK_REVERT_TO_SAVED, _("Re_vert"), None, _("Revert working copy to original state"), self.on_button_revert_clicked), ("VcDeleteLocally", gtk.STOCK_DELETE, None, None, _("Delete from working copy"), self.on_button_delete_clicked), ) toggleactions = ( ("VcFlatten", gtk.STOCK_GOTO_BOTTOM, _("_Flatten"), None, _("Flatten directories"), self.on_button_flatten_toggled, False), ("VcShowModified", "filter-modified-24", _("_Modified"), None, _("Show modified files"), self.on_filter_state_toggled, False), ("VcShowNormal", "filter-normal-24", _("_Normal"), None, _("Show normal files"), self.on_filter_state_toggled, False), ("VcShowNonVC", "filter-nonvc-24", _("Un_versioned"), None, _("Show unversioned files"), self.on_filter_state_toggled, False), ("VcShowIgnored", "filter-ignored-24", _("Ignored"), None, _("Show ignored files"), self.on_filter_state_toggled, False), ) self.ui_file = paths.ui_dir("vcview-ui.xml") self.actiongroup = gtk.ActionGroup('VcviewActions') self.actiongroup.set_translation_domain("meld") self.actiongroup.add_actions(actions) self.actiongroup.add_toggle_actions(toggleactions) for action in ("VcCompare", "VcFlatten", "VcShowModified", "VcShowNormal", "VcShowNonVC", "VcShowIgnored"): self.actiongroup.get_action(action).props.is_important = True for action in ("VcCommit", "VcUpdate", "VcPush", "VcAdd", "VcRemove", "VcShowModified", "VcShowNormal", "VcShowNonVC", "VcShowIgnored", "VcResolved"): button = self.actiongroup.get_action(action) button.props.icon_name = button.props.stock_id self.model = VcTreeStore() self.widget.connect("style-set", self.model.on_style_set) self.treeview.set_model(self.model) selection = self.treeview.get_selection() selection.set_mode(gtk.SELECTION_MULTIPLE) selection.connect("changed", self.on_treeview_selection_changed) self.treeview.set_headers_visible(1) self.treeview.set_search_equal_func(self.model.treeview_search_cb) self.current_path, self.prev_path, self.next_path = None, None, None self.column_name_map = {} column = gtk.TreeViewColumn(_("Name")) column.set_resizable(True) renicon = emblemcellrenderer.EmblemCellRenderer() rentext = gtk.CellRendererText() column.pack_start(renicon, expand=0) column.pack_start(rentext, expand=1) col_index = self.model.column_index column.set_attributes(renicon, icon_name=col_index(tree.COL_ICON, 0), icon_tint=col_index(tree.COL_TINT, 0)) column.set_attributes(rentext, text=col_index(tree.COL_TEXT, 0), foreground_gdk=col_index(tree.COL_FG, 0), style=col_index(tree.COL_STYLE, 0), weight=col_index(tree.COL_WEIGHT, 0), strikethrough=col_index(tree.COL_STRIKE, 0)) column_index = self.treeview.append_column(column) - 1 self.column_name_map[vc.DATA_NAME] = column_index def addCol(name, num, data_name=None): column = gtk.TreeViewColumn(name) column.set_resizable(True) rentext = gtk.CellRendererText() column.pack_start(rentext, expand=0) column.set_attributes(rentext, markup=self.model.column_index(num, 0)) column_index = self.treeview.append_column(column) - 1 if data_name: self.column_name_map[data_name] = column_index return column self.treeview_column_location = addCol(_("Location"), COL_LOCATION) addCol(_("Status"), COL_STATUS, vc.DATA_STATE) addCol(_("Revision"), COL_REVISION, vc.DATA_REVISION) addCol(_("Options"), COL_OPTIONS, vc.DATA_OPTIONS) self.state_filters = [] for s in self.state_actions: if s in self.prefs.vc_status_filters: action_name = self.state_actions[s][0] self.state_filters.append(s) self.actiongroup.get_action(action_name).set_active(True) self.consolestream = ConsoleStream(self.consoleview) self.location = None self.treeview_column_location.set_visible(self.actiongroup.get_action("VcFlatten").get_active()) if not self.prefs.vc_console_visible: self.on_console_view_toggle(self.console_hide_box) self.vc = None self.valid_vc_actions = tuple() # VC ComboBox self.combobox_vcs = gtk.ComboBox() self.combobox_vcs.lock = True self.combobox_vcs.set_model(gtk.ListStore(str, object, bool)) cell = gtk.CellRendererText() self.combobox_vcs.pack_start(cell, False) self.combobox_vcs.add_attribute(cell, 'text', 0) self.combobox_vcs.add_attribute(cell, 'sensitive', 2) self.combobox_vcs.lock = False self.hbox2.pack_end(self.combobox_vcs, expand=False) self.combobox_vcs.show() self.combobox_vcs.connect("changed", self.on_vc_change)
def pkgsaz(self): vbox = gtk.VBox(False, 6) vbox.show() self.pkgsaz_tree = gtk.TreeView() self.pkgsaz_tree.set_headers_visible(True) self.pkgsaz_tree.set_headers_clickable(True) self.pkgsaz_tree.set_enable_search(True) self.pkgsaz_tree.set_search_column(0) self.pkgsaz_tree.get_selection().set_mode(gtk.SELECTION_SINGLE) col = gtk.TreeViewColumn('Package') col.set_clickable(True) col.set_sort_column_id(self.model.COL_NAME) col.set_min_width(220) col1 = gtk.TreeViewColumn('Description') col1.set_resizable(True) col1.set_min_width(360) col2 = gtk.TreeViewColumn('License') col2.set_resizable(True) col2.set_clickable(True) col2.set_sort_column_id(self.model.COL_LIC) col2.set_min_width(170) col3 = gtk.TreeViewColumn('Group') col3.set_clickable(True) col3.set_sort_column_id(self.model.COL_GROUP) col4 = gtk.TreeViewColumn('Included') col4.set_min_width(80) col4.set_max_width(90) col4.set_sort_column_id(self.model.COL_INC) self.pkgsaz_tree.append_column(col) self.pkgsaz_tree.append_column(col1) self.pkgsaz_tree.append_column(col2) self.pkgsaz_tree.append_column(col3) self.pkgsaz_tree.append_column(col4) cell = gtk.CellRendererText() cell1 = gtk.CellRendererText() cell1.set_property('width-chars', 20) cell2 = gtk.CellRendererText() cell2.set_property('width-chars', 20) cell3 = gtk.CellRendererText() cell4 = gtk.CellRendererToggle() cell4.set_property('activatable', True) cell4.connect("toggled", self.toggle_pkg_include_cb, self.pkgsaz_tree) col.pack_start(cell, True) col1.pack_start(cell1, True) col2.pack_start(cell2, True) col3.pack_start(cell3, True) col4.pack_end(cell4, True) col.set_attributes(cell, text=self.model.COL_NAME) col1.set_attributes(cell1, text=self.model.COL_DESC) col2.set_attributes(cell2, text=self.model.COL_LIC) col3.set_attributes(cell3, text=self.model.COL_GROUP) col4.set_attributes(cell4, active=self.model.COL_INC) self.pkgsaz_tree.show() scroll = gtk.ScrolledWindow() scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) scroll.set_shadow_type(gtk.SHADOW_IN) scroll.add(self.pkgsaz_tree) vbox.pack_start(scroll, True, True, 0) hb = gtk.HBox(False, 0) hb.show() self.search = gtk.Entry() self.search.set_icon_from_stock(gtk.ENTRY_ICON_SECONDARY, "gtk-clear") self.search.connect("icon-release", self.search_entry_clear_cb) self.search.show() self.pkgsaz_tree.set_search_entry(self.search) hb.pack_end(self.search, False, False, 0) label = gtk.Label("Search packages:") label.show() hb.pack_end(label, False, False, 6) vbox.pack_start(hb, False, False, 0) return vbox
def create_ui(self): #search lbl_search_uname = gtk.Label('User name') self.ent_search_uname = gtk.Entry() lbl_search_rname = gtk.Label('Real name') self.ent_search_rname = gtk.Entry() self.combo_search = gtk.combo_box_new_text() self.combo_search.append_text('OR') self.combo_search.append_text('AND') self.combo_search.set_active(0) btn_search_do = gtk.Button(stock=gtk.STOCK_FIND) btn_search_do.connect('clicked', self.user_search) btn_search_clear = gtk.Button(stock=gtk.STOCK_CLEAR) btn_search_clear.connect('clicked', self.user_search_clear) hb_search = gtk.HBox() hb_search.pack_start(lbl_search_uname, padding=4, expand=False) hb_search.pack_start(self.ent_search_uname, padding=4) hb_search.pack_start(lbl_search_rname, padding=4, expand=False) hb_search.pack_start(self.ent_search_rname, padding=4) hb_search.pack_start(self.combo_search, padding=4, expand=False) hb_search.pack_start(btn_search_do, padding=4, expand=False) hb_search.pack_start(btn_search_clear, padding=4, expand=False) self.vbox.pack_start(hb_search, padding=10, expand=False) # # scrollw_main = gtk.ScrolledWindow() scrollw_main.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) self.lstore_main = gtk.ListStore(str, str, str, str) self.trview_main = gtk.TreeView(self.lstore_main) self.trview_main.get_selection().set_mode(gtk.SELECTION_MULTIPLE) # trvcol_main_id = gtk.TreeViewColumn('ID') trvcol_main_id.set_min_width(80) cell_main_id = gtk.CellRendererText() trvcol_main_id.pack_start(cell_main_id, True) trvcol_main_id.set_attributes(cell_main_id, text=0) trvcol_main_uname = gtk.TreeViewColumn('User Name') trvcol_main_uname.set_min_width(140) cell_main_uname = gtk.CellRendererText() trvcol_main_uname.pack_start(cell_main_uname, True) trvcol_main_uname.set_attributes(cell_main_uname, text=1) trvcol_main_rname = gtk.TreeViewColumn('Real Name') trvcol_main_rname.set_min_width(240) cell_main_rname = gtk.CellRendererText() trvcol_main_rname.pack_start(cell_main_rname, True) trvcol_main_rname.set_attributes(cell_main_rname, text=2) trvcol_main_group = gtk.TreeViewColumn('Group') trvcol_main_group.set_min_width(140) cell_main_group = gtk.CellRendererText() trvcol_main_group.pack_start(cell_main_group, True) trvcol_main_group.set_attributes(cell_main_group, text=3) # self.trview_main.append_column(trvcol_main_id) self.trview_main.append_column(trvcol_main_uname) self.trview_main.append_column(trvcol_main_rname) self.trview_main.append_column(trvcol_main_group) self.trview_main.set_search_column(1) scrollw_main.add(self.trview_main) self.vbox.pack_start(scrollw_main) # self.lbl_main_count = gtk.Label() self.lbl_main_count.set_alignment(0.005, 0.5) self.vbox.pack_start(self.lbl_main_count, expand=False, padding=10) # # btn_groupedit = gtk.Button('_Group Editor') img_groupedit = gtk.Image() img_groupedit.set_from_stock(gtk.STOCK_EDIT, gtk.ICON_SIZE_BUTTON) btn_groupedit.set_image(img_groupedit) btn_groupedit.connect('clicked', self.group_edit) btn_new = gtk.Button(stock=gtk.STOCK_NEW) btn_new.connect('clicked', self.user_new) btn_edit = gtk.Button(stock=gtk.STOCK_EDIT) btn_edit.connect('clicked', self.user_edit) btn_del = gtk.Button(stock=gtk.STOCK_DELETE) btn_del.connect('clicked', self.user_delete) btn_refresh = gtk.Button(stock=gtk.STOCK_REFRESH) btn_refresh.connect('clicked', self.user_refresh) btnbox = gtk.HButtonBox() btnbox.set_layout(gtk.BUTTONBOX_END) btnbox.pack_start(btn_groupedit) btnbox.pack_start(btn_new) btnbox.pack_start(btn_edit) btnbox.pack_start(btn_del) btnbox.pack_start(btn_refresh) btnbox.set_spacing(10) # hb_action = gtk.HBox() hb_action.pack_start(btnbox, padding=10) self.vbox.pack_start(hb_action, expand=False, padding=10) # return self.vbox
def AddWineListColumn(self, title, columnId): column = gtk.TreeViewColumn(title, gtk.CellRendererText(), text=columnId) self.wineView.append_column(column)
def group_edit(self, widget): self.group_edit_dialog = gtk.Dialog( 'Group Editor', self.parent, gtk.DIALOG_MODAL, (gtk.STOCK_CLOSE, gtk.RESPONSE_ACCEPT)) self.group_edit_dialog.set_size_request(self.width - 100, self.height - 100) # hbox = gtk.HBox() vbox = gtk.VBox() # self.combo_grp = gtk.combo_box_new_text() self.group_populate_groups(combo=self.combo_grp) # lstore_res = gtk.ListStore(bool, str) self.trview_res = gtk.TreeView(lstore_res) trvcol_res_chk = gtk.TreeViewColumn('Select') trvcol_res_chk.set_min_width(60) trvcol_res_name = gtk.TreeViewColumn('Resource') trvcol_res_name.set_min_width(120) cell_res_chk = gtk.CellRendererToggle() cell_res_chk.set_property('activatable', True) cell_res_chk.connect('toggled', self.group_edit_chk_toggle) cell_res_name = gtk.CellRendererText() trvcol_res_chk.pack_start(cell_res_chk, True) trvcol_res_chk.set_attributes(cell_res_chk, active=0) self.trview_res.append_column(trvcol_res_chk) trvcol_res_name.pack_start(cell_res_name, True) trvcol_res_name.set_attributes(cell_res_name, text=1) self.trview_res.append_column(trvcol_res_name) lstore_res.clear() scrollw_res = gtk.ScrolledWindow() scrollw_res.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrollw_res.add(self.trview_res) # vbox.pack_start(self.combo_grp, padding=4, expand=False) vbox.pack_start(scrollw_res, padding=4) # btnbox = gtk.VButtonBox() btnbox.set_spacing(10) btnbox.set_layout(gtk.BUTTONBOX_START) btn_save = gtk.Button(stock=gtk.STOCK_SAVE) btn_save.get_children()[0].get_children()[0].get_children( )[1].set_text('Save settings') btn_save.connect('clicked', self.group_save) btn_del = gtk.Button(stock=gtk.STOCK_DELETE) btn_del.connect('clicked', self.group_delete) btn_rename = gtk.Button(stock=gtk.STOCK_EDIT) btn_rename.get_children()[0].get_children()[0].get_children( )[1].set_text('Rename') btn_rename.connect('clicked', self.group_rename) btn_new = gtk.Button(stock=gtk.STOCK_NEW) btn_new.connect('clicked', self.group_new) btnbox.pack_start(btn_save) btnbox.pack_start(btn_rename) btnbox.pack_start(btn_del) btnbox.pack_start(btn_new) # self.lbl_group_members = gtk.Label() self.lbl_group_members.set_alignment(0.02, 0.5) # hbox.pack_start(vbox, padding=8) hbox.pack_start(btnbox, expand=False, padding=8) # self.combo_grp.connect('changed', self.group_edit_get_res) # self.group_edit_dialog.vbox.pack_start(hbox, padding=4) self.group_edit_dialog.vbox.pack_start(self.lbl_group_members, padding=4, expand=False) self.group_edit_dialog.vbox.show_all() # ret = self.group_edit_dialog.run() self.group_edit_dialog.destroy() # self.draw_users() return ret
def build_gui(self): self.gtkb = gtk.Builder() self.gtkb.add_from_file("mtimeslot.gui") gtkb = self.gtkb ## Main self.gui_main = gtkb.get_object("main") if self.active: self.gui_main.show() else: self.gui_main.hide() self.gui_expander = gtkb.get_object("expander_timeslot") self.gui_expander.connect("notify::expanded", self.gui_expander_expanded) self.gui_timeslot_topLabel = gtkb.get_object("timeSlot_topLabel") self.gui_main_slots_used = gtkb.get_object("label_slots_used") self.gui_main_slots_left = gtkb.get_object("label_slots_left") self.gui_main_slots_total = gtkb.get_object("label_slots_total") self.gui_main_thisSlot_timeUsed = gtkb.get_object( "label_thisSlot_timeUsed") self.gui_main_thisSlot_timeLeft = gtkb.get_object( "label_thisSlot_timeLeft") self.gui_main_thisSlot_timeTotal = gtkb.get_object( "label_thisSlot_timeTotal") self.gui_main_period = gtkb.get_object("timeSlotFrame_period") # # # Preferences # self.gui_pref = gtkb.get_object("preferences") self.gui_pref_timeSlot_active = gtkb.get_object("pref_timeSlot_active") self.gui_pref_totalSlots = gtkb.get_object("pref_totalSlots") self.gui_pref_totalSlots.set_range(1, 999999) self.gui_pref_totalSlots.set_increments(1, 10) self.gui_pref_slotLength = gtkb.get_object("pref_slotLength") self.gui_pref_slotLength.set_range(1, 999999) self.gui_pref_slotLength.set_increments(1, 10) self.gui_pref_auto_disconnect = gtkb.get_object("pref_auto_disconnect") self.gui_pref_period_autoupdate = gtkb.get_object( "pref_period_autoupdate") self.gui_pref_period_length = gtkb.get_object( "pref_period_length") # Combo Box liststore = gtk.ListStore(gobject.TYPE_STRING) entries = [_('Custom'), _('Day'), _('Week'), _('Month'), _('Year')] for entry in entries: liststore.append([entry]) self.gui_pref_period_length.set_model(liststore) cell = gtk.CellRendererText() self.gui_pref_period_length.pack_start(cell, True) self.gui_pref_period_length.add_attribute(cell, 'text', 0) self.gui_pref_period_length.connect("changed", self.pref_period_length_hchanged) self.gui_pref_label_days = gtkb.get_object("pref_label_days") self.gui_pref_days = gtkb.get_object("pref_days") self.gui_pref_days.set_range(1, 999999) self.gui_pref_days.set_increments(1, 10) self.gui_pref_first_day = gtkb.get_object("pref_first_day") self.gui_pref_first_day.connect('clicked', self.gui_pref_first_day_hclicked) self.gui_pref_alert_active = gtkb.get_object("pref_alert_active") self.gui_pref_alert_predate = gtkb.get_object("pref_alert_predate") self.gui_pref_alert_predate.set_range(1, 999999) self.gui_pref_alert_predate.set_increments(1, 10) ## Date Dialog self.gui_date_dialog = gtkb.get_object("date_dialog") self.gui_date_dialog.connect("delete_event", self.date_dialog_hdelete) self.gui_date_dialog_title = gtkb.get_object("date_dialog_title") self.gui_date_dialog_calendar = gtkb.get_object("date_dialog_calendar") self.gui_date_dialog_calendar.select_month(self.first_day.month - 1, self.first_day.year) self.gui_date_dialog_calendar.select_day(self.first_day.day) self.temp_gui_pref_first_day = self.first_day ## i18n #ntmtools.translate_control_markup(gtkb.get_object("label1")) ntmtools.translate_control_markup(gtkb.get_object("label2")) ntmtools.translate_control_markup(gtkb.get_object("label4")) ntmtools.translate_control_markup(gtkb.get_object("label5")) ntmtools.translate_control_markup(gtkb.get_object("label6")) ntmtools.translate_control_markup(gtkb.get_object("timeSlot_topLabel")) ntmtools.translate_control_markup(gtkb.get_object("date_dialog_title")) ntmtools.translate_control_label( gtkb.get_object("date_dialog_cancelButton")) ntmtools.translate_control_label( gtkb.get_object("date_dialog_okButton")) ntmtools.translate_control_label( gtkb.get_object("pref_timeSlot_active")) ntmtools.translate_control_text(gtkb.get_object("pref_label5")) ntmtools.translate_control_text(gtkb.get_object("pref_label10")) ntmtools.translate_control_label( gtkb.get_object("pref_auto_disconnect")) ntmtools.translate_control_text(gtkb.get_object("pref_label12")) ntmtools.translate_control_label( gtkb.get_object("pref_period_autoupdate")) ntmtools.translate_control_text(gtkb.get_object("pref_label1")) ntmtools.translate_control_text(gtkb.get_object("pref_label2")) ntmtools.translate_control_text(gtkb.get_object("pref_label_days")) ntmtools.translate_control_markup(gtkb.get_object("title")) ntmtools.translate_control_label(gtkb.get_object("pref_alert_active")) ntmtools.translate_control_text(gtkb.get_object("label_alert_predate"))
def __init__(self): # Create a new window self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_title("TreeViewColumn Example") #self.window.set_size_request(200, 200) self.window.connect("delete_event", self.delete_event) # create a liststore with one string column to use as the model self.liststore = gtk.ListStore(str, str, str, 'gboolean') # create the TreeView using liststore self.treeview = gtk.TreeView(self.liststore) # create the TreeViewColumns to display the data self.tvcolumn = gtk.TreeViewColumn('Pixbuf and Text') self.tvcolumn1 = gtk.TreeViewColumn('Text Only') # add a row with text and a stock item - color strings for # the background self.liststore.append(['Open', gtk.STOCK_OPEN, 'Open a File', True]) self.liststore.append(['New', gtk.STOCK_NEW, 'New File', True]) self.liststore.append(['Print', gtk.STOCK_PRINT, 'Print File', False]) # add columns to treeview self.treeview.append_column(self.tvcolumn) self.treeview.append_column(self.tvcolumn1) # create a CellRenderers to render the data self.cellpb = gtk.CellRendererPixbuf() self.cell = gtk.CellRendererText() self.cell1 = gtk.CellRendererText() # set background color property self.cellpb.set_property('cell-background', 'yellow') self.cell.set_property('cell-background', 'cyan') self.cell1.set_property('cell-background', 'pink') # add the cells to the columns - 2 in the first self.tvcolumn.pack_start(self.cellpb, False) self.tvcolumn.pack_start(self.cell, True) self.tvcolumn1.pack_start(self.cell1, True) # set the cell attributes to the appropriate liststore column # GTK+ 2.0 doesn't support the "stock_id" property if gtk.gtk_version[1] < 2: self.tvcolumn.set_cell_data_func(self.cellpb, self.make_pb) else: self.tvcolumn.set_attributes(self.cellpb, stock_id=1) self.tvcolumn.set_attributes(self.cell, text=0) self.tvcolumn1.set_attributes(self.cell1, text=2, cell_background_set=3) # make treeview searchable self.treeview.set_search_column(0) # Allow sorting on the column self.tvcolumn.set_sort_column_id(0) # Allow drag and drop reordering of rows self.treeview.set_reorderable(True) self.window.add(self.treeview) self.window.show_all()
def start(self): print "Starting configurator" def name_func(column, cell, model, iter): title = "untitled" site_config = model.get_value(iter, 0) if site_config.has_key("title"): title = site_config["title"] cell.set_property('text', title) def on_destroy(mozembed): gtk.main_quit() def on_start_site(button): site_config = self.get_selected_site_config() config.start_site(site_config["name"]) def on_config_site(button): site_config = self.get_selected_site_config() config.start_site(site_config["name"], config_mode=True) def on_edit_site(button): site_config = self.get_selected_site_config() SiteConfigurator(site_config, self.update_sites_list).start() def on_delete_site(button): site_config = self.get_selected_site_config() config.delete_site(site_config["name"]) self.update_sites_list() def on_add_site(button): SiteConfigurator({}, self.update_sites_list).start() def on_select(list): self.update_buttons_sensitivity() sites_list_name_cell = gtk.CellRendererText() sites_list_name_col = gtk.TreeViewColumn("Sites", sites_list_name_cell) sites_list_name_col.set_cell_data_func(sites_list_name_cell, name_func) self.sites_list = gtk.TreeView() self.sites_list.append_column(sites_list_name_col) self.sites_list.connect("cursor-changed", on_select) scrolledwindow = gtk.ScrolledWindow() scrolledwindow.set_size_request(200, 300) scrolledwindow.add(self.sites_list) self.start_button = gtk.Button("Start") self.start_button.connect("clicked", on_start_site) self.edit_button = gtk.Button("Properties") self.edit_button.connect("clicked", on_edit_site) self.config_button = gtk.Button("Mozilla Config") self.config_button.connect("clicked", on_config_site) self.delete_button = gtk.Button("Delete") self.delete_button.connect("clicked", on_delete_site) add_button = gtk.Button("New Site") add_button.connect("clicked", on_add_site) buttons_box = gtk.VBox() buttons_box.set_spacing(5) buttons_box.pack_start(self.start_button, False, False, 10) buttons_box.pack_start(self.edit_button, False, False) buttons_box.pack_start(self.config_button, False, False) buttons_box.pack_start(self.delete_button, False, False) buttons_box.pack_start(add_button, False, False, 10) main_box = gtk.HBox() main_box.pack_start(scrolledwindow, True, True) main_box.pack_start(buttons_box, False, True, 10) self.win = gtk.Window() self.win.set_title("Kadro") self.win.set_position(gtk.WIN_POS_CENTER) self.win.set_border_width(10) self.win.add(main_box) self.win.connect("destroy", on_destroy) self.win.show_all() self.update_sites_list() gtk.main()
def __init__(self): gtk.Window.__init__(self) bdb.Bdb.__init__(self) self.realize() self.set_title("PyGTKDb") self.connect("destroy", self.do_quit) self.connect("delete_event", self.do_quit) self.box = gtk.VBox() self.add(self.box) self.box.show() self.add_stock_ids() actions = [ ('Next', 'pyide-next', None, None, "Next statement", self.do_next), ('Step', 'pyide-step', None, None, "Step into function", self.do_step), ('Return', 'pyide-return', None, None, "Continue execution to end of function", self.do_return), ('Continue', 'pyide-continue', None, None, "Continue execution to next break point", self.do_continue), ('Break', 'pyide-break', None, None, "Toggle break point at selected line", self.do_break), ('Edit', 'pyide-edit', None, None, "Edit the value of the selected variable", self.do_edit), ('Run', 'pyide-run', None, None, "Execute some code in the current stack context", self.do_run), ('Quit', 'pyide-quit', None, None, "Quit the debugger", self.do_quit), ] self.ag = gtk.ActionGroup('PyIDE Actions') self.ag.add_actions(actions) self.ui = gtk.UIManager() self.ui.insert_action_group(self.ag, 0) self.ui.add_ui_from_string(self.ui_string) self.add_accel_group(self.ui.get_accel_group()) self.box.pack_start(self.ui.get_widget('/Toolbar'), expand=False) sep = gtk.HSeparator() self.box.pack_start(sep, expand=False) sep.show() vpane = gtk.VPaned() self.box.pack_start(vpane) vpane.show() hpane = gtk.HPaned() vpane.add1(hpane) hpane.show() swin = gtk.ScrolledWindow() swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) hpane.add1(swin) swin.show() ls = gtk.ListStore(str) self.stackdisp = gtk.TreeView(ls) tvc = gtk.TreeViewColumn('Stack Frame', gtk.CellRendererText(), text=0) self.stackdisp.append_column(tvc) self.stackdisp.set_size_request(280, 125) selection = self.stackdisp.get_selection() selection.set_mode(gtk.SELECTION_BROWSE) selection.connect("changed", self.update_curstack) self.stackdisp.set_border_width(2) swin.add(self.stackdisp) self.stackdisp.show() swin = gtk.ScrolledWindow() swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) hpane.add2(swin) swin.show() ls = gtk.ListStore(str, str, str) self.vardisp = gtk.TreeView(ls) titles = ['local var', 'type', 'value'] for n in range(len(titles)): tvc = gtk.TreeViewColumn(titles[n], gtk.CellRendererText(), text=n) self.vardisp.append_column(tvc) selection = self.vardisp.get_selection() selection.set_mode(gtk.SELECTION_BROWSE) selection.connect("changed", self.update_selectedvar) self.vardisp.set_border_width(2) self.vardisp.set_border_width(2) swin.add(self.vardisp) self.vardisp.show() self.vardisp.selected = 0 self.vardisp.varnames = [] swin = gtk.ScrolledWindow() swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) vpane.add2(swin) swin.show() self.minibreak = gtk.Image() self.minibreak.set_from_file("minibreak.xpm") self.minibreak.show() ls = gtk.ListStore(gtk.gdk.Pixbuf, str, str) self.filedisp = gtk.TreeView(ls) titles = ['break', 'lineno', 'line'] cell = gtk.CellRendererPixbuf() tvc = gtk.TreeViewColumn(None, cell, pixbuf=0) tvc.set_min_width(14) tvc.set_widget(self.minibreak) self.filedisp.append_column(tvc) cell = gtk.CellRendererText() cell.set_property('xalign', 1.0) tvc = gtk.TreeViewColumn(titles[1], cell, text=1) self.filedisp.append_column(tvc) cell = gtk.CellRendererText() tvc = gtk.TreeViewColumn(titles[2], cell, text=2) self.filedisp.append_column(tvc) self.minibreak = self.minibreak.get_pixbuf() selection = self.filedisp.get_selection() selection.set_mode(gtk.SELECTION_BROWSE) selection.connect("changed", self.update_selection) self.filedisp.connect('row-activated', lambda t,p,c: self.do_break()) self.filedisp.set_border_width(2) self.filedisp.set_size_request(600, 200) swin.add(self.filedisp) self.filedisp.show() separator = gtk.HSeparator() self.box.pack_start(separator, expand=False) separator.show() align = gtk.Alignment(0.0, 0.5, 0.0, 0.0) self.box.pack_start(align, expand=False) align.show() self.status = gtk.Label() self.status.set_padding(4, 1) align.add(self.status) self.status.show() self.filename = None self.selected = 0 self.blockupdate = 0 return