Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell/view/FirstTimeDialog.py
blob: 5e878f90069f0bb0ead2ca0d249fe60692aa84c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Copyright (C) 2006, Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) 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, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

import gtk

from gettext import gettext as _

import conf

class FirstTimeDialog(gtk.Dialog):
	def __init__(self):
		gtk.Dialog.__init__(self)

		label = gtk.Label(_('Nick Name:'))
		label.set_alignment(0.0, 0.5)
		self.vbox.pack_start(label)
		label.show()

		self._entry = gtk.Entry()
		self._entry.connect('changed', self._entry_changed_cb)
		self.vbox.pack_start(self._entry)
		self._entry.show()

		self._ok = gtk.Button(None, gtk.STOCK_OK)
		self._ok.set_sensitive(False)
		self.vbox.pack_start(self._ok)
		self._ok.connect('clicked', self.__ok_button_clicked_cb)
		self._ok.show()

	def _entry_changed_cb(self, entry):
		valid = (len(entry.get_text()) > 0)
		self._ok.set_sensitive(valid)

	def __ok_button_clicked_cb(self, button):
		profile = conf.get_profile()
		profile.set_nick_name(self._entry.get_text())
		self.destroy()

def get_profile():
	profile = conf.get_profile()
	if profile.get_nick_name() == None:
		dialog = FirstTimeDialog()
		dialog.connect('destroy', self.__first_time_dialog_destroy_cb)
		dialog.show()
	return profile