Skip to content

Commit

Permalink
Made character creator button insensitive until changing character
Browse files Browse the repository at this point in the history
  • Loading branch information
carolineclark committed Oct 28, 2015
1 parent 8ca7617 commit 087c97f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
9 changes: 8 additions & 1 deletion kano_avatar_gui/CharacterCreator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#

import os
from gi.repository import Gtk
from gi.repository import Gtk, GObject
from kano_avatar.logic import AvatarCreator, get_avatar_conf
from kano_avatar.paths import AVATAR_DEFAULT_LOC, AVATAR_DEFAULT_NAME
from kano_avatar_gui.Menu import Menu
Expand All @@ -25,6 +25,10 @@ class CharacterCreator(Gtk.EventBox):
avatar_cr = AvatarCreator(configuration)
meny_y_pos = 20

__gsignals__ = {
'character_changed': (GObject.SIGNAL_RUN_FIRST, None, ())
}

def __init__(self, randomise=False, no_sync=False):
Gtk.EventBox.__init__(self)

Expand Down Expand Up @@ -142,6 +146,9 @@ def _update_img(self, widget, selected):
displ_img = self.avatar_cr.create_avatar()
self._imgbox.set_image(displ_img)

# Emit the character changed signal when the image is updated
self.emit('character_changed')

def disable_buttons(self):
self._menu.disable_all_buttons()
self.randomise_button.set_sensitive(False)
Expand Down
15 changes: 12 additions & 3 deletions kano_profile_gui/character_screens.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,14 @@ def __init__(self, win, char_creator):
self._win.pack_in_main_content(self.char_creator)
self.char_creator.reset_selected_menu_items()

save_changes_button = KanoButton(_("Save changes").upper())
save_changes_button.connect("clicked", self.save_changes)
self._save_changes_button = KanoButton(_("Save changes").upper())
self._save_changes_button.connect("clicked", self.save_changes)
self._save_changes_button.set_sensitive(False)

self.char_creator.connect(
"character_changed",
self._make_button_sensitive
)

discard_changes_button = OrangeButton(_("Discard").upper())
discard_changes_button.connect("clicked", self.discard)
Expand All @@ -116,7 +122,7 @@ def __init__(self, win, char_creator):

button_box = Gtk.ButtonBox()
button_box.pack_start(discard_changes_button, False, False, 0)
button_box.pack_start(save_changes_button, False, False, 0)
button_box.pack_start(self._save_changes_button, False, False, 0)
button_box.pack_start(empty_label, False, False, 0)

self._win.pack_in_bottom_bar(button_box)
Expand All @@ -140,3 +146,6 @@ def _go_back_to_display_screen(self):
self._win.empty_bottom_bar()
self._win.menu_bar.enable_buttons()
CharacterDisplay(self._win)

def _make_button_sensitive(self, widget=None):
self._save_changes_button.set_sensitive(True)

0 comments on commit 087c97f

Please sign in to comment.