Example #1
0
 def __init__(self):
     self.TreeView = view.treeview()
     self.Parser = pybib.parser()
     self.Dialog = dialogue.FileDialog()
     self.Messages = dialogue.MessageDialog()
     self.Files = preferences.file_manager()
     self.Menu = menu.MenuManager()
Example #2
0
 def __init__(self):
     self.booklist = []
     self.db = BibDatabase()
     self.TreeView = view.treeview()
     self.entries = ["ENTRYTYPE", "ID", "title", "author", "journal",
                     "year", "publisher", "page", "address", "annote",
                     "booktitle", "chapter", "crossred", "edition",
                     "editor", "howpublished", "institution", "month",
                     "note", "number", "organization", "pages",
                     "school", "series", "type", "url", "volume", "doi", "file"]
Example #3
0
File: menu.py Project: rudrab/mkbib
 def __init__(self):
     self.parsing = pybib.parser()
     self.TreeView = view.treeview()
     self.Dialog = dialogue.FileDialog()
     self.cell = cell.cell_renderer()
Example #4
0
File: main.py Project: rudrab/mkbib
    def __init__(self, application, giofile=None):
        Gtk.ApplicationWindow.__init__(self,
                                       application=application,
                                       default_width=1000,
                                       default_height=200,
                                       border_width=5)

        # Import other files
        self.TreeView = view.treeview()
        self.MenuElem = menu.MenuManager()
        self.Parser = pybib.parser()
        self.Dialog = dialogue.FileDialog()
        self.Messages = dialogue.MessageDialog()
        self.Files = preferences.file_manager()
        self.Datas = getdata.data()
        self.Cell  = cell.cell_renderer()
        #
        # Create HeaderBar and manu
        self.headerbar = Gtk.HeaderBar()
        self.set_titlebar(self.headerbar)
        self.headerbar.set_show_close_button(True)
        # menuicon = Gtk.Image.new_from_icon_name("mkbib-symbolic", 32);
        # Gtk.HeaderBar.pack_start(headerbar,menuicon);

        # global main_header
        self.main_header = "MkBiB"
        self.headerbar.set_title(self.main_header)

        icontheme = Gtk.IconTheme.get_default()
        self.icon = icontheme.load_icon("mkbib", 64, 0)

        # Menu using Gio
        h_grid = Gtk.Grid()
        FileButton = Gtk.MenuButton()
        EditButton = Gtk.MenuButton(
            None, image=Gtk.Image(icon_name="list-add-symbolic"))
        FileButton.props.label = "File"
        filemenu = Gio.Menu()
        editmenu = Gio.Menu()
        filemenu.append("Open", "win.open")
        filemenu.append("Save As", "win.save-as")
        filemenu.append("Save", "win.save")
        filemenu.append("Quit", "app.quit")
        # menumodel.append_submenu("File", filemenu)
        editmenu.append("Copy BiBTeX", "win.edit")
        editmenu.append("Import", "win.import")
        # menumodel.append("Help", "win.about")
        h_grid.attach(FileButton, 0, 0, 3, 1)
        h_grid.attach(EditButton, 3, 0, 1, 1)
        FileButton.set_menu_model(filemenu)
        EditButton.set_menu_model(editmenu)
        self.headerbar.pack_start(h_grid)
        # headerbar.pack_start(EditButton)

        about_action = Gio.SimpleAction.new("about", None)
        about_action.connect("activate", self.Messages.about_activated)
        self.add_action(about_action)

        # accelgroup=Gtk.AccelGroup()
        # self.add_accel_group(accelgroup)

        # Menu (Stable)
        action = Gio.SimpleAction(name="save-as")
        action.connect("activate", self.file_save_as_clicked)
        self.add_action(action)

        # Open menu
        open_action = Gio.SimpleAction(name="open")
        open_action.connect("activate", self.file_open_clicked)
        self.add_action(open_action)

        action = Gio.SimpleAction(name="edit")
        action.connect("activate", self.MenuElem.create_textview)
        self.add_action(action)

        action = Gio.SimpleAction(name="save")
        action.connect("activate", self.file_save_clicked)
        self.add_action(action)

        action = Gio.SimpleAction(name="import")
        action.connect("activate", self.MenuElem.import_format)
        self.add_action(action)


        # Statusbar
        self.Files.chk_rootdir()
        self.status = Gtk.Statusbar()
        self.context = self.status.get_context_id("example")
        self.status.push(self.context, self.Files.root_status)

        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.add(box)
        self.TreeView = view.treeview()

        # Generate Entry type
        key_store = Gtk.ListStore(int, str)
        keys = ["Article", "Book", "Booklet", "Conference", "inBook",
                "inCollection", "inProseedings", "Manual", "MasterThesis",
                "Misc", "Online", "PhdThesis", "Proceedings", "TechReport",
                "Unpublished"]
        for key in keys:
            key_store.append([keys.index(key), key])

        self.key_combo = Gtk.ComboBox.new_with_model_and_entry(key_store)
        self.key_combo.set_entry_text_column(1)
        self.key_combo.connect("changed", self.get_combo_data)
        self.key_combo.connect("changed", self.activate_button)

        # BibTeX Key
        self.KeyEntry = Gtk.Entry()
        self.KeyEntry.set_placeholder_text("BibtexKey")
        self.KeyEntry.connect("changed", self.activate_button)

        #  Generate the  Fields
        self.notebook = Gtk.Notebook()
        xpos = 0
        minf = 0
        self.all_fields = dict()
        self.fields = ["Author",  "Year",  "Journal", "Title", "Publisher",
                       "Page", "Address", "Annote", "Booktitle", "Chapter",
                       "Crossred", "Edition", "Editor", "HowPublished",
                       "Institution", "Month", "Note", "Number",
                       "Organization", "Pages", "School",
                       "Series", "Type", "Url", "Volume", "DOI", "File"]
        # self.fields = self.Parser.entries
        # self.fields = [item.capitalize() for item in self.fields]
        Tabs = ["Essential", "Publishers", "Extra I", "Extra II", "Extra III"]
        for note in range(math.ceil(len(self.fields)/6)):
            ypos = 0
            self.npage = "page"+str(note)
            self.npage = Gtk.Grid()
            self.npage.set_border_width(10)
            maxf = minf+6
            for field in self.fields[minf:maxf]:
                self.lfield = "L" + field
                self.lfield = Gtk.Label(field)
                self.lfield.set_xalign(0)
                self.all_fields[field] = Gtk.Entry()
                self.all_fields[field].set_placeholder_text(field)
                self.npage.attach(self.lfield, xpos, ypos, 1, 1)
                self.lfield.set_yalign(0)
                self.npage.attach_next_to(self.all_fields[field], self.lfield,
                                          Gtk.PositionType.RIGHT, 14, 1)
                ypos += 1
                # self.all_fields[field].connect("changed",
                #   self.activate_scholar)
            self.notebook.append_page(self.npage, Gtk.Label(Tabs[note]))
            minf = maxf
            pdf_load_button = Gtk.Button(image=Gtk.Image(
                icon_name="document-open-symbolic"))
            pdf_load_button.connect("clicked", self.file_attach_cb)
        self.npage.attach_next_to(pdf_load_button, self.all_fields["File"],
                                  Gtk.PositionType.RIGHT, 2, 1)

        # Set tooltip for searchable entries
        self.all_fields["Author"].set_tooltip_text("Search with Google or CrossRef")
        self.all_fields["Year"].set_tooltip_text("Refine Author search with Google")
        self.all_fields["Title"].set_tooltip_text("Search by Title")
        self.all_fields["DOI"].set_tooltip_text("Search DOI")

        self.all_fields["Author"].connect("changed", self.activate_scholar)
        self.all_fields["DOI"].connect("changed", self.activate_scholar)
        self.all_fields["Title"].connect("changed", self.activate_scholar)
        self.all_fields["File"].connect("changed", self.activate_scholar)

        # Create button to get data from manual entry
        self.bcreate = Gtk.Button("Create Manually")
        self.bcreate.set_sensitive(False)
        self.bcreate.connect("clicked", self.get_data)

        # Create the buttons to get data
        # Google/Crossref data fetch
        api_store = Gtk.ListStore(str)
        apis = ["Search", "Search Google", "Search Crossref",
                "Search DOI", "Search by Title", "From PDF"]
        for api in apis:
            api_store.append([api])
        self.bsearch = Gtk.ComboBox.new_with_model(api_store)
        renderer_text = Gtk.CellRendererText()
        self.bsearch.pack_start(renderer_text, True)
        self.bsearch.set_active(0)
        self.bsearch.add_attribute(renderer_text, "text", 0)
        self.bsearch.connect("changed", self.search_gschol)
        self.bsearch.set_sensitive(False)

        scroll = Gtk.ScrolledWindow()
        scroll.set_hexpand(False)
        scroll.set_vexpand(True)

        # self.overlay = Gtk.Overlay()
        # self.overlay.add(scroll)
        # self.box = Gtk.Box()
        # self.box.override_background_color(Gtk.StateType.NORMAL,
                                           # Gdk.RGBA(.5,.5,.5, 1))
        # self.box.pack_start(self.status, True, True, 0)
        # self.box.set_valign(Gtk.Align.END)
        # self.overlay.add_overlay(self.box)
        grid = Gtk.Grid()
        grid.set_column_spacing(10)
        grid.attach(self.key_combo, 0, 0, 1, 1)
        grid.attach(self.KeyEntry, 1, 0, 1, 1)
        # grid.attach(self.status, 0, 3, 20, 1)
        grid.attach(self.notebook, 0, 1, 2, 1)
        grid.attach(scroll, 2, 0, 105, 4)
        grid.attach(self.bcreate, 0, 2,  1, 1)
        grid.attach(self.bsearch, 1, 2,  1, 1)
        box.pack_start(grid, False, False, 0)
        scroll.add(self.TreeView.view)
        # self.overlay.show_all()
        self.show_all()