class MyWindow

Attributes

holder[RW]
mainrouter[RW]
mymenu[RW]
sb[R]

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/mywindow.rb, line 10
        def initialize
                ManqodRPC.instance.register_client
                super()

#       set_auto_startup_notification(true)
#       set_window_position(Gtk::Window::POS_CENTER_ALWAYS)
        self.title='manqod login'
  run
        
        signal_connect("delete-event"){|me,ev|
                !shut_down?
        }
        signal_connect("destroy") {|me,ev|
                if mainrouter
                        mainrouter.destroy 
                        save_conf
                        edebug("quit","main","normal",false)
                end
                Gtk.main_quit
                ManqodRPC.instance.unregister_client
        }
        signal_connect("configure-event"){|me,event|
                if nick
                        set_conf(0,0,"width",event.width.to_s)
                        set_conf(0,0,"height",event.height.to_s)
                        set_conf(0,0,"x",event.x.to_s)
                        set_conf(0,0,"y",event.y.to_s)
                end
                false
        }
        signal_connect("window-state-event"){|me,event|
                if nick
                        set_conf(0,0,"maximized",(event.new_window_state &  Gdk::EventWindowState::MAXIMIZED == Gdk::EventWindowState::MAXIMIZED).to_s)
                        set_conf(0,0,"minimized",(event.new_window_state &  Gdk::EventWindowState::ICONIFIED == Gdk::EventWindowState::ICONIFIED).to_s)
                        set_conf(0,0,"minimized",(event.new_window_state &  Gdk::EventWindowState::FULLSCREEN == Gdk::EventWindowState::FULLSCREEN).to_s)
                end
                false
        }
        
        @@ag = Gtk::AccelGroup.new
        @@ag.connect(Gdk::Keyval::GDK_KEY_F5,nil ,Gtk::ACCEL_VISIBLE){
                @mainrouter.reset_child
          @mymenu.update(self)
        }
        @@ag.connect(Gdk::Keyval::GDK_KEY_F4,nil ,Gtk::ACCEL_VISIBLE){
          gtk_set_edebug
        }
        add_accel_group(@@ag)
        
        
  end

Public Instance Methods

run() click to toggle source
# File lib/mywindow.rb, line 66
def run
              SB.instance.set_parent_window(self)
              load_conf
              DrbImages.instance.load_images
      begin
              if main_image_id_row = admin.qrow("select imageid from gtkmenu order by id limit 1")
                      set_icon(DrbImages.instance.image_of_id(main_image_id_row["imageid"],"gtk-large-toolbar"))
              end
              
              if sw=get_conf(0,0,"width") and sh=get_conf(0,0,"height")
                      resize(sw.to_i,sh.to_i)# if sw.to_i * sh.to_i >0
                      else
                      resize(600,400)
              end
              sx=get_conf(0,0,"x") || 50
              sy=get_conf(0,0,"y") || 60
              move(sx.to_i,sy.to_i)

              maximize if get_conf(0,0,"maximized") == "true"
              iconify if get_conf(0,0,"iconified") == "true"
              fullscreen if get_conf(0,0,"fullscreen") == "true"
              
              #realize;window.set_functions(Gdk::Window::WMFunction::ALL | Gdk::Window::WMFunction::CLOSE)

              @holder = Gtk::Table.new(2,4,false)
              @mainrouter=MainRouter.new(self)
              case get_conf(0,0,"menu-position")
                when "top"
                      @mymenu = if get_conf(0,0,"menu-type")=="buttons" then MenuHolder.new(mainrouter);else BarMenu.new(mainrouter);end
                      holder.attach(mymenu    ,0,1,0,1,Gtk::EXPAND|Gtk::FILL,Gtk::FILL)
                      holder.attach(mainrouter,0,1,1,2,Gtk::EXPAND|Gtk::FILL,Gtk::EXPAND|Gtk::FILL)
                when "bottom"
                      @mymenu = if get_conf(0,0,"menu-type")=="buttons" then MenuHolder.new(mainrouter);else BarMenu.new(mainrouter);end
                      holder.attach(mainrouter,0,1,1,2,Gtk::EXPAND|Gtk::FILL,Gtk::EXPAND|Gtk::FILL)
                      holder.attach(mymenu    ,0,1,2,3,Gtk::EXPAND|Gtk::FILL,Gtk::FILL)
                when "left"
                      @mymenu = if get_conf(0,0,"menu-type")=="buttons" then MenuHolder.new(mainrouter,"vertical");else BarMenu.new(mainrouter,"vertical");end
                      holder.attach(mymenu    ,0,1,0,2,Gtk::FILL,Gtk::EXPAND)
                      holder.attach(mainrouter,1,2,0,1,Gtk::EXPAND|Gtk::FILL,Gtk::EXPAND|Gtk::FILL)
                when "right"
                      @mymenu = if get_conf(0,0,"menu-type")=="buttons" then MenuHolder.new(mainrouter,"vertical");else BarMenu.new(mainrouter,"vertical");end
                      holder.attach(mymenu    ,1,2,0,2,Gtk::FILL,Gtk::EXPAND)
                      holder.attach(mainrouter,0,1,0,1,Gtk::EXPAND|Gtk::FILL,Gtk::EXPAND|Gtk::FILL)
              end
              @holder.attach(SB.instance,0,2,3,4,Gtk::FILL,Gtk::FILL)
              add(holder)
              show_all
              Gtk.show_thread_changes
              mymenu.update(mymenu.last)
              Messaging.instance.check_messages
        rescue  => err
                      tell_exception("error occured",backtrace_to_debug(err),"main","warning")
      end
end
shut_down?() click to toggle source
# File lib/mywindow.rb, line 121
def shut_down?
        enormal("normal shutdown","main")
        if get_conf(0,0,"confirm-exit") == "true"
                warner=Gtk::MessageDialog.new(self,Gtk::Dialog::DESTROY_WITH_PARENT,Gtk::MessageDialog::QUESTION,Gtk::MessageDialog::BUTTONS_YES_NO,"quit")
                warner.set_image(Gtk::Image.new(Gtk::Stock::QUIT,Gtk::IconSize::DIALOG))
                ret=(warner.show_all.run == Gtk::Dialog::RESPONSE_YES)
                warner.destroy
        else
                ret=true
        end
        ret
end