示例#1
0
 def __realize_cb(self, window):
     xid = window.get_window().get_xid()
     SugarExt.wm_set_bundle_id(xid, _BUNDLE_ID)
     activity_id = activityfactory.create_activity_id()
     SugarExt.wm_set_activity_id(xid, str(activity_id))
     self.disconnect(self._realized_sid)
     self._realized_sid = None
示例#2
0
 def __realize_cb(self, window):
     xid = window.get_window().get_xid()
     SugarExt.wm_set_bundle_id(xid, _BUNDLE_ID)
     activity_id = activityfactory.create_activity_id()
     SugarExt.wm_set_activity_id(xid, str(activity_id))
     self.disconnect(self._realized_sid)
     self._realized_sid = None
示例#3
0
 def __realize_cb(self, window):
     display_name = Gdk.Display.get_default().get_name()
     if ':' in display_name: 
         # X11 for sure; this only works in X11
         xid = window.get_window().get_xid()
         SugarExt.wm_set_bundle_id(xid, self.get_bundle_id())
         SugarExt.wm_set_activity_id(xid, str(self._activity_id))
     elif display_name is 'Broadway': 
         # GTK3's HTML5 backend
         # This is needed so that the window takes the whole browser window
         self.maximize()
示例#4
0
 def _realize_cb(self, window):
     xid = window.get_window().get_xid()
     SugarExt.wm_set_bundle_id(xid, self._bundle_id)
     SugarExt.wm_set_activity_id(xid, str(self._activity_id))
示例#5
0
 def __realize_cb(self, window):
     xid = window.get_window().get_xid()
     SugarExt.wm_set_bundle_id(xid, self.get_bundle_id())
     SugarExt.wm_set_activity_id(xid, str(self._activity_id))
示例#6
0
 def __realize_cb(self, widget):
     SugarExt.wm_set_activity_id(widget.get_window().get_xid(),
                                 str(self._activity_id))
示例#7
0
 def __realize_cb(self, widget):
     SugarExt.wm_set_activity_id(widget.get_window().get_xid(),
                                 str(self._activity_id))
示例#8
0
class EBookReader():
    def __init__(self, (filepath, journal_id, )):
        self.pages_list = [
            MyLibraryTab(self),
            GetBooksTab(self),
            ReadTab(self),
            HowToUseTab(self)
        ]

        if not os.path.exists(env.EBOOKREADER_LOCAL_DATA_DIRECTORY):
            os.makedirs(env.EBOOKREADER_LOCAL_DATA_DIRECTORY)
            os.chmod(env.EBOOKREADER_LOCAL_DATA_DIRECTORY, 0755)

        self.window = EBookReaderWindow(self)
        self._tab_toolbars_list = []
        self._toolbar_buttons_list = []

        self.window.connect('key-press-event', self.handle_key_press_cb)
        self._allow_keys_processing = True

        #if (os.path.isfile('/bin/evtest') or os.path.isfile('/usr/bin/evtest')):
        #    GObject.timeout_add(2000, self.__auto_move_between_normal_and_fullscreen_mode)

        self.notebook = Notebook()
        self._last_page = 0

        self._full_screen_wait_signal = FullScreenWaitSignal()
        self._full_screen_wait_signal.set_transient_for(self.window)

        self._bookmark_widget = BookmarkOverlayWidget()

        self._process_bookmarks_in_ebook_mode_widget = ProcessBookmarksInEBookModeWidget(
            self)
        self._process_bookmarks_in_ebook_mode_widget.set_transient_for(
            self.window)

        self._process_zoom_in_ebook_mode_widget = ProcessZoomInEBookModeWidget(
            self)
        self._process_zoom_in_ebook_mode_widget.set_transient_for(self.window)

        self._process_files_in_ebook_mode_widget = ProcessFilesInEBookModeWidget(
            self)
        self._process_files_in_ebook_mode_widget.set_transient_for(self.window)

        self._modes = {}
        self._modes[constants.MODE_NORMAL] = self.get_reader_tab()
        self._modes[
            constants.MODE_ZOOM] = self._process_zoom_in_ebook_mode_widget
        self._modes[
            constants.
            MODE_SELECT_FILE] = self._process_files_in_ebook_mode_widget

        self._current_mode = self._modes[constants.MODE_NORMAL]

        self._toolbar_box = ToolbarBox()
        # Remove the horizontal padding, being caused due to upstream
        # API.
        self._toolbar_box.props.padding = 0

        self.window.set_toolbar_box(self._toolbar_box)

        self._toolbar_box.toolbar.modify_bg(Gtk.StateType.NORMAL,
                                            Gdk.color_parse('#282828'))
        placeholder = SecondaryToolbarButton(None)
        placeholder.props.sensitive = False
        self._toolbar_box._toolbar.insert(placeholder, -1)

        pagenum = 0
        for page in self.pages_list:
            page.set_main_window(self)
            page.set_pagenum(pagenum)

            pagenum = pagenum + 1

            self.add_page(page)
            self.notebook.set_show_tabs(False)

    # Add the "stop" button, in the top-row.
    # But before that, put some space, by inserting a dummy widget,
    # containing only text.
        label_text = ''
        for i in range(0, 85):
            label_text = label_text + ' '
        dummy_label = Gtk.Label(label_text)
        toolitem = Gtk.ToolItem()
        toolitem.add(dummy_label)
        self._toolbar_box._toolbar.insert(toolitem, -1)

        self._stop_button = SecondaryToolbarButton('bookreader-stop',
                                                   _('Stop'), self.destroy)

        separador = Gtk.SeparatorToolItem()
        separador.props.draw = False
        separador.set_size_request(0, -1)
        separador.set_expand(True)
        self._toolbar_box._toolbar.insert(separador, -1)
        self._toolbar_box._toolbar.insert(self._stop_button, -1)
        placeholder = SecondaryToolbarButton(None)
        placeholder.props.sensitive = False
        self._toolbar_box._toolbar.insert(placeholder, -1)
        self._toolbar_box.show_all()

        if (filepath is not None) and (filepath != "") and \
           (filepath != '""'):
            self.load_and_read_book((
                filepath,
                journal_id,
            ))
        else:
            self.notebook.set_current_page(0)
            self._last_page = 0

        self.window.set_canvas(self.notebook)
        self.window.show_all()

        self.window.maximize()
        self.window.show_all()

        if get_active_desktop() == "Sugar":
            for i in range(0, len(sys.argv)):
                if sys.argv[i] == '-a':
                    activity_id = sys.argv[i + 1]
                    break
            xid = self.window.get_window().get_xid()
            SugarExt.wm_set_bundle_id(xid, env.SUGAR_BUNDLE_ID)
            SugarExt.wm_set_activity_id(xid, activity_id)