apply new label when creating it
authorgc <gc>
Mon, 14 Apr 2008 09:03:57 +0000 (09:03 +0000)
committergc <gc>
Mon, 14 Apr 2008 09:03:57 +0000 (09:03 +0000)
bin/booh-classifier

index f02107f..51ccc80 100644 (file)
@@ -904,22 +904,22 @@ def thumbnail_keypressed(entry, event)
                 
                 if label.nil?
                     vb = Gtk::VBox.new(false, 0)
-                    vb.pack_start(entry = Gtk::Entry.new.set_text(char), false, false)
+                    vb.pack_start(labelentry = Gtk::Entry.new.set_text(char), false, false)
                     vb.pack_start(Gtk::Alignment.new(0.5, 0.5, 0, 0).add(bt = Gtk::ColorButton.new))
                     color = bt.color = Gdk::Color.new(16384 + rand(49151), 16384 + rand(49151), 16384 + rand(49151))
                     bt.signal_connect('color-set') { color = bt.color }
                     text = nil
-                    entry.signal_connect('changed') {  #- cannot add a new label with first letter of an existing label
-                        while $labels.has_key?(entry.text[0,1])
-                            entry.text = entry.text.sub(/./, '')
+                    labelentry.signal_connect('changed') {  #- cannot add a new label with first letter of an existing label
+                        while $labels.has_key?(labelentry.text[0,1])
+                            labelentry.text = labelentry.text.sub(/./, '')
                         end
                     }
                     if show_popup($main_window,
                                   utf8(_("You typed the text character '%s', which is not associated with a label.\nType in the full name of the label below to create a new one.")) % char,
-                                  { :okcancel => true, :bottomwidget => vb, :data_getter => proc { text = entry.text },
-                                    :stuff_connector => proc { |stuff| entry.select_region(0, 0)
-                                                                       entry.position = -1
-                                                                       entry.signal_connect('activate') { stuff[:dialog].response(Gtk::Dialog::RESPONSE_OK) } } } )
+                                  { :okcancel => true, :bottomwidget => vb, :data_getter => proc { text = labelentry.text },
+                                    :stuff_connector => proc { |stuff| labelentry.select_region(0, 0)
+                                                                       labelentry.position = -1
+                                                                       labelentry.signal_connect('activate') { stuff[:dialog].response(Gtk::Dialog::RESPONSE_OK) } } } )
                         if text.length > 0
                             char = text[0,1]  #- in case it changed
                             label = Label.new(text)
@@ -935,8 +935,9 @@ def thumbnail_keypressed(entry, event)
                             evt.modify_bg(Gtk::StateType::ACTIVE, label.color.lighter)
                         end
                     end
+                end
 
-                else
+                if label
                     entry.removed = false
                     entry.labeled = label
                     entry.show_bg
@@ -990,12 +991,12 @@ def show_entry(entry, i, tips)
     end
     tips.set_tip(entry.button, entry.get_beautified_name, nil)
     $imagesline.pack_start(entry.alignment = Gtk::Alignment.new(0.5, 1, 0, 0).add(entry.button).show_all, false, false)
+    $last_shown = nil
     entry.button.signal_connect('clicked') {
-        if (last_shown = $mainview.get_shown_entry) != entry
-            entry.alignment.set(0.5, 0, 0, 0)
-            last_shown and last_shown.alignment.set(0.5, 1, 0, 0)
-            $mainview.set_shown_entry(entry)
-        end
+        $lastshown and $lastshown.alignment.set(0.5, 1, 0, 0)
+        entry.alignment.set(0.5, 0, 0, 0)
+        $lastshown = entry
+        $mainview.set_shown_entry(entry)
     }
     entry.button.signal_connect('button-press-event') { |w, event|
         if entry.type == 'video' && event.event_type == Gdk::Event::BUTTON2_PRESS