Beispiel #1
0
    def update_fileview(self, file):
        screen_width, screen_height = screensize.get_screen_size()
        mainbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2)
        mainbox.set_name("fileview")
        lblhead = Gtk.Label(file)
        lblhead.set_name("lblhead")
        scroll = Gtk.ScrolledWindow.new()
        scroll.set_size_request(screen_width / 2, screen_height * 0.4)
        scroll.set_hexpand(True)
        scroll.set_vexpand(True)
        mainbox.pack_start(lblhead, False, False, 0)
        textview = Gtk.TextView()
        textview.override_background_color(Gtk.StateFlags.NORMAL,
                                           Gdk.RGBA(0, 0, 0, 1))
        textbuffer = textview.get_buffer()
        try:
            with open(file, 'r') as fo:
                data = fo.read()
                textbuffer.set_text(data)
        except:
            lblerror = Gtk.Label("Error: File opening error")
            scroll.add(lblerror)

        scroll.add(textview)
        mainbox.pack_start(scroll, False, False, 0)
        maincontainer.add(mainbox)
        maincontainer.show_all()
Beispiel #2
0
    def permission_errorview(self, current_path, maincontainer):

        app_path = os.path.abspath(os.path.dirname(sys.argv[0]))
        dir_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2)
        mainbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2)
        mainbox.set_name("folderview")
        lblhead = Gtk.Label(current_path.replace("/", "  >  "))
        lblhead.set_name("lblhead")
        mainbox.pack_start(lblhead, False, False, 0)

        screen_width, screen_height = screensize.get_screen_size()

        scroll = Gtk.ScrolledWindow()
        scroll.set_size_request(screen_width / 2, screen_height * 0.4)
        # go up box
        rowbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=3)
        imagebox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=4)
        dirimage = Gtk.Image()
        dirimage.set_from_file(app_path + "/icons/icon-up.png")
        imagebox.pack_start(dirimage, True, True, 0)
        dirlable = Gtk.Label("Go up")
        imagebox.pack_end(dirlable, True, True, 0)
        eventbox = Gtk.EventBox()
        eventbox.add(imagebox)
        eventbox.connect("button_press_event", self.on_folder_click,
                         current_path, "goup", maincontainer, scroll)
        eventbox.connect("enter-notify-event", self.on_mouse_enter)
        eventbox.connect("leave-notify-event", self.on_mouse_leave)
        eventbox.set_tooltip_text("Go Up")
        rowbox.pack_start(eventbox, False, False, 50)
        # permission error box
        errorlable = Gtk.Label("Permission denied")
        eventbox1 = Gtk.EventBox()
        eventbox1.add(errorlable)
        eventbox1.connect("button_press_event", self.on_folder_click,
                          current_path, "goup", maincontainer, scroll)
        eventbox1.connect("enter-notify-event", self.on_mouse_enter)
        eventbox1.connect("leave-notify-event", self.on_mouse_leave)
        eventbox1.set_tooltip_text("Go Up")
        rowbox.pack_start(eventbox1, False, False, 50)

        dir_box.pack_start(rowbox, False, False, 0)

        scroll.add(dir_box)
        scroll.show_all()
        mainbox.pack_start(scroll, False, False, 0)
        mainbox.show_all()
        maincontainer.add(mainbox)
Beispiel #3
0
    def update_imageview(self, path):
        screen_width, screen_height = screensize.get_screen_size()
        mainbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2)
        mainbox.set_name("fileview")
        lblhead = Gtk.Label(path)
        lblhead.set_name("lblhead")
        scroll = Gtk.ScrolledWindow.new()
        scroll.set_size_request(screen_width / 2, screen_height * 0.4)
        scroll.set_hexpand(True)
        scroll.set_vexpand(True)
        mainbox.pack_start(lblhead, False, False, 0)

        image = Gtk.Image()
        imagebox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=2)
        image.set_from_file(path)
        image.show_all()
        imagebox.pack_start(image, True, True, 0)
        scroll.add(imagebox)
        mainbox.pack_start(scroll, False, False, 0)
        maincontainer.add(mainbox)
        maincontainer.show_all()
Beispiel #4
0
    def update_foldeview(self, maincontainer, parent_folder):

        root_path = os.path.abspath(os.sep)
        app_path = os.path.abspath(os.path.dirname(sys.argv[0]))

        listoffiles = os.listdir(parent_folder)
        listoffiles.sort()

        col = 1
        dir_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2)
        mainbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2)
        mainbox.set_name("folderview")
        lblhead = Gtk.Label(parent_folder.replace("/", "  >  "))
        lblhead.set_name("lblhead")
        mainbox.pack_start(lblhead, False, False, 0)

        screen_width, screen_height = screensize.get_screen_size()

        scroll = Gtk.ScrolledWindow()
        scroll.set_size_request(screen_width / 2, screen_height * 0.4)

        if parent_folder != root_path:
            rowbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=3)
            imagebox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=4)
            dirimage = Gtk.Image()
            dirimage.set_from_file(app_path + "/icons/icon-up.png")
            imagebox.pack_start(dirimage, True, True, 0)
            dirlable = Gtk.Label("Go up")
            imagebox.pack_end(dirlable, True, True, 0)
            eventbox = Gtk.EventBox()
            eventbox.add(imagebox)
            eventbox.connect("button_press_event", self.on_folder_click,
                             parent_folder, "goup", maincontainer, scroll)
            eventbox.connect("enter-notify-event", self.on_mouse_enter)
            eventbox.connect("leave-notify-event", self.on_mouse_leave)
            eventbox.set_tooltip_text("Go Up")
            rowbox.pack_start(eventbox, False, False, 50)
            col = 2

        # first directories
        for dir_entry in listoffiles:
            fullpath = os.path.join(parent_folder, dir_entry)
            if os.path.isdir(fullpath):
                if col == 1:
                    rowbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL,
                                     spacing=3)

                imagebox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL,
                                   spacing=4)
                dirimage = Gtk.Image()
                dirimage.set_from_file(app_path + "/icons/icon-folder.png")
                imagebox.pack_start(dirimage, True, True, 0)
                dirlable = Gtk.Label(dir_entry)
                dirlable.set_max_width_chars(1)
                dirlable.set_ellipsize(pango.EllipsizeMode.END)
                imagebox.pack_end(dirlable, True, True, 0)
                eventbox = Gtk.EventBox()
                eventbox.add(imagebox)
                eventbox.connect("button_press_event", self.on_folder_click,
                                 fullpath, "dir", maincontainer, scroll)
                eventbox.connect("enter-notify-event", self.on_mouse_enter)
                eventbox.connect("leave-notify-event", self.on_mouse_leave)
                eventbox.set_tooltip_text(dir_entry)
                rowbox.pack_start(eventbox, False, False, 50)

                col = col + 1
                if col == 6:
                    col = 1

            dir_box.pack_start(rowbox, False, False, 0)

        for file_entry in listoffiles:
            fullpath = os.path.join(parent_folder, file_entry)
            if os.path.isdir(fullpath) == False:
                if col == 1:
                    rowbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL,
                                     spacing=3)

                imagebox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL,
                                   spacing=4)
                fileimage = Gtk.Image()
                fileimage.set_from_file(app_path +
                                        self.get_file_icon(fullpath))
                imagebox.pack_start(fileimage, True, True, 0)
                filelable = Gtk.Label(file_entry)
                filelable.set_max_width_chars(1)
                filelable.set_ellipsize(pango.EllipsizeMode.END)
                imagebox.pack_end(filelable, True, True, 0)
                eventbox = Gtk.EventBox()
                eventbox.add(imagebox)
                eventbox.connect("button_press_event", self.on_folder_click,
                                 fullpath, "dir", maincontainer, scroll)
                eventbox.connect("enter-notify-event", self.on_mouse_enter)
                eventbox.connect("leave-notify-event", self.on_mouse_leave)
                eventbox.set_tooltip_text(file_entry)
                rowbox.pack_start(eventbox, False, False, 50)

                col = col + 1
                if col == 6:
                    col = 1

                dir_box.pack_start(rowbox, False, False, 0)

        if len(listoffiles) == 0:
            dir_box.pack_start(rowbox, False, False, 0)

        scroll.add(dir_box)
        scroll.show_all()
        mainbox.pack_start(scroll, False, False, 0)
        mainbox.show_all()
        maincontainer.add(mainbox)
Beispiel #5
0
    def create_foldeview(self):

        self.configure({"working_directory": config.working_directory})

        path = self.options["working_directory"]

        root_path = os.path.abspath(os.sep)

        listoffiles = os.listdir(path)
        listoffiles.sort()

        col = 1
        dir_box = Gtk.VBox()
        screen_width, screen_height = screensize.get_screen_size()

        maincontainer = Gtk.Fixed()
        mainbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2)
        mainbox.set_name("folderview")
        lblhead = Gtk.Label(path.replace("/", "  >  "))
        lblhead.set_name("lblhead")
        mainbox.pack_start(lblhead, False, False, 0)

        scroll = Gtk.ScrolledWindow()
        scroll.set_size_request(screen_width / 2, screen_height * 0.4)

        if path != root_path:
            rowbox = Gtk.HBox(spacing=3)
            imagebox = Gtk.VBox(spacing=4)
            dirimage = Gtk.Image()
            dirimage.set_from_file("./icons/icon-up.png")
            imagebox.pack_start(dirimage, True, True, 0)
            dirlable = Gtk.Label("Go up")
            imagebox.pack_end(dirlable, True, True, 0)
            eventbox = Gtk.EventBox()
            eventbox.add(imagebox)
            eventbox.connect("button_press_event", self.on_folder_click, path,
                             "goup", maincontainer, mainbox)
            eventbox.connect("enter-notify-event", self.on_mouse_enter)
            eventbox.connect("leave-notify-event", self.on_mouse_leave)
            eventbox.set_tooltip_text("Go Up")
            rowbox.pack_start(eventbox, False, False, 50)
            col = 2

        # first directories
        for dir_entry in listoffiles:
            fullpath = os.path.join(path, dir_entry)
            if os.path.isdir(fullpath):
                if col == 1:
                    rowbox = Gtk.HBox(spacing=3)

                imagebox = Gtk.VBox(spacing=4)
                dirimage = Gtk.Image()
                dirimage.set_from_file("./icons/icon-folder.png")
                imagebox.pack_start(dirimage, True, True, 0)
                dirlable = Gtk.Label(dir_entry)
                dirlable.set_max_width_chars(5)
                dirlable.set_ellipsize(pango.EllipsizeMode.END)
                imagebox.pack_end(dirlable, True, True, 0)
                eventbox = Gtk.EventBox()
                eventbox.add(imagebox)
                eventbox.connect("button_press_event", self.on_folder_click,
                                 fullpath, "dir", maincontainer, mainbox)
                eventbox.connect("enter-notify-event", self.on_mouse_enter)
                eventbox.connect("leave-notify-event", self.on_mouse_leave)
                eventbox.set_tooltip_text(dir_entry)
                rowbox.pack_start(eventbox, False, False, 50)

                col = col + 1
                if col == 6:
                    col = 1

                dir_box.pack_start(rowbox, False, False, 0)

        for file_entry in listoffiles:
            fullpath = os.path.join(path, file_entry)
            if os.path.isdir(fullpath) == False:
                if col == 1:
                    rowbox = Gtk.HBox(spacing=3)

                imagebox = Gtk.VBox(spacing=4)
                fileimage = Gtk.Image()
                fileimage.set_from_file("." + self.get_file_icon(fullpath))
                imagebox.pack_start(fileimage, True, True, 0)
                filelable = Gtk.Label(file_entry)
                filelable.set_max_width_chars(5)
                filelable.set_ellipsize(pango.EllipsizeMode.END)
                imagebox.pack_end(filelable, True, True, 0)
                eventbox = Gtk.EventBox()
                eventbox.add(imagebox)
                eventbox.connect("button_press_event", self.on_folder_click,
                                 fullpath, "dir", maincontainer, mainbox)
                eventbox.connect("enter-notify-event", self.on_mouse_enter)
                eventbox.connect("leave-notify-event", self.on_mouse_leave)
                eventbox.set_tooltip_text(file_entry)
                rowbox.pack_start(eventbox, False, False, 50)

                col = col + 1
                if col == 6:
                    col = 1

                dir_box.pack_start(rowbox, False, False, 0)

        scroll.add(dir_box)
        scroll.show_all()
        mainbox.pack_start(scroll, False, False, 0)
        maincontainer.add(mainbox)

        return maincontainer
Beispiel #6
0
    def create_page(self, widget, event):

        main_box = Gtk.VBox()
        main_box.set_name("boxterminal")
        terminal = Vte.Terminal()

        self.configure({
            "shell": config.shell,
            "fallback_shell": config.fallback_shell,
            "working_directory": config.working_directory,
            "audible_bell": config.audible_bell
        })

        terminal.spawn_sync(
            Vte.PtyFlags.DEFAULT,
            self.options["working_directory"],
            [self.options["shell"]],
            [],
            GLib.SpawnFlags.DO_NOT_REAP_CHILD,
            None,
            None,
        )

        screen_width, screen_height = screensize.get_screen_size()

        app_path = os.path.abspath(os.path.dirname(sys.argv[0]))

        box_tab = Gtk.HBox(
            spacing=8)  # Box for notebook tab label and for tab close button
        close_image = Gtk.Image()  # Tab close image
        close_image.set_from_file(app_path + "/icons/icon-close.png")
        eventbox_close = Gtk.EventBox()  # For close image event
        eventbox_close.set_name("eventboxclose")
        eventbox_close.add(close_image)
        eventbox_close.connect("enter-notify-event",
                               self.on_mouse_enter_button_icon)
        eventbox_close.connect("leave-notify-event",
                               self.on_mouse_leave_button_icon)
        eventbox_close.connect("button_press_event", self.close_tab)
        label_title = Gtk.Label()
        label_title.set_text(self.options["shell"])

        box_tab.pack_start(label_title, False, False, 0)
        box_tab.pack_start(eventbox_close, False, False, 0)
        box_tab.set_name("booktab")
        box_tab.show_all()

        tool_box = Gtk.HBox(spacing=30)

        event_plus = Gtk.EventBox()  # notebook tab add button
        event_plus.connect("enter-notify-event",
                           self.on_mouse_enter_button_icon)
        event_plus.connect("leave-notify-event",
                           self.on_mouse_leave_button_icon)
        event_plus.connect("button_press_event", self.create_page)
        event_plus.set_tooltip_text("Open a new tab")
        image_plus = Gtk.Image()
        image_plus.set_from_file("./icons/icon-plus.png")
        event_plus.add(image_plus)

        tool_box.add(event_plus)

        main_box.add(tool_box)
        main_box.add(terminal)
        main_box.set_size_request(screen_width / 2, screen_height * 0.5)
        main_box.show_all()

        self.notebook.append_page(main_box, box_tab)
        self.notebook.set_current_page(self.notebook.get_n_pages() - 1)
        self.notebook.show_all()
Beispiel #7
0
    def create_terminal(self):
        # To add all widgets
        main_box = Gtk.VBox()
        main_box.set_name("boxterminal")

        terminal = Vte.Terminal()

        self.configure({
            "shell": config.shell,
            "fallback_shell": config.fallback_shell,
            "working_directory": config.working_directory,
            "audible_bell": config.audible_bell
        })

        terminal.spawn_sync(
            Vte.PtyFlags.DEFAULT,
            self.options["working_directory"],
            [self.options["shell"]],
            [],
            GLib.SpawnFlags.DO_NOT_REAP_CHILD,
            None,
            None,
        )

        screen_width, screen_height = screensize.get_screen_size()

        # Notebook tab label
        box_tab = Gtk.HBox(spacing=8)
        box_tab.set_name("booktab")
        label_title = Gtk.Label()
        label_title.set_text(self.options["shell"])
        box_tab.pack_start(label_title, False, False, 0)
        box_tab.show_all()

        # tool box for adding new tab and for exit app buttons
        tool_box = Gtk.HBox(spacing=30)

        event_plus = Gtk.EventBox()  # Tool box add button
        event_plus.connect("enter-notify-event",
                           self.on_mouse_enter_button_icon)
        event_plus.connect("leave-notify-event",
                           self.on_mouse_leave_button_icon)
        event_plus.connect("button_press_event", self.create_page)
        event_plus.set_tooltip_text("Open a new tab")
        image_plus = Gtk.Image()
        image_plus.set_from_file("./icons/icon-plus.png")
        event_plus.add(image_plus)

        event_exit = Gtk.EventBox()  #  Tool box exit button
        event_exit.connect("enter-notify-event",
                           self.on_mouse_enter_button_icon)
        event_exit.connect("leave-notify-event",
                           self.on_mouse_leave_button_icon)
        event_exit.set_tooltip_text("Exit application")
        image_exit = Gtk.Image()
        image_exit.set_from_file("./icons/icon-exit.png")
        event_exit.add(image_exit)

        tool_box.add(event_plus)
        tool_box.add(event_exit)

        main_box.add(tool_box)
        main_box.add(terminal)
        main_box.show_all()
        main_box.set_size_request(screen_width / 2, screen_height * 0.5)

        self.notebook.append_page(main_box, box_tab)
        self.notebook.show_all

        self.notebook.set_current_page(0)

        return self.notebook, event_exit
Beispiel #8
0
    def create_page(self, widget, event):

        overlay = Gtk.Overlay()
        # Address bar
        url_bar = Gtk.Entry()
        url_bar.set_name("urlbar")
        webview = WebKit2.WebView()
        # History list for entry completion
        liststore = Gtk.ListStore(str)
        entrycompletion = Gtk.EntryCompletion()
        entrycompletion.set_model(liststore)
        entrycompletion.set_text_column(0)
        # Stop loading web page and its event box
        stop_image = Gtk.Image()
        eventbox_stop = Gtk.EventBox()
        vboxmain = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2)
        vboxmain.set_name("boxbrowser")

        view_boxbrowser = Gtk.Box()
        screen_width, screen_height = screensize.get_screen_size()
        webview.set_size_request(screen_width / 2, screen_height * 0.5)
        webview.show()
        view_boxbrowser.pack_start(webview, True, True, 0)
        vboxmain.pack_end(view_boxbrowser, True, True, 0)

        # Address box
        address_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL,
                              spacing=2)
        # web page backward button
        backward_image = Gtk.Image()
        backward_image.set_from_file(app_path + "/icons/icon-back.png")
        eventbox_back = Gtk.EventBox()
        eventbox_back.add(backward_image)
        eventbox_back.connect("enter-notify-event",
                              self.on_mouse_enter_button_icon)
        eventbox_back.connect("leave-notify-event",
                              self.on_mouse_leave_button_icon)
        eventbox_back.set_tooltip_text("Go back")

        # Webpage forward button
        forward_image = Gtk.Image()
        forward_image.set_from_file(app_path + "/icons/icon-next.png")
        eventbox_next = Gtk.EventBox()
        eventbox_next.add(forward_image)
        eventbox_next.connect("enter-notify-event",
                              self.on_mouse_enter_button_icon)
        eventbox_next.connect("leave-notify-event",
                              self.on_mouse_leave_button_icon)
        eventbox_next.set_tooltip_text("Go forward")

        # Stop loading page, button
        stop_image.set_from_file(app_path + "/icons/icon-stop.png")
        stop_image.show()
        eventbox_stop.add(stop_image)
        eventbox_stop.connect("enter-notify-event",
                              self.on_mouse_enter_button_icon)
        eventbox_stop.connect("leave-notify-event",
                              self.on_mouse_leave_button_icon)
        eventbox_stop.set_tooltip_text("Stop loading")

        # Go button, load url
        go_image = Gtk.Image()
        go_image.set_from_file(app_path + "/icons/icon-go.png")
        eventbox_go = Gtk.EventBox()
        eventbox_go.add(go_image)
        eventbox_go.connect("enter-notify-event",
                            self.on_mouse_enter_button_icon)
        eventbox_go.connect("leave-notify-event",
                            self.on_mouse_leave_button_icon)
        eventbox_go.set_tooltip_text("Load url")

        #entry
        self.append_liststore(liststore)
        url_bar.set_completion(entrycompletion)
        url_bar.set_placeholder_text("Enter address")
        url_bar.connect("activate", self.load_url, stop_image, eventbox_stop,
                        webview)

        # History button, to show history dialog
        history_image = Gtk.Image()
        history_image.set_from_file(app_path + "/icons/icon-history.png")
        history_image.show()
        eventbox_history = Gtk.EventBox()
        eventbox_history.add(history_image)
        eventbox_history.connect("enter-notify-event",
                                 self.on_mouse_enter_button_icon)
        eventbox_history.connect("leave-notify-event",
                                 self.on_mouse_leave_button_icon)
        eventbox_history.set_tooltip_text("Show history")

        event_plus = Gtk.EventBox()  # notebook tab close button
        event_plus.connect("enter-notify-event",
                           self.on_mouse_enter_button_icon)
        event_plus.connect("leave-notify-event",
                           self.on_mouse_leave_button_icon)
        event_plus.set_tooltip_text("Open a new tab")
        image_plus = Gtk.Image()
        image_plus.set_from_file(app_path + "/icons/icon-plus.png")
        event_plus.add(image_plus)

        # Adding addressbox to its widgets
        address_box.add(eventbox_back)
        address_box.add(eventbox_next)
        address_box.add(eventbox_stop)
        address_box.pack_start(url_bar, True, True, 0)
        address_box.add(eventbox_go)
        address_box.add(eventbox_history)
        address_box.add(event_plus)

        # Address box to main box
        vboxmain.add(address_box)
        # webvew to main box
        vboxmain.pack_start(view_boxbrowser, True, True, 0)

        message_bar = MessageBar()
        overlay.add(vboxmain)
        overlay.add_overlay(message_bar)

        # Notebokk tab box
        box_tab = Gtk.HBox(spacing=8)
        close_image = Gtk.Image()
        close_image.set_from_file(app_path + "/icons/icon-close.png")
        image_icon = Gtk.Image()
        eventbox_close = Gtk.EventBox()
        eventbox_close.set_name("eventboxclose")
        eventbox_close.add(close_image)
        eventbox_close.connect("enter-notify-event",
                               self.on_mouse_enter_button_icon)
        eventbox_close.connect("leave-notify-event",
                               self.on_mouse_leave_button_icon)
        label_title = Gtk.Label()
        label_title.set_text("New tab")
        box_tab.pack_start(image_icon, False, False, 0)
        box_tab.pack_start(label_title, False, False, 0)
        box_tab.pack_start(eventbox_close, False, False, 0)
        box_tab.set_name("booktab")

        box_tab.show_all()
        overlay.show_all()
        self.notebook.append_page(overlay, box_tab)

        webview.connect("load-failed", webview.do_load_failed)
        webview.connect("load-changed", self.on_load_changed, stop_image,
                        eventbox_stop, message_bar, image_icon)
        webview.connect("resource_load_started", self.on_resource_load_started,
                        message_bar)
        webview.connect('notify::title', self.change_title, label_title,
                        webview)
        eventbox_back.connect("button_press_event", self.webview_goback,
                              webview)
        eventbox_next.connect("button_press_event", self.webview_goforward,
                              webview)
        eventbox_stop.connect("button_press_event", self.webview_stop_reload,
                              stop_image, webview, eventbox_stop, message_bar)
        eventbox_go.connect("button_press_event", self.on_go_click, url_bar,
                            stop_image, eventbox_stop, webview)
        eventbox_history.connect("button_press_event", self.show_history_page,
                                 stop_image, eventbox_stop, webview, url_bar)
        event_plus.connect("button_press_event", self.create_page)
        eventbox_close.connect("button_press_event", self.close_tab)

        # Show page newly added
        self.notebook.set_current_page(self.notebook.get_n_pages() - 1)
        self.notebook.show_all()
Beispiel #9
0
    def __init__(self, parent, *args, **kwargs):
        super(HistoryDialog, self).__init__(*args, **kwargs)
        Gtk.Dialog.__init__(self, "My Dialog", parent, 0)

        screen_width, screen_height = screensize.get_screen_size()
        self.set_default_size(screen_width / 2, screen_height / 2)
        # Without title bar
        self.set_titlebar(None)
        self.set_decorated(False)

        # Two buttons ok and cancel
        self.add_button("Ok", Gtk.ResponseType.OK)
        self.add_button("Cancel", Gtk.ResponseType.CANCEL)

        # List selection entry
        self.entry_path = Gtk.Entry()
        self.entry_path.set_editable(False)
        self.entry_name = Gtk.Entry()
        self.entry_name.set_editable(False)
        self.lbl_path = Gtk.Label()
        self.lbl_path.set_text("Path:")
        self.lbl_name = Gtk.Label()
        self.lbl_name.set_text("Name:")

        history_list = []
        cur.execute('''SELECT title, link FROM history''')
        # Appending to history list from sqlite cursor
        for row in cur:
            history_list.append([row[0], row[1]])

        # Liststore with two columns, path and nama
        self.history_liststore = Gtk.ListStore(str, str)

        # Appendig to liststore from history list
        for history_ref in history_list:
            self.history_liststore.append(list(history_ref))

        # A treeview with model history liststore
        self.treeview = Gtk.TreeView.new_with_model(
            model=self.history_liststore)

        # Setting column headers, name and location
        for i, column_title in enumerate(["Name", "Location"]):
            renderer = Gtk.CellRendererText()
            column = Gtk.TreeViewColumn(column_title, renderer, text=i)
            self.treeview.append_column(column)

        # Setting up activation on single click
        self.treeview.set_activate_on_single_click(True)
        self.treeview.connect("row-activated", self.on_activate_treeview)
        self.treeview.show_all()

        self.scrollable_treelist = Gtk.ScrolledWindow()
        self.scrollable_treelist.set_vexpand(True)
        self.scrollable_treelist.add(self.treeview)

        # Getting Dialog content area
        box = self.get_content_area()
        # Then adding widgets to content area, box
        box.add(self.scrollable_treelist)
        box.add(self.lbl_name)
        box.add(self.entry_name)
        box.add(self.lbl_path)
        box.add(self.entry_path)

        # If there is history then selecting first row of history list
        if len(history_list) > 0:
            self.on_activate_treeview(self.treeview, 0, 0)

        self.show_all()