def __init__(self, keywords):
        loc = get_locale_code("deepin-system-settings", get_parent_dir(__file__, 2) + "/locale")
        print loc
        if loc == "zh_HK":      # No translation and search for HongKong
            loc = "zh_TW"
        self.search_db_dir = os.path.join(get_parent_dir(__file__, 2), "search_db/%s" % loc)
        self.__xappy = None

        self.__keywords = keywords
示例#2
0
    def __init__(self, keywords):
        loc = get_locale_code("deepin-system-settings",
                              get_parent_dir(__file__, 2) + "/locale")
        print loc
        if loc == "zh_HK":  # No translation and search for HongKong
            loc = "zh_TW"
        self.search_db_dir = os.path.join(get_parent_dir(__file__, 2),
                                          "search_db/%s" % loc)
        self.__xappy = None

        self.__keywords = keywords
示例#3
0
    def __init__(self, cache):
        self.cache = cache
        self.db_path = os.path.join(get_parent_dir(__file__, 3),
                                    "data/cache_soft.db")

        remove_file(self.db_path)
        touch_file_dir(self.db_path)

        self.connect = sqlite3.connect(self.db_path)
        self.cursor = self.connect.cursor()

        self.cursor.execute("CREATE TABLE IF NOT EXISTS software (\
            pkg_name PRIMARY KEY NOT NULL, short_desc, long_desc, version, \
            homepage, size)")

        for pkg in self.cache:
            try:
                self.cursor.execute("INSERT INTO software VALUES(?,?,?,?,?,?)",
                                    (pkg.name, unicode(pkg.candidate.summary),
                                     unicode(pkg.candidate.description),
                                     unicode(pkg.candidate.version),
                                     unicode(pkg.candidate.homepage),
                                     unicode(pkg.candidate.size)))
            except Exception, e:
                print "Error in db_build: %s %s" % (e, pkg.name)
示例#4
0
    def __init__(self, cache):
        self.cache = cache
        self.db_path = os.path.join(get_parent_dir(__file__, 3),
                "data/cache_soft.db")

        remove_file(self.db_path)
        touch_file_dir(self.db_path)

        self.connect = sqlite3.connect(self.db_path)
        self.cursor = self.connect.cursor()

        self.cursor.execute(
            "CREATE TABLE IF NOT EXISTS software (\
            pkg_name PRIMARY KEY NOT NULL, short_desc, long_desc, version, \
            homepage, size)")

        for pkg in self.cache:
            try:
                self.cursor.execute(
                    "INSERT INTO software VALUES(?,?,?,?,?,?)",
                    (pkg.name,
                    unicode(pkg.candidate.summary),
                    unicode(pkg.candidate.description),
                    unicode(pkg.candidate.version),
                    unicode(pkg.candidate.homepage),
                    unicode(pkg.candidate.size)
                    ))
            except Exception, e:
                print "Error in db_build: %s %s" % (e, pkg.name)
示例#5
0
def get_config_file(path):
    ''' get config file. '''
    configfile = os.path.join(xdg_config_home, PROGRAM_NAME, path)
    configdir = get_parent_dir(configfile)
    if not os.path.isdir(configdir):
        os.makedirs(configdir)
    return configfile    
示例#6
0
def get_cache_file(path):
    ''' get cache file. '''
    cachefile = os.path.join(xdg_cache_home, PROGRAM_NAME, path)
    cachedir = get_parent_dir(cachefile)
    if not os.path.isdir(cachedir):
        os.makedirs(cachedir)
    return cachefile    
示例#7
0
    def share_action(self, widget, data=None):
        if not self.share_show:
            #rect = self.content_page.get_allocation()
            rect = self.window.get_allocation()
            width = rect.width
            height = rect.height
            pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width,
                                    height)
            pixbuf = pixbuf.get_from_drawable(self.window.window,
                                              self.window.get_colormap(),
                                              rect.x, rect.y, 0, 0, width,
                                              height)

            filename = self.save_to_tmp_file(pixbuf)
            share_path = os.path.join(get_parent_dir(__file__), 'share.py')

            order = ['python2', share_path, filename]
            try:
                self.share_p = subprocess.Popen(order,
                                                stderr=subprocess.STDOUT,
                                                shell=False)
            except OSError:
                order[0] = 'python'
                self.share_p = subprocess.Popen(order,
                                                stderr=subprocess.STDOUT,
                                                shell=False)
            self.share_show = True
            self.external_pause_action()
            self.hand_pause = True
            gtk.timeout_add(200, self.check_share_dialog_close)
示例#8
0
def init_user_guide(callback=None, show_start_button=False):
    # Get language in current environment.
    (lang, _) = locale.getdefaultlocale()
    if lang == "zh_CN":
        slide_lang = lang
    elif lang in ["zh_HK", "zh_TW"]:
        slide_lang = "zh_HK"
    else:
        slide_lang = "en"

    # Get image directory.
    image_dir = os.path.join(get_parent_dir(__file__, 1), "user_guide")
    lang_dir = os.path.join(image_dir, slide_lang)

    # Init user guide.
    user_guide = Wizard(
        [os.path.join(lang_dir, "%d.png" % i) for i in range(3)], (
            os.path.join(image_dir, "dot_normal.png"),
            os.path.join(image_dir, "dot_active.png"),
        ), (
            os.path.join(lang_dir, "start_normal.png"),
            os.path.join(lang_dir, "start_press.png"),
        ), show_start_button, callback)

    # Show user guide.
    user_guide.show_all()
示例#9
0
    def create_mirror_select_table(self):
        main_table = gtk.Table(3, 2)
        main_table.set_row_spacings(CONTENT_ROW_SPACING)

        mirror_select_title = Label(_("Select mirror"))
        self.select_best_mirror_button = Button(self.select_best_mirror_button_texts["normal"])
        self.select_best_mirror_button.connect("clicked", self.select_best_mirror)

        self.mirrors_dir = os.path.join(get_parent_dir(__file__, 2), 'mirrors')
        self.current_mirror_hostname = utils.get_current_mirror_hostname()
        self.mirror_items = self.get_mirror_items()
        self.mirror_view = TreeView(self.mirror_items,
                                enable_drag_drop=False,
                                enable_multiple_select=False,
                                mask_bound_height=0,
                             )
        self.mirror_view.set_expand_column(1)
        self.mirror_view.set_size_request(-1, 280)
        self.mirror_view.draw_mask = self.mirror_treeview_draw_mask

        main_table.attach(mirror_select_title, 0, 1, 0, 1, yoptions=gtk.FILL)
        main_table.attach(self.select_best_mirror_button, 1, 2, 0, 1, xoptions=gtk.FILL)
        main_table.attach(create_separator_box(), 0, 2, 1, 2, xoptions=gtk.FILL)
        main_table.attach(self.mirror_view, 0, 2, 2, 3, xoptions=gtk.FILL)


        return main_table
示例#10
0
 def showMutiPlaylistDialog(self, _id, _type):
     self._id = _id
     self._type = _type
     self.setSource(QUrl.fromLocalFile(
         os.path.join(get_parent_dir(__file__, 2), 'views','dialogs' ,'MutiPlaylistChoseDialog.qml')))
     self.moveCenter()
     self.show()
示例#11
0
    def create_mirror_select_table(self):
        main_table = gtk.Table(3, 2)
        main_table.set_row_spacings(CONTENT_ROW_SPACING)

        mirror_select_title = Label(_("Select mirror"))
        self.select_best_mirror_button = Button(self.select_best_mirror_button_texts["normal"])
        self.select_best_mirror_button.connect("clicked", self.select_best_mirror)

        self.mirrors_dir = os.path.join(get_parent_dir(__file__, 2), 'mirrors')
        self.current_mirror_hostname = utils.get_current_mirror_hostname()
        self.mirror_items = self.get_mirror_items()
        self.mirror_view = TreeView(self.mirror_items,
                                enable_drag_drop=False,
                                enable_multiple_select=False,
                                mask_bound_height=0,
                             )
        self.mirror_view.set_expand_column(1)
        self.mirror_view.set_size_request(-1, 280)
        self.mirror_view.draw_mask = self.mirror_treeview_draw_mask

        main_table.attach(mirror_select_title, 0, 1, 0, 1, yoptions=gtk.FILL)
        main_table.attach(self.select_best_mirror_button, 1, 2, 0, 1, xoptions=gtk.FILL)
        main_table.attach(create_separator_box(), 0, 2, 1, 2, xoptions=gtk.FILL)
        main_table.attach(self.mirror_view, 0, 2, 2, 3, xoptions=gtk.FILL)


        return main_table
示例#12
0
 def get_trayicon(self):
     if is_true(setting_config.get_trayicon_config("pause")):
         icon_name = "pause_trayicon.png"
     else:
         icon_name = "trayicon.png"
         
     return QIcon(os.path.join(get_parent_dir(__file__), "image", icon_name))
示例#13
0
    def initQMLContext(self):
        self.mainWindow.setContexts(contexts)
        self.mainWindow.setSource(QUrl.fromLocalFile(os.path.join(
            get_parent_dir(__file__, 2), 'views', 'Main.qml')))

        self.qmlDialog = QmlDialog(self.mainWindow.engine())
        self.mainWindow.setContext('QmlDialog', self.qmlDialog)
示例#14
0
def get_cache_file(path):
    ''' get cache file. '''
    cachefile = os.path.join(xdg_cache_home, PROGRAM_NAME, path)
    cachedir = get_parent_dir(cachefile)
    if not os.path.isdir(cachedir):
        os.makedirs(cachedir)
    return cachefile
示例#15
0
def get_config_file(path):
    ''' get config file. '''
    configfile = os.path.join(xdg_config_home, PROGRAM_NAME, path)
    configdir = get_parent_dir(configfile)
    if not os.path.isdir(configdir):
        os.makedirs(configdir)
    return configfile
示例#16
0
    def __init__(self):
        Window.__init__(self)

        from tts_interface import (word_voice_model, words_voice_model,
                                   tts_interface)
        from dict_interface import (source_lang_model, dest_lang_model,
                                    word_translate_model,
                                    words_translate_model, dict_interface)

        self.qml_context.setContextProperty("dictInterface", dict_interface)
        self.qml_context.setContextProperty("ttsIntreface", tts_interface)
        self.qml_context.setContextProperty("sourceLangModel",
                                            source_lang_model)
        self.qml_context.setContextProperty("destLangModel", dest_lang_model)
        self.qml_context.setContextProperty("wordTranslateModel",
                                            word_translate_model)
        self.qml_context.setContextProperty("wordsTranslateModel",
                                            words_translate_model)
        self.qml_context.setContextProperty("wordVoiceModel", word_voice_model)
        self.qml_context.setContextProperty("wordsVoiceModel",
                                            words_voice_model)
        self.qml_context.setContextProperty("screenWidth", screen_width)
        self.qml_context.setContextProperty("screenHeight", screen_height)
        self.qml_context.setContextProperty("windowView", self)
        self.qml_context.setContextProperty("settingConfig", setting_config)
        self.setSource(
            QtCore.QUrl.fromLocalFile(
                os.path.join(get_parent_dir(__file__), 'SettingView.qml')))
示例#17
0
def init_user_guide(callback=None, show_start_button=False):
    # Get language in current environment.
    (lang, _) = locale.getdefaultlocale()
    if lang == "zh_CN":
        slide_lang = lang
    elif lang in ["zh_HK", "zh_TW"]:
        slide_lang = "zh_HK"
    else:
        slide_lang = "en"
        
    # Get image directory.
    image_dir = os.path.join(get_parent_dir(__file__, 1), "user_guide")
    lang_dir  = os.path.join(image_dir, slide_lang)

    # Init user guide.
    user_guide = Wizard(
        [os.path.join(lang_dir, "%d.png" % i) for i in range(3)],
        (os.path.join(image_dir, "dot_normal.png"),
         os.path.join(image_dir, "dot_active.png"),             
         ),
        (os.path.join(lang_dir, "start_normal.png"),
            os.path.join(lang_dir, "start_press.png"),),
        show_start_button,
        callback
        )
    
    # Show user guide.
    user_guide.show_all()
示例#18
0
    def __init__(self):
        QObject.__init__(self)

        self.plugin_config_name = "config.ini"
        self.plugin_module_name = "translate.py"
        self.plugin_dir = os.path.join(get_parent_dir(__file__), "plugins")

        self.scan_plugin_info()
示例#19
0
    def get_trayicon(self):
        if is_true(setting_config.get_trayicon_config("pause")):
            icon_name = "pause_trayicon.png"
        else:
            icon_name = "trayicon.png"

        return QIcon(os.path.join(get_parent_dir(__file__), "image",
                                  icon_name))
示例#20
0
 def __init__(self):
     QObject.__init__(self)
     
     self.plugin_config_name = "config.ini"
     self.plugin_module_name = "translate.py"
     self.plugin_dir = os.path.join(get_parent_dir(__file__), "plugins")
     
     self.scan_plugin_info()
示例#21
0
 def del_source_list_d(self):
     white_list_path = os.path.join(get_parent_dir(__file__), 'white_list.txt')
     if os.path.exists(white_list_path):
         with open(white_list_path) as fp:
             for line in fp:
                 line = line.strip()
                 if os.path.exists(line):
                     os.remove(line)
 def change_auto_update(self, widget, data=None):
     self.update_spin.set_sensitive(widget.get_active())
     set_auto_update(widget.get_active())
     self.update_label.set_sensitive(widget.get_active())
     self.hour_lablel.set_sensitive(widget.get_active())
     dsc_daemon_path = os.path.join(get_parent_dir(__file__, 2), 'update_data/apt/dsc-daemon.py')
     if widget.get_active():
         subprocess.Popen(['python', dsc_daemon_path], stderr=subprocess.STDOUT, shell=False)
示例#23
0
 def call_flash_game(self, local_path):
     flash_frame_path = os.path.join(get_parent_dir(__file__), 'flash_frame.py')
     order = ['python2', flash_frame_path, self.appid]
     try:
         self.p = subprocess.Popen(order, stderr=subprocess.STDOUT, shell=False)
     except OSError:    
         order[0] = 'python'
         self.p = subprocess.Popen(order, stderr=subprocess.STDOUT, shell=False)
    def expose_canopy(self, widget, event):
        # Init.
        cr = widget.window.cairo_create()
        rect = widget.allocation
        canopy_color = app_theme.get_color("sidebar_select").get_color()
        
        canopy_img_blue_path = os.path.join(get_parent_dir(__file__, 2), "image", "canopy", "canopy-blue.png")
        canopy_img_yellow_path = os.path.join(get_parent_dir(__file__, 2), "image", "canopy", "canopy-yellow.png")

        draw_pixbuf(
            cr,
            gtk.gdk.pixbuf_new_from_file(canopy_img_yellow_path),
            rect.x,
            rect.y)
        
        surface = cairo.ImageSurface.create_from_png(canopy_img_blue_path)
        cr.set_source_rgb(*color_hex_to_cairo(canopy_color))
        cr.mask_surface(surface, rect.x, rect.y)
示例#25
0
 def del_source_list_d(self):
     white_list_path = os.path.join(get_parent_dir(__file__),
                                    'white_list.txt')
     if os.path.exists(white_list_path):
         with open(white_list_path) as fp:
             for line in fp:
                 line = line.strip()
                 if os.path.exists(line):
                     os.remove(line)
示例#26
0
    def initQMLContext(self):
        self.mainWindow.setContexts(contexts)
        self.mainWindow.setSource(
            QUrl.fromLocalFile(
                os.path.join(get_parent_dir(__file__, 2), 'views',
                             'Main.qml')))

        self.qmlDialog = QmlDialog(self.mainWindow.engine())
        self.mainWindow.setContext('QmlDialog', self.qmlDialog)
示例#27
0
def init_theme():
    '''
    Use deepin-ui's default theme.
    '''
    init_skin(
        "deepin-ui",
        "1.0",
        "default",
        os.path.join(get_parent_dir(__file__, 2), "skin"),
        )
def check_is_in_virtual_pc():
    '''just check vmware and virtualbox'''
    cmd = ['lspci', '-b']
    p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    p.wait()
    s = p.communicate()[0]
    s = s.lower()
    path = os.path.join(get_parent_dir(__file__, 3), 'deepin-system-settings/modules/power/src/tray_shutdown_plugin.py')
    if len(s.split("vmware")) > 1 or len(s.split("virtualbox")) > 1:
        subprocess.Popen(['python', path, 'vpc'])
示例#29
0
def init_theme():
    '''
    Use deepin-ui's default theme.
    '''
    init_skin(
        "deepin-ui",
        "1.0",
        "default",
        os.path.join(get_parent_dir(__file__, 2), "skin"),
    )
示例#30
0
    def expose_canopy(self, widget, event):
        # Init.
        cr = widget.window.cairo_create()
        rect = widget.allocation
        canopy_color = app_theme.get_color("sidebar_select").get_color()

        canopy_img_blue_path = os.path.join(get_parent_dir(__file__,
                                                           2), "image",
                                            "canopy", "canopy-blue.png")
        canopy_img_yellow_path = os.path.join(get_parent_dir(__file__,
                                                             2), "image",
                                              "canopy", "canopy-yellow.png")

        draw_pixbuf(cr, gtk.gdk.pixbuf_new_from_file(canopy_img_yellow_path),
                    rect.x, rect.y)

        surface = cairo.ImageSurface.create_from_png(canopy_img_blue_path)
        cr.set_source_rgb(*color_hex_to_cairo(canopy_color))
        cr.mask_surface(surface, rect.x, rect.y)
示例#31
0
 def show_play(self, data):
     data = data.split(',')
     player_path = os.path.join(get_parent_dir(__file__), 'deepin-game-center.py')
     order = ['python2', player_path]
     order.append('-p')
     order.append(','.join(data))
     try:
         self.p = subprocess.Popen(order, stderr=subprocess.STDOUT, shell=False)
     except OSError:    
         order[0] = 'python'
         self.p = subprocess.Popen(order, stderr=subprocess.STDOUT, shell=False)
 def __init__(self):
     super(WallpaperView, self).__init__(padding_x=30, padding_y=10)
     self.backgrounds_dir = os.path.join(get_parent_dir(__file__, 2), "backgrounds")
     self.default_background_files = map(lambda filename: os.path.join(self.backgrounds_dir, filename), os.listdir(self.backgrounds_dir))
     self.first_part_background_files = self.default_background_files[0:20]
     self.second_part_backgroun_files = self.default_background_files[20::]
     self.local_background_load_finish = False
     self.add_items(map(lambda background_file: WallpaperItem(background_file), self.first_part_background_files))
     
     self.download_dir = get_download_wallpaper_dir()
     self.__fetch_thread_id = 0
     self.network_interface = Bizhi360()
示例#33
0
 def __init__(self, url):
     super(Browser, self).__init__()
     
     self.view = QWebView(self)
     self.view.load(QUrl(url))
     self.view.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
     self.view.page().linkClicked.connect(self.link_clicked)
     self.view.page().mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)
         
     self.view.settings().setUserStyleSheetUrl(QUrl.fromLocalFile(os.path.join(get_parent_dir(__file__), "scrollbar.css")))
     
     self.layout.addWidget(self.view)
示例#34
0
 def call_flash_game(self, local_path):
     flash_frame_path = os.path.join(get_parent_dir(__file__),
                                     'flash_frame.py')
     order = ['python2', flash_frame_path, self.appid]
     try:
         self.p = subprocess.Popen(order,
                                   stderr=subprocess.STDOUT,
                                   shell=False)
     except OSError:
         order[0] = 'python'
         self.p = subprocess.Popen(order,
                                   stderr=subprocess.STDOUT,
                                   shell=False)
示例#35
0
    def __init__(self, engine=None, parent=None):
        super(DQuickView, self).__init__(engine, parent)
        self.setResizeMode(QtQuick.QQuickView.SizeViewToRootObject)
        self.engine().addImportPath(os.sep.join([get_parent_dir(__file__, 2),
                                                 'qml']))
        if isWebengineUsed:
            # self.initWebengine()
            pass

        format = QSurfaceFormat()
        format.setAlphaBufferSize(8)
        format.setRenderableType(QSurfaceFormat.OpenGL)

        self.setFormat(format)
        self.setColor(QColor(Qt.transparent))
        self.setClearBeforeRendering(True)
示例#36
0
    def render_name(self, cr, rect):
        text_color = "#333333"
        font_image_color = app_theme.get_color("sidebar_select").get_color()
        if self.is_select:
            cr.set_source_rgba(*color_hex_to_cairo(
                app_theme.get_color("sidebar_select").get_color()))
            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.fill()

            text_color = "#FFFFFF"
            font_image_color = "#FFFFFF"
        elif self.is_hover:
            cr.set_source_rgba(*color_hex_to_cairo(
                app_theme.get_color("sidebar_hover").get_color()))
            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.fill()

        pixbuf = app_theme.get_pixbuf("category/%s.png" %
                                      (self.index)).get_pixbuf()

        category_img_path = os.path.join(get_parent_dir(__file__, 2), "image",
                                         "category",
                                         "%s.png" % (self.index + 1, ))
        surface = cairo.ImageSurface.create_from_png(category_img_path)
        cr.set_source_rgb(*color_hex_to_cairo(font_image_color))
        cr.mask_surface(surface, rect.x + 14, rect.y + (rect.height - 24) / 2)

        draw_text(
            cr,
            get_category_name(self.first_category_name),
            rect.x + pixbuf.get_width() + 22,
            rect.y,
            rect.width,
            rect.height,
            text_size=CATEGORY_ITEM_NAME_SIZE,
            text_color=text_color,
        )

        if self.is_hover:
            if self.is_expand:
                pixbuf = app_theme.get_pixbuf("sidebar/close.png").get_pixbuf()
            else:
                pixbuf = app_theme.get_pixbuf("sidebar/open.png").get_pixbuf()

            draw_pixbuf(cr, pixbuf,
                        rect.x + rect.width - CATEGORY_ITEM_EXPAND_PADDING_X,
                        rect.y + (rect.height - pixbuf.get_height()) / 2)
示例#37
0
    def change_auto_update(self, widget, data=None):
        widget_active = widget.get_active()
        self.update_spin.set_sensitive(widget_active)
        self.update_label.set_sensitive(widget_active)
        self.hour_lablel.set_sensitive(widget_active)

        utils.set_auto_update(widget_active)

        daemon_running = is_dbus_name_exists(DSC_UPDATE_DAEMON_NAME)
        if widget_active and not daemon_running:
            dsc_daemon_path = os.path.join(get_parent_dir(__file__, 2), 'update_data/apt/dsc-daemon.py')
            subprocess.Popen(['python', dsc_daemon_path], stderr=subprocess.STDOUT, shell=False)
        elif not widget_active and daemon_running:
            session = dbus.SessionBus()
            dbus_obj = session.get_object(DSC_UPDATE_DAEMON_NAME, DSC_UPDATE_DAEMON_PATH)
            iface = dbus.Interface(dbus_obj, DSC_UPDATE_DAEMON_NAME)
            iface.quit()
示例#38
0
 def __init__(self, url):
     super(Browser, self).__init__()
     
     self.view = QWebView(self)
     self.layout.addWidget(self.view)        
     self.view.settings().setAttribute(QWebSettings.PluginsEnabled, True) # enable plugins
     self.view.settings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True) # enable dev tools
     self.view.settings().setUserStyleSheetUrl(QUrl.fromLocalFile(os.path.join(get_parent_dir(__file__), "scrollbar.css")))
     
     self.view.load(QUrl(url))
     self.view.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
     self.view.page().mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)
     # self.view.page().mainFrame().evaluateJavaScript(self.plugin_public_js)
     self.view.page().mainFrame().evaluateJavaScript(self.plugin_qvod_search_js)
     
     self.view.loadFinished.connect(self.url_load_finished)
     self.view.page().linkClicked.connect(self.link_clicked)        
示例#39
0
    def __init__(self):
        super(WallpaperView, self).__init__(padding_x=30, padding_y=10)
        self.backgrounds_dir = os.path.join(get_parent_dir(__file__, 2),
                                            "backgrounds")
        self.default_background_files = map(
            lambda filename: os.path.join(self.backgrounds_dir, filename),
            os.listdir(self.backgrounds_dir))
        self.first_part_background_files = self.default_background_files[0:20]
        self.second_part_backgroun_files = self.default_background_files[20::]
        self.local_background_load_finish = False
        self.add_items(
            map(lambda background_file: WallpaperItem(background_file),
                self.first_part_background_files))

        self.download_dir = get_download_wallpaper_dir()
        self.__fetch_thread_id = 0
        self.network_interface = Bizhi360()
示例#40
0
    def change_auto_update(self, widget, data=None):
        widget_active = widget.get_active()
        self.update_spin.set_sensitive(widget_active)
        self.update_label.set_sensitive(widget_active)
        self.hour_lablel.set_sensitive(widget_active)

        utils.set_auto_update(widget_active)

        daemon_running = is_dbus_name_exists(DSC_UPDATE_DAEMON_NAME)
        if widget_active and not daemon_running:
            dsc_daemon_path = os.path.join(get_parent_dir(__file__, 2), 'update_data/apt/dsc-daemon.py')
            subprocess.Popen(['python', dsc_daemon_path], stderr=subprocess.STDOUT, shell=False)
        elif not widget_active and daemon_running:
            session = dbus.SessionBus()
            dbus_obj = session.get_object(DSC_UPDATE_DAEMON_NAME, DSC_UPDATE_DAEMON_PATH)
            iface = dbus.Interface(dbus_obj, DSC_UPDATE_DAEMON_NAME)
            iface.quit()
示例#41
0
 def __init__(self, session_bus):
     dbus.service.Object.__init__(self, session_bus, DSC_UPDATE_MONITOR_PATH)
     icon_path = os.path.join(get_parent_dir(__file__, 3), 'image/logo48.png')
     self.status_icon = gtk.status_icon_new_from_file(icon_path)
     self.status_icon.connect("activate", self.show)
     self.status_icon.connect("popup-menu", self.show)
     self.win  = TrayIconWin()
     self.width = 150
     self.height = 70
     self.win.resize(self.width, self.height)
     self.win.move(1366-self.width-160, 768-self.height-30)
     self.label = WrapLabel()
     info = ("软件中心\n正在下载: 80.5%")
     self.label.set_label(info)
     label_align = self.create_align((0.5, 0.5, 1, 1), (3, 3, 5, 0))
     label_align.add(self.label)
     self.win.add_plugin(label_align)
     gtk.timeout_add(5000, self.show)
示例#42
0
 def save_snapshot(self, filename=None, filetype='png', clip_flag=False):
     '''
     Save snapshot.
     @param filename: the filename to save, a string type
     @param filetype: the filetype to save, a string type. Default is 'png'
     @param clip_flag: a flag if copy the snapshot to clipboard. Default is False
     '''
     failed_flag = False
     tipContent = ""
     parent_dir = get_parent_dir(__file__, 1)
     # Save snapshot.
     if self.rect_width == 0 or self.rect_height == 0:
         tipContent = _("The width or height of selected area cannot be 0")
         failed_flag = True
     else:
         self.window.finish_flag = True
         surface = self.make_pic_file(
             self.desktop_background.subpixbuf(*self.get_rectangel_in_monitor()))
         # Save to file
         if filename:
             tipContent = "%s '%s'" % (_("Picture has been saved to file"), filename)
             try:
                 surface.write_to_png(filename)
                 SCROT_BUS.emit_finish(1, filename)
                 # copy to clipboard
                 if clip_flag:
                     pixbuf = gtk.gdk.pixbuf_new_from_file(filename)
                     clipboard = gtk.Clipboard(selection="CLIPBOARD")
                     clipboard.set_image(pixbuf)
                     clipboard.store()
                     #tipContent +=  _("Picture has been saved to clipboard")
                     #try:
                         #cmd = ('python2', '%s/%s' % (parent_dir, 'tipswindow.py'), _("Picture has been saved to clipboard"), '1')
                         #subprocess.Popen(cmd)
                     #except OSError:    
                         #cmd = ('python', '%s/%s' % (parent_dir, 'tipswindow.py'), _("Picture has been saved to clipboard"), '1')
                         #subprocess.Popen(cmd)
                     #notify("Deepin Screenshot", 0, summary=_("DSnapshot"), body=tipContent)
                     
             except Exception, e:
                 tipContent = "%s:%s" % (_("Failed to save the picture"), str(e))
         # Save snapshot to clipboard
         else:
    def render_name(self, cr, rect):
        text_color = "#333333"
        font_image_color = app_theme.get_color("sidebar_select").get_color()
        if self.is_select:
            cr.set_source_rgba(*color_hex_to_cairo(app_theme.get_color("sidebar_select").get_color()))
            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.fill()
            
            text_color = "#FFFFFF"
            font_image_color = "#FFFFFF"
        elif self.is_hover:
            cr.set_source_rgba(*color_hex_to_cairo(app_theme.get_color("sidebar_hover").get_color()))
            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.fill()
        
        pixbuf = app_theme.get_pixbuf("category/%s.png" % (self.index)).get_pixbuf()

        category_img_path = os.path.join(get_parent_dir(__file__, 2), "image", "category", "%s.png" % (self.index+1, ))
        surface = cairo.ImageSurface.create_from_png(category_img_path)
        cr.set_source_rgb(*color_hex_to_cairo(font_image_color))
        cr.mask_surface(surface, rect.x+14, rect.y+(rect.height-24)/2)

        draw_text(cr, 
                  get_category_name(self.first_category_name),
                  rect.x + pixbuf.get_width() + 22, 
                  rect.y,
                  rect.width,
                  rect.height,
                  text_size=CATEGORY_ITEM_NAME_SIZE,
                  text_color=text_color,
                  )
        
        if self.is_hover:
            if self.is_expand:
                pixbuf = app_theme.get_pixbuf("sidebar/close.png").get_pixbuf()
            else:
                pixbuf = app_theme.get_pixbuf("sidebar/open.png").get_pixbuf()
                
            draw_pixbuf(
                cr,
                pixbuf,
                rect.x + rect.width - CATEGORY_ITEM_EXPAND_PADDING_X,
                rect.y + (rect.height - pixbuf.get_height()) / 2)
示例#44
0
    def show_wizard_win(self, show_button=False, callback=None):
        program_dir = get_parent_dir(__file__, 2)
        wizard_dir = os.path.join(program_dir, 'wizard', LANGUAGE)
        if not os.path.exists(wizard_dir):
            wizard_dir = os.path.join(program_dir, 'wizard', 'en_US')
        wizard_root_dir = os.path.dirname(wizard_dir)

        self.wizard = Wizard(
            [os.path.join(wizard_dir, "%d.png" % i) for i in range(3)],
            (os.path.join(wizard_root_dir, "dot_normal.png"),
             os.path.join(wizard_root_dir, "dot_active.png"),
             ),
            (os.path.join(wizard_dir, "start_normal.png"),
             os.path.join(wizard_dir, "start_press.png"),
             ),
            show_button,
            callback
            )
        self.wizard.set_icon(utils.get_common_image_pixbuf("logo48.png"))
        if not self.init_hide:
            self.wizard.show_all()
    def __init__(self):
        Window.__init__(self)
    
        from tts_interface import (word_voice_model, words_voice_model, tts_interface)
        from dict_interface import (source_lang_model, dest_lang_model, 
                                    word_translate_model, words_translate_model,
                                    dict_interface)

        self.qml_context.setContextProperty("dictInterface", dict_interface)
        self.qml_context.setContextProperty("ttsIntreface", tts_interface)
        self.qml_context.setContextProperty("sourceLangModel", source_lang_model)
        self.qml_context.setContextProperty("destLangModel", dest_lang_model)
        self.qml_context.setContextProperty("wordTranslateModel", word_translate_model)
        self.qml_context.setContextProperty("wordsTranslateModel", words_translate_model)
        self.qml_context.setContextProperty("wordVoiceModel", word_voice_model)
        self.qml_context.setContextProperty("wordsVoiceModel", words_voice_model)
        self.qml_context.setContextProperty("screenWidth", screen_width)
        self.qml_context.setContextProperty("screenHeight", screen_height)
        self.qml_context.setContextProperty("windowView", self)
        self.qml_context.setContextProperty("settingConfig", setting_config)
        self.setSource(QtCore.QUrl.fromLocalFile(os.path.join(get_parent_dir(__file__), 'SettingView.qml')))
    def create_mirror_select_table(self):
        vbox = gtk.VBox()
        vbox.set_size_request(423, -1)
        main_table = gtk.Table(2, 2)
        main_table.set_row_spacings(CONTENT_ROW_SPACING)
        
        dir_title_label = Label(_("Select mirror"))
        dir_title_label.set_size_request(423, 12)
        label_align = gtk.Alignment()
        label_align.set_padding(0, 0, 10, 0)
        label_align.add(dir_title_label)

        self.mirrors_dir = os.path.join(get_parent_dir(__file__, 2), 'mirrors')
        self.current_mirror_hostname = utils.get_current_mirror_hostname()
        self.mirror_items = self.get_mirror_items()
        self.mirror_view = TreeView(self.mirror_items,
                                enable_drag_drop=False,
                                enable_multiple_select=False,
                                #mask_bound_height=0,
                             )
        self.mirror_view.set_expand_column(1)
        self.mirror_view.set_size_request(-1, len(self.mirror_view.visible_items) * self.mirror_view.visible_items[0].get_height())
        self.mirror_view.draw_mask = self.mirror_treeview_draw_mask
        #self.display_current_mirror()

        self.mirror_test_progressbar = ProgressBar()

        main_table.attach(label_align, 0, 2, 0, 1, yoptions=gtk.FILL, xpadding=8)
        main_table.attach(create_separator_box(), 0, 2, 1, 2, yoptions=gtk.FILL)
        
        title = _("Select best mirror")
        info_message = _("Please wait. The process will take 30 seconds or more depending on your network connection")
        self.select_best_mirror_dialog = WaitingDialog(title, info_message, self.cancel_mirror_test)
        global_event.register_event("mirror-changed", self.mirror_changed_handler)
        global_event.register_event("update-list-finish", self.update_list_finish_handler)

        vbox.pack_start(main_table, False, False)
        vbox.pack_start(self.mirror_view, False, False)

        return vbox
示例#47
0
    def render_name(self, cr, rect):
        text_color = "#333333"
        font_image_color = app_theme.get_color("sidebar_select").get_color()
        if self.is_select:
            cr.set_source_rgba(*color_hex_to_cairo(
                app_theme.get_color("sidebar_select").get_color()))
            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.fill()

            text_color = "#FFFFFF"
            font_image_color = "#FFFFFF"
        elif self.is_hover:
            cr.set_source_rgba(*color_hex_to_cairo(
                app_theme.get_color("sidebar_hover").get_color()))
            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.fill()

        pixbuf = app_theme.get_pixbuf("category/12.png").get_pixbuf()
        #draw_pixbuf(
        #cr,
        #pixbuf,
        #rect.x + 12,
        #rect.y + (rect.height - pixbuf.get_height()) / 2)

        category_img_path = os.path.join(get_parent_dir(__file__, 2), "image",
                                         "category", "1.png")
        surface = cairo.ImageSurface.create_from_png(category_img_path)
        cr.set_source_rgb(*color_hex_to_cairo(font_image_color))
        cr.mask_surface(surface, rect.x + 14, rect.y + (rect.height - 24) / 2)

        draw_text(
            cr,
            self.name,
            rect.x + pixbuf.get_width() + 22,
            rect.y,
            rect.width,
            rect.height,
            text_size=CATEGORY_ITEM_NAME_SIZE,
            text_color=text_color,
        )
示例#48
0
 def __init__(self, qml_file):
     QQuickView.__init__(self)
     
     surface_format = QSurfaceFormat()
     surface_format.setAlphaBufferSize(8)
     
     self.setColor(QColor(0, 0, 0, 0))
     self.setResizeMode(QtQuick.QQuickView.SizeRootObjectToView)
     self.setFormat(surface_format)
     
     self.setFlags(QtCore.Qt.Popup)
     
     self.qml_context = self.rootContext()
     
     self.init_translate_info()
     
     self.qml_context.setContextProperty("translateInfo", self.translate_info)
     self.qml_context.setContextProperty("windowView", self)
     self.qml_context.setContextProperty("settingConfig", setting_config)
     self.qml_context.setContextProperty("qApp", qApp)
     
     self.setSource(QtCore.QUrl.fromLocalFile(os.path.join(get_parent_dir(__file__), qml_file)))
示例#49
0
    def share_action(self, widget, data=None):
        if not self.share_show:
            #rect = self.content_page.get_allocation()
            rect = self.window.get_allocation()
            width = rect.width
            height = rect.height
            pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width, height)
            pixbuf = pixbuf.get_from_drawable(self.window.window, self.window.get_colormap(), 
                                                rect.x, rect.y, 0, 0, width, height)

            filename = self.save_to_tmp_file(pixbuf)
            share_path = os.path.join(get_parent_dir(__file__), 'share.py')
            
            order = ['python2', share_path, filename]
            try:
                self.share_p = subprocess.Popen(order, stderr=subprocess.STDOUT, shell=False)
            except OSError:    
                order[0] = 'python'
                self.share_p = subprocess.Popen(order, stderr=subprocess.STDOUT, shell=False)
            self.share_show = True
            self.external_pause_action()
            self.hand_pause = True
            gtk.timeout_add(200, self.check_share_dialog_close)
示例#50
0
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import dbus
from deepin_utils.file import get_parent_dir

image_path = "%s/theme/logo/deepin-screenshot.png" % get_parent_dir(
    __file__, 2)


def notify(app_name,
           replaces_id,
           app_icon=image_path,
           summary="",
           body="",
           actions=[],
           hints={"image-path": image_path},
           timeout=3500):
    try:
        session_bus = dbus.SessionBus()
        obj = session_bus.get_object('org.freedesktop.Notifications',
                                     '/org/freedesktop/Notifications')
        interface = dbus.Interface(obj, 'org.freedesktop.Notifications')
示例#51
0
#from sound_manager import SoundSetting
from constant import PROGRAM_NAME
from events import global_event
import utils

from dtk.ui.utils import (alpha_color_hex_to_cairo, container_remove_all,
                          propagate_expose)
from dtk.ui.skin_config import skin_config
from dtk.ui.draw import draw_pixbuf
from dtk.ui.constant import DEFAULT_FONT_SIZE
from deepin_utils.file import get_parent_dir, touch_file_dir
from deepin_utils.ipc import is_dbus_name_exists
from dtk.ui.button import ImageButton
from dtk.ui.theme import DynamicPixbuf

info_data = os.path.join(get_parent_dir(__file__, 2), "data", "info.db")
static_dir = os.path.join(get_parent_dir(__file__, 2), "static")


class Player(dbus.service.Object):
    def __init__(self, session_bus, argv, dbus_name, dbus_path):
        dbus.service.Object.__init__(self, session_bus, dbus_path)

        (self.appid, self.game_name, self.width, self.height, self.swf_url,
         self.resizable) = argv
        self.game_name = urllib.unquote(self.game_name)
        self.width = int(self.width)
        self.height = int(self.height)
        self.plug_status = False
        self.conf_db = get_config_file("conf.db")
        self.p = None
#! /usr/bin/env python
# -*- coding: utf-8 -*-

from dtk.ui.init_skin import init_skin
import os
from deepin_utils.file import get_parent_dir, get_current_dir
app_theme = init_skin(
    "deepin-ui",
    "1.0",
    "default",
    os.path.join(get_parent_dir(__file__, 2), "skin"),
    os.path.join(get_current_dir(__file__), "app_theme"),
)
from dtk.ui.application import Application
from dtk.ui.button import ImageButton
from dtk.ui.dialog import ConfirmDialog
import gtk

if __name__ == "__main__":
    application = Application()
    application.set_default_size(600, 450)
    application.add_titlebar(title="ImageButton example!")

    image_button = ImageButton(
        normal_dpixbuf=app_theme.get_pixbuf("action/play_normal.png"),
        hover_dpixbuf=app_theme.get_pixbuf("action/play_hover.png"),
        press_dpixbuf=app_theme.get_pixbuf("action/play_press.png"),
        insensitive_dpixbuf=None,
        scale_x=False,
        content=None,
    )
示例#53
0
 def __init__(self):
     TranslateInterface.__init__(
         self, os.path.join(get_parent_dir(__file__), "Translate.qml"))
示例#54
0
    def __init__(self):
        gobject.GObject.__init__(self)
        image_dir = os.path.join(get_parent_dir(__file__, 3), "image")
        application = Application("DMuisc", resizable=False)
        application.close_callback = self.prompt_quit
        application.set_icon(os.path.join(image_dir, "logo.ico"))
        application.set_skin_preview(os.path.join(image_dir, "frame.png"))
        application.add_titlebar(["theme", "menu", "min", "close"],
                                 os.path.join(image_dir, "logo1.png"),
                                 _("DMusic"))
        application.titlebar.menu_button.connect("button-press-event",
                                                 self.menu_button_press)
        application.titlebar.connect("button-press-event", self.right_click_cb)

        # Window mode change.
        self.revert_toggle_button = self.create_revert_button()
        self.revert_toggle_button.connect("toggled", self.change_view)

        application.titlebar.button_box.pack_start(self.revert_toggle_button)
        application.titlebar.button_box.reorder_child(
            self.revert_toggle_button, 1)
        self.window = application.window
        self.window.is_disable_window_maximized = self.is_disable_window_maximized
        utils.set_main_window(self)

        self.plugins = plugins.PluginsManager(self, False)
        self.browser_manager = BrowserMananger()
        self.tray_icon = TrayIcon(self)
        self.lyrics_display = LyricsModule()
        self.list_manager = ListManager()
        self.simple_header_bar = SimpleHeadbar()
        self.preference_dialog = PreferenceDialog()
        self.equalizer_win = EqualizerWindow()
        self.mmkeys = MMKeys()
        self.audiocd = AudioCDSource()
        self.playlist_ui = playlist_ui

        self.mini_window = MiniWindow()

        self.window.add_move_event(self.simple_header_bar)

        bottom_box = gtk.HBox()
        self.browser_align = gtk.Alignment()
        self.browser_align.set_padding(0, 0, 0, 0)
        self.browser_align.set(0.5, 0.5, 1, 1)

        list_manager_align = gtk.Alignment()
        list_manager_align.set_padding(0, 0, 0, 0)
        list_manager_align.set(1, 1, 1, 1)
        list_manager_align.add(self.list_manager)

        self.browser_align.add(self.browser_manager)
        bottom_box.pack_start(list_manager_align, False, False)
        bottom_box.pack_start(self.browser_align, True, True)
        self.browser_align.set_no_show_all(True)

        main_box = gtk.VBox()
        self.header_box = gtk.VBox()
        self.header_box.add(self.simple_header_bar)
        main_box.pack_start(self.header_box, False)
        main_box.pack_start(bottom_box, True)

        self.link_box = gtk.HBox()
        self.link_box.pack_start(create_right_align(), True, True)
        self.link_box.pack_start(
            LinkButton(_("Join us"), "http://www.linuxdeepin.com/joinus/job"),
            False, False)

        status_box = gtk.HBox(spacing=5)
        status_box.pack_start(jobs_manager)
        status_box.pack_start(self.link_box, padding=5)

        status_bar = gtk.EventBox()
        status_bar.set_visible_window(False)
        status_bar.set_size_request(-1, 22)
        status_bar.add(status_box)

        application.main_box.pack_start(main_box)
        application.main_box.pack_start(status_bar, False, True)

        # if config.get("globalkey", "enable", "false") == "true":
        # global_hotkeys.start_bind()

        if config.get("setting", "window_mode") == "simple":
            self.revert_toggle_button.set_active(False)
        else:
            self.revert_toggle_button.set_active(True)

        self.change_view(self.revert_toggle_button)

        if config.get("window", "x") == "-1":
            self.window.set_position(gtk.WIN_POS_CENTER)
        else:
            self.window.move(int(config.get("window", "x")),
                             int(config.get("window", "y")))

        # try:
        #     self.window.resize(int(config.get("window","width")),int(config.get("window","height")))
        # except:
        #     pass

        # window_state = config.get("window", "state")
        # if window_state == "maximized":
        #     self.window.maximize()
        # elif window_state == "normal":
        #     self.window.unmaximize()

        self.window.connect("delete-event", self.quit)
        self.window.connect("configure-event", self.on_configure_event)
        self.window.connect("destroy", self.quit)

        Dispatcher.connect("quit", self.force_quit)
        Dispatcher.connect("show-main-menu", self.show_instance_menu)
        Dispatcher.connect("show-setting",
                           lambda w: self.preference_dialog.show_all())
        Dispatcher.connect(
            "show-desktop-page",
            lambda w: self.preference_dialog.show_desktop_lyrics_page())
        Dispatcher.connect(
            "show-scroll-page",
            lambda w: self.preference_dialog.show_scroll_lyrics_page())
        Dispatcher.connect("show-job", self.hide_link_box)
        Dispatcher.connect("hide-job", self.show_link_box)

        gobject.idle_add(self.ready)
示例#55
0
from song import Song
import common
import utils
from source.audiocd import AudioCDSource

from helper import Dispatcher
from logger import Logger
import locale


def mainloop():
    gtk.main()


(lang, encode) = locale.getdefaultlocale()
wizard_dir = os.path.join(get_parent_dir(__file__, 3), "wizard/en")
wizard_root_dir = os.path.dirname(wizard_dir)
if lang == "zh_CN":
    wizard_dir = os.path.join(get_parent_dir(__file__, 3), "wizard/zh_CN")
elif lang in ["zh_HK", "zh_TW"]:
    wizard_dir = os.path.join(get_parent_dir(__file__, 3), "wizard/zh_HK")


class DeepinMusic(gobject.GObject, Logger):
    __gsignals__ = {"ready": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ())}

    def __init__(self):
        gobject.GObject.__init__(self)
        image_dir = os.path.join(get_parent_dir(__file__, 3), "image")
        application = Application("DMuisc", resizable=False)
        application.close_callback = self.prompt_quit