Add new interface to raise dialogs

This commit is contained in:
Philipp Hörist 2017-12-08 19:50:04 +01:00
parent dc52f560ed
commit 61ad783658
2 changed files with 55 additions and 0 deletions

50
gajim/dialog_messages.py Normal file
View File

@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2017 Philipp Hörist <philipp AT hoerist.com>
#
# This file is part of Gajim.
#
# Gajim is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Gajim 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 Gajim. If not, see <http://www.gnu.org/licenses/>.
from collections import namedtuple
from gi.repository import GLib
from gajim.common.app import app
Message = namedtuple('Message', ['title', 'text', 'dialog'])
messages = {}
def get_dialog(name, *args, **kwargs):
message = messages.get(name, None)
if message is None:
raise ValueError('Dialog %s does not exist' % name)
# Set transient window
transient_for = kwargs.get('transient_for', None)
if transient_for is None:
transient_for = app.get_active_window()
else:
del kwargs['transient_for']
if args:
message_text = message.text % args
else:
message_text = message.text % kwargs
dialog = message.dialog(message.title,
GLib.markup_escape_text(message_text),
transient_for=transient_for)
return dialog

View File

@ -67,6 +67,7 @@ from gajim import gui_menu_builder
from gajim import dialogs
from gajim import notify
from gajim import message_control
from gajim.dialog_messages import get_dialog
from gajim.chat_control_base import ChatControlBase
from gajim.chat_control import ChatControl
@ -143,6 +144,10 @@ class Interface:
cls(obj.pri_txt, GLib.markup_escape_text(obj.sec_txt))
@staticmethod
def raise_dialog(name, *args, **kwargs):
get_dialog(name, *args, **kwargs)
def handle_ask_new_nick(self, account, room_jid, parent_win):
title = _('Unable to join group chat')
prompt = _('Your desired nickname in group chat\n'