src/gimdb.rb in gimdb-0.0.3 vs src/gimdb.rb in gimdb-0.0.4

- old
+ new

@@ -23,10 +23,11 @@ exit -1 end require "#{$GIMDB_PATH}/lib/imdb" require "#{$GIMDB_PATH}/src/controller" require "#{$GIMDB_PATH}/src/movie_box" +require "#{$GIMDB_PATH}/src/manager_box" class GimdbGlade include GetText @@ -64,14 +65,16 @@ @image_connection = @glade.get_widget('image_connection') @image_spinner = @glade.get_widget('image_spinner') @scrolled = @glade.get_widget('scrolled') @vbox_movies = Gtk::VBox.new @dialog_users = @glade.get_widget('dialog_users') - @entry_user = @glade.get_widget('entry_user') - @combo_del_users = @glade.get_widget('combo_del_users') - @table_combo = @glade.get_widget('table_combo') - @check_genres_all = @glade.get_widget('check_genres_all') + @dialog_users_box = @glade.get_widget('dialog_users_box').pack_start(GtkGimdb::ManagerBox.new(:users, :name) do |t| + @label_status.text = _(t) + @label_status.show + build_users_menu + end) + @check_genres_all = @glade.get_widget('check_genres_all') @genres = [ :action,:adventure,:animation,:biography,:comedy, :crime,:documentary,:drama,:family,:fantasy,:film_noir, :game_show,:history,:horror,:music,:musical,:mystery,:news, @@ -83,11 +86,10 @@ end end # Some stuffs @users = User.find(:all, :conditions => 'selected = 1') - @all_users = User.all build_users_menu @spin_year_to.value = Time.now.year.to_i @combo_rating_from.active = 0 @combo_rating_to.active = 9 @combo_sort.active = 0 @@ -234,11 +236,11 @@ end def build_users_menu submenu = Gtk::Menu.new - @all_users.sort{|x,y| x.name <=> y.name}.each do |u| + User.all.sort{|x,y| x.name <=> y.name}.each do |u| m = Gtk::CheckMenuItem.new(u.name) m.active = true if @users.include?(u) submenu.append(m) m.signal_connect('toggled') do if m.active? @@ -320,60 +322,54 @@ def on_show_sidebar(widget, arg = nil) widget.active? ? @sidebar.show : @sidebar.hide end def on_manage_users_clicked(widget, arg = nil) - @combo_del_users = Gtk::ComboBox.new - @table_combo.attach(@combo_del_users, 0,1, 1,2) - @all_users.sort{|x,y| x.name <=> y.name}.each do |u| - @combo_del_users.append_text(u.name) - end - @combo_del_users.active = 0 @dialog_users.show_all end - def on_add_users_clicked(widget, arg = nil) - unless @entry_user.text.empty? - u = User.new(:name => @entry_user.text) - begin - u.save - @all_users << u - build_users_menu - @combo_del_users.append_text(u.name) - @combo_del_users.active = 0 - @entry_user.text = '' - @label_status.text = _('New user added') - @label_status.show - # @dialog_users.hide - rescue - nil - end - end - end - - def on_del_users_clicked(widget, arg = nil) - name = @combo_del_users.active_text - u = User.find_by_name(name) - unless u.nil? - u.destroy - @all_users.delete(u) - build_users_menu - @combo_del_users.remove_text(@combo_del_users.active) - @label_status.text = _('User deleted') - @label_status.show - # @combo_del_users.active = 0 - end - end - def on_select_all_users_clicked(widget, arg = nil) @users_menu_item.submenu.children.each do |c| c.active = !c.active? end @dialog_users.hide + @label_status.hide end def on_close_manage_users_clicked(widget, arg = nil) @dialog_users.hide @label_status.hide + end + + def on_about_clicked(widget, arg = nil) + @dialog_about = Gtk::AboutDialog.new + begin + f = File.open("#{$GIMDB_PATH}/VERSION", 'r') + version = '' + f.each_line { |line| version += line } + @dialog_about.version = version + rescue + nil + end + begin + f = File.open("#{$GIMDB_PATH}/LICENSE", 'r') + license = '' + f.each_line { |line| license += line } + @dialog_about.license = license + rescue + nil + end + @dialog_about.program_name = 'GIMDB' + @dialog_about.logo = Gdk::Pixbuf.new("#{$GIMDB_PATH}/data/icons/imdb.png") + @dialog_about.comments = 'GTK graphical interface for the Internet Movie DataBase.' + @dialog_about.copyright = "Copyright © #{Time.now.year} Enrico Pilotto" + @dialog_about.website = 'http://github.com/pioz/gimdb' + @dialog_about.website_label = 'Website' + @dialog_about.authors = ['Enrico Pilotto <enrico@megiston.it>'] + @dialog_about.translator_credits = 'Italian: Enrico Pilotto <enrico@megiston.it>' + @dialog_about.modal = true + @dialog_about.skip_taskbar_hint = true + @dialog_about.signal_connect('response') { @dialog_about.hide } + @dialog_about.run end end