def __init__(self, parent, auth_event): self.__auth_event = auth_event builder = Gtk.Builder() builder.add_from_file(FileCatalog.get_elsaclipper_glade()) self.__dialog = builder.get_object("SettingLogDialog") self.__dialog.set_icon_from_file(FileCatalog.get_elsaclipper_icon('elsaclipper_config.png')) self.__dialog.show_all() self.__radiobutton_yinxiang = builder.get_object(SettingDialog.UI_RADIOBUTTON_YINXIANG) self.__radiobutton_evernote_international = builder.get_object(SettingDialog.UI_RADIOBUTTON_EVERNOTE_INTERNATIONAL) if MetaData.get_evernote_host() == MetaData.VAL_Evernote_HOST_Yinxiang: self.__radiobutton_yinxiang.set_active(True) else: self.__radiobutton_evernote_international.set_active(True) # self.__notebook_selecter = builder.get_object(SettingDialog.UI_NOTEBOOK_SELECTER) # self.__notebook_selecter_changed_times = 0 # self.__notebook_spinner = builder.get_object(SettingDialog.UI_NOTEBOOK_SPINNER) # self.__notebook_spinner.start() # self.__notebook_image = builder.get_object(SettingDialog.UI_NOTEBOOK_IMAGE) # self.__notebook_image.hide() self.__auth_status_image = builder.get_object(SettingDialog.UI_AUTH_STATUS_IMAGE) self.__auth_status_spinner = builder.get_object(SettingDialog.UI_AUTH_STATUS_SPINNER) self.__auth_status_spinner.hide() # self.__notebook_updater = None self.__shortcut_text_entry = builder.get_object(SettingDialog.UI_SHORTCUT_ENTRY) self.__shortcut_text_entry.set_text(MetaData.get_snapshoot_shortcut_value()) self.__shortcut_alt_check_box = builder.get_object(SettingDialog.UI_SHORTCUT_ALT_CHECK) self.__shortcut_alt_check_box.set_active(MetaData.get_snapshoot_shortcut_alt_modifier()) builder.connect_signals( { "on_close_button_clicked" : self.on_close_button_clicked, 'on_authorize_button_clicked': self.on_authorize_button_clicked_cb, 'on_shortcut_entry_changed': self.on_shortcut_entry_changed, 'on_alt_check_toggled': self.on_alt_check_toggled, 'on_account_type_changed':self.on_account_type_changed } ) self.__authorize_button = builder.get_object(SettingDialog.UI_OBJECT_AUTH_BUTTON) authToken = KeyRing.get_auth_token() logging.debug('auth token = %s' % authToken) if authToken is None or authToken=='': self.__authorize_button.set_label(SettingDialog.BUTTON_LABLE_AUTHORIZE) self.__auth_status_image.set_from_icon_name('dialog-warning',Gtk.IconSize.BUTTON) # self.__notebook_image.set_from_icon_name('dialog-warning',Gtk.IconSize.BUTTON) # self.__notebook_image.show() # self.__notebook_spinner.hide() else: self.__authorize_button.set_label(SettingDialog.BUTTON_LABLE_UNAUTHORIZE) self.__auth_status_image.set_from_icon_name('dialog-ok',Gtk.IconSize.BUTTON)
def change_state(self, state): cls = self.__class__ if state == cls.STATE_NORMAL: logging.debug("State change to STATE_NORMAL") self.__ind.set_icon(cls.PNG_MAIN_ICON) self.__error_item.hide() elif state == cls.STATE_UPLADING: logging.debug("State change to STATE_UPLADING") self.__ind.set_icon(cls.PNG_MAIN_ICON_UPLOAD) self.__error_item.hide() elif state == cls.STATE_NOTAUTHED: logging.debug("State change to STATE_NOTAUTHED") self.__ind.set_icon(cls.PNG_MAIN_ICON_ERROR) self.show_error_message(cls.ERROR_MSG_NOTAUTHED) # self.error_info_item.set_label(cls.ERROR_MSG_NOTAUTHED) Notify.Notification.new( cls.ERROR_MSG_FAILED_SAVING, cls.ERROR_MSG_NOTAUTHED, FileCatalog.get_elsaclipper_icon( 'elseclipper_alert_icon.png')).show() elif state == cls.STATE_NOTEBOOK_DELETED: logging.debug("State change to STATE_NOTEBOOK_DELETED") self.__ind.set_icon(cls.PNG_MAIN_ICON_ERROR) self.show_error_message(cls.ERROR_MSG_NOTEBOOK_DELETED % (EvernoteAdapter.get_notebook_name())) # self.error_info_item.set_label('sdfsd') # self.error_info_item.set_label( # cls.ERROR_MSG_NOTEBOOK_DELETED % (EvernoteAdapter.get_notebook_name()) # ) Notify.Notification.new( cls.ERROR_MSG_FAILED_SAVING, cls.ERROR_MSG_NOTEBOOK_DELETED % (EvernoteAdapter.get_notebook_name()), FileCatalog.get_elsaclipper_icon( 'elseclipper_alert_icon.png')).show() KeyRing.set_auth_token('') elif state == cls.STATE_AUTH_EXPIRED: logging.debug("State change to STATE_AUTH_EXPIRED") self.__ind.set_icon(cls.PNG_MAIN_ICON_ERROR) self.show_error_message(cls.ERROR_MSG_AUTH_EXPIRED) Notify.Notification.new( cls.ERROR_MSG_AUTH_EXPIRED, '', FileCatalog.get_elsaclipper_icon( 'elseclipper_alert_icon.png')).show() KeyRing.set_auth_token('')
def run(self,): self.__status_icon.change_state(StatusIcon.STATE_NORMAL) NoteListenerThread.start() while True: filename = self.status_queue.get() if type(filename) is str: # logging.debug(str(filename)) if not EvernoteAdapter.auth_OK(): login_res = EvernoteAdapter.login() while login_res!=EvernoteAdapter.STATUS_LOGIN_OK: if login_res == EvernoteAdapter.STATUS_LOGIN_AUTH_EXPIRED: self.__status_icon.change_state(StatusIcon.STATE_AUTH_EXPIRED) elif login_res == EvernoteAdapter.STATUS_LOGIN_NO_AUTH_TOKEN: self.__status_icon.change_state(StatusIcon.STATE_NOTAUTHED) elif login_res == EvernoteAdapter.STATE_NOTEBOOK_DELETED: self.__status_icon.change_state(StatusIcon.STATE_NOTEBOOK_DELETED) self.__auth_event.clear() self.__auth_event.wait() if not NoteListenerThread.is_running(): return login_res = EvernoteAdapter.login() # self.__status_icon.change_state(StatusIcon.STATE_NOTAUTHED) # # self.__indicator.set_icon(StatusIcon.PNG_MAIN_ICON_ERROR) # self.__auth_event.clear() # self.__auth_event.wait() # if not NoteListenerThread.is_running(): # return # logging.debug('Trying login') # EvernoteAdapter.login() self.__status_icon.change_state(StatusIcon.STATE_UPLADING) # self.__indicator.set_icon(StatusIcon.PNG_MAIN_ICON_UPLOAD) while True: ret = EvernoteAdapter.savePicture(filename) if ret == EvernoteAdapter.STATUS_SAVE_OK : self.__status_icon.change_state(StatusIcon.STATE_NORMAL) time_str = time.ctime(os.path.getmtime(filename)) Notify.Notification.new('Snapshoot saved to Evernote',time_str, FileCatalog.get_elsaclipper_icon('elseclipper_save_icon.png') ).show() os.remove(filename) break elif ret == EvernoteAdapter.STATUS_SAVE_ERROR_NOTEBOOK_DELETED: self.__status_icon.change_state(StatusIcon.STATE_NOTEBOOK_DELETED) self.__auth_event.clear() self.__auth_event.wait() if not NoteListenerThread.is_running(): return logging.debug('Trying login') EvernoteAdapter.login() else: break pass
def change_state(self,state): cls = self.__class__ if state == cls.STATE_NORMAL: logging.debug("State change to STATE_NORMAL") self.__ind.set_icon(cls.PNG_MAIN_ICON) self.__error_item.hide() elif state == cls.STATE_UPLADING: logging.debug("State change to STATE_UPLADING") self.__ind.set_icon(cls.PNG_MAIN_ICON_UPLOAD) self.__error_item.hide() elif state == cls.STATE_NOTAUTHED: logging.debug("State change to STATE_NOTAUTHED") self.__ind.set_icon(cls.PNG_MAIN_ICON_ERROR) self.show_error_message(cls.ERROR_MSG_NOTAUTHED) # self.error_info_item.set_label(cls.ERROR_MSG_NOTAUTHED) Notify.Notification.new(cls.ERROR_MSG_FAILED_SAVING, cls.ERROR_MSG_NOTAUTHED, FileCatalog.get_elsaclipper_icon('elseclipper_alert_icon.png') ).show() elif state == cls.STATE_NOTEBOOK_DELETED: logging.debug("State change to STATE_NOTEBOOK_DELETED") self.__ind.set_icon(cls.PNG_MAIN_ICON_ERROR) self.show_error_message(cls.ERROR_MSG_NOTEBOOK_DELETED % (EvernoteAdapter.get_notebook_name())) # self.error_info_item.set_label('sdfsd') # self.error_info_item.set_label( # cls.ERROR_MSG_NOTEBOOK_DELETED % (EvernoteAdapter.get_notebook_name()) # ) Notify.Notification.new(cls.ERROR_MSG_FAILED_SAVING, cls.ERROR_MSG_NOTEBOOK_DELETED % (EvernoteAdapter.get_notebook_name()), FileCatalog.get_elsaclipper_icon('elseclipper_alert_icon.png') ).show() KeyRing.set_auth_token('') elif state==cls.STATE_AUTH_EXPIRED: logging.debug("State change to STATE_AUTH_EXPIRED") self.__ind.set_icon(cls.PNG_MAIN_ICON_ERROR) self.show_error_message(cls.ERROR_MSG_AUTH_EXPIRED) Notify.Notification.new(cls.ERROR_MSG_AUTH_EXPIRED, '', FileCatalog.get_elsaclipper_icon('elseclipper_alert_icon.png') ).show() KeyRing.set_auth_token('')
def __init__(self, ): self.__auth_token = None self.__authData = {} builder = Gtk.Builder() builder.add_from_file(FileCatalog.get_elsaclipper_glade()) self.__dialog = builder.get_object('auth_dialog') self.__dialog.set_icon_from_file(FileCatalog.get_elsaclipper_icon('elsaclipper_config.png')) self.__spinner = builder.get_object('connecting_spinner') self.__status_label = builder.get_object('connecting_label') self.__status_label.set_text(AuthDialog.STATUS_MESSAGE_CONNECTING) webview = WebKit.WebView() webview.connect("navigation-requested",self.on_navigation_requested) webview.connect("notify::load-status",self.on_load_status) url = self._getEverNoteOAuthURL() logging.debug(url) webview.open(url) viewport = builder.get_object('webkit_viewport') viewport.add(webview) self.__dialog.show_all()
def __init__(self, ): self.__auth_token = None self.__authData = {} builder = Gtk.Builder() builder.add_from_file(FileCatalog.get_elsaclipper_glade()) self.__dialog = builder.get_object('auth_dialog') self.__dialog.set_icon_from_file( FileCatalog.get_elsaclipper_icon('elsaclipper_config.png')) self.__spinner = builder.get_object('connecting_spinner') self.__status_label = builder.get_object('connecting_label') self.__status_label.set_text(AuthDialog.STATUS_MESSAGE_CONNECTING) webview = WebKit.WebView() webview.connect("navigation-requested", self.on_navigation_requested) webview.connect("notify::load-status", self.on_load_status) url = self._getEverNoteOAuthURL() logging.debug(url) webview.open(url) viewport = builder.get_object('webkit_viewport') viewport.add(webview) self.__dialog.show_all()
def run(self, ): self.__status_icon.change_state(StatusIcon.STATE_NORMAL) NoteListenerThread.start() while True: filename = self.status_queue.get() if type(filename) is str: # logging.debug(str(filename)) if not EvernoteAdapter.auth_OK(): login_res = EvernoteAdapter.login() while login_res != EvernoteAdapter.STATUS_LOGIN_OK: if login_res == EvernoteAdapter.STATUS_LOGIN_AUTH_EXPIRED: self.__status_icon.change_state( StatusIcon.STATE_AUTH_EXPIRED) elif login_res == EvernoteAdapter.STATUS_LOGIN_NO_AUTH_TOKEN: self.__status_icon.change_state( StatusIcon.STATE_NOTAUTHED) elif login_res == EvernoteAdapter.STATE_NOTEBOOK_DELETED: self.__status_icon.change_state( StatusIcon.STATE_NOTEBOOK_DELETED) self.__auth_event.clear() self.__auth_event.wait() if not NoteListenerThread.is_running(): return login_res = EvernoteAdapter.login() # self.__status_icon.change_state(StatusIcon.STATE_NOTAUTHED) # # self.__indicator.set_icon(StatusIcon.PNG_MAIN_ICON_ERROR) # self.__auth_event.clear() # self.__auth_event.wait() # if not NoteListenerThread.is_running(): # return # logging.debug('Trying login') # EvernoteAdapter.login() self.__status_icon.change_state(StatusIcon.STATE_UPLADING) # self.__indicator.set_icon(StatusIcon.PNG_MAIN_ICON_UPLOAD) while True: ret = EvernoteAdapter.savePicture(filename) if ret == EvernoteAdapter.STATUS_SAVE_OK: self.__status_icon.change_state( StatusIcon.STATE_NORMAL) time_str = time.ctime(os.path.getmtime(filename)) Notify.Notification.new( 'Snapshoot saved to Evernote', time_str, FileCatalog.get_elsaclipper_icon( 'elseclipper_save_icon.png')).show() os.remove(filename) break elif ret == EvernoteAdapter.STATUS_SAVE_ERROR_NOTEBOOK_DELETED: self.__status_icon.change_state( StatusIcon.STATE_NOTEBOOK_DELETED) self.__auth_event.clear() self.__auth_event.wait() if not NoteListenerThread.is_running(): return logging.debug('Trying login') EvernoteAdapter.login() else: break pass
class StatusIcon: PNG_MAIN_ICON = FileCatalog.get_elsaclipper_icon( 'elsaclipper_main_icon.png' ) # root.get_full_path('evernote_adapter','icon','main_icon.png') PNG_MAIN_ICON_UPLOAD = FileCatalog.get_elsaclipper_icon( 'elsaclipper_main_icon_upload.png' ) #root.get_full_path('evernote_adapter','icon','main_icon_upload.png') PNG_MAIN_ICON_ERROR = FileCatalog.get_elsaclipper_icon( 'elsaclipper_main_icon_error.png' ) # root.get_full_path('evernote_adapter','icon','main_icon_error.png') class NoteListenerManagerThread(threading.Thread): def __init__(self, status_icon, auth_event): threading.Thread.__init__(self) self.status_queue = Queue() NoteListenerThread.init(self.status_queue) Notify.init(__file__) self.__status_icon = status_icon self.__auth_event = auth_event def run(self, ): self.__status_icon.change_state(StatusIcon.STATE_NORMAL) NoteListenerThread.start() while True: filename = self.status_queue.get() if type(filename) is str: # logging.debug(str(filename)) if not EvernoteAdapter.auth_OK(): login_res = EvernoteAdapter.login() while login_res != EvernoteAdapter.STATUS_LOGIN_OK: if login_res == EvernoteAdapter.STATUS_LOGIN_AUTH_EXPIRED: self.__status_icon.change_state( StatusIcon.STATE_AUTH_EXPIRED) elif login_res == EvernoteAdapter.STATUS_LOGIN_NO_AUTH_TOKEN: self.__status_icon.change_state( StatusIcon.STATE_NOTAUTHED) elif login_res == EvernoteAdapter.STATE_NOTEBOOK_DELETED: self.__status_icon.change_state( StatusIcon.STATE_NOTEBOOK_DELETED) self.__auth_event.clear() self.__auth_event.wait() if not NoteListenerThread.is_running(): return login_res = EvernoteAdapter.login() # self.__status_icon.change_state(StatusIcon.STATE_NOTAUTHED) # # self.__indicator.set_icon(StatusIcon.PNG_MAIN_ICON_ERROR) # self.__auth_event.clear() # self.__auth_event.wait() # if not NoteListenerThread.is_running(): # return # logging.debug('Trying login') # EvernoteAdapter.login() self.__status_icon.change_state(StatusIcon.STATE_UPLADING) # self.__indicator.set_icon(StatusIcon.PNG_MAIN_ICON_UPLOAD) while True: ret = EvernoteAdapter.savePicture(filename) if ret == EvernoteAdapter.STATUS_SAVE_OK: self.__status_icon.change_state( StatusIcon.STATE_NORMAL) time_str = time.ctime(os.path.getmtime(filename)) Notify.Notification.new( 'Snapshoot saved to Evernote', time_str, FileCatalog.get_elsaclipper_icon( 'elseclipper_save_icon.png')).show() os.remove(filename) break elif ret == EvernoteAdapter.STATUS_SAVE_ERROR_NOTEBOOK_DELETED: self.__status_icon.change_state( StatusIcon.STATE_NOTEBOOK_DELETED) self.__auth_event.clear() self.__auth_event.wait() if not NoteListenerThread.is_running(): return logging.debug('Trying login') EvernoteAdapter.login() else: break pass def stop(self, ): NoteListenerThread.stop() self.__auth_event.set() STATE_NORMAL = 0 STATE_UPLADING = 1 STATE_NOTEBOOK_DELETED = 2 STATE_NOTAUTHED = 3 STATE_AUTH_EXPIRED = 4 ERROR_MSG_FAILED_SAVING = 'Failed saving snapshoot to Evernote' ERROR_MSG_NOTAUTHED = 'Authorization is needed before uploading any screenshot.' ERROR_MSG_NOTEBOOK_DELETED = 'Notebook %s is deleted, please authorize again' ERROR_MSG_AUTH_EXPIRED = 'Authorization expired, please authorize again' def __init__(self, ): self.__ind = AppIndicator.Indicator.new( "elsaclipper-indicator", "indicator-messages", AppIndicator.IndicatorCategory.APPLICATION_STATUS) self.__ind.set_status(AppIndicator.IndicatorStatus.ACTIVE) self.__ind.set_icon(StatusIcon.PNG_MAIN_ICON) menu = Gtk.Menu() # setting menu setting_item = Gtk.MenuItem("Setting") setting_item.connect("activate", self.on_setting) setting_item.show() menu.append(setting_item) # error message menu self.__error_item = Gtk.MenuItem("Error message") self.__error_item.hide() menu.append(self.__error_item) # quit menu quit_item = Gtk.MenuItem("Quit") quit_item.connect("activate", self.on_quit) quit_item.show() menu.append(quit_item) menu.set_has_tooltip(True) menu.set_tooltip_text("Make screenshot and save to Evernote") menu.trigger_tooltip_query() self.__ind.set_menu(menu) self.__auth_event = threading.Event() self.__note_listener_manager = StatusIcon.NoteListenerManagerThread( self, self.__auth_event) self.__note_listener_manager.start() def show_error_message(self, msg): menu_sub = Gtk.Menu() error_info_item = Gtk.MenuItem(msg) error_info_item.show() menu_sub.append(error_info_item) self.__error_item.set_submenu(menu_sub) self.__error_item.show() def change_state(self, state): cls = self.__class__ if state == cls.STATE_NORMAL: logging.debug("State change to STATE_NORMAL") self.__ind.set_icon(cls.PNG_MAIN_ICON) self.__error_item.hide() elif state == cls.STATE_UPLADING: logging.debug("State change to STATE_UPLADING") self.__ind.set_icon(cls.PNG_MAIN_ICON_UPLOAD) self.__error_item.hide() elif state == cls.STATE_NOTAUTHED: logging.debug("State change to STATE_NOTAUTHED") self.__ind.set_icon(cls.PNG_MAIN_ICON_ERROR) self.show_error_message(cls.ERROR_MSG_NOTAUTHED) # self.error_info_item.set_label(cls.ERROR_MSG_NOTAUTHED) Notify.Notification.new( cls.ERROR_MSG_FAILED_SAVING, cls.ERROR_MSG_NOTAUTHED, FileCatalog.get_elsaclipper_icon( 'elseclipper_alert_icon.png')).show() elif state == cls.STATE_NOTEBOOK_DELETED: logging.debug("State change to STATE_NOTEBOOK_DELETED") self.__ind.set_icon(cls.PNG_MAIN_ICON_ERROR) self.show_error_message(cls.ERROR_MSG_NOTEBOOK_DELETED % (EvernoteAdapter.get_notebook_name())) # self.error_info_item.set_label('sdfsd') # self.error_info_item.set_label( # cls.ERROR_MSG_NOTEBOOK_DELETED % (EvernoteAdapter.get_notebook_name()) # ) Notify.Notification.new( cls.ERROR_MSG_FAILED_SAVING, cls.ERROR_MSG_NOTEBOOK_DELETED % (EvernoteAdapter.get_notebook_name()), FileCatalog.get_elsaclipper_icon( 'elseclipper_alert_icon.png')).show() KeyRing.set_auth_token('') elif state == cls.STATE_AUTH_EXPIRED: logging.debug("State change to STATE_AUTH_EXPIRED") self.__ind.set_icon(cls.PNG_MAIN_ICON_ERROR) self.show_error_message(cls.ERROR_MSG_AUTH_EXPIRED) Notify.Notification.new( cls.ERROR_MSG_AUTH_EXPIRED, '', FileCatalog.get_elsaclipper_icon( 'elseclipper_alert_icon.png')).show() KeyRing.set_auth_token('') def show_error(self, message): self.error_info_item.set_label(message) self.__error_item.show() def hide_error(self): self.__error_item.hide() def on_setting(self, widget): settingDtalog = SettingDialog(widget, self.__auth_event) settingDtalog.run() settingDtalog.destroy() def on_quit(self, widget): self.__note_listener_manager.stop() Gtk.main_quit(widget) sys.exit()
def __init__(self, parent, auth_event): self.__auth_event = auth_event builder = Gtk.Builder() builder.add_from_file(FileCatalog.get_elsaclipper_glade()) self.__dialog = builder.get_object("SettingLogDialog") self.__dialog.set_icon_from_file( FileCatalog.get_elsaclipper_icon('elsaclipper_config.png')) self.__dialog.show_all() self.__radiobutton_yinxiang = builder.get_object( SettingDialog.UI_RADIOBUTTON_YINXIANG) self.__radiobutton_evernote_international = builder.get_object( SettingDialog.UI_RADIOBUTTON_EVERNOTE_INTERNATIONAL) if MetaData.get_evernote_host() == MetaData.VAL_Evernote_HOST_Yinxiang: self.__radiobutton_yinxiang.set_active(True) else: self.__radiobutton_evernote_international.set_active(True) # self.__notebook_selecter = builder.get_object(SettingDialog.UI_NOTEBOOK_SELECTER) # self.__notebook_selecter_changed_times = 0 # self.__notebook_spinner = builder.get_object(SettingDialog.UI_NOTEBOOK_SPINNER) # self.__notebook_spinner.start() # self.__notebook_image = builder.get_object(SettingDialog.UI_NOTEBOOK_IMAGE) # self.__notebook_image.hide() self.__auth_status_image = builder.get_object( SettingDialog.UI_AUTH_STATUS_IMAGE) self.__auth_status_spinner = builder.get_object( SettingDialog.UI_AUTH_STATUS_SPINNER) self.__auth_status_spinner.hide() # self.__notebook_updater = None self.__shortcut_text_entry = builder.get_object( SettingDialog.UI_SHORTCUT_ENTRY) self.__shortcut_text_entry.set_text( MetaData.get_snapshoot_shortcut_value()) self.__shortcut_alt_check_box = builder.get_object( SettingDialog.UI_SHORTCUT_ALT_CHECK) self.__shortcut_alt_check_box.set_active( MetaData.get_snapshoot_shortcut_alt_modifier()) builder.connect_signals({ "on_close_button_clicked": self.on_close_button_clicked, 'on_authorize_button_clicked': self.on_authorize_button_clicked_cb, 'on_shortcut_entry_changed': self.on_shortcut_entry_changed, 'on_alt_check_toggled': self.on_alt_check_toggled, 'on_account_type_changed': self.on_account_type_changed }) self.__authorize_button = builder.get_object( SettingDialog.UI_OBJECT_AUTH_BUTTON) authToken = KeyRing.get_auth_token() logging.debug('auth token = %s' % authToken) if authToken is None or authToken == '': self.__authorize_button.set_label( SettingDialog.BUTTON_LABLE_AUTHORIZE) self.__auth_status_image.set_from_icon_name( 'dialog-warning', Gtk.IconSize.BUTTON) # self.__notebook_image.set_from_icon_name('dialog-warning',Gtk.IconSize.BUTTON) # self.__notebook_image.show() # self.__notebook_spinner.hide() else: self.__authorize_button.set_label( SettingDialog.BUTTON_LABLE_UNAUTHORIZE) self.__auth_status_image.set_from_icon_name( 'dialog-ok', Gtk.IconSize.BUTTON)
# 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 gettext import locale from comm.file_catalog import FileCatalog DEFAULT_LANG = None #DEFAULT_LANG = "default" #DEFAULT_LANG = "zh_CN" #DEFAULT_LANG = "zh_TW" if DEFAULT_LANG == None: (lang, _) = locale.getdefaultlocale() if lang in ["zh_CN", "zh_TW"]: __ = gettext.translation('deepin-scrot', FileCatalog.get_locale_path(), languages=[lang]).gettext else: __ = gettext.translation('deepin-scrot', FileCatalog.get_locale_path(), languages=["en_US"]).gettext else: __ = gettext.translation('deepin-scrot', FileCatalog.get_locale_path(), languages=[DEFAULT_LANG]).gettext
def getThemeDir(self): '''Get theme directory.''' return FileCatalog.get_theme_path(self.themeName)
# 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 gettext import locale from comm.file_catalog import FileCatalog DEFAULT_LANG = None #DEFAULT_LANG = "default" #DEFAULT_LANG = "zh_CN" #DEFAULT_LANG = "zh_TW" if DEFAULT_LANG == None: (lang, _) = locale.getdefaultlocale() if lang in ["zh_CN", "zh_TW"]: __ = gettext.translation('deepin-scrot', FileCatalog.get_locale_path() , languages=[lang]).gettext else: __ = gettext.translation('deepin-scrot', FileCatalog.get_locale_path() , languages=["en_US"]).gettext else: __ = gettext.translation('deepin-scrot', FileCatalog.get_locale_path(), languages=[DEFAULT_LANG]).gettext