Esempio n. 1
0
def check_support(min_texture_size=0, force_enable=False):
    try:
        from xpra.platform.paths import get_icon_dir
        opengl_icon = os.path.join(get_icon_dir(), "opengl.png")
    except:
        opengl_icon = None
    #tricks to get py2exe to include what we need / load it from its unusual path:
    if sys.platform.startswith("win"):
        #This is supposed to help py2exe
        #(must be done after we setup the sys.path in platform.win32.paths):
        from OpenGL.platform import win32   #@UnusedImport

    props = {}
    import gtk.gdk
    import gtk.gdkgl, gtk.gtkgl
    assert gtk.gdkgl is not None and gtk.gtkgl is not None
    debug("pygdkglext version=%s", gtk.gdkgl.pygdkglext_version)
    props["pygdkglext_version"] = gtk.gdkgl.pygdkglext_version
    debug("pygdkglext OpenGL version=%s", gtk.gdkgl.query_version())
    props["gdkgl_version"] = gtk.gdkgl.query_version()
    display_mode = get_DISPLAY_MODE()
    try:
        glconfig = gtk.gdkgl.Config(mode=display_mode)
    except gtk.gdkgl.NoMatches, e:
        debug("no match: %s, toggling double-buffering", e)
        display_mode &= ~gtk.gdkgl.MODE_DOUBLE
        glconfig = gtk.gdkgl.Config(mode=display_mode)
Esempio n. 2
0
 def get_pixbuf(self, icon_name):
     icon_filename = os.path.join(get_icon_dir(), icon_name)
     if os.path.exists(icon_filename):
         try:
             return GdkPixbuf.Pixbuf.new_from_file(icon_filename)
         except Exception as e:
             log("pixbuf_new_from_file(%s) failed: %s", icon_filename, e)
     return None
Esempio n. 3
0
 def get_tray_icon_filename(self, cmdlineoverride=None):
     if cmdlineoverride and os.path.exists(cmdlineoverride):
         debug("get_tray_icon_filename using %s from command line", cmdlineoverride)
         return  cmdlineoverride
     f = os.path.join(get_icon_dir(), self.default_icon_name)
     if os.path.exists(f):
         debug("get_tray_icon_filename using default: %s", f)
         return  f
     return  None
Esempio n. 4
0
 def get_tray_icon_filename(self, cmdlineoverride=None):
     if cmdlineoverride and os.path.exists(cmdlineoverride):
         debug("get_tray_icon_filename using %s from command line",
               cmdlineoverride)
         return cmdlineoverride
     f = os.path.join(get_icon_dir(), self.default_icon_name)
     if os.path.exists(f):
         debug("get_tray_icon_filename using default: %s", f)
         return f
     return None
Esempio n. 5
0
 def set_icon(self, basefilename):
     if not self.macapp:
         return
     with_ext = "%s.png" % basefilename
     icon_dir = get_icon_dir()
     filename = os.path.join(icon_dir, with_ext)
     if not os.path.exists(filename):
         log.error("could not find icon '%s' in osx icon dir: %s", with_ext, icon_dir)
         return
     pixbuf = gtk.gdk.pixbuf_new_from_file(filename)
     self.macapp.set_dock_icon_pixbuf(pixbuf)
Esempio n. 6
0
 def set_tray_icon(self, filename):
     if not self.tray_widget:
         return
     try:
         from xpra.platform.paths import get_icon_dir
         if not os.path.isabs(filename):
             icon_filename = os.path.join(get_icon_dir(), filename)
         self.tray_widget.set_icon(icon_filename)
     except Exception as e:
         traylog.warn("Warning: failed to set tray icon to %s", filename)
         traylog.warn(" %s", e)
Esempio n. 7
0
 def set_icon(self, basefilename):
     if not self.macapp:
         return
     with_ext = "%s.png" % basefilename
     icon_dir = get_icon_dir()
     filename = os.path.join(icon_dir, with_ext)
     if not os.path.exists(filename):
         log.error("could not find icon '%s' in osx icon dir: %s", with_ext,
                   icon_dir)
         return
     pixbuf = gtk.gdk.pixbuf_new_from_file(filename)
     self.macapp.set_dock_icon_pixbuf(pixbuf)
Esempio n. 8
0
def get_appimage(app_name, icondata=None, menu_icon_size=24):
    pixbuf = None
    if app_name and not icondata:
        #try to load from our icons:
        nstr = bytestostr(app_name).lower()
        icon_filename = os.path.join(get_icon_dir(), "%s.png" % nstr)
        if os.path.exists(icon_filename):
            pixbuf = GdkPixbuf.Pixbuf.new_from_file(icon_filename)

    def err(e):
        log("failed to load icon", exc_info=True)
        log.error("Error: failed to load icon data for '%s':",
                  bytestostr(app_name))
        log.error(" %s", e)
        log.error(" data=%s", repr_ellipsized(icondata))

    if not pixbuf and icondata:
        #gtk pixbuf loader:
        try:
            pixbuf = load_pixbuf(icondata)
        except Exception as e:
            log("pixbuf loader failed", exc_info=True)
            if re.findall(INKSCAPE_RE, icondata):
                try:
                    pixbuf = load_pixbuf(re.sub(INKSCAPE_RE, b"", icondata))
                    e = None
                except Exception:
                    #there is almost no chance pillow will be able to load it
                    #(it doesn't even have svg support at time of writing)
                    #so don't bother showing another error for the same data:
                    icondata = None
            if e:
                err(e)
    if not pixbuf and icondata:
        #let's try pillow:
        try:
            from xpra.codecs.pillow.decoder import open_only  #pylint: disable=import-outside-toplevel
            img = open_only(icondata)
            has_alpha = img.mode == "RGBA"
            width, height = img.size
            rowstride = width * (3 + int(has_alpha))
            pixbuf = get_pixbuf_from_data(img.tobytes(), has_alpha, width,
                                          height, rowstride)
            return scaled_image(pixbuf, icon_size=menu_icon_size)
        except Exception:
            err(e)
    if pixbuf:
        return scaled_image(pixbuf, icon_size=menu_icon_size)
    return None
Esempio n. 9
0
 def __init__(self, menu, tooltip, icon_filename, size_changed_cb, click_cb, mouseover_cb, exit_cb):
     TrayBase.__init__(self, menu, tooltip, icon_filename, size_changed_cb, click_cb, mouseover_cb, exit_cb)
     filename = self.get_tray_icon_filename(icon_filename)
     self.appindicator = get_appindicator()
     assert self.appindicator, "appindicator is not available!"
     self.tray_widget = self.appindicator.Indicator(tooltip, filename, self.appindicator.CATEGORY_APPLICATION_STATUS)
     if hasattr(self.tray_widget, "set_icon_theme_path"):
         self.tray_widget.set_icon_theme_path(get_icon_dir())
     self.tray_widget.set_attention_icon("xpra.png")
     if filename:
         self.tray_widget.set_icon(filename)
     else:
         self.tray_widget.set_label("Xpra")
     if menu:
         self.tray_widget.set_menu(menu)
Esempio n. 10
0
 def __init__(self, *args, **kwargs):
     TrayBase.__init__(self, *args, **kwargs)
     filename = get_icon_filename(self.default_icon_filename) or "xpra.png"
     self._has_icon = False
     self.tmp_filename = None
     self.tray_widget = Indicator(self.tooltip, filename, APPLICATION_STATUS)
     if hasattr(self.tray_widget, "set_icon_theme_path"):
         self.tray_widget.set_icon_theme_path(get_icon_dir())
     self.tray_widget.set_attention_icon("xpra.png")
     if filename:
         self.set_icon_from_file(filename)
     if not self._has_icon:
         self.tray_widget.set_label("Xpra")
     if self.menu:
         self.tray_widget.set_menu(self.menu)
Esempio n. 11
0
 def set_icon(self, basefilename=None):
     if basefilename is None:
         #use default filename, or find file with default icon name:
         filename = self.default_icon_filename or self.get_tray_icon_filename()
     else:
         #create full path + filename from basefilename:
         with_ext = "%s.%s" % (basefilename, self.default_icon_extension)
         icon_dir = get_icon_dir()
         filename = os.path.join(icon_dir, with_ext)
     if not os.path.exists(filename):
         log.error("could not find icon '%s' for name '%s'", filename, basefilename)
         return
     abspath = os.path.abspath(filename)
     debug("set_icon(%s) using filename=%s", basefilename, abspath)
     self.set_icon_from_file(abspath)
Esempio n. 12
0
 def __init__(self, *args):
     TrayBase.__init__(self, *args)
     filename = self.get_tray_icon_filename(self.default_icon_filename)
     self.appindicator = get_appindicator()
     self._has_icon = False
     assert self.appindicator, "appindicator is not available!"
     self.tray_widget = self.appindicator.Indicator(self.tooltip, filename, self.appindicator.CATEGORY_APPLICATION_STATUS)
     if hasattr(self.tray_widget, "set_icon_theme_path"):
         self.tray_widget.set_icon_theme_path(get_icon_dir())
     self.tray_widget.set_attention_icon("xpra.png")
     if filename:
         self.set_icon_from_file(filename)
     if not self._has_icon:
         self.tray_widget.set_label("Xpra")
     if self.menu:
         self.tray_widget.set_menu(self.menu)
Esempio n. 13
0
 def do_notify_startup(self, title, body="", replaces_nid=0):
     #overriden here so we can show the notification
     #directly on the screen we shadow
     notifylog("do_notify_startup%s", (title, body, replaces_nid))
     if self.notifier:
         tray = self.get_notification_tray()  #pylint: disable=assignment-from-none
         nid = XPRA_STARTUP_NOTIFICATION_ID
         actions = []
         hints = {}
         icon = None
         icon_filename = os.path.join(get_icon_dir(),
                                      "server-connected.png")
         if os.path.exists(icon_filename):
             icon = parse_image_path(icon_filename)
         self.notifier.show_notify("", tray, nid, "Xpra", replaces_nid, "",
                                   title, body, actions, hints, 10 * 1000,
                                   icon)
Esempio n. 14
0
 def set_icon(self, basefilename=None):
     if basefilename is None:
         #use default filename, or find file with default icon name:
         filename = self.default_icon_filename or self.get_tray_icon_filename(
         )
     else:
         #create full path + filename from basefilename:
         with_ext = "%s.%s" % (basefilename, self.default_icon_extension)
         icon_dir = get_icon_dir()
         filename = os.path.join(icon_dir, with_ext)
     if not os.path.exists(filename):
         log.error("could not find icon '%s' for name '%s'", filename,
                   basefilename)
         return
     abspath = os.path.abspath(filename)
     debug("set_icon(%s) using filename=%s", basefilename, abspath)
     self.set_icon_from_file(abspath)
Esempio n. 15
0
 def notify_new_user(self, ss):
     #overriden here so we can show the notification
     #directly on the screen we shadow
     notifylog("notify_new_user(%s) notifier=%s", ss, self.notifier)
     if self.notifier:
         tray = self.get_notification_tray()  #pylint: disable=assignment-from-none
         nid = XPRA_NEW_USER_NOTIFICATION_ID
         title = "User '%s' connected to the session" % (
             ss.name or ss.username or ss.uuid)
         body = "\n".join(ss.get_connect_info())
         actions = []
         hints = {}
         icon = None
         icon_filename = os.path.join(get_icon_dir(), "user.png")
         if os.path.exists(icon_filename):
             icon = parse_image_path(icon_filename)
         self.notifier.show_notify("", tray, nid, "Xpra", 0, "", title,
                                   body, actions, hints, 10 * 1000, icon)
Esempio n. 16
0
 def __init__(self, menu, tooltip, icon_filename, size_changed_cb, click_cb,
              mouseover_cb, exit_cb):
     TrayBase.__init__(self, menu, tooltip, icon_filename, size_changed_cb,
                       click_cb, mouseover_cb, exit_cb)
     filename = self.get_tray_icon_filename(icon_filename)
     self.appindicator = get_appindicator()
     assert self.appindicator, "appindicator is not available!"
     self.tray_widget = self.appindicator.Indicator(
         tooltip, filename, self.appindicator.CATEGORY_APPLICATION_STATUS)
     if hasattr(self.tray_widget, "set_icon_theme_path"):
         self.tray_widget.set_icon_theme_path(get_icon_dir())
     self.tray_widget.set_attention_icon("xpra.png")
     if filename:
         self.tray_widget.set_icon(filename)
     else:
         self.tray_widget.set_label("Xpra")
     if menu:
         self.tray_widget.set_menu(menu)
Esempio n. 17
0
    def __init__(self, title="Title", prompt="", info=(), icon="", buttons=()):
        log("ConfirmDialogWindow%s", (title, prompt, info, icon, buttons))
        super().__init__()
        self.set_border_width(20)
        self.set_position(Gtk.WindowPosition.CENTER)
        self.connect("delete-event", self.quit)
        self.set_default_size(400, 150)
        self.set_title(title)
        add_close_accel(self, self.quit)

        if icon:
            icon_filename = os.path.join(get_icon_dir(), icon)
            if os.path.exists(icon_filename):
                icon_pixbuf = GdkPixbuf.Pixbuf.new_from_file(icon_filename)
                if icon_pixbuf:
                    self.set_icon(icon_pixbuf)

        vbox = self.get_content_area()
        vbox.set_spacing(10)

        def al(label, font="sans 14", xalign=0):
            l = Gtk.Label(label=label)
            l.modify_font(Pango.FontDescription(font))
            if label.startswith("WARNING"):
                red = color_parse("red")
                l.modify_fg(Gtk.StateType.NORMAL, red)
            al = Gtk.Alignment(xalign=xalign, yalign=0.5, xscale=0.0, yscale=0)
            al.add(l)
            al.show_all()
            return al

        vbox.add(al(title, "sans 18", 0.5))
        info_box = Gtk.VBox()
        for i in info:
            info_box.add(al(i, "sans 14"))
        info_box.show_all()
        vbox.add(info_box)
        vbox.add(al(prompt, "sans 14"))

        # Buttons:
        for label, code in buttons:
            btn = self.add_button(label, code)
            btn.set_size_request(100, 48)
Esempio n. 18
0
    def __init__(self, title="Title", prompt="", icon=""):
        super().__init__()
        self.set_border_width(20)
        self.set_position(Gtk.WindowPosition.CENTER)
        self.connect("delete-event", self.quit)
        self.set_default_size(400, 150)
        self.set_title(title)
        add_close_accel(self, self.cancel)
        self.password = None

        if icon:
            icon_filename = os.path.join(get_icon_dir(), icon)
            if os.path.exists(icon_filename):
                icon_pixbuf = GdkPixbuf.Pixbuf.new_from_file(icon_filename)
                if icon_pixbuf:
                    self.set_icon(icon_pixbuf)

        vbox = self.get_content_area()
        vbox.set_spacing(10)

        def al(label, font="sans 14", xalign=0):
            l = Gtk.Label(label)
            l.modify_font(Pango.FontDescription(font))
            al = Gtk.Alignment(xalign=xalign, yalign=0.5, xscale=0.0, yscale=0)
            al.add(l)
            vbox.add(al)
            al.show_all()

        #window title is visible so this would be redundant:
        #al(title, "sans 18", 0.5)
        al(prompt, "sans 14")
        self.password_input = Gtk.Entry()
        self.password_input.set_max_length(255)
        self.password_input.set_width_chars(32)
        self.password_input.connect('activate', self.password_activate)
        self.password_input.connect('changed', self.password_changed)
        self.password_input.set_visibility(False)
        vbox.add(self.password_input)

        self.confirm_btn = self.add_button("Confirm", 0)
        self.set_default(self.confirm_btn)
        self.set_focus(self.confirm_btn)
        self.cancel_btn = self.add_button("Cancel", 1)
Esempio n. 19
0
def get_appimage(app_name, icondata=None, menu_icon_size=24):
    pixbuf = None
    if app_name and not icondata:
        #try to load from our icons:
        nstr = bytestostr(app_name).lower()
        icon_filename = os.path.join(get_icon_dir(), "%s.png" % nstr)
        if os.path.exists(icon_filename):
            pixbuf = GdkPixbuf.Pixbuf.new_from_file(icon_filename)
    if not pixbuf and icondata:
        #gtk pixbuf loader:
        try:
            loader = GdkPixbuf.PixbufLoader()
            loader.write(icondata)
            loader.close()
            pixbuf = loader.get_pixbuf()
        except Exception as e:
            log("pixbuf loader failed", exc_info=True)
            log.error("Error: failed to load icon data for '%s':",
                      bytestostr(app_name))
            log.error(" %s", e)
            log.error(" data=%s", repr_ellipsized(icondata))
    if not pixbuf and icondata:
        #let's try pillow:
        try:
            from xpra.codecs.pillow.decoder import open_only
            img = open_only(icondata)
            has_alpha = img.mode == "RGBA"
            width, height = img.size
            rowstride = width * (3 + int(has_alpha))
            pixbuf = get_pixbuf_from_data(img.tobytes(), has_alpha, width,
                                          height, rowstride)
            return scaled_image(pixbuf, icon_size=menu_icon_size)
        except Exception:
            log.error("Error: failed to load icon data for %s",
                      bytestostr(app_name),
                      exc_info=True)
            log.error(" data=%s", repr_ellipsized(icondata))
    if pixbuf:
        return scaled_image(pixbuf, icon_size=menu_icon_size)
    return None
Esempio n. 20
0
 def __init__(self, *args, **kwargs):
     TrayBase.__init__(self, *args, **kwargs)
     filename = get_icon_filename(self.default_icon_filename)
     self.appindicator = get_appindicator()
     self._has_icon = False
     assert self.appindicator, "appindicator is not available!"
     category = get_application_category(self.appindicator)
     assert category is not None, "appindicator category is not available!"
     if PYTHON2:
         self.tray_widget = self.appindicator.Indicator(self.tooltip, filename, category)
     else:
         self.tray_widget = self.appindicator.Indicator()
         self.tray_widget.set_property("label", self.tooltip)
         self.tray_widget.set_property("category", category)
     if hasattr(self.tray_widget, "set_icon_theme_path"):
         self.tray_widget.set_icon_theme_path(get_icon_dir())
     self.tray_widget.set_attention_icon("xpra.png")
     if filename:
         self.set_icon_from_file(filename)
     if not self._has_icon:
         self.tray_widget.set_label("Xpra")
     if self.menu:
         self.tray_widget.set_menu(self.menu)
Esempio n. 21
0
 def get_icon(self, icon_name):
     from xpra.platform.paths import get_icon_dir
     icon_filename = os.path.join(get_icon_dir(), icon_name)
     if os.path.exists(icon_filename):
         return pixbuf_new_from_file(icon_filename)
     return None
Esempio n. 22
0
 def get_icon(self, icon_name):
     from xpra.platform.paths import get_icon_dir
     icon_filename = os.path.join(get_icon_dir(), icon_name)
     if os.path.exists(icon_filename):
         return pixbuf_new_from_file(icon_filename)
     return None
Esempio n. 23
0
 def get_icon(self, icon_name):
     icon_filename = os.path.join(get_icon_dir(), icon_name)
     if os.path.exists(icon_filename):
         return pixbuf_new_from_file(icon_filename)
     return None
Esempio n. 24
0
def get_pixbuf(icon_name):
    icon_filename = os.path.join(get_icon_dir(), icon_name)
    if os.path.exists(icon_filename):
        return GdkPixbuf.Pixbuf.new_from_file(icon_filename)
    return None
Esempio n. 25
0
 def get_icon(self, icon_name):
     icon_filename = os.path.join(get_icon_dir(), icon_name)
     if os.path.exists(icon_filename):
         return pixbuf_new_from_file(icon_filename)
     return None
Esempio n. 26
0
 def set_icon(self, basefilename):
     with_ext = "%s.png" % basefilename
     icon_dir = get_icon_dir()
     filename = os.path.join(icon_dir, with_ext)
     self.set_icon_from_file(filename)