View Full Version : PGCEdit: How to highlight an instance of PGCEdit [solved]
ggtop
18th October 2011, 07:45
Hi r0Lz,
normally I have at least 2 instances of PGCEWdit running. One with the DVD structure I want to edit and the original. It happens quite often that I edit the wrong source becaue it is quite hard to distinguish between the window despite the full path in the window title.
Maybe you have an idea to make it more obvious in which window you are in. Maybe some kind of red border or the tool bar in another color. Is this something that could be implemented?
I store all my untouched rips in a separat folder, maybe you could look for this. Or the existence of a certain file (original.txt).
ggtop
r0lZ
19th October 2011, 10:25
Hum, I can't code something specifically for you or your way to work with PgcEdit, especially if the distinction is based on absolute paths.
What I can probably do that may be useful to others is to highlight the main PgcEdit window in some way when the source files are read-only. That may be useful to remember that editing that DVD is useless. And in your case, all you will have to do is to change the Read Only attribute of the folder containing the original files (or load the original DVD from the DVD drive, if it is not CSS encrypted). Furthermore, you will not be able to save the modifications made by mistake.
Another thing that can be done easily is a little plugin with a command that will toggle the highlight. You will have to call that command when you want to highlight a specific PgcEdit instance. (It should be possible also to let the plugin highlight the read-only DVDs automatically.)
Is it OK for you?
ggtop
19th October 2011, 15:10
Don't get me wrong. I don't want to hire you as my personal developper :D
This is only if YOU think this might be useful, too.
The idea with the plugin is great. And if that is something that could be done quite easily...perfect.
BTW It is not an absolute path but I always store my rips in a subfolder called "\DVD_ORIGINAL\", so an INSTR() would do it. Maybe it's time for a little Tcl/Tk on my end :o.
ggtop
r0lZ
19th October 2011, 18:48
OK, I wrote this plugin:
#############################################################################
# highlight_instance_plugin.tcl Copyright 2011 r0lZ
# PgcEdit plugin to highlight specific instances of PgcEdit.
#
# This plugin is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This plugin is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#############################################################################
# Usage: copy this file in the <PgcEdit's install dir>/plugins directory.
# An "Highlight Instance" menu will be added in the Plugins menu.
# You need PgcEdit 9.3 or more to use this plugin.
#############################################################################
# Version History:
#
# v 1.0 (October 19, 2011)
# - First public release
#############################################################################
namespace eval ::plugins {}
namespace eval ::plugins::highlight {}
# Add Plugins -> Highlight Instance menu
if {! [winfo exists .mainmenu.plugins.highlight]} {
.mainmenu.plugins add cascade -label "Highlight Instance" -menu .mainmenu.plugins.highlight
menu .mainmenu.plugins.highlight
.mainmenu.plugins.highlight add checkbutton -label "Highlight this instance?" -variable ::plugins::highlight::highlight_this -command {::plugins::highlight::highlight_this}
.mainmenu.plugins.highlight add checkbutton -label "Auto highlight read-only DVDs?" -variable ::plugins::highlight::auto_highlight -command {::plugins::highlight::auto_highlight}
.mainmenu.plugins.highlight add separator
.mainmenu.plugins.highlight add command -label "About" -command {
tk_messageBox -title "Highlight Instance plugin" -icon info \
-message "Highlight Instance plugin for PgcEdit 9.3 or more.\nVersion $::plugins::highlight::version\nAuthor: r0lZ\nFreeware!"
}
}
namespace eval ::plugins::highlight {
set version "1.0"
set highlight_this 0
set auto_highlight 0
proc highlight_this {} {
if {$::plugins::highlight::highlight_this} {
. configure -background $::plugins::highlight::highlight_color
} else {
. configure -background SystemButtonFace
}
}
proc auto_highlight {} {
if {$::plugins::highlight::auto_highlight} {
trace add variable ::dvddir write ::plugins::highlight::dvddir_changed
.mainmenu.plugins.highlight entryconfigure "Highlight this instance?" -state disabled
::plugins::highlight::dvddir_changed
} else {
trace remove variable ::dvddir write ::plugins::highlight::dvddir_changed
.mainmenu.plugins.highlight entryconfigure "Highlight this instance?" -state normal
::plugins::highlight::highlight_this
}
::plugins::highlight::save_config
}
proc dvddir_changed {{name ""} {index ""} {op ""}} {
if {[info exists ::dvddir] && ! [file writable [file join $::dvddir "VIDEO_TS.IFO"]]} {
. configure -background $::plugins::highlight::highlight_color
} else {
. configure -background SystemButtonFace
}
}
proc save_config {} {
set data "# colour of the highlight in #RRGGBB format:\n"
set data "${data}set ::plugins::highlight::highlight_color $::plugins::highlight::highlight_color\n"
set data "${data}# Change this setting only from the plugins menu:\n"
set data "${data}set ::plugins::highlight::auto_highlight $::plugins::highlight::auto_highlight"
saveFile [file join $::config(config_directory) highlight_instance_plugin.cfg] auto $data
}
} ;# end of namespace ::plugins::highlight
set ::plugins::highlight::auto_highlight 0
set ::plugins::highlight::highlight_color #FFFF00
if {[catch {source [file join $::config(config_directory) highlight_instance_plugin.cfg]}]} {
::plugins::highlight::save_config
}
if {$::plugins::highlight::auto_highlight} {
::plugins::highlight::dvddir_changed
}
Copy the whole script and paste it in your plugins directory as highlight_instance.tcl, and restart PgcEdit.
You can toggle the highlight manually, or set the option to highlight automatically the read-only DVDs with the Plugins -> Highlight Instance menu.
The first time the plugin is executed, it will create the new config file "%appdata%\PgcEdit\highlight_instance_plugin.cfg".
Note that you can change the highlight colour (by default yellow) by editing the config file.
For example, to draw a red border, change the second line to:
set ::plugins::highlight::highlight_color #FF0000
Note also that a DVD is considered read-only if VIDEO_TS.IFO is read-only. So, to highlight automatically a specific DVD, you can just change the read-only attribute of that file, although I recommend to change it for all files, as otherwise strange things can happen if you edit and save the DVD.
ggtop
20th October 2011, 09:04
Hi r0lZ,
I just tested it and it works great. Many thanks. I changed the color to red and wasn't aware that I have to delete the "%appdata%\PgcEdit\highlight_instance_plugin.cfg" in this case.
I'll play a little with this line:
if {[info exists ::dvddir] && ! [file writable [file join $::dvddir "VIDEO_TS.IFO"]]} {
ggtop
r0lZ
20th October 2011, 09:32
I changed the color to red and wasn't aware that I have to delete the "%appdata%\PgcEdit\highlight_instance_plugin.cfg" in this case.
You should change it in the config file directly, as I've explained in my previous post.
I'll play a little with this line:
if {[info exists ::dvddir] && ! [file writable [file join $::dvddir "VIDEO_TS.IFO"]]} {
Yep, it's the line to change if you want to test the path instead of the read-only attribute.
To test is the DVD is somewhere in the folder containing the original DVDs, you could change it to something like this:
if {[info exists ::dvddir] && [string first [file nativename $::dvddir] "\DVD_ORIGINAL\"] > 0} {
Or, if the DVD is always in, say "...\DVD_ORIGINAL\<DVD_NAME>\VIDEO_TS\", then this test should work too:
if {[info exists ::dvddir] && [file tail [file dirname [file dirname $::dvddir]]] == "DVD_ORIGINAL"} {
[file dirname $::dvddir] returns the path without its last component, and [file tail $::dvddir] returns the last component.
Note that, if the DVD files are in a VIDEO_TS directory, $::dvddir ends always with "\VIDEO_TS", even if \VIDEO_TS is not always displayed in the GUI.
So, to test for "...\<DVD_NAME>\DVD_ORIGINAL\VIDEO_TS\", you should use this:
if {[info exists ::dvddir] && [file tail [file dirname $::dvddir]] == "DVD_ORIGINAL"} {
ggtop
21st October 2011, 20:26
To test is the DVD is somewhere in the folder containing the original DVDs, you could change it to something like this:
if {[info exists ::dvddir] && [string first [file nativename $::dvddir] "\DVD_ORIGINAL\"] > 0} {
That is exactly what I wanted.:thanks:
BTW 'string first' works the other way round: ;)
And I don't think the quotes are needed... And I had to double the backslash. I guess it acts as an escape character when alone.
So I changed it to:
if {[info exists ::dvddir] && [string first \\DVD_ORIGINAL\\ [file nativename $::dvddir]] > 0} {
What about adding some excel functionality next? :)
ggtop
r0lZ
21st October 2011, 23:10
BTW 'string first' works the other way round: ;)
And I don't think the quotes are needed... And I had to double the backslash. I guess it acts as an escape character when alone.:( Oops, right. I haven't tested the code. Just wrote it here.
(The quotes are necessary only if the string includes spaces.)
What about adding some excel functionality next? :)
Of course! And it should cook the eggs, too. ;)
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.