def __init__(self, base): QWidget.__init__(self) self.base = base self.showed = False self.setFixedSize(500, 120) self.text_edit = CompletionTextEdit() self.upload_button = ImageButton(base, 'action-upload.png', i18n.get('upload_image')) self.short_button = ImageButton(base, 'action-shorten.png', i18n.get('short_urls')) font = QFont() font.setPointSize(18) font.setBold(True) self.char_count = QLabel('140') self.char_count.setFont(font) self.update_button = QPushButton(i18n.get('update')) self.update_button.setToolTip(self.base.get_shortcut_string('Enter')) self.queue_button = QPushButton(i18n.get('add_to_queue')) self.queue_button.setToolTip(self.base.get_shortcut_string('P')) self.accounts_combo = QComboBox() buttons = QHBoxLayout() buttons.setSpacing(4) buttons.addWidget(self.accounts_combo) buttons.addWidget(self.upload_button) buttons.addWidget(self.short_button) buttons.addStretch(0) buttons.addWidget(self.char_count) buttons.addWidget(self.queue_button) buttons.addWidget(self.update_button) self.loader = BarLoadIndicator() self.error_message = ErrorLabel() self.update_button.clicked.connect(self.__update_status) self.queue_button.clicked.connect(self.__queue_status) self.short_button.clicked.connect(self.__short_urls) self.upload_button.clicked.connect(self.__upload_image) self.text_edit.textChanged.connect(self.__update_count) self.text_edit.quit.connect(self.closeEvent) self.text_edit.activated.connect(self.__update_status) self.text_edit.enqueued.connect(self.__queue_status) layout = QVBoxLayout() layout.setSpacing(0) layout.addWidget(self.text_edit) layout.addWidget(self.loader) layout.addSpacing(5) layout.addWidget(self.error_message) layout.addLayout(buttons) layout.setContentsMargins(5, 5, 5, 5) self.setLayout(layout) self.__clear()
def update(self): if self.showed: self.model.clear() empty = True self.btn_login.set_sensitive(False) self.btn_delete.set_sensitive(False) for acc in self.base.get_all_accounts(): empty = False imagename = "%s.png" % acc.protocol_id pix = self.base.load_image(imagename, True) username = "******" % acc.username status = "" status_pix = None if acc.logged_in == LoginStatus.NONE: status = i18n.get("disconnected") status_pix = self.base.load_image("mark-disconnected.png", True) elif acc.logged_in == LoginStatus.IN_PROGRESS: status = i18n.get("connecting...") status_pix = self.base.load_image("mark-connecting.png", True) elif acc.logged_in == LoginStatus.DONE: status = i18n.get("connected") status_pix = self.base.load_image("mark-connected.png", True) self.model.append([pix, username, status_pix, status, acc]) del pix del status_pix if empty: self.btn_login.set_label(i18n.get("login")) else: self.acc_list.set_cursor((0,))
def __repeat_status(self, status): confirmation = self.base.show_confirmation_message( i18n.get('confirm_retweet'), i18n.get('do_you_want_to_retweet_status')) if confirmation: self.lock_status(status.id_) self.base.repeat_status(self.id_, self.account_id, status)
def __login_action_tag(self, account): if account.logged_in == LoginStatus.NONE: return "<a href='cmd:login:%s'>%s</a>" % (account.id_, i18n.get('login')) elif account.logged_in == LoginStatus.IN_PROGRESS: return "<span class=\"progress\">%s</span>" % (i18n.get('in_progress')) elif account.logged_in == LoginStatus.DONE: return "<span class=\"done\">%s</span>" % (i18n.get('logged_in'))
def __init__(self, base, url): QDialog.__init__(self) self.base = base self.setWindowTitle(i18n.get('authorize_turpial')) self.resize(800, 550) self.setModal(True) self.webview = QWebView() qurl = QUrl(url) self.webview.setUrl(qurl) message = QLabel(i18n.get('copy_the_pin')) #message.setAlignment(Qt.AlignRight) self.pin = QLineEdit() self.pin.setPlaceholderText(i18n.get('type_the_pin')) authorize_btn = QPushButton(i18n.get('save')) authorize_btn.clicked.connect(self.accept) widgets_box = QHBoxLayout() widgets_box.setSpacing(3) widgets_box.setContentsMargins(3, 3, 3, 3) widgets_box.addWidget(message, 1) widgets_box.addWidget(self.pin) widgets_box.addWidget(authorize_btn) layout = QVBoxLayout() layout.addWidget(self.webview) layout.addLayout(widgets_box) layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout) self.exec_()
def empty(self): if self.child: self.remove(self.child) placeholder = Gtk.Image() image = Gtk.Image() image.set_from_pixbuf(self.base.load_image('logo.png', True)) welcome = Gtk.Label() welcome.set_use_markup(True) welcome.set_markup('<b>' + i18n.get('welcome') + '</b>') no_accounts = Gtk.Label() no_accounts.set_use_markup(True) no_accounts.set_line_wrap(True) no_accounts.set_justify(Gtk.Justification.CENTER) if len(self.base.get_accounts_list()) > 0: no_accounts.set_markup(i18n.get('no_registered_columns')) else: no_accounts.set_markup(i18n.get('no_active_accounts')) self.child = Gtk.VBox() self.child.pack_start(placeholder, False, False, 40) self.child.pack_start(image, False, False, 20) self.child.pack_start(welcome, False, False, 10) self.child.pack_start(no_accounts, False, False, 0) self.add(self.child) self.show_all()
def update_statuses(self, statuses): statuses_ = statuses[:] content = '' current_page = self.page().currentFrame().toHtml() if current_page == self.EMPTY_PAGE: for status in statuses_: content += self.__render_status(status) column = self.__load_template('column.html') args = { 'stylesheet': self.stylesheet, 'content': content, 'favorite_tooltip': i18n.get('mark_as_favorite'), 'unfavorite_tooltip': i18n.get('remove_from_favorites') } html = column.render(args) fd = open('/tmp/turpial-debug.html', 'w') fd.write(html.encode('ascii', 'ignore')) fd.close() self.setHtml(html) else: statuses_.reverse() for status in statuses_: content = self.__render_status(status) self.append_status(content, status.id_)
def __init__(self, base): Window.__init__(self, base, i18n.get('image_preview')) self.loader = BarLoadIndicator() self.view = QLabel() self.view.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored) self.view.setScaledContents(True) scroll_area = QScrollArea() scroll_area.setBackgroundRole(QPalette.Dark) scroll_area.setWidget(self.view) scroll_area.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) scroll_area.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.error_label = QLabel(i18n.get('error_loading_image')) self.error_label.setAlignment(Qt.AlignHCenter) self.error_label.setStyleSheet("QLabel {background-color: #ffecec;}") layout = QVBoxLayout() layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.loader) layout.addWidget(self.error_label) layout.addWidget(scroll_area) self.setLayout(layout) self.__clear()
def __init__(self, base): ModalDialog.__init__(self, 320, 250) self.setWindowTitle(i18n.get('about_turpial')) icon = QLabel() icon.setPixmap(base.load_image('turpial.png', True)) icon.setAlignment(Qt.AlignCenter) app_name = QLabel("<b>Turpial %s</b>" % VERSION) app_name.setAlignment(Qt.AlignCenter) app_description = QLabel(i18n.get('about_description')) app_description.setAlignment(Qt.AlignCenter) copyright = QLabel('Copyleft (C) 2009 - 2013 Wil Alvarez') copyright.setAlignment(Qt.AlignCenter) close_button = QPushButton(i18n.get('close')) close_button.clicked.connect(self.__on_close) button_box = QHBoxLayout() button_box.addStretch(1) button_box.setSpacing(4) button_box.addWidget(close_button) vbox = QVBoxLayout() vbox.setSpacing(10) vbox.addWidget(icon, 1) vbox.addWidget(app_name) vbox.addWidget(app_description) vbox.addWidget(copyright) vbox.addLayout(button_box) self.setLayout(vbox) self.exec_()
def __repeat_item(self, status): # TODO: Validates if is protected if not status.is_own: if status.get_protocol_id() == ProtocolType.TWITTER: qt = "RT @%s %s" % (status.username, status.text) if status.retweeted: repeat = Gtk.MenuItem(i18n.get('retweeted')) repeat.connect('activate', self.__on_unrepeat, status) else: repeat = Gtk.MenuItem(i18n.get('retweet')) repeat.connect('activate', self.__on_repeat, status) elif status.get_protocol_id() == ProtocolType.IDENTICA: qt = "RD @%s %s" % (status.username, status.text) if status.repeated: repeat = Gtk.MenuItem(i18n.get('redented')) repeat.connect('activate', self.__on_unrepeat, status) else: repeat = Gtk.MenuItem(i18n.get('redent')) repeat.connect('activate', self.__on_repeat, status) quote = Gtk.MenuItem(i18n.get('quote')) quote.connect('activate', self.__on_quote, qt) self.append(repeat) self.append(quote)
def __short_url(self, widget): self.lock(i18n.get('shorting_urls')) message = self.update_text.get_text() if len(message) == 0: self.unlock(i18n.get('no_url_to_short')) else: self.base.autoshort_url(message)
def __show(self): self.update_friends_list() short_service = self.base.get_shorten_url_service() short_tooltip = "%s (%s)" % (i18n.get('short_url'), short_service) self.short_button.setToolTip(short_tooltip) upload_service = self.base.get_upload_media_service() upload_tooltip = "%s (%s)" % (i18n.get('upload_image'), upload_service) self.upload_button.setToolTip(upload_tooltip) self.accounts_combo.clear() accounts = self.base.core.get_registered_accounts() if len(accounts) > 1: self.accounts_combo.addItem('--', '') for account in accounts: protocol = get_protocol_from(account.id_) icon = QIcon(self.base.get_image_path('%s.png' % protocol)) self.accounts_combo.addItem(icon, get_username_from(account.id_), account.id_) if len(accounts) > 1: icon = QIcon(self.base.get_image_path('action-conversation.png')) self.accounts_combo.addItem(icon, i18n.get('broadcast'), 'broadcast') if self.account_id: index = self.accounts_combo.findData(self.account_id) if index > 0: self.accounts_combo.setCurrentIndex(index) self.accounts_combo.setEnabled(False) if self.message: self.text_edit.setText(self.message) cursor = self.text_edit.textCursor() cursor.movePosition(self.cursor_position, QTextCursor.MoveAnchor) self.text_edit.setTextCursor(cursor) QWidget.show(self) self.showed = True
def update(self): if self.showed: self.model.clear() empty = True self.btn_login.set_sensitive(False) self.btn_delete.set_sensitive(False) for acc in self.base.get_all_accounts(): empty = False imagename = "%s.png" % acc.protocol_id pix = self.base.load_image(imagename, True) username = "******" % acc.username status = '' status_pix = None if acc.logged_in == LoginStatus.NONE: status = i18n.get('disconnected') status_pix = self.base.load_image('mark-disconnected.png', True) elif acc.logged_in == LoginStatus.IN_PROGRESS: status = i18n.get('connecting...') status_pix = self.base.load_image('mark-connecting.png', True) elif acc.logged_in == LoginStatus.DONE: status = i18n.get('connected') status_pix = self.base.load_image('mark-connected.png', True) self.model.append([pix, username, status_pix, status, acc]) del pix del status_pix if empty: self.btn_login.set_label(i18n.get('login')) else: self.acc_list.set_cursor((0, ))
def __delete_status(self, status): confirmation = self.base.show_confirmation_message( i18n.get('confirm_delete'), i18n.get('do_you_want_to_delete_status')) if confirmation: self.lock_status(status.id_) self.base.delete_status(self.id_, self.account_id, status)
def updates(self, column, count, filtered=0): if count > 1: message = i18n.get('new_tweets_updated') % count else: message = i18n.get('new_tweet_updated') title = " ".join([i18n.get('updated'), column.slug]) self.notify(title, message)
def __on_config_restore(self): confirmation = self.base.show_confirmation_message( i18n.get("confirm_restore"), i18n.get("do_you_want_to_restore_config") ) if confirmation: self.base.restore_config() self.base.show_information_message(i18n.get("restart_turpial"), i18n.get("config_restored_successfully")) self.base.main_quit()
def __login_action_tag(self, account): if account.logged_in == LoginStatus.NONE: return "<a href='cmd:login:%s'>%s</a>" % (account.id_, i18n.get('login')) elif account.logged_in == LoginStatus.IN_PROGRESS: return "<span class=\"progress\">%s</span>" % ( i18n.get('in_progress')) elif account.logged_in == LoginStatus.DONE: return "<span class=\"done\">%s</span>" % (i18n.get('logged_in'))
def __delete_all(self): self.__disable() message = i18n.get('clear_message_queue_confirm') confirmation = self.base.show_confirmation_message(i18n.get('confirm_delete'), message) if not confirmation: self.__enable() return self.base.clear_queue()
def __init__(self, mainwin, parent, account_id): Gtk.Window.__init__(self) self.account_id = account_id self.mainwin = mainwin self.set_title(i18n.get('secure_auth')) self.set_default_size(800, 550) self.set_transient_for(parent) self.set_modal(True) self.set_position(Gtk.WindowPosition.CENTER_ON_PARENT) self.connect('delete-event', self.__cancel) self.view = HtmlView() self.view.connect('load-started', self.__started) self.view.connect('load-finished', self.__finished) self.label = Gtk.Label() self.label.set_use_markup(True) self.label.set_alignment(0, 0) self.label.set_markup(i18n.get('authorize_turpial')) self.waiting_label = Gtk.Label() self.waiting_label.set_use_markup(True) self.waiting_label.set_alignment(1.0, 0.0) self.spinner = Gtk.Spinner() lblbox = Gtk.HBox(False, 2) lblbox.pack_start(self.label, True, True, 2) lblbox.pack_start(self.waiting_label, True, True, 2) lblbox.pack_start(self.spinner, False, False, 2) self.pin = Gtk.Entry() cancel = Gtk.Button(stock=Gtk.STOCK_CANCEL) cancel.set_size_request(80, 0) accept = Gtk.Button(stock=Gtk.STOCK_OK) accept.set_size_request(80, 0) accept.set_can_default(True) accept.grab_default() hbox = Gtk.HBox(False, 0) hbox.pack_start(self.pin, True, True, 2) hbox.pack_start(cancel, False, False, 2) hbox.pack_start(accept, False, False, 2) vbox = Gtk.VBox(False, 5) vbox.pack_start(self.view, True, True, 0) vbox.pack_start(lblbox, False, False, 2) vbox.pack_start(hbox, False, False, 2) vbox.set_property('margin', 10) self.pin.connect('activate', self.__accept) cancel.connect('clicked', self.__cancel) accept.connect('clicked', self.__accept) self.add(vbox) self.show_all()
def __fav_item(self, status): if status.favorited: unfav = Gtk.MenuItem(i18n.get('favorited')) unfav.connect('activate', self.__on_unfavorite, status) self.append(unfav) else: fav = Gtk.MenuItem(i18n.get('favorite')) fav.connect('activate', self.__on_favorite, status) self.append(fav)
def __delete_all(self): self.__disable() message = i18n.get('clear_message_queue_confirm') confirmation = self.base.show_confirmation_message( i18n.get('confirm_delete'), message) if not confirmation: self.__enable() return self.base.clear_queue()
def __build_common_menu(self): settings = QAction(i18n.get('settings'), self) settings.triggered.connect(self.__settings_clicked) quit = QAction(i18n.get('quit'), self) #FIXME: create a signal for this quit.triggered.connect(self.base.main_quit) self.menu.addAction(settings) self.menu.addSeparator() self.menu.addAction(quit)
def __delete_all(self): self.__enable(False) message = i18n.get('clear_filters_confirm') confirmation = self.base.show_confirmation_message( i18n.get('confirm_delete'), message) if not confirmation: self.__enable(True) return self.list_.clear() self.__save_filters()
def __on_config_restore(self): confirmation = self.base.show_confirmation_message( i18n.get('confirm_restore'), i18n.get('do_you_want_to_restore_config')) if confirmation: self.base.restore_config() self.base.show_information_message( i18n.get('restart_turpial'), i18n.get('config_restored_successfully')) self.base.main_quit()
def __delete_all(self): self.__enable(False) message = i18n.get('clear_filters_confirm') confirmation = self.base.show_confirmation_message(i18n.get('confirm_delete'), message) if not confirmation: self.__enable(True) return self.list_.clear() self.__save_filters()
def __init__(self, base): BasePage.__init__(self, i18n.get('notifications_tab_description')) notify_on_updates = base.core.get_notify_on_updates() notify_on_actions = base.core.get_notify_on_actions() sound_on_login = base.core.get_sound_on_login() sound_on_updates = base.core.get_sound_on_updates() self.notify_on_updates = CheckBox( i18n.get('notify_on_updates'), checked=notify_on_updates, tooltip=i18n.get('notify_on_updates_toolip')) self.notify_on_actions = CheckBox( i18n.get('notify_on_actions'), checked=notify_on_actions, tooltip=i18n.get('notify_on_actions_toolip')) self.sound_on_login = CheckBox( i18n.get('sound_on_login'), checked=sound_on_login, tooltip=i18n.get('sound_on_login_tooltip')) self.sound_on_updates = CheckBox( i18n.get('sound_on_updates'), checked=sound_on_updates, tooltip=i18n.get('sound_on_updates_tooltip')) self.layout.addWidget(self.notify_on_updates) self.layout.addWidget(self.notify_on_actions) self.layout.addSpacing(15) self.layout.addWidget(self.sound_on_login) self.layout.addWidget(self.sound_on_updates) self.layout.addStretch(1)
def __init__(self, base): BasePage.__init__(self, i18n.get('advanced_tab_description')) self.base = base socket_timeout = base.core.get_socket_timeout() show_avatars = base.core.get_show_user_avatars() clean_cache_caption = "%s\n(%s)" % ( i18n.get('delete_all_files_in_cache'), base.get_cache_size()) self.clean_cache = PushButton(clean_cache_caption, i18n.get('clean_cache')) self.clean_cache.clicked.connect(self.__on_clean_cache) self.restore_config = PushButton(i18n.get('restore_config_to_default'), i18n.get('restore_config')) self.restore_config.clicked.connect(self.__on_config_restore) self.socket_timeout = Slider( i18n.get('socket_timeout'), default_value=socket_timeout, minimum_value=5, maximum_value=120, unit='sec', tooltip=i18n.get('socket_timeout_tooltip')) self.show_avatars = CheckBox(i18n.get('show_avatars'), checked=show_avatars, tooltip=i18n.get('show_avatars_tooltip')) self.layout.addWidget(self.clean_cache) self.layout.addWidget(self.restore_config) self.layout.addSpacing(15) self.layout.addWidget(self.socket_timeout) self.layout.addSpacing(10) self.layout.addWidget(self.show_avatars) self.layout.addStretch(1)
def __init__(self, base): BasePage.__init__(self, i18n.get("notifications_tab_description")) notify_on_updates = base.core.get_notify_on_updates() notify_on_actions = base.core.get_notify_on_actions() sound_on_login = base.core.get_sound_on_login() sound_on_updates = base.core.get_sound_on_updates() self.notify_on_updates = CheckBox( i18n.get("notify_on_updates"), checked=notify_on_updates, tooltip=i18n.get("notify_on_updates_toolip") ) self.notify_on_actions = CheckBox( i18n.get("notify_on_actions"), checked=notify_on_actions, tooltip=i18n.get("notify_on_actions_toolip") ) self.sound_on_login = CheckBox( i18n.get("sound_on_login"), checked=sound_on_login, tooltip=i18n.get("sound_on_login_tooltip") ) self.sound_on_updates = CheckBox( i18n.get("sound_on_updates"), checked=sound_on_updates, tooltip=i18n.get("sound_on_updates_tooltip") ) self.layout.addWidget(self.notify_on_updates) self.layout.addWidget(self.notify_on_actions) self.layout.addSpacing(15) self.layout.addWidget(self.sound_on_login) self.layout.addWidget(self.sound_on_updates) self.layout.addStretch(1)
def __init__(self, base): BasePage.__init__(self, i18n.get("advanced_tab_description")) self.base = base socket_timeout = base.core.get_socket_timeout() show_avatars = base.core.get_show_user_avatars() clean_cache_caption = "%s\n(%s)" % (i18n.get("delete_all_files_in_cache"), base.get_cache_size()) self.clean_cache = PushButton(clean_cache_caption, i18n.get("clean_cache")) self.clean_cache.clicked.connect(self.__on_clean_cache) self.restore_config = PushButton(i18n.get("restore_config_to_default"), i18n.get("restore_config")) self.restore_config.clicked.connect(self.__on_config_restore) self.socket_timeout = Slider( i18n.get("socket_timeout"), default_value=socket_timeout, minimum_value=5, maximum_value=120, unit="sec", tooltip=i18n.get("socket_timeout_tooltip"), ) self.show_avatars = CheckBox( i18n.get("show_avatars"), checked=show_avatars, tooltip=i18n.get("show_avatars_tooltip") ) self.layout.addWidget(self.clean_cache) self.layout.addWidget(self.restore_config) self.layout.addSpacing(15) self.layout.addWidget(self.socket_timeout) self.layout.addSpacing(10) self.layout.addWidget(self.show_avatars) self.layout.addStretch(1)
def update_after_short_url(self, response): if response.code == 815: self.unlock(i18n.get('url_already_short')) elif response.code == 812: self.unlock(i18n.get('no_url_to_short')) elif response.code > 0: self.unlock(i18n.get('couldnt_shrink_urls')) else: self.update_text.set_text(response.items) self.update_text.move_cursor(MessageTextView.CURSOR_END) self.unlock()
def __delete_message(self): self.__disable() selection = self.list_.selectionModel() index = selection.selectedIndexes()[0] message = i18n.get('delete_message_from_queue_confirm') confirmation = self.base.show_confirmation_message( i18n.get('confirm_delete'), message) if not confirmation: self.__enable() return self.base.delete_message_from_queue(index.row())
def __delete_message(self): self.__disable() selection = self.list_.selectionModel() index = selection.selectedIndexes()[0] message = i18n.get('delete_message_from_queue_confirm') confirmation = self.base.show_confirmation_message(i18n.get('confirm_delete'), message) if not confirmation: self.__enable() return self.base.delete_message_from_queue(index.row())
def normal(self): self.menu = Gtk.Menu() tweet = Gtk.MenuItem(i18n.get('new_tweet')) tweet.connect('activate', self.base.show_update_box) direct = Gtk.MenuItem(i18n.get('direct_message')) direct.connect('activate', self.base.show_update_box, True) self.menu.append(tweet) self.menu.append(direct) self.__build_common_menu()
def normal(self): self.menu = QMenu() updates = QAction(i18n.get('update_status'), self) updates.triggered.connect(self.__updates_clicked) messages = QAction(i18n.get('send_direct_message'), self) messages.triggered.connect(self.__messages_clicked) self.menu.addAction(updates) self.menu.addAction(messages) self.__build_common_menu() self.setContextMenu(self.menu)
def show_config_menu(self, widget): notif = Gtk.CheckMenuItem(i18n.get('notificate')) sound = Gtk.CheckMenuItem(i18n.get('sound')) refresh = Gtk.MenuItem(i18n.get('manual_update')) refresh.connect('activate', self.__refresh, self.column.id_) self.menu = Gtk.Menu() self.menu.append(sound) self.menu.append(notif) self.menu.append(refresh) self.menu.show_all() self.menu.popup(None, None, None, None, 0, Gtk.get_current_event_time())
def closeEvent(self, event=None): message = unicode(self.text_edit.toPlainText()) if len(message) > 0: confirmation = self.base.show_confirmation_message(i18n.get('confirm_discard'), i18n.get('do_you_want_to_discard_message')) if not confirmation: return if event: event.ignore() self.__clear() self.hide()
def __init__(self, parent=None, mode='user'): Gtk.Window.__init__(self, Gtk.WindowType.TOPLEVEL) self.mainwin = parent self.current = parent.get_config() self.set_default_size(450, 400) self.set_title(i18n.get('preferences')) self.set_border_width(6) self.set_transient_for(parent) self.set_modal(True) self.set_position(Gtk.WindowPosition.CENTER_ON_PARENT) btn_save = Gtk.Button(i18n.get('save')) btn_close = Gtk.Button(i18n.get('close')) box_button = Gtk.HButtonBox() box_button.set_spacing(6) box_button.set_layout(Gtk.ButtonBoxStyle.END) box_button.pack_start(btn_close, False, False, 0) box_button.pack_start(btn_save, False, False, 0) notebook = Gtk.Notebook() notebook.set_scrollable(True) notebook.set_border_width(3) notebook.set_properties('tab-pos', Gtk.PositionType.LEFT) # Tabs self.general = GeneralTab(self.current['General']) self.notif = NotificationsTab(self.current['Notifications'], self.current['Sounds']) self.services = ServicesTab(self.current['Services']) self.browser = BrowserTab(self.mainwin, self.current['Browser']) self.filtered = FilterTab(self.mainwin) #self.proxy = ProxyTab(self.current['Proxy']) self.advanced = AdvancedTab(self.mainwin, self.current['Advanced']) notebook.append_page(self.general, Gtk.Label(i18n.get('general'))) notebook.append_page(self.notif, Gtk.Label(i18n.get('notifications'))) notebook.append_page(self.services, Gtk.Label(i18n.get('services'))) notebook.append_page(self.browser, Gtk.Label(i18n.get('web_browser'))) notebook.append_page(self.filtered, Gtk.Label(i18n.get('filters'))) #notebook.append_page(self.proxy, Gtk.Label(i18n.get('proxy'))) notebook.append_page(self.advanced, Gtk.Label(i18n.get('advanced'))) vbox = Gtk.VBox() #vbox.set_spacing(4) vbox.pack_start(notebook, True, True, 0) vbox.pack_start(box_button, False, False, 0) btn_close.connect('clicked', self.__close) btn_save.connect('clicked', self.__save) self.connect('delete-event', self.__close) self.add(vbox) self.showed = False
def empty(self, with_accounts=None): if self.child: self.clear_layout(self) image = self.base.load_image("turpial-196.png", True) logo = QLabel() logo.setPixmap(image) logo.setAlignment(Qt.AlignCenter) logo.setContentsMargins(0, 80, 0, 0) appname = QLabel("Turpial 3") if detect_os() == OS_MAC: font = QFont("Maven Pro Light", 28, 0, False) font2 = QFont("Ubuntu", 16, 0, False) else: font = QFont("Maven Pro Light", 18, QFont.Light, False) font2 = QFont("Ubuntu", 12, QFont.Normal, False) appname.setFont(font) welcome = QLabel() welcome.setText(i18n.get("welcome")) welcome.setAlignment(Qt.AlignCenter) welcome.setFont(font) message = QLabel() if with_accounts: text = "%s <a href='cmd:add_columns'>%s</a>" % ( i18n.get("you_have_accounts_registered"), i18n.get("add_some_columns"), ) else: text = "<a href='cmd:add_accounts'>%s</a> %s" % ( i18n.get("add_new_account"), i18n.get("to_start_using_turpial"), ) message.setText(text) message.linkActivated.connect(self.__link_clicked) message.setAlignment(Qt.AlignCenter) message.setWordWrap(True) message.setFont(font2) self.child = QVBoxLayout() self.child.addWidget(logo) self.child.addWidget(welcome) self.child.setSpacing(10) self.child.addWidget(message) self.child.setSpacing(10) self.child.setContentsMargins(30, 0, 30, 60) self.insertLayout(0, self.child) self.is_empty = True
def __upload_image(self): index = self.accounts_combo.currentIndex() accounts = self.base.core.get_registered_accounts() if index == 0 and len(accounts) > 1: self.error(i18n.get('select_an_account_before_post')) return False account_id = str(self.accounts_combo.itemData(index).toPyObject()) filename = str(QFileDialog.getOpenFileName(self, i18n.get('upload_image'), self.base.home_path)) if filename != '': self.enable(False) self.base.upload_media(account_id, filename)
def __validate(self, message, accounts, index): if len(message) == 0: self.error(i18n.get('you_can_not_submit_an_empty_message')) return False if index == 0 and len(accounts) > 1: self.error(i18n.get('select_an_account_before_post')) return False if self.__count_chars() < 0: self.error(i18n.get('message_too_long')) return False return True
def error(self, error=''): if error: self.error_msg.set_label(error) else: self.error_msg.set_label(i18n.get('error_loading_profile')) self.spinner.stop() self.spinner.hide()
def __clean_cache(self, widget): self.mainwin.delete_all_cache() self.cachebtn.set_sensitive(False) label = "%s <span foreground='#999999'>%s</span>" % ( i18n.get('delete_all_images_in_cache'), self.mainwin.get_cache_size()) self.cachelbl.set_markup(label)
def __init__(self, base): Gtk.Window.__init__(self) self.base = base self.window_width = 300 self.set_title(i18n.get('user_profile')) self.set_default_size(self.window_width, 250) #self.set_resizable(False) self.set_icon(self.base.load_image('turpial.png', True)) self.set_transient_for(self.base) self.set_position(Gtk.WindowPosition.CENTER_ON_PARENT) self.set_gravity(Gdk.Gravity.STATIC) self.connect('delete-event', self.__close) #self.connect('key-press-event', self.__key_pressed) self.profile_box = ProfileBox(self.base) # Error stuffs self.error_msg = Gtk.Label() self.error_msg.set_alignment(0.5, 0.5) self.spinner = Gtk.Spinner() self.loading_box = Gtk.Box(spacing=0) self.loading_box.set_orientation(Gtk.Orientation.VERTICAL) self.loading_box.pack_start(self.spinner, True, False, 0) self.loading_box.pack_start(self.error_msg, True,True, 0) self.showed = False