[PD-cvs] pd/src desire.tk, 1.1.2.302, 1.1.2.303 desire.c, 1.1.2.98, 1.1.2.99

Mathieu Bouchard matju at users.sourceforge.net
Tue Aug 8 23:15:18 CEST 2006


Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23628

Modified Files:
      Tag: devel_0_39
	desire.tk desire.c 
Log Message:
reimplemented window close


Index: desire.tk
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.tk,v
retrieving revision 1.1.2.302
retrieving revision 1.1.2.303
diff -C2 -d -r1.1.2.302 -r1.1.2.303
*** desire.tk	8 Aug 2006 19:52:47 -0000	1.1.2.302
--- desire.tk	8 Aug 2006 21:15:16 -0000	1.1.2.303
***************
*** 174,178 ****
  	global poolset
  	if {[info exists poolset($origin)]} {
! 		post %s "def Manager notice: double dirty"
  		# nothing for now
  	} {
--- 174,178 ----
  	global poolset
  	if {[info exists poolset($origin)]} {
! 		# post %s "def Manager notice: double dirty"
  		# nothing for now
  	} {
***************
*** 193,196 ****
--- 193,201 ----
  }
  
+ def History can_undo? {} {return [expr [llength @undo] > 0]}
+ def History can_redo? {} {return [expr [llength @redo] > 0]}
+ def History next_undo_name {} {return stuff}
+ def History next_redo_name {} {return stuff}
+ 
  # overload this if you want to control how many levels
  # of undo may be kept.
***************
*** 477,480 ****
--- 482,487 ----
  set ctrls_meter_on 0
  
+ def Client window {} {return .}
+ 
  def Client init_binds {} {
      global OS
***************
*** 699,707 ****
  }
  
  def Client open_file {} {
!     global pd_opendir
      set filename [tk_getOpenFile -defaultextension .pd \
!     	-filetypes { {{pd files} {.pd}} {{max files} {.pat}}} \
!         -initialdir $pd_opendir]
      if {$filename != ""} {$self open_file_really $filename}
  }
--- 706,719 ----
  }
  
+ set patch_filetypes {
+ 	{"pd files"  ".pd"}
+ 	{"max files" ".pat"}
+ 	{"all files" "*"}
+ }
+ 
  def Client open_file {} {
!     global pd_opendir patch_filetypes
      set filename [tk_getOpenFile -defaultextension .pd \
!     	-filetypes $patch_filetypes -initialdir $pd_opendir]
      if {$filename != ""} {$self open_file_really $filename}
  }
***************
*** 957,963 ****
  class_new Canvas {Menuable ObjectBox}
  
! #def Canvas close  {} {pd $self menuclose 0}
! def* Canvas save   {} {
! 	$self checkgeometry 
  	if {[string length $@file]} {
  		pd .$self savetofile $@file $@directory
--- 969,982 ----
  class_new Canvas {Menuable ObjectBox}
  
! def Canvas close {} {
!   switch [tk_messageBox -message [say savechanges?] -icon question -type yesnocancel -default cancel] {
!     yes    {$self save; pd .$self close}
!     no     {            pd .$self close}
!     cancel {}
!   }
! }
! 
! def Canvas save {} {
! 	$self checkgeometry
  	if {[string length $@file]} {
  		pd .$self savetofile $@file $@directory
***************
*** 967,978 ****
  }
  
- 
  def Canvas save_as {} {
  	$self checkgeometry
! 	set types {
! 		{{Pd Files}       {.pd} }
! 		{{All Files}      *     }
! 	}
! 	set filename [tk_getSaveFile -filetypes $types]
  	if {$filename != ""} {
  		set @file [string range $filename [expr [string last / $filename]+1] end]
--- 986,993 ----
  }
  
  def Canvas save_as {} {
+ 	global patch_filetypes
  	$self checkgeometry
! 	set filename [tk_getSaveFile -filetypes $patch_filetypes]
  	if {$filename != ""} {
  		set @file [string range $filename [expr [string last / $filename]+1] end]
***************
*** 983,988 ****
  }
  
- 
- 
  def Canvas print  {} {
      set filename [tk_getSaveFile -initialfile pd.ps -defaultextension .ps \
--- 998,1001 ----
***************
*** 1099,1108 ****
  }
  
! def* Canvas getscroll {args} {}
  
! def Canvas close {} {
! 	pd .$self menuclose 0
! 	$self fix_window_menu
! }
  
  #-----------------------------------------------------------------------------------#
--- 1112,1118 ----
  }
  
! def Canvas getscroll {args} {}
  
! def Canvas window {} {return .$self}
  
  #-----------------------------------------------------------------------------------#
***************
*** 1351,1365 ****
  # LATER also cut/copy/paste
  def Canvas fix_edit_menu {} {
-     return ;# hehe
      set e .$self.m.edit
      set t [say undo]
!     if {[llength $@undo]} {
! 	$e entryconfigure $t -state normal   -label "$t [$@history undoaction]"
      } else {
  	$e entryconfigure $t -state disabled -label "[say cannot] $t"
      }
      set t [say redo]
!     if {[llength $@redo]} {
! 	$e entryconfigure $t -state normal   -label "$t [$@history redoaction]"
      } else {
  	$e entryconfigure $t -state disabled -label "[say cannot] $t"
--- 1361,1374 ----
  # LATER also cut/copy/paste
  def Canvas fix_edit_menu {} {
      set e .$self.m.edit
      set t [say undo]
!     if {[$@history can_undo?]} {
! 	$e entryconfigure $t -state normal   -label "$t [$@history next_undo_name]"
      } else {
  	$e entryconfigure $t -state disabled -label "[say cannot] $t"
      }
      set t [say redo]
!     if {[$@history can_redo?]} {
! 	$e entryconfigure $t -state normal   -label "$t [$@history next_redo_name]"
      } else {
  	$e entryconfigure $t -state disabled -label "[say cannot] $t"
***************
*** 1373,1378 ****
      set menu $@menubar.window
      $menu delete 0 end
! #	{"parentwindow" {menu_windowparent} ""}
!     foreach w $window_list {$menu add command -label $w -command "$w raise"}
  }
  
--- 1382,1387 ----
      set menu $@menubar.window
      $menu delete 0 end
!     foreach w $window_list {$menu add command -label [wm title [$w window]] -command "$w raise"}
! #   {"parentwindow" {menu_windowparent} ""}
  }
  
***************
*** 3526,3532 ****
  
  def* AtomBox init {args} {
- 	super
  	global font
! 	eval [concat [list super] $args]
  	set @clicking 0
  	set @val 0
--- 3535,3540 ----
  
  def* AtomBox init {args} {
  	global font
! 	super
  	set @clicking 0
  	set @val 0

Index: desire.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.c,v
retrieving revision 1.1.2.98
retrieving revision 1.1.2.99
diff -C2 -d -r1.1.2.98 -r1.1.2.99
*** desire.c	8 Aug 2006 19:52:47 -0000	1.1.2.98
--- desire.c	8 Aug 2006 21:15:16 -0000	1.1.2.99
***************
*** 2817,2894 ****
  }
  
!     /* quit, after calling glist_finddirty() on all toplevels and verifying
!     the user really wants to discard changes  */
! void glob_verifyquit(void *dummy, t_floatarg f)
! {
!     t_glist *g, *g2;
!         /* find all root canvases */
!     for (g = canvas_list; g; g = g->gl_next)
!         if ((g2 = glist_finddirty(g)))
!     {
!         canvas_vis(g2, 1);
!         sys_vgui(
! "pdtk_check {Discard changes to this window??} {.x%lx menuclose 3;\n} no\n",
!                (long) g2);
!         return;
!     }
!     if (f == 0)
!         sys_vgui("pdtk_check {really quit?} {pd quit;\n} yes\n");
!     else glob_quit(0);
! }
! 
!     /* close a window (or possibly quit Pd), checking for dirty flags.
!     The "force" parameter is interpreted as follows:
!         0 - request from GUI to close, verifying whether clean or dirty
!         1 - request from GUI to close, no verification
!         2 - verified - mark this one clean, then continue as in 1
!         3 - verified - mark this one clean, then verify-and-quit
!     */
! void canvas_menuclose(t_canvas *x, t_floatarg fforce)
! {
!     int force = fforce;
!     t_glist *g;
!     if (x->gl_owner && (force == 0 || force == 1))
!         canvas_vis(x, 0);   /* if subpatch, just invis it */
!     else if (force == 0)    
!     {
!         g = glist_finddirty(x);
!         if (g)
!         {
!             canvas_vis(g, 1);
!             sys_vgui(
! "pdtk_check {Discard changes to this window??} {.x%lx menuclose 2;\n} no\n",
!                 (long)g);
!             return;
!         }
!         else
!         {
!             sys_vgui(
! "pdtk_check {Close this window??} {.x%lx menuclose 1;\n} yes\n",
!                 (long)x);
!         }
!     }
!     else if (force == 1)
!         pd_free(&x->gl_pd);
!     else if (force == 2)
!     {
!         canvas_dirty(x, 0);
!         while (x->gl_owner)
!             x = x->gl_owner;
!         g = glist_finddirty(x);
!         if (g)
!         {
!             canvas_vis(g, 1);
!             sys_vgui(
! "pdtk_check {Discard changes to this window??} {.x%lx menuclose 2;\n} no\n",
!                 (long)g);
!             return;
!         }
!         else pd_free(&x->gl_pd);
!     }
!     else if (force == 3)
!     {
!         canvas_dirty(x, 0);
!         glob_verifyquit(0, 1);
!     }
  }
  
--- 2817,2822 ----
  }
  
! void canvas_close(t_canvas *x) {
!     if (x->gl_owner) canvas_vis(x, 0); else pd_free(&x->gl_pd);
  }
  
***************
*** 12701,12705 ****
  
      class_addmethod3(c,canvas_key,"key","*");
!     class_addmethod3(c,canvas_menuclose,"menuclose","F");
  
  /* should die: */
--- 12629,12633 ----
  
      class_addmethod3(c,canvas_key,"key","*");
!     class_addmethod3(c,canvas_close,"close","F");
  
  /* should die: */
***************
*** 12958,12962 ****
      for (x = canvas_list; x; ) {
          y = x->gl_next;
!         canvas_menuclose(x, fforce); /* forced closing of this root canvas */
          x = y;
      }
--- 12886,12890 ----
      for (x = canvas_list; x; ) {
          y = x->gl_next;
!         canvas_close(x); /* forced closing of this root canvas */
          x = y;
      }





More information about the Pd-cvs mailing list