Exemplo n.º 1
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)
                 # 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)
                     
             except Exception, e:
                 tipContent = "%s:%s" % (_("Failed to save the picture"), str(e))
         # Save snapshot to clipboard
         else:
Exemplo n.º 2
0
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from dtk.ui.init_skin import init_skin
from dtk.ui.utils import get_parent_dir
from dtk.ui.theme import DynamicPixbuf, DynamicColor
from constant import *
import os
import gtk

app_theme = init_skin(
    "deepin-screenshot",
    "2.1",
    "01",
    os.path.join(get_parent_dir(__file__, 2), "skin"),
    os.path.join(get_parent_dir(__file__, 2), "theme"))

theme_cursor = {
    DRAG_INSIDE: gtk.gdk.Cursor(gtk.gdk.FLEUR),
    DRAG_OUTSIDE: None,
    DRAG_TOP_LEFT_CORNER: gtk.gdk.Cursor(gtk.gdk.TOP_LEFT_CORNER),
    DRAG_TOP_RIGHT_CORNER: gtk.gdk.Cursor(gtk.gdk.TOP_RIGHT_CORNER),
    DRAG_BOTTOM_LEFT_CORNER: gtk.gdk.Cursor(gtk.gdk.BOTTOM_LEFT_CORNER),
    DRAG_BOTTOM_RIGHT_CORNER: gtk.gdk.Cursor(gtk.gdk.BOTTOM_RIGHT_CORNER),
    DRAG_TOP_SIDE: gtk.gdk.Cursor(gtk.gdk.TOP_SIDE),
    DRAG_BOTTOM_SIDE: gtk.gdk.Cursor(gtk.gdk.BOTTOM_SIDE),
    DRAG_LEFT_SIDE: gtk.gdk.Cursor(gtk.gdk.LEFT_SIDE),
    DRAG_RIGHT_SIDE: gtk.gdk.Cursor(gtk.gdk.RIGHT_SIDE),
    ACTION_INIT: None,
    ACTION_RECTANGLE: gtk.gdk.Cursor(gtk.gdk.TCROSS),
Exemplo n.º 3
0
# 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 sys
import os
from dtk.ui.utils import get_parent_dir

sys.path.append(os.path.join(get_parent_dir(__file__, 4), "dss"))

from a11y_view import A11yView
from module_frame import ModuleFrame

if __name__ == "__main__":
    module_frame = ModuleFrame(
        os.path.join(get_parent_dir(__file__, 2), "config.ini"))

    a11y_view = A11yView()

    module_frame.add(a11y_view)

    def message_handler(*message):
        (message_type, message_content) = message
        if message_type == "show_again":
Exemplo n.º 4
0
# 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/>.

from dtk.ui.init_skin import init_skin
from dtk.ui.utils import get_parent_dir
import os

app_theme = init_skin(
    "deepin-ui-demo", 
    "1.0",
    "01",
    os.path.join(get_parent_dir(__file__), "skin"),
    os.path.join(get_parent_dir(__file__), "app_theme"),
    )

from dtk.ui.application import Application
from dtk.ui.new_treeview import TreeView
from dtk.ui.constant import DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT
from dtk.ui.file_treeview import (get_dir_items, sort_by_name, sort_by_size,
                                  sort_by_type, sort_by_mtime)
import gtk

if __name__ == "__main__":
    # Init application.
    application = Application()

    # Set application default size.
Exemplo n.º 5
0
# 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/>.

from dtk.ui.init_skin import init_skin
from dtk.ui.utils import get_parent_dir
import os

app_theme = init_skin(
    "deepin-a11y-settings", 
    "1.0",
    "01",
    os.path.join(get_parent_dir(__file__, 2), "skin"),
    os.path.join(get_parent_dir(__file__, 2), "app_theme"),
    )

from dtk.ui.label import Label
from dtk.ui.combo import ComboBox
from dtk.ui.button import ToggleButton
from dtk.ui.constant import DEFAULT_FONT_SIZE, ALIGN_START, ALIGN_END
from dtk.ui.utils import get_optimum_pixbuf_from_file
from a11y_manager import A11yManager
import gobject
import gtk

class A11yView(gtk.VBox):
    '''
    class docs
Exemplo n.º 6
0
# This program is free software: you can redistribute it and/or modify
# 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/>.

# To test other language, use below method:
#       env LANG=zh_CN LANGUAGE=zh_CN foo.py

from dtk.ui.utils import get_parent_dir
import gettext
import os

APP_NAME="deepin-media-player"
LOCALE_DIR=os.path.join(get_parent_dir(__file__, 2), "locale")
if not os.path.exists(LOCALE_DIR):
        LOCALE_DIR="/usr/share/locale"
    
_ = None    
try:
    _ = gettext.translation(APP_NAME, LOCALE_DIR).gettext
except Exception, e:
    _ = lambda i : i
Exemplo n.º 7
0
#               2011 ~ 2012 Wang Yong
#
# Author:     Wang Yong <*****@*****.**>
# Maintainer: Wang Yong <*****@*****.**>
#
# This program is free software: you can redistribute it and/or modify
# 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/>.

from constant import PROGRAM_NAME, PROGRAM_VERSION
from dtk.ui.init_skin import init_skin
from dtk.ui.utils import get_parent_dir
import os

app_theme = init_skin(
    PROGRAM_NAME,
    PROGRAM_VERSION,
    "blue",
    os.path.join(get_parent_dir(__file__, 2), "../skin"),
    os.path.join(get_parent_dir(__file__, 2), "../app_theme"),
)
Exemplo n.º 8
0
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Import skin and theme, those must before at any other modules.
# from skin import ui_theme, app_theme
import time
start_time = time.time()

from dtk.ui.init_skin import init_skin
from dtk.ui.utils import get_parent_dir
import os

app_theme = init_skin(
    "deepin-ui-demo", 
    "1.0",
    "01",
    os.path.join(get_parent_dir(__file__), "skin"),
    os.path.join(get_parent_dir(__file__), "app_theme"),
    )


# Load other modules.
from dtk.ui.application import Application
from dtk.ui.browser import WebView
from dtk.ui.button import CheckButton, RadioButton, ComboButton
from dtk.ui.button import ImageButton, LinkButton, Button
from dtk.ui.categorybar import Categorybar
from dtk.ui.color_selection import ColorButton
from dtk.ui.combo import ComboBox
from dtk.ui.constant import DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT, WIDGET_POS_BOTTOM_LEFT
from dtk.ui.droplist import Droplist
from dtk.ui.entry import ShortcutKeyEntry, InputEntry
Exemplo n.º 9
0
def get_banner_image():
    return os.path.join(get_parent_dir(__file__, 3), "data", "banner", "default.png")
Exemplo n.º 10
0
from nls import _
from config import config
from player import Player
from library import MediaDB
from mmkeys_wrap import MMKeys

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")    
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)
        application = Application("DMuisc")
        application.close_callback = self.quit
        application.set_icon(app_theme.get_pixbuf("skin/logo.ico"))
        application.set_skin_preview(app_theme.get_pixbuf("frame.png"))
        application.add_titlebar(
Exemplo n.º 11
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 sys
import os
from dtk.ui.utils import get_parent_dir
sys.path.append(os.path.join(get_parent_dir(__file__, 4), "dss"))

from a11y_view import A11yView
from module_frame import ModuleFrame

if __name__ == "__main__":
    module_frame = ModuleFrame(os.path.join(get_parent_dir(__file__, 2), "config.ini"))

    a11y_view = A11yView()
    
    module_frame.add(a11y_view)
    
    def message_handler(*message):
        (message_type, message_content) = message
        if message_type == "show_again":
            module_frame.send_module_info()