def _set_default_icon(self): # set the icon so that it doesn't flash when the window is # realized in Application.build_window(). # if this isn't a themed Miro, then we use the default icon set ico_path = resources.share_path("icons/hicolor/24x24/apps/miro.png") if app.config.get(prefs.THEME_NAME) != prefs.THEME_NAME.default and app.config.get(options.WINDOWS_ICON): theme_ico_path = resources.theme_path( app.config.get(prefs.THEME_NAME), app.config.get(options.WINDOWS_ICON) ) if os.path.exists(theme_ico_path): ico_path = theme_ico_path gtk.window_set_default_icon_from_file(ico_path) else: gtk.icon_theme_get_default().append_search_path(resources.share_path("icons")) gtk.window_set_default_icon_name("miro") return ico_path
def _set_default_icon(self): # set the icon so that it doesn't flash when the window is # realized in Application.build_window(). # if this isn't a themed Miro, then we use the default icon set ico_path = resources.share_path("icons/hicolor/24x24/apps/miro.png") if ((app.config.get(prefs.THEME_NAME) != prefs.THEME_NAME.default and app.config.get(options.WINDOWS_ICON))): theme_ico_path = resources.theme_path( app.config.get(prefs.THEME_NAME), app.config.get(options.WINDOWS_ICON)) if os.path.exists(theme_ico_path): ico_path = theme_ico_path gtk.window_set_default_icon_from_file(ico_path) else: gtk.icon_theme_get_default().append_search_path( resources.share_path('icons')) gtk.window_set_default_icon_name("miro") return ico_path
def __init__(self, icon): self.indicator = appindicator.Indicator( app.config.get(prefs.SHORT_APP_NAME), icon, appindicator.CATEGORY_APPLICATION_STATUS) self.indicator.set_status(appindicator.STATUS_PASSIVE) self.menu_items = [] self.indicator.set_icon_theme_path(resources.share_path('icons')) self.calculate_popup_menu() #FIXME: this is a bit of a hack since the signal probably # wasn't meant to be used this way. However, it is emitted # every time app.menu_manager.update_menus() is called # and therefore it covers all situations where we want to # update the app indicator menu. The signal is also emitted # sometimes when no update to the app indicator menu is needed # (espcecially during downloads). Therefore we later only set # a new app indicator menu if there actually is a change in # the menu text. This avoids a flickering menu. app.menu_manager.connect('enabled-changed', self._on_menu_update)
def __init__(self, icon): self.indicator = appindicator.Indicator( app.config.get(prefs.SHORT_APP_NAME), icon, appindicator.CATEGORY_APPLICATION_STATUS) self.indicator.set_status(appindicator.STATUS_PASSIVE) self.menu_items = [] self.indicator.set_icon_theme_path(resources.share_path('icons')) self.calculate_popup_menu() #FIXME: this is a bit of a hack since the signal probably # wasn't meant to be used this way. However, it is emitted # every time app.menu_manager.update_menus() is called # and therefore it covers all situations where we want to # update the app indicator menu. The signal is also emitted # sometimes when no update to the app indicator menu is needed # (espcecially during downloads). Therefore we later only set # a new app indicator menu if there actually is a change in # the menu text. This avoids a flickering menu. app.menu_manager.connect('menus-updated', self._on_menu_update)
def update_autostart(self, value): autostart_dir = resources.get_autostart_dir() destination = os.path.join(autostart_dir, "miro.desktop") if value: if os.path.exists(destination): return try: if not os.path.exists(autostart_dir): os.makedirs(autostart_dir) shutil.copy(resources.share_path("applications/miro.desktop"), destination) except OSError: logging.exception("Problems creating or populating " "autostart dir.") else: if not os.path.exists(destination): return try: os.remove(destination) except OSError: logging.exception("Problems removing autostart dir.")
def update_autostart(self, value): autostart_dir = resources.get_autostart_dir() destination = os.path.join(autostart_dir, "miro.desktop") if value: if os.path.exists(destination): return try: if not os.path.exists(autostart_dir): os.makedirs(autostart_dir) shutil.copy(resources.share_path('applications/miro.desktop'), destination) except OSError: logging.exception("Problems creating or populating " "autostart dir.") else: if not os.path.exists(destination): return try: os.remove(destination) except OSError: logging.exception("Problems removing autostart dir.")
def build_content(self): packing_vbox = layout.VBox(spacing=20) icon_pixbuf = gtk.gdk.pixbuf_new_from_file_at_size( resources.share_path('icons/hicolor/128x128/apps/miro.png'), 48, 48) packing_vbox._widget.pack_start(gtk.image_new_from_pixbuf(icon_pixbuf)) if app.config.get(prefs.APP_REVISION_NUM): version = "%s (%s)" % ( app.config.get(prefs.APP_VERSION), app.config.get(prefs.APP_REVISION_NUM)) else: version = "%s" % app.config.get(prefs.APP_VERSION) name_label = gtk.Label( '<span size="xx-large" weight="bold">%s %s</span>' % ( app.config.get(prefs.SHORT_APP_NAME), version)) name_label.set_use_markup(True) packing_vbox._widget.pack_start(name_label) copyright_text = _( '%(copyright)s. See license.txt file for details.\n' '%(trademark)s', {"copyright": app.config.get(prefs.COPYRIGHT), "trademark": app.config.get(prefs.TRADEMARK)}) copyright_label = gtk.Label('<small>%s</small>' % copyright_text) copyright_label.set_use_markup(True) copyright_label.set_justify(gtk.JUSTIFY_CENTER) packing_vbox._widget.pack_start(copyright_label) # FIXME - make the project url clickable packing_vbox._widget.pack_start( gtk.Label(app.config.get(prefs.PROJECT_URL))) contributor_label = gtk.Label( _("Thank you to all the people who contributed to %(appname)s " "%(version)s:", {"appname": app.config.get(prefs.SHORT_APP_NAME), "version": app.config.get(prefs.APP_VERSION)})) contributor_label.set_justify(gtk.JUSTIFY_CENTER) packing_vbox._widget.pack_start(contributor_label) # get contributors, remove newlines and wrap it contributors = open(resources.path('CREDITS'), 'r').readlines() contributors = [c[2:].strip() for c in contributors if c.startswith("* ")] contributors = ", ".join(contributors) # show contributors contrib_buffer = gtk.TextBuffer() contrib_buffer.set_text(contributors) contrib_view = gtk.TextView(contrib_buffer) contrib_view.set_editable(False) contrib_view.set_cursor_visible(False) contrib_view.set_wrap_mode(gtk.WRAP_WORD) contrib_window = gtk.ScrolledWindow() contrib_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) contrib_window.add(contrib_view) contrib_window.set_size_request(-1, 100) packing_vbox._widget.pack_start(contrib_window) # FIXME - make the project url clickable donate_label = gtk.Label( _("To help fund continued %(appname)s development, visit the " "donation page at:", {"appname": app.config.get(prefs.SHORT_APP_NAME)})) donate_label.set_justify(gtk.JUSTIFY_CENTER) packing_vbox._widget.pack_start(donate_label) packing_vbox._widget.pack_start( gtk.Label(app.config.get(prefs.DONATE_URL))) return packing_vbox
def upgrade(): # dot directory src = os.path.expanduser('~/.democracy') dst = os.path.expanduser('~/.miro') if os.path.isdir(src) and not os.path.exists(dst): shutil.move(src, dst) shutil.rmtree(os.path.join(dst, "icon-cache"), True) # autostart file if "KDE_FULL_SESSION" in os.environ: if os.environ.get("KDE_SESSION_VERSION") == "4": autostart_dir = "~/.kde/share/autostart" else: autostart_dir = "~/.kde/Autostart" else: config_home = os.environ.get('XDG_CONFIG_HOME', '~/.config') autostart_dir = os.path.join(config_home, "autostart") autostart_dir = os.path.expanduser(autostart_dir) old_file = os.path.join(autostart_dir, "democracyplayer.desktop") destination = os.path.join(autostart_dir, "miro.desktop") if os.path.exists(old_file) and not os.path.exists(destination): try: if not os.path.exists(autostart_dir): os.makedirs(autostart_dir) shutil.copy(resources.share_path('applications/miro.desktop'), destination) os.remove(old_file) except OSError: pass # gconf settings client = gconf.client_get_default() def _copy_gconf(src, dst): for entry in client.all_entries(src): entry_dst = dst + '/' + entry.key.split('/')[-1] client.set(entry_dst, entry.value) for subdir in client.all_dirs(src): subdir_dst = dst + '/' + subdir.split('/')[-1] _copy_gconf(subdir, subdir_dst) if ((client.dir_exists("/apps/democracy/player") and not client.dir_exists("/apps/miro"))): _copy_gconf("/apps/democracy/player", "/apps/miro") client.recursive_unset("/apps/democracy", 1) # Set the MoviesDirectory and NonVideoDirectory based on the # possibilities that we've had over the years and what exists on # the user's system. This codifies it in the user's gconf so that # when we change it in future, then the user isn't affected. from miro.plat import options if options.gconf_name is None: options.gconf_name = "miro" key = "/apps/%s/MoviesDirectory" % options.gconf_name if client.get(key) is None: for mem in [ "~/.miro/Movies", # packages "~/Videos/Miro", "~/Movies/Miro", # pre 3.5 "~/Movies/Democracy" # democracy player ]: mem = os.path.expanduser(mem) if os.path.exists(mem): client.set_string(key, mem) break key = "/apps/%s/NonVideoDirectory" % options.gconf_name if client.get(key) is None: for mem in ["~/.miro/Nonvideo" # packages ]: mem = os.path.expanduser(mem) if os.path.exists(mem): client.set_string(key, mem) break
def upgrade(): # dot directory src = os.path.expanduser('~/.democracy') dst = os.path.expanduser('~/.miro') if os.path.isdir(src) and not os.path.exists(dst): shutil.move(src, dst) shutil.rmtree(os.path.join(dst, "icon-cache"), True) # autostart file if "KDE_FULL_SESSION" in os.environ: if os.environ.get("KDE_SESSION_VERSION") == "4": autostart_dir = "~/.kde/share/autostart" else: autostart_dir = "~/.kde/Autostart" else: config_home = os.environ.get('XDG_CONFIG_HOME', '~/.config') autostart_dir = os.path.join(config_home, "autostart") autostart_dir = os.path.expanduser(autostart_dir) old_file = os.path.join(autostart_dir, "democracyplayer.desktop") destination = os.path.join(autostart_dir, "miro.desktop") if os.path.exists(old_file) and not os.path.exists(destination): try: if not os.path.exists(autostart_dir): os.makedirs(autostart_dir) shutil.copy(resources.share_path('applications/miro.desktop'), destination) os.remove(old_file) except OSError: pass # gconf settings client = gconf.client_get_default() def _copy_gconf(src, dst): for entry in client.all_entries(src): entry_dst = dst + '/' + entry.key.split('/')[-1] client.set(entry_dst, entry.value) for subdir in client.all_dirs(src): subdir_dst = dst + '/' + subdir.split('/')[-1] _copy_gconf(subdir, subdir_dst) if ((client.dir_exists("/apps/democracy/player") and not client.dir_exists("/apps/miro"))): _copy_gconf("/apps/democracy/player", "/apps/miro") client.recursive_unset("/apps/democracy", 1) # Set the MoviesDirectory and NonVideoDirectory based on the # possibilities that we've had over the years and what exists on # the user's system. This codifies it in the user's gconf so that # when we change it in future, then the user isn't affected. from miro.plat import options if options.gconf_name is None: options.gconf_name = "miro" key = "/apps/%s/MoviesDirectory" % options.gconf_name if client.get(key) is None: for mem in ["~/.miro/Movies", # packages "~/Videos/Miro", "~/Movies/Miro", # pre 3.5 "~/Movies/Democracy" # democracy player ]: mem = os.path.expanduser(mem) if os.path.exists(mem): client.set_string(key, mem) break key = "/apps/%s/NonVideoDirectory" % options.gconf_name if client.get(key) is None: for mem in ["~/.miro/Nonvideo" # packages ]: mem = os.path.expanduser(mem) if os.path.exists(mem): client.set_string(key, mem) break
def build_content(self): packing_vbox = layout.VBox(spacing=20) icon_pixbuf = gtk.gdk.pixbuf_new_from_file_at_size( resources.share_path('icons/hicolor/128x128/apps/miro.png'), 48, 48) packing_vbox._widget.pack_start(gtk.image_new_from_pixbuf(icon_pixbuf)) if app.config.get(prefs.APP_REVISION_NUM): version = "%s (%s)" % (app.config.get( prefs.APP_VERSION), app.config.get(prefs.APP_REVISION_NUM)) else: version = "%s" % app.config.get(prefs.APP_VERSION) name_label = gtk.Label( '<span size="xx-large" weight="bold">%s %s</span>' % (app.config.get(prefs.SHORT_APP_NAME), version)) name_label.set_use_markup(True) packing_vbox._widget.pack_start(name_label) copyright_text = _( '%(copyright)s. See license.txt file for details.\n' '%(trademark)s', { "copyright": app.config.get(prefs.COPYRIGHT), "trademark": app.config.get(prefs.TRADEMARK) }) copyright_label = gtk.Label('<small>%s</small>' % copyright_text) copyright_label.set_use_markup(True) copyright_label.set_justify(gtk.JUSTIFY_CENTER) packing_vbox._widget.pack_start(copyright_label) # FIXME - make the project url clickable packing_vbox._widget.pack_start( gtk.Label(app.config.get(prefs.PROJECT_URL))) contributor_label = gtk.Label( _( "Thank you to all the people who contributed to %(appname)s " "%(version)s:", { "appname": app.config.get(prefs.SHORT_APP_NAME), "version": app.config.get(prefs.APP_VERSION) })) contributor_label.set_justify(gtk.JUSTIFY_CENTER) packing_vbox._widget.pack_start(contributor_label) # get contributors, remove newlines and wrap it contributors = open(resources.path('CREDITS'), 'r').readlines() contributors = [ c[2:].strip() for c in contributors if c.startswith("* ") ] contributors = ", ".join(contributors) # show contributors contrib_buffer = gtk.TextBuffer() contrib_buffer.set_text(contributors) contrib_view = gtk.TextView(contrib_buffer) contrib_view.set_editable(False) contrib_view.set_cursor_visible(False) contrib_view.set_wrap_mode(gtk.WRAP_WORD) contrib_window = gtk.ScrolledWindow() contrib_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) contrib_window.add(contrib_view) contrib_window.set_size_request(-1, 100) packing_vbox._widget.pack_start(contrib_window) # FIXME - make the project url clickable donate_label = gtk.Label( _( "To help fund continued %(appname)s development, visit the " "donation page at:", {"appname": app.config.get(prefs.SHORT_APP_NAME)})) donate_label.set_justify(gtk.JUSTIFY_CENTER) packing_vbox._widget.pack_start(donate_label) packing_vbox._widget.pack_start( gtk.Label(app.config.get(prefs.DONATE_URL))) return packing_vbox