Exemplo n.º 1
0
    def __init__(self,
                 key,
                 dialog,
                 app,
                 ext,
                 label=u"New File Types",
                 icon=None):
        dialog_app_options.Section.__init__(self, key, dialog, app, label,
                                            icon)

        self.ext = ext
        self._filetypes = []
        self._current_filetype = None

        # setup UI
        w = self.get_default_widget()
        h = gtk.HBox(False, 5)
        w.add(h)

        # left column (file type list)
        v = gtk.VBox(False, 5)
        h.pack_start(v, False, True, 0)

        self.filetype_store = gtk.ListStore(str, object)
        self.filetype_listview = gtk.TreeView(self.filetype_store)
        self.filetype_listview.set_headers_visible(False)
        self.filetype_listview.get_selection().connect("changed",
                                                       self.on_listview_select)

        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.set_shadow_type(gtk.SHADOW_IN)
        sw.add(self.filetype_listview)
        sw.set_size_request(160, 200)
        v.pack_start(sw, False, True, 0)

        # create the treeview column
        column = gtk.TreeViewColumn()
        self.filetype_listview.append_column(column)
        cell_text = gtk.CellRendererText()
        column.pack_start(cell_text, True)
        column.add_attribute(cell_text, 'text', 0)

        # add/del buttons
        h2 = gtk.HBox(False, 5)
        v.pack_start(h2, False, True, 0)

        button = gtk.Button("New")
        button.connect("clicked", self.on_new_filetype)
        h2.pack_start(button, True, True, 0)

        button = gtk.Button("Delete")
        button.connect("clicked", self.on_delete_filetype)
        h2.pack_start(button, True, True, 0)

        # right column (file type editor)
        v = gtk.VBox(False, 5)
        h.pack_start(v, False, True, 0)

        table = gtk.Table(3, 2)
        self.filetype_editor = table
        v.pack_start(table, False, True, 0)

        # file type name
        label = gtk.Label("File type name:")
        table.attach(label,
                     0,
                     1,
                     0,
                     1,
                     xoptions=0,
                     yoptions=0,
                     xpadding=2,
                     ypadding=2)

        self.filetype = gtk.Entry()
        table.attach(self.filetype,
                     1,
                     2,
                     0,
                     1,
                     xoptions=gtk.FILL,
                     yoptions=0,
                     xpadding=2,
                     ypadding=2)

        # default filename
        label = gtk.Label("Default filename:")
        table.attach(label,
                     0,
                     1,
                     1,
                     2,
                     xoptions=0,
                     yoptions=0,
                     xpadding=2,
                     ypadding=2)

        self.filename = gtk.Entry()
        table.attach(self.filename,
                     1,
                     2,
                     1,
                     2,
                     xoptions=gtk.FILL,
                     yoptions=0,
                     xpadding=2,
                     ypadding=2)

        # example new file
        label = gtk.Label("Example new file:")
        table.attach(label,
                     0,
                     1,
                     2,
                     3,
                     xoptions=0,
                     yoptions=0,
                     xpadding=2,
                     ypadding=2)

        self.example_file = gtk.Entry()
        table.attach(self.example_file,
                     1,
                     2,
                     2,
                     3,
                     xoptions=gtk.FILL,
                     yoptions=0,
                     xpadding=2,
                     ypadding=2)

        # browse button
        button = gtk.Button(_("Browse..."))
        button.set_image(
            gtk.image_new_from_stock(gtk.STOCK_OPEN,
                                     gtk.ICON_SIZE_SMALL_TOOLBAR))
        button.show()
        button.connect(
            "clicked",
            lambda w: dialog_app_options.on_browse(w.get_toplevel(
            ), "Choose Example New File", "", self.example_file))
        table.attach(button,
                     1,
                     2,
                     3,
                     4,
                     xoptions=gtk.FILL,
                     yoptions=0,
                     xpadding=2,
                     ypadding=2)

        w.show_all()

        self.set_filetypes()
        self.set_filetype_editor(None)
Exemplo n.º 2
0
    def __init__(self, key, dialog, app, ext,
                 label=u"New File Types", 
                 icon=None):
        dialog_app_options.Section.__init__(self, key, dialog, app, label, icon)

        self.ext = ext
        self._filetypes = []
        self._current_filetype = None


        # setup UI
        w = self.get_default_widget()
        h = gtk.HBox(False, 5)
        w.add(h)

        # left column (file type list)
        v = gtk.VBox(False, 5)
        h.pack_start(v, False, True, 0)

        self.filetype_store = gtk.ListStore(str, object)
        self.filetype_listview = gtk.TreeView(self.filetype_store)
        self.filetype_listview.set_headers_visible(False)
        self.filetype_listview.get_selection().connect("changed", 
                                                       self.on_listview_select)

        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.set_shadow_type(gtk.SHADOW_IN)
        sw.add(self.filetype_listview)
        sw.set_size_request(160, 200)
        v.pack_start(sw, False, True, 0)
        

        # create the treeview column
        column = gtk.TreeViewColumn()
        self.filetype_listview.append_column(column)
        cell_text = gtk.CellRendererText()
        column.pack_start(cell_text, True)
        column.add_attribute(cell_text, 'text', 0)

        # add/del buttons
        h2 = gtk.HBox(False, 5)
        v.pack_start(h2, False, True, 0)

        button = gtk.Button("New")
        button.connect("clicked", self.on_new_filetype)
        h2.pack_start(button, True, True, 0)

        button = gtk.Button("Delete")
        button.connect("clicked", self.on_delete_filetype)
        h2.pack_start(button, True, True, 0)




        # right column (file type editor)
        v = gtk.VBox(False, 5)
        h.pack_start(v, False, True, 0)

        table = gtk.Table(3, 2)
        self.filetype_editor = table
        v.pack_start(table, False, True, 0)


        # file type name
        label = gtk.Label("File type name:")
        table.attach(label, 0, 1, 0, 1,
                     xoptions=0, yoptions=0,
                     xpadding=2, ypadding=2)

        self.filetype = gtk.Entry()
        table.attach(self.filetype, 1, 2, 0, 1,
                     xoptions=gtk.FILL, yoptions=0,
                     xpadding=2, ypadding=2)


        # default filename
        label = gtk.Label("Default filename:")
        table.attach(label, 0, 1, 1, 2,
                     xoptions=0, yoptions=0,
                     xpadding=2, ypadding=2)

        self.filename = gtk.Entry()
        table.attach(self.filename, 1, 2, 1, 2,
                     xoptions=gtk.FILL, yoptions=0,
                     xpadding=2, ypadding=2)


        # example new file
        label = gtk.Label("Example new file:")
        table.attach(label, 0, 1, 2, 3,
                     xoptions=0, yoptions=0,
                     xpadding=2, ypadding=2)

        self.example_file = gtk.Entry()
        table.attach(self.example_file, 1, 2, 2, 3,
                     xoptions=gtk.FILL, yoptions=0,
                     xpadding=2, ypadding=2)
        

        # browse button
        button = gtk.Button(_("Browse..."))
        button.set_image(
            gtk.image_new_from_stock(gtk.STOCK_OPEN,
                                     gtk.ICON_SIZE_SMALL_TOOLBAR))
        button.show()
        button.connect("clicked", lambda w: 
                       dialog_app_options.on_browse(
                w.get_toplevel(), "Choose Example New File", "", 
                self.example_file))
        table.attach(button, 1, 2, 3, 4,
                     xoptions=gtk.FILL, yoptions=0,
                     xpadding=2, ypadding=2)



        w.show_all()


        self.set_filetypes()
        self.set_filetype_editor(None)