def __init__(self, title, init_text, default_width=330, default_height=145, confirm_callback=None, cancel_callback=None): '''Init confirm dialog.''' # Init. DialogBox.__init__(self, title, default_width, default_height, DIALOG_MASK_SINGLE_PAGE) self.confirm_callback = confirm_callback self.cancel_callback = cancel_callback self.entry_align = gtk.Alignment() self.entry_align.set(0.5, 0.5, 0, 0) self.entry_align.set_padding(0, 0, 8, 8) self.entry = InputEntry(init_text) self.entry.set_size(default_width - 20, 25) self.confirm_button = Button(_("OK")) self.cancel_button = Button(_("Cancel")) self.confirm_button.connect("clicked", lambda w: self.click_confirm_button()) self.cancel_button.connect("clicked", lambda w: self.click_cancel_button()) self.entry_align.add(self.entry) self.body_box.pack_start(self.entry_align, True, True) self.right_button_box.set_buttons([self.confirm_button, self.cancel_button]) self.connect("show", self.focus_input)
def __init__(self, title, message, default_width=330, default_height=145, confirm_callback=None, cancel_callback=None): '''Init confirm dialog.''' # Init. DialogBox.__init__(self, title, default_width, default_height, DIALOG_MASK_SINGLE_PAGE) self.confirm_callback = confirm_callback self.cancel_callback = cancel_callback self.label_align = gtk.Alignment() self.label_align.set(0.5, 0.5, 0, 0) self.label_align.set_padding(0, 0, 8, 8) self.label = Label(message, text_x_align=ALIGN_MIDDLE, text_size=11) self.confirm_button = Button(_("OK")) self.cancel_button = Button(_("Cancel")) self.confirm_button.connect("clicked", lambda w: self.click_confirm_button()) self.cancel_button.connect("clicked", lambda w: self.click_cancel_button()) # Connect widgets. self.body_box.pack_start(self.label_align, True, True) self.label_align.add(self.label) self.right_button_box.set_buttons([self.confirm_button, self.cancel_button])
def __init__( self, title, items, confirm_callback=None, cancel_callback=None, window_width=458, window_height=472, dockfill=False, current_tab_index=-1, ): ''' Initialize TabWindow clas. @param title: Tab window title. @param items: A list of tab item, tab item format: (tab_name, tab_widget) @param confirm_callback: Callback when user click ok button. @param cancel_callback: Callback when user click cancel button. @param window_width: Default window width. @param window_height: Default window height. @param dockfill: Fill the tab items @param current_tab_index: The index of current tab, default is -1. ''' DialogBox.__init__(self, title, window_width, window_height, mask_type=DIALOG_MASK_TAB_PAGE) self.confirm_callback = confirm_callback self.cancel_callback = cancel_callback self.window_box = gtk.VBox() self.tab_window_width = window_width self.tab_window_height = window_height self.tab_box = TabBox(can_close_tab=True, dockfill=dockfill, current_tab_index=current_tab_index) self.tab_box.add_items(items) self.tab_box.connect("switch-tab", self.switched_tab) self.tab_align = gtk.Alignment() self.tab_align.set(0.5, 0.5, 1.0, 1.0) self.tab_align.set_padding(8, 0, 0, 0) self.tab_align.add(self.tab_box) self.confirm_button = Button(_("OK")) self.cancel_button = Button(_("Cancel")) self.window_box.pack_start(self.tab_align, True, True) self.confirm_button.connect("clicked", lambda w: self.click_confirm_button()) self.cancel_button.connect("clicked", lambda w: self.click_cancel_button()) self.connect("destroy", lambda w: self.destroy()) self.body_box.pack_start(self.window_box, True, True) self.right_button_box.set_buttons( [self.confirm_button, self.cancel_button])
def sendBye(): bye_responses = [ _("Bye Sir. Have a nice day"), _("Until next time Sir"), _("Be nice, bye Sir!") ] jasminResponse(random.choice(bye_responses)) sys.exit()
def sendGreetings(): day_time = int(strftime('%H')) if day_time < 12: jasminResponse(_('Hello Sir. Good morning')) elif 12 <= day_time < 20: jasminResponse(_('Hello Sir. Good afternoon')) else: jasminResponse(_('Hello Sir. Good evening'))
def __init__(self): gtk.Button.__init__(self) self.text = _("Advanced settings") width = eval(_("('button_size', 100)")) # width = 50 width = width[1] height = 20 self.set_size_request(width, height) # Init event. self.connect("expose-event", self.label_button_expose_event)
def __init__(self, dir=HOME_DIR, view_mode=ICONVIEW): HPaned.__init__(self) self.categorybar = Categorybar([ (ui_theme.get_pixbuf("filemanager/computer.png"), _("Computer"), None), (ui_theme.get_pixbuf("filemanager/user-home.png"), _("Home"), lambda: self.open_dir(self.HOME_DIR)), (ui_theme.get_pixbuf("filemanager/user-desktop.png"), _("Desktop"), lambda: self.open_dir(self.HOME_DIR + "Desktop/")), (ui_theme.get_pixbuf("filemanager/folder-documents.png"), _("Documents"), lambda: self.open_dir(self.HOME_DIR + "Documents/")), (ui_theme.get_pixbuf("filemanager/folder-download.png"), _("Downloads"), lambda: self.open_dir(self.HOME_DIR + "Downloads/")), (ui_theme.get_pixbuf("filemanager/folder-music.png"), _("Music"), lambda: self.open_dir(self.HOME_DIR + "Music/")), (ui_theme.get_pixbuf("filemanager/folder-pictures.png"), _("Pictures"), lambda: self.open_dir(self.HOME_DIR + "Pictures/")), (ui_theme.get_pixbuf("filemanager/folder-videos.png"), _("Videos"), lambda: self.open_dir(self.HOME_DIR + "Videos/")), (ui_theme.get_pixbuf("filemanager/user-trash.png"), _("Trash"), lambda: self.open_dir("trash:///")) ]) self.icon_size = 48 self.iconview = FileIconView() self.iconview.add_items(iconview_get_dir_items(dir, self.icon_size)) self.treeview = TreeView(get_dir_items(dir)) self.add1(self.categorybar) if view_mode == self.ICONVIEW: self.add2(self.iconview) else: self.add2(self.treeview)
def __init__(self, dir=HOME_DIR, view_mode=ICONVIEW ): HPaned.__init__(self) self.categorybar = Categorybar([ (ui_theme.get_pixbuf("filemanager/computer.png"), _("Computer"), None), (ui_theme.get_pixbuf("filemanager/user-home.png"), _("Home"), lambda : self.open_dir(self.HOME_DIR)), (ui_theme.get_pixbuf("filemanager/user-desktop.png"), _("Desktop"), lambda : self.open_dir(self.HOME_DIR + "Desktop/")), (ui_theme.get_pixbuf("filemanager/folder-documents.png"), _("Documents"), lambda : self.open_dir(self.HOME_DIR + "Documents/")), (ui_theme.get_pixbuf("filemanager/folder-download.png"), _("Downloads"), lambda : self.open_dir(self.HOME_DIR + "Downloads/")), (ui_theme.get_pixbuf("filemanager/folder-music.png"), _("Music"), lambda : self.open_dir(self.HOME_DIR + "Music/")), (ui_theme.get_pixbuf("filemanager/folder-pictures.png"), _("Pictures"), lambda : self.open_dir(self.HOME_DIR + "Pictures/")), (ui_theme.get_pixbuf("filemanager/folder-videos.png"), _("Videos"), lambda : self.open_dir(self.HOME_DIR + "Videos/")), (ui_theme.get_pixbuf("filemanager/user-trash.png"), _("Trash"), lambda : self.open_dir("trash:///")) ]) self.icon_size = 48 self.iconview = FileIconView() self.iconview.add_items(iconview_get_dir_items(dir, self.icon_size)) self.treeview = TreeView(get_dir_items(dir)) self.add1(self.categorybar) if view_mode == self.ICONVIEW: self.add2(self.iconview) else: self.add2(self.treeview)
def __top_toolbar_above_button_clicked(self, widget): if not self.keep_above_check: self.app.window.set_keep_above(True) self.keep_above_check = True # 提示. tooltip_text(widget, _("Disable always-on-top")) else: self.app.window.set_keep_above(False) self.keep_above_check = False # 提示. tooltip_text(widget, _("Always on Top"))
def openApplication(input): if 'google chrome' in input: os.system('google-chrome') jasminResponse(_('Google Chrome was open for you Sir.')) elif 'launch app' in input: reg_ex = re.search('launch app (.*)', input) if reg_ex: appname = reg_ex.group(1) subprocess.Popen(appname) jasminResponse(_('I have launched the desired application'))
def __init__(self): self.opacity = 0.0 self.show = False self.hbox = gtk.HBox() self.default_opacity = 0.9 self.toolbar_radio_button = ToolbarRadioButton(None, [None, None]) # full buton. self.toolbar_full_hframe = self.toolbar_radio_button.full_button_align self.toolbar_full_button = self.toolbar_radio_button.full_button # self.toolbar_common_hframe = self.toolbar_radio_button.win_mode_button_align self.toolbar_common_button = self.toolbar_radio_button.win_mode_button # self.toolbar_concise_hframe = self.toolbar_radio_button.concise_button_align self.toolbar_concise_button = self.toolbar_radio_button.concise_button # 1X conect-> self.set_2x_video_play self.toolbar_1X_hframe = HorizontalFrame(5) self.toolbar_1X_button = ToggleHoverButton(None, [None, None], app_theme.get_pixbuf("top_toolbar/1_window_normal.png"), app_theme.get_pixbuf("top_toolbar/1_window_hover.png"), app_theme.get_pixbuf("top_toolbar/1_window_normal.png"), app_theme.get_pixbuf("top_toolbar/1_window_hover.png"), ) tooltip_text(self.toolbar_1X_button, _("100%")) self.toolbar_1X_hframe.add(self.toolbar_1X_button) # 2X conect-> self.set_2x_video_play 显示是 1.5倍. self.toolbar_2X_hframe = HorizontalFrame(5) self.toolbar_2X_button = ToggleHoverButton(None, [None, None], app_theme.get_pixbuf("top_toolbar/2_window_normal.png"), app_theme.get_pixbuf("top_toolbar/2_window_hover.png"), app_theme.get_pixbuf("top_toolbar/2_window_normal.png"), app_theme.get_pixbuf("top_toolbar/2_window_hover.png"), ) tooltip_text(self.toolbar_2X_button, _("150%")) self.toolbar_2X_hframe.add(self.toolbar_2X_button) self.toolbar_above_hframe = HorizontalFrame(5) self.toolbar_above_button = ToggleHoverButton(None, [None, None]) tooltip_text(self.toolbar_above_button, _("Always on Top")) self.toolbar_above_hframe.add(self.toolbar_above_button) self.hbox.pack_start(self.toolbar_radio_button, False, False) self.hbox.pack_start(self.toolbar_1X_hframe, False, False) self.hbox.pack_start(self.toolbar_2X_hframe, False, False) self.hbox.pack_start(self.toolbar_above_hframe, False, False) # above_button self.hbox_hframe = VerticalFrame(padding=4) self.hbox_hframe.add(self.hbox) self.show_time_id = None
def __init__(self): self.opacity = 0.0 self.show = False self.hbox = gtk.HBox() self.default_opacity = 0.9 self.toolbar_radio_button = ToolbarRadioButton(None, [None, None]) # full buton. self.toolbar_full_hframe = self.toolbar_radio_button.full_button_align self.toolbar_full_button = self.toolbar_radio_button.full_button # self.toolbar_common_hframe = self.toolbar_radio_button.win_mode_button_align self.toolbar_common_button = self.toolbar_radio_button.win_mode_button # self.toolbar_concise_hframe = self.toolbar_radio_button.concise_button_align self.toolbar_concise_button = self.toolbar_radio_button.concise_button # 1X conect-> self.set_2x_video_play self.toolbar_1X_hframe = HorizontalFrame(5) self.toolbar_1X_button = ToggleHoverButton(None, [None, None], app_theme.get_pixbuf("top_toolbar/1_window_normal.png"), app_theme.get_pixbuf("top_toolbar/1_window_hover.png"), app_theme.get_pixbuf("top_toolbar/1_window_normal.png"), app_theme.get_pixbuf("top_toolbar/1_window_hover.png"), ) tooltip_text(self.toolbar_1X_button, _("100%")) self.toolbar_1X_hframe.add(self.toolbar_1X_button) # 2X conect-> self.set_2x_video_play self.toolbar_2X_hframe = HorizontalFrame(5) self.toolbar_2X_button = ToggleHoverButton(None, [None, None], app_theme.get_pixbuf("top_toolbar/2_window_normal.png"), app_theme.get_pixbuf("top_toolbar/2_window_hover.png"), app_theme.get_pixbuf("top_toolbar/2_window_normal.png"), app_theme.get_pixbuf("top_toolbar/2_window_hover.png"), ) tooltip_text(self.toolbar_2X_button, _("200%")) self.toolbar_2X_hframe.add(self.toolbar_2X_button) self.toolbar_above_hframe = HorizontalFrame(5) self.toolbar_above_button = ToggleHoverButton(None, [None, None]) tooltip_text(self.toolbar_above_button, _("Always on Top")) self.toolbar_above_hframe.add(self.toolbar_above_button) self.hbox.pack_start(self.toolbar_radio_button, False, False) self.hbox.pack_start(self.toolbar_1X_hframe, False, False) self.hbox.pack_start(self.toolbar_2X_hframe, False, False) self.hbox.pack_start(self.toolbar_above_hframe, False, False) # above_button self.hbox_hframe = VerticalFrame(padding=4) self.hbox_hframe.add(self.hbox) self.show_time_id = None
def __init__(self, title, items, confirm_callback=None, cancel_callback=None, window_width=458, window_height=472, dockfill=False, current_tab_index=-1, ): ''' Initialize TabWindow clas. @param title: Tab window title. @param items: A list of tab item, tab item format: (tab_name, tab_widget) @param confirm_callback: Callback when user click ok button. @param cancel_callback: Callback when user click cancel button. @param window_width: Default window width. @param window_height: Default window height. @param dockfill: Fill the tab items @param current_tab_index: The index of current tab, default is -1. ''' DialogBox.__init__(self, title, window_width, window_height, mask_type=DIALOG_MASK_TAB_PAGE) self.confirm_callback = confirm_callback self.cancel_callback = cancel_callback self.window_box = gtk.VBox() self.tab_window_width = window_width self.tab_window_height = window_height self.tab_box = TabBox(can_close_tab=True, dockfill=dockfill, current_tab_index=current_tab_index) self.tab_box.add_items(items) self.tab_box.connect("switch-tab", self.switched_tab) self.tab_align = gtk.Alignment() self.tab_align.set(0.5, 0.5, 1.0, 1.0) self.tab_align.set_padding(8, 0, 0, 0) self.tab_align.add(self.tab_box) self.confirm_button = Button(_("OK")) self.cancel_button = Button(_("Cancel")) self.window_box.pack_start(self.tab_align, True, True) self.confirm_button.connect("clicked", lambda w: self.click_confirm_button()) self.cancel_button.connect("clicked", lambda w: self.click_cancel_button()) self.connect("destroy", lambda w: self.destroy()) self.body_box.pack_start(self.window_box, True, True) self.right_button_box.set_buttons([self.confirm_button, self.cancel_button])
def __init__(self, title, init_text, default_width=330, default_height=145, confirm_callback=None, cancel_callback=None, cancel_first=True): ''' Initialize InputDialog class. @param title: Input dialog title. @param init_text: Initialize input text. @param default_width: Width of dialog, default is 330 pixel. @param default_height: Height of dialog, default is 330 pixel. @param confirm_callback: Callback when user click confirm button, this callback accept one argument that return by user input text. @param cancel_callback: Callback when user click cancel button, this callback not need argument. @param cancel_first: Set as True if to make cancel button before confirm button, default is True. ''' # Init. DialogBox.__init__(self, title, default_width, default_height, DIALOG_MASK_SINGLE_PAGE) self.confirm_callback = confirm_callback self.cancel_callback = cancel_callback self.entry_align = gtk.Alignment() self.entry_align.set(0.5, 0.5, 0, 0) self.entry_align.set_padding(0, 0, 8, 8) self.entry = InputEntry(init_text) self.entry.set_size(default_width - 20, 25) self.confirm_button = Button(_("OK")) self.cancel_button = Button(_("Cancel")) self.confirm_button.connect("clicked", lambda w: self.click_confirm_button()) self.cancel_button.connect("clicked", lambda w: self.click_cancel_button()) self.entry_align.add(self.entry) self.body_box.pack_start(self.entry_align, True, True) if cancel_first: self.right_button_box.set_buttons([self.cancel_button, self.confirm_button]) else: self.right_button_box.set_buttons([self.confirm_button, self.cancel_button]) self.connect("show", self.focus_input) self.entry.connect("key-press-event", self.m_key_press) self.keymap = { "Return" : self.m_press_return, }
def __init__(self): self.input_string = "play_control_panel: " self.hbox_hframe = HorizontalFrame() self.hbox = gtk.HBox() self.hbox_hframe.add(self.hbox) self.stop_button = StartButton(app_theme.get_pixbuf("bottom_buttons/stop_normal.png"), app_theme.get_pixbuf("bottom_buttons/stop_hover.png"), app_theme.get_pixbuf("bottom_buttons/stop_press.png"), app_theme.get_pixbuf("bottom_buttons/stop_normal.png"), app_theme.get_pixbuf("bottom_buttons/stop_hover.png"), app_theme.get_pixbuf("bottom_buttons/stop_press.png") ) tooltip_text(self.stop_button, _("Stop")) self.pre_button = StartButton(app_theme.get_pixbuf("bottom_buttons/pre_button_normal.png"), app_theme.get_pixbuf("bottom_buttons/pre_button_hover.png"), app_theme.get_pixbuf("bottom_buttons/pre_button_press.png"), app_theme.get_pixbuf("bottom_buttons/pre_button_normal.png"), app_theme.get_pixbuf("bottom_buttons/pre_button_hover.png"), app_theme.get_pixbuf("bottom_buttons/pre_button_press.png")) tooltip_text(self.pre_button, _("Previous")) self.start_button = StartButton(image_y_padding=1) tooltip_text(self.start_button, _("Play")) self.next_button = StartButton(app_theme.get_pixbuf("bottom_buttons/next_button_normal.png"), app_theme.get_pixbuf("bottom_buttons/next_button_hover.png"), app_theme.get_pixbuf("bottom_buttons/next_button_press.png"), app_theme.get_pixbuf("bottom_buttons/next_button_normal.png"), app_theme.get_pixbuf("bottom_buttons/next_button_hover.png"), app_theme.get_pixbuf("bottom_buttons/next_button_press.png")) tooltip_text(self.next_button, _("Next")) self.open_button = StartButton(app_theme.get_pixbuf("bottom_buttons/open_normal.png"), app_theme.get_pixbuf("bottom_buttons/open_hover.png"), app_theme.get_pixbuf("bottom_buttons/open_press.png"), app_theme.get_pixbuf("bottom_buttons/open_normal.png"), app_theme.get_pixbuf("bottom_buttons/open_hover.png"), app_theme.get_pixbuf("bottom_buttons/open_press.png")) tooltip_text(self.open_button, _("Open File")) self.hbox.pack_start(self.stop_button, False, False) self.hbox.pack_start(self.pre_button, False, False) self.hbox.pack_start(self.start_button, False, False) self.hbox.pack_start(self.next_button, False, False) self.hbox.pack_start(self.open_button, False, False)
def __init__(self): '''application.''' self.app = Application(False) # application set. self.app.set_default_size(800, 500) # self.app.window.resize self.app.set_icon(app_theme.get_pixbuf("icon.ico")) self.app.set_skin_preview(app_theme.get_pixbuf("frame.png")) # set titlebar. self.app.add_titlebar(["theme", "menu", "max", "min", "close"], app_theme.get_pixbuf("logo.png"), _("Deepin Media Player"), " ", add_separator = False) # self.main_ali = gtk.Alignment() self.main_vbox = gtk.VBox() self.main_ali.add(self.main_vbox) self.main_ali.set(0, 0, 1.0, 1.0) self.main_ali.set_padding(0, 2, 2, 2) '''movie screen. 电影播放屏幕.''' # 播放屏幕和播放列表的HBOX. self.screen_and_play_list_hbox = gtk.HBox() self.screen_frame = gtk.Alignment(0.0, 0.0, 1.0, 1.0) self.screen = gtk.DrawingArea() self.screen_frame.add(self.screen) # self.play_list = gtk.Button("播放列表") # self.screen_and_play_list_hbox.pack_start(self.screen_frame, True, True) self.screen_and_play_list_hbox.pack_start(self.play_list, False, False) # self.main_vbox.pack_start(self.screen_and_play_list_hbox, True, True) # self.app.main_box.pack_start(self.main_ali, True, True)
def __init__(self): self.button = ToggleButton( app_theme.get_pixbuf("bottom_buttons/play_list_button.png"), app_theme.get_pixbuf("bottom_buttons/list_button_background.png"), ) self.button.set_active(False) tooltip_text(self.button, _("Playlist"))
def __init__(self): gtk.HBox.__init__(self) # self.__init_menu() # self.left_hover_pixbuf = app_theme.get_pixbuf( "screen_mid/hover_button_left.png") self.left_press_pixbuf = app_theme.get_pixbuf( "screen_mid/press_button_left.png") self.left_normal_pixbuf = app_theme.get_pixbuf( "screen_mid/normal_button_left.png") # self.right_hover_pixbuf = app_theme.get_pixbuf( "screen_mid/hover_button_right.png") self.right_press_pixbuf = app_theme.get_pixbuf( "screen_mid/press_button_right.png") self.right_normal_pixbuf = app_theme.get_pixbuf( "screen_mid/normal_button_right.png") # self.select_btn = gtk.Button(_("Open file")) self.popup_btn = gtk.Button("Open Menu") pixbuf = self.left_normal_pixbuf.get_pixbuf() self.select_btn.set_size_request(pixbuf.get_width(), pixbuf.get_height()) pixbuf = self.right_normal_pixbuf.get_pixbuf() self.popup_btn.set_size_request(pixbuf.get_width(), pixbuf.get_height()) # self.select_btn.connect("expose-event", self.__select_btn_expose_event) self.popup_btn.connect("clicked", self.__popup_btn_clicked) self.popup_btn.connect("expose-event", self.__popup_btn_expose_event) # self.pack_start(self.select_btn, True, True) self.pack_start(self.popup_btn, True, True)
def __create_clear_recent_play(self): self.menus.recent_played_menu.add_menu_items([ (None) ]) self.menus.recent_played_menu.add_menu_items([ (None, _("Clear Playlist"), self.__clear_recent_play_list), ])
def __init__(self): gtk.HBox.__init__(self) # self.__init_menu() # self.left_hover_pixbuf = app_theme.get_pixbuf("screen_mid/hover_button_left.png") self.left_press_pixbuf = app_theme.get_pixbuf("screen_mid/press_button_left.png") self.left_normal_pixbuf = app_theme.get_pixbuf("screen_mid/normal_button_left.png") # self.right_hover_pixbuf = app_theme.get_pixbuf("screen_mid/hover_button_right.png") self.right_press_pixbuf = app_theme.get_pixbuf("screen_mid/press_button_right.png") self.right_normal_pixbuf = app_theme.get_pixbuf("screen_mid/normal_button_right.png") # self.select_btn = gtk.Button(_("Open file")) self.popup_btn = gtk.Button("Open Menu") pixbuf = self.left_normal_pixbuf.get_pixbuf() self.select_btn.set_size_request(pixbuf.get_width(), pixbuf.get_height()) pixbuf = self.right_normal_pixbuf.get_pixbuf() self.popup_btn.set_size_request(pixbuf.get_width(), pixbuf.get_height()) # self.select_btn.connect("expose-event", self.__select_btn_expose_event) self.popup_btn.connect("clicked", self.__popup_btn_clicked) self.popup_btn.connect("expose-event", self.__popup_btn_expose_event) # self.pack_start(self.select_btn, True, True) self.pack_start(self.popup_btn, True, True)
def telegramAssistant(telegramProcess): telegramCommand = sendCommand() if 'kill telegram' in telegramCommand: telegramProcess.kill() jasminResponse(_('Closing Telegram Sir.')) print 'Telegram Process: ', telegramProcess.pid elif 'open chat' in telegramCommand: reg_ex = re.search('open (.*) (.+)', telegramCommand) if reg_ex: chatName = reg_ex.group(2) print(chatName) keyboard = Controller() keyboard.type(chatName) keyboard.press(Key.enter) keyboard.release(Key.enter) time.sleep(0.8) keyboard.press(Key.ctrl_l) keyboard.press('f') keyboard.release('f') keyboard.release(Key.ctrl_l) time.sleep(0.5) keyboard.press(Key.ctrl_l) keyboard.press('a') keyboard.release('a') keyboard.release(Key.ctrl_l) if telegramCommand == 'kill telegram': return else: telegramAssistant(telegramProcess)
def tellCurrentTime(): now = datetime.datetime.now() jasminResponse( _('Current time is %(hour)d hours %(mins)d minutes') % ({ 'hour': now.hour, 'mins': now.minute }))
def __init__(self, title, message, default_width=330, default_height=145, confirm_callback=None, cancel_callback=None, cancel_first=True, message_text_size=11, ): ''' Initialize ConfirmDialog class. @param title: Title for confirm dialog. @param message: Confirm message. @param default_width: Dialog width, default is 330 pixel. @param default_height: Dialog height, default is 145 pixel. @param confirm_callback: Callback when user click confirm button. @param cancel_callback: Callback when user click cancel button. @param cancel_first: Set as True if to make cancel button before confirm button, default is True. @param message_text_size: Text size of message, default is 11. ''' # Init. DialogBox.__init__(self, title, default_width, default_height, DIALOG_MASK_SINGLE_PAGE) self.confirm_callback = confirm_callback self.cancel_callback = cancel_callback self.label_align = gtk.Alignment() self.label_align.set(0.5, 0.5, 0, 0) self.label_align.set_padding(0, 0, 8, 8) self.label = Label(message, text_x_align=ALIGN_MIDDLE, text_size=message_text_size) self.confirm_button = Button(_("OK")) self.cancel_button = Button(_("Cancel")) self.confirm_button.connect("clicked", lambda w: self.click_confirm_button()) self.cancel_button.connect("clicked", lambda w: self.click_cancel_button()) # Connect widgets. self.body_box.pack_start(self.label_align, True, True) self.label_align.add(self.label) if cancel_first: self.right_button_box.set_buttons([self.cancel_button, self.confirm_button]) else: self.right_button_box.set_buttons([self.confirm_button, self.cancel_button])
def openWebsite(command): reg_ex = re.search('open website (.+)', command) if reg_ex: domain = reg_ex.group(1) print(domain) url = url = 'https://www.' + domain webbrowser.open(url) jasminResponse(domain + _(' has been opened for you Sir.'))
def openReddit(command): reg_ex = re.search('open reddit (.*)', command) url = 'https://www.reddit.com/' if reg_ex: subreddit = reg_ex.group(1) url = url + 'r/' + subreddit webbrowser.open(url) jasminResponse(_('The Reddit content has been opened for you Sir.'))
def __init_values(self): self.__index = None self.__menu_height = 25 self.__save_show_menu = None self.child_check = False self.menu_parent = None # self.bg = app_theme.get_pixbuf("screen_mid/menu_bg_normal.png") self.open_cdrom = app_theme.get_pixbuf("screen_mid/screen_menu_open_cdrom.png") self.open_dir = app_theme.get_pixbuf("screen_mid/screen_menu_open_dir.png") self.open_url = app_theme.get_pixbuf("screen_mid/screen_menu_open_url.png") self.menu_items = [] if self.menu_items == []: temp_items = [#(self.open_cdrom.get_pixbuf(), _("Open CDROM")), (self.open_dir.get_pixbuf(), _("Open Directory")), (self.open_url.get_pixbuf(), _("Open URL")),] self.set_menu_items(temp_items)
def set_shortcut_key(self, shortcut_key): '''Set shortcut key.''' self.shortcut_key = shortcut_key self.entry.editable_flag = True if self.shortcut_key == None: self.set_text(_("Disabled")) else: self.set_text(self.shortcut_key) self.entry.editable_flag = False
def sendEmail(): jasminResponse(_('Who is the recipient?')) recipient = sendCommand() if 'myself' in recipient: jasminResponse(_('What should I say to him?')) body = sendCommand() jasminResponse(_('What is the subject?')) subject = sendCommand() content = 'Subject: {}\n\n{}'.format(subject,body) mail = smtplib.SMTP('smtp.gmail.com', 587) mail.ehlo() mail.starttls() mail.login(constants.EMAIL_ADDR, constants.EMAIL_SECRET) mail.sendmail(constants.EMAIL_ADDR, constants.EMAIL_RECIPIENT, content) mail.close() jasminResponse(_("Email has been sent successfully.")) else: jasminResponse(_("I don't know what you mean!"))
def __init__(self, label_content, label_wrap_width, label_init_height, label_init_line, label_font_size, label_font_color, animation_time=200, # milliseconds ): ''' Initialize ResizableLabelBuffer class. @param label_content: The content of label. @param label_wrap_width: The wrap width of label. @param label_init_height: The initialize height of label. @param label_init_line: The initialize line number of label. @param label_font_size: The font size. @param label_font_color: The font color. @param animation_time: The time of animation, default is 200 milliseconds. ''' gobject.GObject.__init__(self) self.label_content = label_content self.label_init_height = label_init_height self.label_init_line = label_init_line self.label_font_size = label_font_size self.label_font_color = label_font_color self.label_wrap_width = label_wrap_width self.animation_time = animation_time self.in_animation = False self.label_line_height = int(float(self.label_init_height / self.label_init_line)) self.label_expand_height = self.label_line_height * 2 (self.max_width, self.max_height) = self.get_max_size() self.is_expandable = not (self.max_height <= self.label_init_height) (self.init_width, self.init_height) = self.get_init_size() self.has_expand = False (self.expand_width, self.expand_height) = self.get_expand_size() self.expand_button_content = _("Expand") self.shrink_button_content = _("Shrink") (self.expand_button_width, self.expand_button_height) = get_content_size(self.expand_button_content, self.label_font_size) (self.shrink_button_width, self.shrink_button_height) = get_content_size(self.shrink_button_content, self.label_font_size)
def __init__(self): DialogBox.__init__(self, _("Open Url"), mask_type=DIALOG_MASK_MULTIPLE_PAGE, window_pos=gtk.WIN_POS_CENTER ) self.hbox_ali = gtk.Alignment(0, 0, 1, 1) self.hbox_ali.set_padding(5, 5, 5, 5) self.hbox = gtk.HBox() self.hbox_ali.add(self.hbox) self.url_text = InputEntry() self.ok_btn = Button(_("Ok")) self.cancel_btn = Button(_("Cancel")) self.url_text.set_size(280, 25) self.hbox.pack_start(self.url_text, True, True) #self.hbox.pack_start(self.ok_btn, True, True, 5) self.right_button_box.set_buttons([self.ok_btn, self.cancel_btn]) # self.body_box.pack_start(self.hbox_ali, True, True) # self.cancel_btn.connect("clicked", self.__cancel_btn_clicked_event)
def init_widgets(self): self.scrolled_window = ScrolledWindow() self.list_view = ListView() self.list_view.draw_mask = self.get_mask_func(self.list_view) self.scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) self.scrolled_window.add_child(self.list_view) # self.start_btn = Button(_("Start")) self.show_time_label = Label("") self.pause_btn = Button(_("Pause")) self.close_btn = Button(_("Close")) self.show_time_label_align = gtk.Alignment() self.show_time_label_align.set(0.0, 0.5, 1.0, 1.0) self.show_time_label_align.add(self.show_time_label) self.left_button_box.set_buttons([self.show_time_label_align]) self.right_button_box.set_buttons([self.pause_btn, self.close_btn]) self.close_btn.connect("clicked", lambda w : self.hide_all())
def __init__(self): '''application.''' self.__init_values() self.app = Application(False) # application set. app_w, app_h = 890, 590 min_app_w, min_app_h = 480, 300 self.app.set_default_size(min_app_w, min_app_h) self.app.window.set_default_size(app_w, app_h) # self.app.window.resize self.app.set_icon(app_theme.get_pixbuf("icon.ico")) self.app.set_skin_preview(app_theme.get_pixbuf("frame.png")) # set titlebar. self.app.add_titlebar(["theme", "menu", "max", "min", "close"], app_theme.get_pixbuf("logo.png"), _("Deepin Media Player"), " ", add_separator = False) # self.play_menus = PlayMenus() # 设置主题菜单. self.app.set_menu_callback(lambda button: self.play_menus.show_theme_menu(button)) # self.main_ali = gtk.Alignment() self.main_vbox = gtk.VBox() self.main_ali.add(self.main_vbox) self.main_ali.set(0, 0, 1.0, 1.0) self.main_ali.set_padding(0, 2, 2, 2) '''movie screen. 电影播放屏幕.''' # 播放屏幕和播放列表的HBOX. self.play_list_view = PlayListView() self.screen_paned = Paned() self.screen_paned.paint_bottom_window = self.__paint_bottom_toolbar_background self.screen_frame = gtk.Alignment(0.0, 0.0, 1.0, 1.0) self.screen = gtk.DrawingArea() self.screen_frame.add(self.screen) self.top_toolbar = ToolBar() self.bottom_toolbar = BottomToolBar() # BUG: 当显示上部工具条的时候,画面抖动. self.screen_paned.add_top_widget(self.top_toolbar.hbox_hframe) self.screen_paned.add_bottom_widget(self.bottom_toolbar.vbox) # self.screen_frame_event = self.screen_paned self.screen_paned.screen = self.screen # self.screen_paned.add1(self.screen_frame) self.screen_paned.add2(self.play_list_view.play_list_vbox) # self.play_control_panel = BottomToolBar(False) # self.main_vbox.pack_start(self.screen_paned, True, True) self.main_vbox.pack_start(self.play_control_panel.vbox, False, False) # self.app.main_box.pack_start(self.main_ali, True, True)
def __init_values(self): self.__index = None self.__menu_height = 25 self.__save_show_menu = None self.child_check = False self.menu_parent = None # self.bg = app_theme.get_pixbuf("screen_mid/menu_bg_normal.png") self.open_cdrom = app_theme.get_pixbuf( "screen_mid/screen_menu_open_cdrom.png") self.open_dir = app_theme.get_pixbuf( "screen_mid/screen_menu_open_dir.png") self.open_url = app_theme.get_pixbuf( "screen_mid/screen_menu_open_url.png") self.menu_items = [] if self.menu_items == []: temp_items = [ #(self.open_cdrom.get_pixbuf(), _("Open CDROM")), (self.open_dir.get_pixbuf(), _("Open Directory")), (self.open_url.get_pixbuf(), _("Open URL")), ] self.set_menu_items(temp_items)
def sayWeatherConditions(city): openWeatherMap = OWM(API_key=OWM_KEY) observation = openWeatherMap.weather_at_place(city) weather = observation.get_weather() status = weather.get_status() temperature = weather.get_temperature(unit='celsius') response = _("Current weather in %(city)s is %(status)s. The maximum temperature is %(temp_max)0.1f and the minimum temperature is %(temp_min)0.1f degree celcius") % ({ 'city': city, 'status': status, 'temp_max': temperature['temp_max'], 'temp_min': temperature['temp_min'] }) jasminResponse(response)
def start_desktop_file(desktop_path): ''' Start application with given desktop path. @param desktop_path: The path of desktop file. @return: Return True if launch application successfully, otherwise return error string. ''' if not os.path.exists(desktop_path): return _("The desktop file doesn't exist: %s") % desktop_path else: app_info = gio.unix.desktop_app_info_new_from_filename(desktop_path) if app_info == None: return _("The desktop file is not valid: %s") % desktop_path else: try: app_info.launch() return True except Exception, e: traceback.print_exc(file=sys.stdout) return str(e)
def handle_button_press(self, widget, event): '''Button press entry.''' # Get input focus. self.entry.grab_focus() self.shortcut_key_record = self.shortcut_key if is_left_button(event): self.entry.editable_flag = True self.emit("wait-key-input", self.shortcut_key) self.set_text(_("Please input new shortcuts")) self.entry.editable_flag = False self.entry.queue_draw()
def __init__(self): DialogBox.__init__(self, _("Task Manager for format conversion"), FORM_WIDTH, FORM_HEIGHT, mask_type=DIALOG_MASK_SINGLE_PAGE, #DIALOG_MASK_MULTIPLE_PAGE, close_callback=self.hide_all, modal=True, window_hint=gtk.gdk.WINDOW_TYPE_HINT_DIALOG, window_pos=gtk.WIN_POS_CENTER, resizable=False, ) self.init_widgets() # add widgets. self.body_box.pack_start(self.scrolled_window, False, False)
def __init__(self): DialogBox.__init__(self, _("Convert"), FORM_WIDTH, FORM_HEIGHT, mask_type=DIALOG_MASK_SINGLE_PAGE, close_callback=self.hide_all, modal=True, window_hint=gtk.gdk.WINDOW_TYPE_HINT_DIALOG, window_pos=gtk.WIN_POS_CENTER, # skip_taskbar_hint=False, resizable=False, ) # Init value. self.init_value() # Init all widgets. self.InitializeComponent()
def show_open_dir_dialog_window(self): open_dialog = gtk.FileChooserDialog( _("Choose a directory"), None, gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)) # current floader set. open_dialog.set_current_folder(self.get_home_path()) # run dir dialog window. res = open_dialog.run() if res == gtk.RESPONSE_OK: path_string = open_dialog.get_filename() if path_string: self.save_path_entry.set_text(path_string) # destroy dialog window. open_dialog.destroy()
def show_open_dir_dialog_window(self): open_dialog = gtk.FileChooserDialog( _("Choose a directory"), None, gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK), ) # current floader set. open_dialog.set_current_folder(self.get_home_path()) # run dir dialog window. res = open_dialog.run() if res == gtk.RESPONSE_OK: path_string = open_dialog.get_filename() if path_string: self.save_path_entry.set_text(path_string) # destroy dialog window. open_dialog.destroy()
def __init__(self): DialogBox.__init__( self, _("Convert"), FORM_WIDTH, FORM_HEIGHT, mask_type=DIALOG_MASK_SINGLE_PAGE, close_callback=self.hide_all, modal=True, window_hint=gtk.gdk.WINDOW_TYPE_HINT_DIALOG, window_pos=gtk.WIN_POS_CENTER, # skip_taskbar_hint=False, resizable=False, ) # Init value. self.init_value() # Init all widgets. self.InitializeComponent()
def label_button_expose_event(self, widget, event): cr = widget.window.cairo_create() rect = widget.allocation color = "#2685e3" draw_line_bool = False if widget.state == gtk.STATE_NORMAL: color = "#2685e3" draw_line_bool = False elif widget.state == gtk.STATE_PRELIGHT: color = "#257bd0" draw_line_bool = True elif widget.state == gtk.STATE_ACTIVE: color = "#257bd0" draw_line_bool = True # draw text. draw_text(cr, _("Advanced settings"), rect.x, rect.y, rect.width, rect.height, text_color=color, underline=draw_line_bool) return True
def __init__( self, init_color="#FFFFFF", confirm_callback=None, cancel_callback=None, cancel_first=True, ): ''' Initialize ColorSelectDialog class. @param init_color: Initialize color of dialog. @param confirm_callback: Callback when user click OK, this callback accept one argument, color string. @param cancel_callback: Callback when user click cancel, this callback don't accept any argument. @param cancel_first: Set as True if to make cancel button before confirm button, default is True. ''' DialogBox.__init__(self, _("Select color"), mask_type=DIALOG_MASK_SINGLE_PAGE) self.confirm_callback = confirm_callback self.cancel_callback = cancel_callback self.cancel_first = cancel_first self.color_box = gtk.HBox() self.color_align = gtk.Alignment() self.color_align.set(0.5, 0.5, 0.0, 0.0) self.color_align.set_padding(10, 0, 8, 8) self.color_align.add(self.color_box) self.color_hsv = HSV() self.color_string = init_color (self.color_r, self.color_g, self.color_b) = self.color_hsv.get_rgb_color() self.color_hsv.get_hsv_widget().connect( "button-release-event", lambda w, e: self.update_color_info( self.color_hsv.get_color_string())) self.color_box.pack_start(self.color_hsv, False, False) self.color_right_box = gtk.VBox() self.color_right_align = gtk.Alignment() self.color_right_align.set(0.5, 0.5, 0.0, 0.0) self.color_right_align.set_padding(8, 0, 0, 0) self.color_right_align.add(self.color_right_box) self.color_box.pack_start(self.color_right_align) self.color_info_box = gtk.HBox() self.color_right_box.pack_start(self.color_info_box, False, False) self.color_display_box = gtk.VBox() self.color_display_button = gtk.Button() self.color_display_button.connect("expose-event", self.expose_display_button) self.color_display_button.set_size_request(70, 58) self.color_display_align = gtk.Alignment() self.color_display_align.set(0.5, 0.5, 1.0, 1.0) self.color_display_align.set_padding(5, 5, 5, 5) self.color_display_align.add(self.color_display_button) self.color_display_box.pack_start(self.color_display_align, False, False, 5) self.color_hex_box = gtk.HBox() self.color_hex_label = Label(_("Color value")) self.color_hex_box.pack_start(self.color_hex_label, False, False, 5) self.color_hex_entry = InputEntry(self.color_string) self.color_hex_entry.entry.check_text = is_hex_color self.color_hex_entry.entry.connect("press-return", self.press_return_color_entry) self.color_hex_entry.set_size(70, 24) self.color_hex_box.pack_start(self.color_hex_entry, False, False, 5) self.color_display_box.pack_start(self.color_hex_box, False, False, 5) self.color_info_box.pack_start(self.color_display_box, False, False, 5) self.color_rgb_box = gtk.VBox() self.color_r_box = gtk.HBox() self.color_r_label = Label(_("Red: ")) self.color_r_spin = SpinBox(self.color_r, 0, 255, 1, check_text=self.is_color_value) self.color_r_spin.connect("value-changed", lambda s, v: self.click_rgb_spin()) self.color_r_box.pack_start(self.color_r_label, False, False) self.color_r_box.pack_start(self.color_r_spin, False, False) self.color_g_box = gtk.HBox() self.color_g_label = Label(_("Green: ")) self.color_g_spin = SpinBox(self.color_g, 0, 255, 1, check_text=self.is_color_value) self.color_g_spin.connect("value-changed", lambda s, v: self.click_rgb_spin()) self.color_g_box.pack_start(self.color_g_label, False, False) self.color_g_box.pack_start(self.color_g_spin, False, False) self.color_b_box = gtk.HBox() self.color_b_label = Label(_("Blue: ")) self.color_b_spin = SpinBox(self.color_b, 0, 255, 1, check_text=self.is_color_value) self.color_b_spin.connect("value-changed", lambda s, v: self.click_rgb_spin()) self.color_b_box.pack_start(self.color_b_label, False, False) self.color_b_box.pack_start(self.color_b_spin, False, False) self.color_rgb_box.pack_start(self.color_r_box, False, False, 8) self.color_rgb_box.pack_start(self.color_g_box, False, False, 8) self.color_rgb_box.pack_start(self.color_b_box, False, False, 8) self.color_info_box.pack_start(self.color_rgb_box, False, False, 5) self.color_select_view = IconView() self.color_select_view.set_size_request(250, 60) self.color_select_view.connect( "button-press-item", lambda view, item, x, y: self.update_color_info(item.color, False)) self.color_select_view.draw_mask = self.get_mask_func( self.color_select_view) self.color_select_scrolled_window = ScrolledWindow() for color in self.DEFAULT_COLOR_LIST: self.color_select_view.add_items([ColorItem(color)]) self.color_select_align = gtk.Alignment() self.color_select_align.set(0.5, 0.5, 1.0, 1.0) self.color_select_align.set_padding(10, 5, 6, 5) self.color_select_scrolled_window.add_child(self.color_select_view) self.color_select_scrolled_window.set_size_request(-1, 60) self.color_select_align.add(self.color_select_scrolled_window) self.color_right_box.pack_start(self.color_select_align, True, True) self.confirm_button = Button(_("OK")) self.cancel_button = Button(_("Cancel")) self.confirm_button.connect("clicked", lambda w: self.click_confirm_button()) self.cancel_button.connect("clicked", lambda w: self.click_cancel_button()) if self.cancel_first: self.right_button_box.set_buttons( [self.cancel_button, self.confirm_button]) else: self.right_button_box.set_buttons( [self.confirm_button, self.cancel_button]) self.body_box.pack_start(self.color_align, True, True) self.update_color_info(self.color_string)
def __init__(self, button_mask=["theme", "menu", "max", "min", "close"], icon_path=None, app_name=None, title=None, add_separator=False, height=26, show_title=True, enable_gaussian=True, name_size=DEFAULT_FONT_SIZE, title_size=DEFAULT_FONT_SIZE, ): ''' Initialize the title bar. @param button_mask: A string list. Each item of it indicates that there is a corresponding button on the title bar. By default, it's ["theme", "menu", "max", "min", "close"], which means theme button, menu button, max button, min button and close button, respectively. @param icon_path: The path of icon image. @param app_name: Application name string. It will be displayed just next to the icon_dpixbuf. By default, it's None. @param title: Title string of the application. It will be displayed on the center of the title bar. By default, it's None. @param add_separator: If True, add a separation line between the title bar and the body of the window. By default, it's False. @param height: The height of the title bar. By default, it's 26 pixels. @param show_title: If False, the title bar will not be displayed. By default, it's True. @param enable_gaussian: Whether enable gaussian on title, default is True. @param name_size: The size of name, default is DEFAULT_FONT_SIZE. @param title_size: The size of title, default is DEFAULT_FONT_SIZE. ''' # Init. EventBox.__init__(self) self.set_size_request(-1, height) self.v_layout_box = gtk.VBox() self.h_layout_box = gtk.HBox() self.add(self.v_layout_box) self.v_layout_box.pack_start(self.h_layout_box, True, True) # Init separator. if add_separator: self.separator = gtk.HBox() self.separator.set_size_request(-1, 1) self.separator.connect("expose-event", self.expose_titlebar_separator) self.v_layout_box.pack_start(self.separator, True, True) # Add drag event box. self.drag_box = EventBox() self.h_layout_box.pack_start(self.drag_box, True, True) # Init left box to contain icon and title. self.left_box = gtk.HBox() self.drag_box.add(self.left_box) if show_title: # Add icon. if icon_path != None: self.icon_image_box = gtk.image_new_from_pixbuf(gtk.gdk.pixbuf_new_from_file(icon_path)) self.icon_align = gtk.Alignment() self.icon_align.set(0.5, 0.5, 0.0, 0.0) self.icon_align.set_padding(5, 5, 5, 0) self.icon_align.add(self.icon_image_box) self.left_box.pack_start(self.icon_align, False, False) # Add app name. if app_name == None: app_name_label = "" else: app_name_label = app_name self.app_name_box = Label( app_name_label, text_color=ui_theme.get_color("title_text"), enable_gaussian=enable_gaussian, text_size=name_size, ) self.app_name_align = gtk.Alignment() self.app_name_align.set(0.5, 0.5, 0.0, 0.0) self.app_name_align.set_padding(2, 0, 5, 0) self.app_name_align.add(self.app_name_box) self.left_box.pack_start(self.app_name_align, False, False) # Add title. if title == None: title_label = "" else: title_label = title self.title_box = Label( title_label, text_color=ui_theme.get_color("title_text"), enable_gaussian=enable_gaussian, text_x_align=pango.ALIGN_CENTER, text_size=title_size, ) self.title_align = gtk.Alignment() self.title_align.set(0.5, 0.5, 0.0, 0.0) self.title_align.set_padding(2, 0, 30, 30) self.title_align.add(self.title_box) self.left_box.pack_start(self.title_align, True, True) # Add button box. self.button_box = gtk.HBox() self.button_align = gtk.Alignment() self.button_align.set(1.0, 0.0, 0.0, 0.0) self.button_align.set_padding(0, 0, 0, 0) self.button_align.add(self.button_box) self.right_box = gtk.VBox() self.right_box.pack_start(self.button_align, False, False) self.h_layout_box.pack_start(self.right_box, False, False) # Add theme button. if "theme" in button_mask: self.theme_button = ThemeButton() self.button_box.pack_start(self.theme_button, False, False, 1) Tooltip.text(self.theme_button, _("Change skin")).show_delay(self.theme_button, 2000) # Add menu button. if "menu" in button_mask: self.menu_button = MenuButton() self.button_box.pack_start(self.menu_button, False, False, 1) Tooltip.text(self.menu_button, _("Main menu")).show_delay(self.menu_button, 2000) # Add min button. if "min" in button_mask: self.min_button = MinButton() self.button_box.pack_start(self.min_button, False, False, 1) Tooltip.text(self.min_button, _("Minimum")).show_delay(self.min_button, 2000) # Add max button. if "max" in button_mask: self.max_button = MaxButton() self.button_box.pack_start(self.max_button, False, False, 1) Tooltip.text(self.max_button, _("Maximize")).show_delay(self.max_button, 2000) # Add close button. if "close" in button_mask: self.close_button = CloseButton() self.button_box.pack_start(self.close_button, False, False) Tooltip.text(self.close_button, _("Close")).show_delay(self.close_button, 2000) # Show. self.show_all()
def init_media_player_config(config): path = get_config_path() print "init_media_player_config...", path # 创建保存东西的文件夹. for subdir in ["subtitle", "buffer", "image", "plugins"]: subpath = os.path.join(path, subdir) if not os.path.exists(subpath): print subpath os.makedirs(subpath) # 创建临时文件. for subdir in ["/tmp/buffer", "/tmp/preview"]: if not os.path.exists(subdir): os.makedirs(subdir) # 创建配置文件. config_path = os.path.join(path, "config.ini") if not os.path.exists(config_path): fp = open(config_path, "a") fp.close() # Create media config file if it not exists. media_config_path = os.path.join(path, "deepin_media_config.ini") if not os.path.exists(media_config_path): fp = open(media_config_path, "a") fp.close() # Init config.ini #config = Config(media_config_path) # Init window. config.set("Window", "init_window", "True") #[FilePlay] # 播放设置. # 2 视频适应窗口. for argv, value in ([ # 视频文件打开时. ("video_file_open", 2), # 打开新文件时清空播放列表. ("open_new_file_clear_play_list", "True"), # 自动从上次停止位置播放. ("memory_up_close_player_file_postion", "True"), # 自动查找相似文件连续播放. ("find_play_file_relation_file", "False"), # 鼠标悬停进度条时显示预览图. ("mouse_progressbar_show_preview", "False"), # 允许同时运行多个深度影音. ("check_run_a_deepin_media_player", "False"), # 最小化暂停播放. ("minimize_pause_play", "True") ]): config.set("FilePlay", argv, value) #[SystemSet] # 系统设置. for argv, value in ([ # 启用相同气泡提示. ("start_sys_bubble_msg", "False"), # 启用播放窗口提示. ("start_play_win_msg", "True"), # 字体. ("font", "文泉驿微米黑"), # 字号. ("font_size", "16") ]): config.set("SystemSet", argv, value) # 快捷键 #[PlayControl] 播放控制. for argv, value in ([ # 开启热键. ("play_control_bool", "True"), # 打开文件 ("open_file_key", "Ctrl + o"), # 打开目录. ("open_file_dir_key", "Ctrl + f"), # 暂停/播放. ("play_or_pause_key", "Space"), # 快进. ("seek_key", "Right"), # 倒退. ("back_key", "Left"), # 全屏. ("full_key", "Return"), # 上一首. ("pre_a_key", "Page_Up"), # 下一首. ("next_a_key", "Page_Down"), # 增大音量. ("add_volume_key", "Up"), # 增小音量. ("sub_volume_key", "Down"), # 静音. ("mute_key", "m"), # 简洁模式. ("concise_key", "Shift + Return") ]): config.set("PlayControl", argv, value) #[SubKey] 字幕控制. for argv, value in ([ # 开启热键. ("subkey_bool", "True"), # 字幕提前0.5秒. ("subkey_add_delay_key", "["), # 字幕延时0.5秒. ("subkey_sub_delay_key", "]"), # 自动载入字幕. ("subkey_load_key", "Alt + o"), # 增大字幕尺寸. ("subkey_add_scale_key", "Alt + Left"), # 减少字幕尺寸. ("subkey_sub_scale_key", "Alt + Right"), ]): config.set("SubKey", argv, value) #[OtherKey] 其它快捷键. for argv, value in ([ # 开启热键. ("other_key_bool", "True"), # 升高音量 ("add_brightness_key", "="), # 降低音量 ("sub_brightness_key", "-"), # 逆时针旋转. ("inverse_rotation_key", "w"), # 顺时针旋转. ("clockwise_key", "e"), # 截图. ("sort_image_key", "Alt + a"), # 钱换音轨. ("switch_audio_track_key", _("Disabled")), # ("load_subtitle_key", "Alt + o"), # ("subtitle_delay_key", "]"), # ("subtitle_advance_key", "["), # 鼠标左键单击. ("mouse_left_single_clicked", _("Pause/Play")), # 鼠标左键双击. ("mouse_left_double_clicked", _("Full Screen")), # 鼠标滚轮. ("mouse_wheel_event", _("Volume")), ]): config.set("OtherKey", argv, value) #[SubtitleSet] 字幕. for argv, value in ([ ("ai_load_subtitle", "True"), # ("specific_location_search", os.path.join(get_home_path(), ".config/deepin-media-player/subtitle")) ("specific_location_search", "~/.config/deepin-media-player/subtitle") ]): config.set("SubtitleSet", argv, value) #[ScreenshotSet] 截图设置. for argv, value in ([ ("save_clipboard", "False"), ("save_file", "True"), # ("save_path", os.path.join(get_home_path(), ".config/deepin-media-player/image")), ("save_path", "~/.config/deepin-media-player/image"), ("save_type", ".png"), ("current_show_sort", "False") ]): config.set("ScreenshotSet", argv, value) config.save()
def openTelegram(): telegramProcess = subprocess.Popen("telegram") jasminResponse(_('Telegram ready as always.')) print 'Telegram Process: ', telegramProcess.pid telegram.telegramAssistant(telegramProcess)
def expose_icon_view(self, widget, event): ''' Internal callback for `expose-event` signal. ''' # Update vadjustment. self.update_vadjustment() # Init. cr = widget.window.cairo_create() rect = widget.allocation # Get offset. (offset_x, offset_y, viewport) = self.get_offset_coordinate(widget) # Draw background on widget cairo. self.draw_background(widget, cr) # Draw mask on widget cairo. scrolled_window = get_match_parent(self, ["ScrolledWindow"]) vadjust = scrolled_window.get_vadjustment() vadjust_value = int(vadjust.get_value()) hadjust = scrolled_window.get_hadjustment() hadjust_value = int(hadjust.get_value()) self.draw_mask(cr, hadjust_value, vadjust_value, viewport.allocation.width, viewport.allocation.height) # We need clear render surface every time. with cairo_state(self.render_surface_cr): self.render_surface_cr.set_operator(cairo.OPERATOR_CLEAR) self.render_surface_cr.paint() if self.is_loading: load_text = _("Loading...") load_width, load_height = get_content_size(load_text) draw_text(cr, load_text, rect.x + (rect.width - load_width) / 2, rect.y + rect.height - load_height, rect.width, load_height) # Draw items on surface cairo. self.draw_items(self.render_surface_cr, rect) # Draw bound mask. scrolled_window = get_match_parent(self, ["ScrolledWindow"]) width = scrolled_window.allocation.width height = scrolled_window.allocation.height vadjust_value = int(scrolled_window.get_vadjustment().get_value()) vadjust_upper = int(scrolled_window.get_vadjustment().get_upper()) vadjust_page_size = int( scrolled_window.get_vadjustment().get_page_size()) hadjust_value = int(scrolled_window.get_hadjustment().get_value()) if vadjust_value == 0: with cairo_state(cr): cr.rectangle(hadjust_value, vadjust_value, width, self.mask_bound_height) cr.clip() cr.set_source_surface(self.render_surface, hadjust_value, vadjust_value) cr.paint() elif self.mask_bound_height > 0: i = 0 while (i <= self.mask_bound_height): with cairo_state(cr): cr.rectangle(hadjust_value, vadjust_value + i, width, 1) cr.clip() cr.set_source_surface(self.render_surface, hadjust_value, vadjust_value) cr.paint_with_alpha( math.sin(i * math.pi / 2 / self.mask_bound_height)) i += 1 with cairo_state(cr): cr.rectangle(hadjust_value, vadjust_value + self.mask_bound_height, width, height - self.mask_bound_height * 2) cr.clip() cr.set_source_surface(self.render_surface, hadjust_value, vadjust_value) cr.paint() if vadjust_value + vadjust_page_size == vadjust_upper: with cairo_state(cr): cr.rectangle(hadjust_value, vadjust_value + height - self.mask_bound_height, width, self.mask_bound_height) cr.clip() cr.set_source_surface(self.render_surface, hadjust_value, vadjust_value) cr.paint() elif self.mask_bound_height > 0: i = 0 while (i < self.mask_bound_height): with cairo_state(cr): cr.rectangle( hadjust_value, vadjust_value + height - self.mask_bound_height + i, width, 1) cr.clip() cr.set_source_surface(self.render_surface, hadjust_value, vadjust_value) cr.paint_with_alpha(1.0 - (math.sin(i * math.pi / 2 / self.mask_bound_height))) i += 1 return False
def __mid_combo_menu_actiav_event(self, menu, index): if index == _("Open Directory"): # 打开文件夹对话框. self.this.open_dirs_to_play_list() elif index == _("Open URL"): # 打开地址对话框. self.this.open_url_dialog(True)
def __init__(self): ''' Initialize IPV4Entry class. ''' gtk.VBox.__init__(self) self.width = 120 self.height = 22 self.set_size_request(self.width, self.height) self.normal_frame = ui_theme.get_color("entry_normal_frame") self.alert_frame = ui_theme.get_color("entry_alert_frame") self.frame_color = self.normal_frame self.default_address = "..." self.ip = self.default_address self.dot_size = 2 self.grab_focus_flag = False self.segment_split_char = "." self.ip_chars = map(str, range(0, 10)) + [self.segment_split_char] self.select_active_color=ui_theme.get_shadow_color("select_active_background") self.select_inactive_color=ui_theme.get_shadow_color("select_inactive_background") self.segment_number = 4 self.last_segment_index = self.segment_number - 1 self.segment_max_chars = 3 self.cursor_index = 0 self.cursor_padding_y = 2 self.cursor_positions = [] self.cursor_segment_index = 0 self.highlight_segment_index = None self.cursor_alpha = 1 self.cursor_blank_id = None self.edit_complete_flag = True self.edit_timeout_id = None self.draw_area = gtk.EventBox() self.draw_area.set_visible_window(False) self.draw_area.add_events(gtk.gdk.ALL_EVENTS_MASK) self.draw_area.set_can_focus(True) # can focus to response key-press signal self.pack_start(self.draw_area, True, True, 1) self.draw_area.connect("button-press-event", self.button_press_ipv4_entry) self.draw_area.connect("key-press-event", self.key_press_ipv4_entry) self.draw_area.connect("expose-event", self.expose_ipv4_entry) self.draw_area.connect("focus-in-event", self.focus_in_ipv4_entry) self.draw_area.connect("focus-out-event", self.focus_out_ipv4_entry) self.connect("editing", self.__edit_going) self.keymap = { "Left" : self.move_to_left, "Right" : self.move_to_right, "Home" : self.move_to_start, "End" : self.move_to_end, "Ctrl + a" : self.select_current_segment, "Ctrl + c" : self.copy_to_clipboard, "Ctrl + x" : self.cut_to_clipboard, "Ctrl + v" : self.paste_from_clipboard, "BackSpace" : self.backspace, "Space" : self.insert_ip_dot, "." : self.insert_ip_dot, } self.right_menu = Menu( [(None, _("Cut"), self.cut_to_clipboard), (None, _("Copy"), self.copy_to_clipboard), (None, _("Paste"), self.paste_from_clipboard), ], True) self.calculate_cursor_positions()
def __init__(self, connect_function, argv, ############## full_normal_pixbuf = app_theme.get_pixbuf("top_toolbar/full_window_normal.png"), full_hover_pixbuf = app_theme.get_pixbuf("top_toolbar/full_window_hover.png"), ########################## window_mode_normal_pixbuf = app_theme.get_pixbuf("top_toolbar/window_mode_normal.png"), window_mode_hover_pixbuf = app_theme.get_pixbuf("top_toolbar/window_mode_hover.png"), ########################################### concise_normal_pixbuf = app_theme.get_pixbuf("top_toolbar/concise_window_normal.png"), concise_hover_pixbuf = app_theme.get_pixbuf("top_toolbar/concise_hover.png") ): gtk.HBox.__init__(self) self.connect_function = connect_function self.argv = argv # Init pixbuf. self.full_normal_pixbuf = full_normal_pixbuf self.full_hover_pixbuf = full_hover_pixbuf self.window_mode_normal_pixbuf = window_mode_normal_pixbuf self.window_mode_hover_pixbuf = window_mode_hover_pixbuf self.concise_normal_pixbuf = concise_normal_pixbuf self.concise_hover_pixbuf = concise_hover_pixbuf # Init value. self.window_state = 0 # 0-> window mode state; 1-> concise state. self.full_state = 1 # 0-> quit full state; 1-> full state. # Init buttons. self.full_button_align = gtk.Alignment() self.full_button_align.set_padding(0, 0, 5, 5) self.full_button = gtk.Button() self.full_button_align.add(self.full_button) tooltip_text(self.full_button, _("Full Screen")) self.full_button.add_events(gtk.gdk.ALL_EVENTS_MASK) self.full_button.connect("expose-event", self.expose_draw_full_button) self.full_button.connect("motion-notify-event", self.show_toolbar) self.win_mode_button_align = gtk.Alignment() self.win_mode_button_align.set_padding(0, 0, 5, 5) self.win_mode_button = gtk.Button() self.win_mode_button_align.add(self.win_mode_button) tooltip_text(self.win_mode_button, _("Normal Mode")) self.win_mode_button.add_events(gtk.gdk.ALL_EVENTS_MASK) self.win_mode_button.connect("expose-event", self.expose_draw_win_mode_button) self.win_mode_button.connect("motion-notify-event", self.show_toolbar) self.concise_button_align = gtk.Alignment() self.concise_button_align.set_padding(0, 0, 5, 5) self.concise_button = gtk.Button() self.concise_button_align.add(self.concise_button) tooltip_text(self.concise_button, _("Compact Mode")) self.concise_button.add_events(gtk.gdk.ALL_EVENTS_MASK) self.concise_button.connect("expose-event", self.expose_draw_concise_button) self.concise_button.connect("motion-notify-event", self.show_toolbar) # add buttons. self.pack_start(self.full_button_align, False, False) self.pack_start(self.win_mode_button_align, False, False) self.pack_start(self.concise_button_align, False, False) self.show_all()
def __init__(self, button_mask=["theme", "menu", "max", "min", "close"], icon_dpixbuf=None, app_name=None, title=None, add_separator=False, height=26, show_title=True, ): """ Initialize the title bar. @param button_mask: A string list. Each item of it indicates that there is a corresponding button on the title bar. By default, it's ["theme", "menu", "max", "min", "close"], which means theme button, menu button, max button, min button and close button, respectively. @param icon_dpixbuf: A pixbuf of type dtk.ui.theme.DynamicPixbuf. It will be displayed at the top left of the window. By default, it's None. @param app_name: Application name string. It will be displayed just next to the icon_dpixbuf. By default, it's None. @param title: Title string of the application. It will be displayed on the center of the title bar. By default, it's None. @param add_separator: If True, add a separation line between the title bar and the body of the window. By default, it's False. @param height: The hight of the title bar. By default, it's 26 pixels. @param show_title: If False, the title bar will not be displayed. By default, it's True. """ # Init. EventBox.__init__(self) self.set_size_request(-1, height) self.v_layout_box = gtk.VBox() self.h_layout_box = gtk.HBox() self.add(self.v_layout_box) self.v_layout_box.pack_start(self.h_layout_box, True, True) # Init separator. if add_separator: self.separator = gtk.HBox() self.separator.set_size_request(-1, 1) self.separator.connect("expose-event", self.expose_titlebar_separator) self.v_layout_box.pack_start(self.separator, True, True) # Add drag event box. self.drag_box = EventBox() self.h_layout_box.pack_start(self.drag_box, True, True) # Init left box to contain icon and title. self.left_box = gtk.HBox() self.drag_box.add(self.left_box) if show_title: # Add icon. if icon_dpixbuf != None: self.icon_image_box = ImageBox(icon_dpixbuf) self.icon_align = gtk.Alignment() self.icon_align.set(0.5, 0.5, 0.0, 0.0) self.icon_align.set_padding(5, 5, 5, 0) self.icon_align.add(self.icon_image_box) self.left_box.pack_start(self.icon_align, False, False) # Add app name. if app_name != None: self.app_name_box = Label(app_name, enable_gaussian=True) self.app_name_align = gtk.Alignment() self.app_name_align.set(0.5, 0.5, 0.0, 0.0) self.app_name_align.set_padding(2, 0, 5, 0) self.app_name_align.add(self.app_name_box) self.left_box.pack_start(self.app_name_align, False, False) # Add title. if title != None: self.title_box = Label(title, enable_gaussian=True, text_x_align=pango.ALIGN_CENTER) self.title_align = gtk.Alignment() self.title_align.set(0.5, 0.5, 0.0, 0.0) self.title_align.set_padding(2, 0, 30, 30) self.title_align.add(self.title_box) self.left_box.pack_start(self.title_align, True, True) # Add button box. self.button_box = gtk.HBox() self.button_align = gtk.Alignment() self.button_align.set(1.0, 0.0, 0.0, 0.0) self.button_align.set_padding(0, 0, 0, 0) self.button_align.add(self.button_box) self.h_layout_box.pack_start(self.button_align, False, False) # Add theme button. if "theme" in button_mask: self.theme_button = ThemeButton() self.button_box.pack_start(self.theme_button, False, False, 1) Tooltip.text(self.theme_button, _("Change skin")).show_delay(self.theme_button, 2000) # Add menu button. if "menu" in button_mask: self.menu_button = MenuButton() self.button_box.pack_start(self.menu_button, False, False, 1) Tooltip.text(self.menu_button, _("Main menu")).show_delay(self.menu_button, 2000) # Add min button. if "min" in button_mask: self.min_button = MinButton() self.button_box.pack_start(self.min_button, False, False, 1) Tooltip.text(self.min_button, _("Minimum")).show_delay(self.min_button, 2000) # Add max button. if "max" in button_mask: self.max_button = MaxButton() self.button_box.pack_start(self.max_button, False, False, 1) Tooltip.text(self.max_button, _("Maximize")).show_delay(self.max_button, 2000) # Add close button. if "close" in button_mask: self.close_button = CloseButton() self.button_box.pack_start(self.close_button, False, False) Tooltip.text(self.close_button, _("Close")).show_delay(self.close_button, 2000) # Show. self.show_all()