Ejemplo n.º 1
0
 def __create_initial_windows(self, foreground):
     """
         Create initial windows based on saved session
         @param foreground  as bool if foreground loading allowed
     """
     size = (800, 600)
     maximized = False
     try:
         windows = load(open(EOLIE_DATA_PATH + "/session_states.bin", "rb"))
         if self.settings.get_value("remember-session"):
             for window in windows:
                 if not window["states"]:
                     continue
                 new_window = self.get_new_window(window["size"],
                                                  window["maximized"])
                 items = []
                 i = 0 if foreground else 1
                 for (uri, title, atime, gtime, ephemeral,
                      state) in window["states"]:
                     loading_type = wanted_loading_type(i)
                     webkit_state = WebKit2.WebViewSessionState(
                         GLib.Bytes.new(state))
                     items.append((uri, title, atime, gtime, ephemeral,
                                   webkit_state, loading_type))
                     i += 1
                 new_window.container.add_webviews(items)
         elif windows:
             size = windows[0]["size"]
             maximized = windows[0]["maximized"]
     except Exception as e:
         print("Application::__create_initial_windows()", e)
     if not self.get_windows():
         self.get_new_window(size, maximized)
Ejemplo n.º 2
0
 def __on_command_line(self, app, app_cmd_line):
     """
         Handle command line
         @param app as Gio.Application
         @param options as Gio.ApplicationCommandLine
     """
     self.__externals_count = 0
     args = app_cmd_line.get_arguments()
     options = app_cmd_line.get_options_dict()
     if options.contains("show-tls"):
         self.show_tls = True
     if options.contains("disable-artwork-cache"):
         self.art.disable_cache()
     ephemeral = options.contains("private")
     if not self.get_windows():
         self.__create_initial_windows(len(args) < 2)
         active_window = self.active_window
     elif options.contains("new") or len(args) == 1:
         active_window = self.get_new_window()
     else:
         active_window = self.active_window
     # Open command line args
     if len(args) > 1:
         items = []
         i = 0
         for uri in args[1:]:
             # Transform path to uri
             parsed = urlparse(uri)
             if not parsed.scheme:
                 if uri.startswith('/'):
                     uri = "file://%s" % uri
                 else:
                     uri = "http://%s" % uri
             loading_type = wanted_loading_type(i)
             items.append((uri, uri, 0, ephemeral, None, loading_type))
             i += 1
         active_window.container.add_webviews(items)
         # https://bugzilla.gnome.org/show_bug.cgi?id=766284
         monotonic_time = int(GLib.get_monotonic_time() / 1000)
         active_window.present_with_time(monotonic_time)
     # Add default start page
     if not active_window.container.views:
         active_window.container.add_webview(self.start_page,
                                             LoadingType.FOREGROUND,
                                             ephemeral)
     if self.settings.get_value("debug"):
         WebKit2.WebContext.get_default().get_plugins(
             None, self.__on_get_plugins, None)
     Gdk.notify_startup_complete()
     return 0
Ejemplo n.º 3
0
 def __on_command_line(self, app, app_cmd_line):
     """
         Handle command line
         @param app as Gio.Application
         @param options as Gio.ApplicationCommandLine
     """
     self.__externals_count = 0
     args = app_cmd_line.get_arguments()
     options = app_cmd_line.get_options_dict()
     if options.contains("debug"):
         GLib.setenv("WEBKIT_DEBUG", "network", True)
         self.debug = True
     if options.contains("show-tls"):
         self.show_tls = True
     if options.contains("disable-artwork-cache"):
         self.art.disable_cache()
     ephemeral = options.contains("private")
     if not self.get_windows():
         self.__create_initial_windows(len(args) < 2)
     if options.contains("new"):
         active_window = self.get_new_window()
     else:
         active_window = self.active_window
     # Open command line args
     if len(args) > 1:
         items = []
         i = 0
         for uri in args[1:]:
             # Transform path to uri
             parsed = urlparse(uri)
             if not parsed.scheme:
                 if uri.startswith('/'):
                     uri = "file://%s" % uri
                 else:
                     uri = "http://%s" % uri
             loading_type = wanted_loading_type(i)
             items.append((uri, uri, 0, 0, ephemeral, None, loading_type))
             i += 1
         active_window.container.add_webviews(items)
         active_window.present_with_time(Gtk.get_current_event_time())
     # Add default start page
     if not active_window.container.views:
         active_window.container.add_webview(self.start_page,
                                             LoadingType.FOREGROUND,
                                             ephemeral)
     if self.debug:
         WebKit2.WebContext.get_default().get_plugins(
             None, self.__on_get_plugins, None)
     return 0
Ejemplo n.º 4
0
 def __on_openall_clicked(self, action, variant):
     """
         Add all entries
         @param Gio.SimpleAction
         @param GVariant
     """
     items = []
     for i in range(0, self.__closed_section.get_n_items()):
         uri_attr = self.__closed_section.get_item_attribute_value(i, "uri")
         title_attr = self.__closed_section.get_item_attribute_value(
             i, "label")
         if uri_attr is None or title_attr is None:
             continue
         uri = uri_attr.get_string()
         title = title_attr.get_string()
         loading_type = wanted_loading_type(i)
         items.append((uri, title, 0, 0, False, None, loading_type))
         i += 1
     El().active_window.container.add_webviews(items)
     self.__closed_section.remove_all()
Ejemplo n.º 5
0
 def __on_open_clicked(self, button):
     """
         Open all bookmarks
         @param button as Gtk.Button
     """
     self.__window.close_popovers()
     tag_id = self.__item.get_property("id")
     if tag_id == Type.POPULARS:
         items = El().bookmarks.get_populars(50)
     elif tag_id == Type.RECENTS:
         items = El().bookmarks.get_recents()
     elif tag_id == Type.UNCLASSIFIED:
         items = El().bookmarks.get_unclassified()
     else:
         items = El().bookmarks.get_bookmarks(tag_id)
     pages = []
     i = 0
     for (bid, uri, title) in items:
         loading_type = wanted_loading_type(i)
         pages.append((uri, title, 0, 0, False, None, loading_type))
         i += 1
     self.__window.container.add_webviews(pages)