~ubuntu-app-review-contributors/ubuntu-app-reviews/armorforge

« back to all changes in this revision

Viewing changes to armorforge/NewprofileDialog.py

  • Committer: Daniel Holbach
  • Author(s): Andre Gregor-Herrmann
  • Date: 2012-07-14 17:48:26 UTC
  • Revision ID: daniel.holbach@canonical.com-20120714174826-2qpq2dx7hgevcq4q
Tags: 12.07.18-public2
New release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
 
2
### BEGIN LICENSE
 
3
# Copyright (C) 2012 Andre Gregor-Herrmann <am.herrmann@gmx.de>
 
4
# This program is free software: you can redistribute it and/or modify it 
 
5
# under the terms of the GNU General Public License version 3, as published 
 
6
# by the Free Software Foundation.
 
7
 
8
# This program is distributed in the hope that it will be useful, but 
 
9
# WITHOUT ANY WARRANTY; without even the implied warranties of 
 
10
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 
 
11
# PURPOSE.  See the GNU General Public License for more details.
 
12
 
13
# You should have received a copy of the GNU General Public License along 
 
14
# with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
### END LICENSE
 
16
 
 
17
from gi.repository import Gtk # pylint: disable=E0611
 
18
 
 
19
from armorforge_lib.helpers import get_builder
 
20
 
 
21
import gettext
 
22
from gettext import gettext as _
 
23
gettext.textdomain('armorforge')
 
24
 
 
25
class NewprofileDialog(Gtk.Dialog):
 
26
    __gtype_name__ = "NewprofileDialog"
 
27
 
 
28
    def __new__(cls):
 
29
        """Special static method that's automatically called by Python when 
 
30
        constructing a new instance of this class.
 
31
        
 
32
        Returns a fully instantiated NewprofileDialog object.
 
33
        """
 
34
        builder = get_builder('NewprofileDialog')
 
35
        new_object = builder.get_object('newprofile_dialog')
 
36
        new_object.finish_initializing(builder)
 
37
        return new_object
 
38
 
 
39
    def finish_initializing(self, builder):
 
40
        """Called when we're finished initializing.
 
41
 
 
42
        finish_initalizing should be called after parsing the ui definition
 
43
        and creating a NewprofileDialog object with it in order to
 
44
        finish initializing the start of the new NewprofileDialog
 
45
        instance.
 
46
        """
 
47
        # Get a reference to the builder and set up the signals.
 
48
        self.builder = builder
 
49
        self.ui = builder.get_ui(self)
 
50
        
 
51
        self.newprofileentry = self.builder.get_object("newprofileentry")
 
52
 
 
53
    @property
 
54
    def get_newprofilename(self):
 
55
        return self.newprofileentry.get_text()
 
56
 
 
57
 
 
58
    def on_btn_ok_clicked(self, widget, data=None):
 
59
        """The user has elected to save the changes.
 
60
 
 
61
        Called before the dialog returns Gtk.ResponseType.OK from run().
 
62
        """
 
63
        pass
 
64
 
 
65
    def on_btn_cancel_clicked(self, widget, data=None):
 
66
        """The user has elected cancel changes.
 
67
 
 
68
        Called before the dialog returns Gtk.ResponseType.CANCEL for run()
 
69
        """
 
70
        pass
 
71
 
 
72
 
 
73
if __name__ == "__main__":
 
74
    dialog = NewprofileDialog()
 
75
    dialog.show()
 
76
    Gtk.main()