Пример #1
0
	def remove_map_cb (self, mobj, a):
		map = MapList.get_by_window(mobj)
		if map:
		    MapList.delete(map)
		    self.view.emit ('cursor-changed')
		    return
		raise "Cant remove map of window %s" % mobj
Пример #2
0
	def delete_clicked (self, button):
		map = self.get_selected_map ()
		if not map:
			raise "You clicked on delete but had no map selected"
		error_message = ""
		if map.window:
			error_message =  _("The map cannot be deleted right now. Is it open?")
		elif not map.filename:
			error_message = _("The map has no associated filename.")
		if error_message:
			dialog = Gtk.MessageDialog (self, Gtk.DialogFlags.MODAL, Gtk.MessageType.WARNING, Gtk.ButtonsType.OK,
 									_("Cannot delete this map"))
			dialog.format_secondary_text (error_message)
			dialog.run ()
			dialog.hide ()
			del (dialog)
			return
		dialog = Gtk.MessageDialog (self, Gtk.DialogFlags.MODAL, Gtk.MessageType.WARNING, Gtk.ButtonsType.YES_NO,
									_("Do you really want to delete this Map?"))
		resp = dialog.run ()
		dialog.hide ()
		del (dialog)
		if resp != Gtk.ResponseType.YES:
			return
		MapList.delete (map)
		self.view.emit ('cursor-changed')
Пример #3
0
 def delete_clicked (self, button):
     map = self.get_selected_map ()
     if not map:
         raise ValueError("You clicked on delete but had no map selected")
     error_message = ""
     if map.window:
         error_message =  _("The map cannot be deleted right now. Is it open?")
     elif not map.filename:
         error_message = _("The map has no associated filename.")
     if error_message:
         dialog = gtk.MessageDialog (self, gtk.DIALOG_MODAL, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK,
                                                         _("Cannot delete this map"))
         dialog.format_secondary_text (error_message)
         dialog.run ()
         dialog.hide ()
         del (dialog)
         return
     dialog = gtk.MessageDialog (self, gtk.DIALOG_MODAL, gtk.MESSAGE_WARNING, gtk.BUTTONS_YES_NO,
                                                             _("Do you really want to delete this Map?"))
     resp = dialog.run ()
     dialog.hide ()
     del (dialog)
     if resp != gtk.RESPONSE_YES:
         return
     MapList.delete (map)
     self.view.emit ('cursor-changed')
Пример #4
0
 def remove_map_cb (self, mobj, a):
     map = MapList.get_by_window(mobj)
     if map:
         MapList.delete(map)
         self.view.emit ('cursor-changed')
         return
     raise ValueError("Cant remove map of window %s" % mobj)
Пример #5
0
 def delete_clicked (self, button):
     map = self.get_selected_map ()
     if not map:
         raise ValueError("You clicked on delete but had no map selected")
     error_message = ""
     if map.window:
         error_message =  _("The map cannot be deleted right now. Is it open?")
     elif not map.filename:
         error_message = _("The map has no associated filename.")
     if error_message:
         dialog = gtk.MessageDialog (self, gtk.DIALOG_MODAL, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK,
                                                         _("Cannot delete this map"))
         dialog.format_secondary_text (error_message)
         dialog.run ()
         dialog.hide ()
         del (dialog)
         return
     dialog = gtk.MessageDialog (self, gtk.DIALOG_MODAL, gtk.MESSAGE_WARNING, gtk.BUTTONS_YES_NO,
                                                             _("Do you really want to delete this Map?"))
     resp = dialog.run ()
     dialog.hide ()
     del (dialog)
     if resp != gtk.RESPONSE_YES:
         return
     MapList.delete (map)
     self.view.emit ('cursor-changed')
Пример #6
0
 def get_selected_map(self):
     sel = self.view.get_selection ()
     (model, it) = sel.get_selected ()
     if it:
         (num,) = MapList.tree_view_model.get (it, self.COL_ID)
         return MapList.get_by_index(num)
     return None
Пример #7
0
	def get_selected_map(self):
		sel = self.view.get_selection ()
		(model, it) = sel.get_selected ()
		if it:
		    (num,) = MapList.tree_view_model.get (it, self.COL_ID)
		    return MapList.get_by_index(num)
		return None
Пример #8
0
	def open_map (self, map, imported=False):
		win = MainWindow.LabyrinthWindow (map.filename, imported)
		win.connect ("title-changed", self.map_title_cb)
		win.connect ("window_closed", self.remove_map_cb)
		win.connect ("file_saved", self.file_save_cb)
		win.show ()
		map.window = win
		return (MapList.index(map), win)
Пример #9
0
 def open_map (self, map, imported=False):
     win = MainWindow.LabyrinthWindow (map.filename, imported)
     win.connect ("title-changed", self.map_title_cb)
     win.connect ("window_closed", self.remove_map_cb)
     win.connect ("file_saved", self.file_save_cb)
     win.show ()
     map.window = win
     return (MapList.index(map), win)
Пример #10
0
    def quit_clicked (self, button, other=None, *data):
        for map in MapList.get_open_windows():
            map.window.close_window_cb (None)

        width, height = self.main_window.get_size()

        if os.name != 'nt':
            self.config_client.set_int('/apps/labyrinth/width', width)
            self.config_client.set_int('/apps/labyrinth/height', height)

        gtk.main_quit ()
Пример #11
0
	def quit_clicked (self, button, other=None, *data):
		for map in MapList.get_open_windows():
			map.window.close_window_cb (None)
		
		width, height = self.main_window.get_size()

		if os.name != 'nt':
			self.config_client.set_int('/apps/labyrinth/width', width)
			self.config_client.set_int('/apps/labyrinth/height', height)
		
		Gtk.main_quit ()
Пример #12
0
    def populate_view (self):
        cellrenderer = gtk.CellRendererText()
        cellrenderer.set_property("ellipsize", pango.ELLIPSIZE_END)
        column = gtk.TreeViewColumn(_("Map Name"), cellrenderer,
                                                                text=self.COL_TITLE)
        column.set_resizable(True)
        column.set_expand (True)
        column.set_sort_column_id (1)
        self.view.append_column(column)

        col1 = gtk.TreeViewColumn (_("Last Modified"), gtk.CellRendererText(),
                                                           text=self.COL_MODTIME)
        col1.set_resizable(True)
        col1.set_sort_column_id (2)
        self.view.append_column(col1)

        self.view.set_model (MapList.get_TreeViewModel())
        self.view.set_search_column(self.COL_TITLE)
        self.view.set_enable_search (True)
Пример #13
0
	def populate_view (self):
		cellrenderer = Gtk.CellRendererText()
		cellrenderer.set_property("ellipsize", Pango.EllipsizeMode.END)
		column = Gtk.TreeViewColumn(_("Map Name"), cellrenderer, 
									text=self.COL_TITLE)
		column.set_resizable(True)
		column.set_expand (True)
		column.set_sort_column_id (1)
		self.view.append_column(column)
 
		col1 = Gtk.TreeViewColumn (_("Last Modified"), Gtk.CellRendererText(),
								   text=self.COL_MODTIME)
		col1.set_resizable(True)
		col1.set_sort_column_id (2)
		self.view.append_column(col1)

		self.view.set_model (MapList.get_TreeViewModel())
		self.view.set_search_column(self.COL_TITLE)
		self.view.set_enable_search (True)
Пример #14
0
    def import_clicked(self, button, other=None, *data):
        chooser = Gtk.FileChooserDialog(title=_("Open File"), action=Gtk.FileChooserAction.OPEN, \
                                        buttons=(Gtk.STOCK_CANCEL, Gtk.ResponeType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK))

        filtr = Gtk.FileFilter()
        filtr.set_name(_('MAPZ Compressed Map (*.mapz)'))
        filtr.add_pattern('*.mapz')
        chooser.add_filter(filtr)

        response = chooser.run()
        if response == Gtk.ResponseType.OK:
            filename = chooser.get_filename()
            tf = tarfile.open(filename)
            mapname = utils.get_save_dir() + tf.getnames()[0]
            tf.extractall(utils.get_save_dir())
            tf.close()
            map = MapList.new_from_file(mapname)
            map.filename = mapname

        chooser.destroy()
Пример #15
0
	def import_clicked(self, button, other=None, *data):
		chooser = Gtk.FileChooserDialog(title=_("Open File"), action=Gtk.FileChooserAction.OPEN, \
										buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
										
		filtr = Gtk.FileFilter ()
		filtr.set_name(_('MAPZ Compressed Map (*.mapz)'))
		filtr.add_pattern('*.mapz')
		chooser.add_filter(filtr)
			
		response = chooser.run()
		if response == Gtk.ResponseType.OK:
			filename = chooser.get_filename()
			tf = tarfile.open(filename)
			mapname = utils.get_save_dir() + tf.getnames()[0]
			tf.extractall(utils.get_save_dir())
			tf.close()
			map = MapList.new_from_file(mapname)
			map.filename = mapname
			
		chooser.destroy()
Пример #16
0
    def import_clicked(self, button, other=None, *data):
        chooser = gtk.FileChooserDialog(title=_("Open File"), action=gtk.FILE_CHOOSER_ACTION_OPEN, \
                                                                        buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK))

        filtr = gtk.FileFilter ()
        filtr.set_name(_('MAPZ Compressed Map (*.mapz)'))
        filtr.add_pattern('*.mapz')
        chooser.add_filter(filtr)

        response = chooser.run()
        if response == gtk.RESPONSE_OK:
            filename = chooser.get_filename()
            tf = tarfile.open(filename)
            mapname = os.path.join (utils.get_save_dir (), tf.getnames()[0])
            tf.extractall(utils.get_save_dir())
            tf.close()
            map = MapList.new_from_file(mapname)
            map.filename = mapname

        chooser.destroy()
Пример #17
0
    def import_clicked(self, button, other=None, *data):
        chooser = gtk.FileChooserDialog(title=_("Open File"), action=gtk.FILE_CHOOSER_ACTION_OPEN, \
                                                                        buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK))

        filtr = gtk.FileFilter ()
        filtr.set_name(_('MAPZ Compressed Map (*.mapz)'))
        filtr.add_pattern('*.mapz')
        chooser.add_filter(filtr)

        response = chooser.run()
        if response == gtk.RESPONSE_OK:
            filename = chooser.get_filename()
            tf = tarfile.open(filename)
            mapname = os.path.join (utils.get_save_dir (), tf.getnames()[0])
            tf.extractall(utils.get_save_dir())
            tf.close()
            map = MapList.new_from_file(mapname)
            map.filename = mapname

        chooser.destroy()
Пример #18
0
 def new_clicked (self, button):
     map = MapList.create_empty_map()
     self.open_map(map)
Пример #19
0
	def file_save_cb (self, mobj, new_fname, mobj1):
		map = MapList.get_by_window(mobj)
		if map:
			map.window = None
			map.filename = new_fname
		return
Пример #20
0
 def file_save_cb (self, mobj, new_fname, mobj1):
     map = MapList.get_by_window(mobj)
     if map:
         map.window = None
         map.filename = new_fname
     return
Пример #21
0
	def new_clicked (self, button):
		map = MapList.create_empty_map()
		self.open_map(map)
Пример #22
0
 def map_title_cb (self, mobj, new_title, mobj1):
     map = MapList.get_by_window(mobj)
     if not map:
         raise AttributeError ("What a mess, can't find the map")
     map.title = new_title
Пример #23
0
	def map_title_cb (self, mobj, new_title, mobj1):
		map = MapList.get_by_window(mobj)
		if not map:
			raise AttributeError ("What a mess, can't find the map")
		map.title = new_title