Andreas Volz wrote:
>Am Sun, 25 Sep 2005 11:08:34 +0200 schrieb dienekes:
>
>
>
>>Andreas Volz wrote:
>>
>>
>>
>>>Hello,
>>>
>>>Is there a graphical key editor for E17 in CVS? Perhaps a very early
>>>one?
>>>
>>>regards
>>>Andreas
>>>
>>>
>>>
>>>
>>e17_remote can do that.
>>
>>
>
>I know this and did it, but a GUI is great for such stuff. I'm
>currently installing GTK2-Perl to try erme.
>
>
>
e17_remote is a GUI tool!
http://c7obs.net/~adi/projects/perl/e17_remote
Unfortunately it disappeared. I have no idea why. Its such a great tool.
Thererfore I attached a copy.
-Dienekes
#!/usr/bin/perl -w
use strict;
use Gtk2 '-init';
use constant TRUE => 1;
use constant FALSE => 0;
use constant LOAD => 1;
use constant ADD => 0;
use constant DEBUG => 0;
use constant VERBOSE => 1;
##################################################
# README
#
# This code is release under a public domain licence
# You will need GTK2::Perl to run this script
#
# Enlightenment_remote change often and you must keep
# this script updated.
#
# The combo box values may change frequently so please
# update them
#
# The code from Mouse and key bindings is a mess
# The code from Options and Winlist is designed to be
# modified very easy. So you should add or modify it
# very easy.
#
# THE END
##############################################
###############################################
# values for COMBO BOXE
### this value must be updated at each change of e17
my @context_vals =('ANY');
my @key_vals =
('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
'Insert','Tab','Menu','Delete','Meta','Home','End',
'F1','F2','F3','F4','F5','F6','F7','F8','F9','F10','F11','F12',
'Left','Up','Down','Right');
my @action_vals = ('desktop_linear_flip_to',
'desktop_linear_flip_by',
'desk_flip_by',
'window_menu','window_close','window_kill','window_raise','window_lower',
'window_sticky_toggle','window_iconic_toggle','window_maximized_toggle','window_shaded_toggle',
'edit_mode_toggle',
'menu_show',
'winlist',
'exec');
my @mouse_button_vals = ('1','2','3');
my @mouse_context_vals = ('ZONE','BORDER','CONTAINER');
my @par_vals = ('','main','favorites','clients');
##########################################
# GLOBAL VARIABLES
#for keys tab
my @context;
my @key;
my @mod_alt;
my @mod_ctrl;
my @mod_shift;
my @any;
my @action;
my @par;
my @delete;
#for keys tab initial field values
my @init_key;
my @init_mod;
my @init_action;
my @init_par;
#for mouse tab
my @mouse_context;
my @mouse_button;
my @mouse_mod_alt;
my @mouse_mod_ctrl;
my @mouse_mod_shift;
my @mouse_action;
my @mouse_par;
my @mouse_delete;
my @mouse_init_context;
my @mouse_init_button;
my @mouse_init_mod;
my @mouse_init_action;
my @mouse_init_par;
my @mouse_deleted;
#general layout
my $hbox;
my $vbox_key;
my $vbox_mouse;
my $notebook;
my $init_nr = 0;
my $i = 0;
my $m_i = 0;
my @deleted_keys;
#containers for fields
my $vboxk_context;
my $vboxk_key;
my $vboxk_mod_alt;
my $vboxk_mod_ctrl;
my $vboxk_mod_shift;
my $vboxk_any;
my $vboxk_action;
my $vboxk_par;
my $vboxk_delete;
my %value_bool;
my %value_num;
my %value_string;
my %value_string_free;
my %widget_bool;
my %widget_num;
my %widget_string;
my %widget_string_free;
#######################################3
# WINDOW
my $window = Gtk2::Window->new;
$window->set_title ('Simple key binding');
$window->resize (750, 400);
# signal 1, attached to the main window, when it is destroyed, clicked close
# button, <alt-f4>, etc., quit the main loop
$window->signal_connect (destroy => sub { Gtk2->main_quit; });
# END OF WINDOW DEF
#===================================
#create and pack the containers
my $vboxmain = Gtk2::VBox->new(FALSE, 5);
my $temp_cont;
$notebook=Gtk2::Notebook->new();
$window->add($vboxmain);
#add top buttons
if (VERBOSE) {print "Adding control buttons\n"}
add_buttons($vboxmain);
#add notebook
$vboxmain->pack_start($notebook,TRUE,TRUE, 0);
#add keys
if (VERBOSE) {print "Adding keys binding\n"}
$temp_cont = Gtk2::HBox->new(TRUE, 5);
$notebook->append_page ($temp_cont, "Keys");
add_keys($temp_cont);
#add mouse
if (VERBOSE) {print "Adding mouse binding\n"}
$temp_cont = Gtk2::HBox->new(TRUE, 5);
$notebook->append_page ($temp_cont, "Mouse");
add_mouse($temp_cont);
#add options
if (VERBOSE) {print "Adding general options\n"}
$temp_cont = Gtk2::HBox->new(TRUE, 5);
$notebook->append_page ($temp_cont, "Options");
add_options($temp_cont);
#add winlist
if (VERBOSE) {print "Adding winlist options\n"}
$temp_cont = Gtk2::HBox->new(TRUE, 5);
$notebook->append_page ($temp_cont, "Winlist");
add_winlist($temp_cont);
#add desktop
if (VERBOSE) {print "Adding desktop options\n"}
$temp_cont = Gtk2::HBox->new(TRUE, 5);
$notebook->append_page ($temp_cont, "Desktops");
add_desktop($temp_cont);
#start the fire
$window->show_all;
Gtk2->main;
################################
# TOP BUTToNS
sub add_buttons
{
my $hboxb = Gtk2::HBox->new(FALSE, 5);
$_[0]->pack_start($hboxb, FALSE, TRUE, 0);
my $button_new = Gtk2::Button->new ('New');
$button_new->signal_connect (clicked => \&action_new);
my $button_ok = Gtk2::Button->new ('OK');
$button_ok->signal_connect (clicked => \&action_ok);
my $button_cancel = Gtk2::Button->new ('Cancel');
$button_cancel->signal_connect (clicked => sub { Gtk2->main_quit; });
my $button_apply = Gtk2::Button->new ('Apply');
$button_apply->signal_connect (clicked => \&action_apply);
$hboxb->pack_start($button_new, FALSE, TRUE, 0);
$hboxb->pack_start($button_apply, FALSE, TRUE, 0);
$hboxb->pack_start($button_ok, FALSE, TRUE, 0);
$hboxb->pack_start($button_cancel, FALSE, TRUE, 0);
}
####################################################################
# KEYS tab
#####################################################################
sub add_keys
{
#
my $pane_box = Gtk2::VBox->new(FALSE,0);
$_[0]->pack_start($pane_box, TRUE, TRUE, 0);
my $hboxk = Gtk2::HBox->new(FALSE, 5);
$pane_box->pack_start($hboxk, FALSE, FALSE,0);
my $table_header;
#create table header
#CONTEXT IS OUT
#$table_header = Gtk2::Label->new('Context');
#$vboxk_context = Gtk2::VBox->new(FALSE, 5);
#$vboxk_context->pack_start($table_header,FALSE,FALSE,5);
#$hboxk->pack_start($vboxk_context,FALSE,FALSE,0);
$table_header = Gtk2::Label->new('Key');
$vboxk_key = Gtk2::VBox->new(FALSE, 5);
$vboxk_key->pack_start($table_header,FALSE,FALSE,5);
$hboxk->pack_start($vboxk_key,FALSE,FALSE,0);
$table_header = Gtk2::Label->new('Alt');
$vboxk_mod_alt = Gtk2::VBox->new(FALSE, 5);
$vboxk_mod_alt->pack_start($table_header,FALSE,FALSE,5);
$hboxk->pack_start($vboxk_mod_alt,FALSE,FALSE,0);
$table_header = Gtk2::Label->new('Ctrl');
$vboxk_mod_ctrl = Gtk2::VBox->new(FALSE, 5);
$vboxk_mod_ctrl->pack_start($table_header,FALSE,FALSE,5);
$hboxk->pack_start($vboxk_mod_ctrl,FALSE,FALSE,0);
$table_header = Gtk2::Label->new('Shift');
$vboxk_mod_shift = Gtk2::VBox->new(FALSE, 5);
$vboxk_mod_shift->pack_start($table_header,FALSE,FALSE,5);
$hboxk->pack_start($vboxk_mod_shift,FALSE,FALSE,0);
#ANY IS OUT
#$table_header = Gtk2::Label->new('Any');
#$vboxk_any = Gtk2::VBox->new(FALSE, 5);
#$vboxk_any->pack_start($table_header,FALSE,FALSE,5);
#$hboxk->pack_start($vboxk_any,FALSE,FALSE,0);
$table_header = Gtk2::Label->new('Action');
$vboxk_action = Gtk2::VBox->new(FALSE, 5);
$vboxk_action->pack_start($table_header,FALSE,FALSE,5);
$hboxk->pack_start($vboxk_action,FALSE,FALSE,0);
$table_header = Gtk2::Label->new('Parameters');
$vboxk_par = Gtk2::VBox->new(FALSE, 5);
$vboxk_par->pack_start($table_header,FALSE,FALSE,5);
$hboxk->pack_start($vboxk_par,FALSE,FALSE,0);
$table_header = Gtk2::Label->new('');
$vboxk_delete = Gtk2::VBox->new(FALSE, 5);
$vboxk_delete->pack_start($table_header,FALSE,FALSE,5);
$hboxk->pack_start($vboxk_delete,FALSE,FALSE,0);
#end of table header
#define scrooled windows
my $sw = Gtk2::ScrolledWindow->new(undef,undef);
$pane_box->pack_start($sw,TRUE,TRUE, 0);
#define layout
$vbox_key = Gtk2::VBox->new(FALSE, 5);
$sw->add_with_viewport ($vbox_key);
$hboxk = Gtk2::HBox->new(FALSE, 5);
$vbox_key->pack_start($hboxk, FALSE, FALSE,0);
my $key_i;
my $key_field;
my $mod_alt_i;
my $mod_ctrl_i;
my $mod_field;
my $any_i;
my $action_i;
my $action_field;
my $par_i;
my $par_field;
my $delete_i;
#now parse the output of e_remote -bind-key-list and create the widgets
open(KBL, "enlightenment_remote -binding-key-list|");
while (<KBL>){
if (/REPLY: BINDING CONTEXT=(.*) KEY="(.*)" MODIFIERS=(.*)
ANY_MOD=(.*) ACTION="(.*)" PARAMS="(.*)".*/){
if (DEBUG) {print "context=$1 key=$2 mod=$3 any=$4
action=$5 par=$6\n";}
$mod_field=$3;
$key_field=$2;
$action_field=$5;
$par_field=$6;
#instance variables - created temporarly and then added to
the array - are overwrited
# in the next iteration
if ($i > 0) {
$hbox = Gtk2::HBox->new(FALSE, 5);
$vbox_key->pack_start($hbox, TRUE, TRUE, 0);
}
#CONTEXT IS OUT
#add_field_context();
add_field_key(LOAD,$key_field);
add_field_mod_alt(LOAD,$mod_field);
add_field_mod_ctrl(LOAD,$mod_field);
add_field_mod_shift(LOAD,$mod_field);
add_field_action(LOAD,$action_field);
add_field_par(LOAD,$par_field);
add_field_delete();
#====ANY
#$any_i = Gtk2::Label->new('0');
#$vboxk_any->pack_start($any_i, FALSE, FALSE, 4);
#increment i
$i++;
}
}
$init_nr = $i;
}
#################################################################3
# FIELDS
sub add_field_key
{
my $key_field = $_[1];
if ($_[0] == LOAD)
{
push(@init_key,$key_field);
}else{
push(@init_key,"a");
}
#====KeY
my $key_i = Gtk2::Combo->new ();
@key = (@key, $key_i);
$key[$i]->set_popdown_strings(@key_vals);
$key[$i]->set('enable-arrow-keys',TRUE);
$key[$i]->set('value-in-list',TRUE);
$key[$i]->set('allow-empty' ,FALSE);
$key[$i]->entry->set_text ($key_field);
if ($i == 0)
{
$vboxk_key->pack_start($key[$i], FALSE, FALSE, 0);
}else{
$hbox->pack_start($key[$i], FALSE, FALSE, 0);
}
}
sub add_field_mod_alt
{
my $mod_field = $_[1];
if ($_[0] == LOAD)
{
push(@init_mod,$mod_field);
}else{
push(@init_mod,"");
}
#====MOD ALT
my $mod_alt_i = Gtk2::CheckButton->new();
if ( $mod_field =~ /.*ALT.*/) {$mod_alt_i->set_active (TRUE);}
@mod_alt = (@mod_alt, $mod_alt_i);
if ($i == 0)
{
$vboxk_mod_alt->pack_start($mod_alt[$i],FALSE,FALSE,0);
}else{
$hbox->pack_start($mod_alt[$i], FALSE, FALSE, 0);
}
}
sub add_field_mod_ctrl
{
my $mod_field = $_[1];
#==== MOD CTRL
my $mod_ctrl_i = Gtk2::CheckButton->new();
if ( $mod_field =~ /.*CTRL.*/) {$mod_ctrl_i->set_active (TRUE);}
@mod_ctrl = (@mod_ctrl, $mod_ctrl_i);
if ($i == 0)
{
$vboxk_mod_ctrl->pack_start($mod_ctrl[$i],FALSE,FALSE,0);
}else{
$hbox->pack_start($mod_ctrl[$i], FALSE, FALSE, 0);
}
}
sub add_field_mod_shift
{
my $mod_field = $_[1];
#==== MOD CTRL
my $mod_shift_i = Gtk2::CheckButton->new();
if ( $mod_field =~ /.*SHIFT.*/) {$mod_shift_i->set_active (TRUE);}
@mod_shift = (@mod_shift, $mod_shift_i);
if ($i == 0)
{
$vboxk_mod_shift->pack_start($mod_shift[$i],FALSE,FALSE,0);
}else{
$hbox->pack_start($mod_shift[$i], FALSE, FALSE, 0);
}
}
sub add_field_action
{
my $field_action = $_[1];
if ($_[0] == LOAD)
{
push(@init_action,$field_action);
}else{
push(@init_action,"exec");
}
#====ACTION
my $action_i = Gtk2::Combo->new ();
@action = (@action, $action_i);
$action[$i]->set_popdown_strings(@action_vals);
$action[$i]->set('enable-arrow-keys',TRUE);
$action[$i]->set('value-in-list',TRUE);
$action[$i]->set('allow-empty' ,FALSE);
$action[$i]->entry->set_text ($field_action);
if ($i == 0)
{
$vboxk_action->pack_start($action[$i], FALSE, FALSE, 0);
}else{
$hbox->pack_start($action[$i], FALSE, FALSE, 0);
}
}
sub add_field_par
{
my $field_par = $_[1];
if ($_[0] == LOAD)
{
push(@init_par,$field_par);
}else{
push(@init_par,"xterm");
}
#====PAR
my $par_i = Gtk2::Combo->new ();
@par = (@par, $par_i);
$par[$i]->set_popdown_strings(@par_vals);
$par[$i]->set('enable-arrow-keys',TRUE);
#$action[$i]->set('value-in-list',TRUE);
#$action[$i]->set('allow-empty' ,FALSE);
$par[$i]->entry->set_text ($field_par);
if ($i == 0)
{
$vboxk_par->pack_start($par[$i], FALSE, FALSE, 0);
}else{
$hbox->pack_start($par[$i], FALSE, FALSE, 0);
}
}
sub add_field_delete
{
#====DETELE button
my $delete_i = Gtk2::Button->new ('Delete');
$delete_i->signal_connect (clicked => \&action_delete_key, $i);
@delete = (@delete,$delete_i);
if ($i == 0)
{
$vboxk_delete->pack_start($delete_i, FALSE, FALSE, 1);
}else{
$hbox->pack_start($delete_i, FALSE, FALSE, 0);
}
}
#APPLY KEYS
sub action_apply_keys
{
my @keys_probably_updated;
my @keys_updated;
my $iter;
#FIRST DELETE ALL KEY FROM @deleted_keys
foreach $iter (@deleted_keys){
my $cmd_del = "enlightenment_remote -binding-key-del ANY
$init_key[$iter] \"$init_mod[$iter]\" 0 $init_action[$iter]
\"$init_par[$iter]\"";
print "$cmd_del \n";
system ($cmd_del);
}
for (my $j=0; $j<$i; $j++){
if (!member(@deleted_keys,$j)) {push
(@keys_probably_updated,$j);}
}
if (DEBUG) {print "Keys probably updated @keys_probably_updated \n";}
foreach $iter (@keys_probably_updated){
my $has_changed = FALSE;
$has_changed=FALSE;
my $new_mod = "";
my $new_key = $key[$iter]->entry->get_text();
my $new_action = $action[$iter]->entry->get_text();
my $new_par = $par[$iter]->entry->get_text();
#if ($iter < $init_nr) {
if ($init_key[$iter] ne $new_key) {$has_changed=TRUE;}
if ($init_action[$iter] ne $new_action)
{$has_changed=TRUE;}
if ($init_par[$iter] ne $new_par) {$has_changed=TRUE;}
if ($mod_shift[$iter]->get_active())
{$new_mod=$new_mod."|SHIFT"};
if ($mod_ctrl[$iter]->get_active())
{$new_mod=$new_mod."|CTRL"};
if ($mod_alt[$iter]->get_active())
{$new_mod=$new_mod."|ALT"};
if ($new_mod eq "") {$new_mod="NONE";}
if (substr($new_mod,0,1) eq '|')
{$new_mod=substr($new_mod,1);}
if ($init_mod[$iter] ne $new_mod) {$has_changed=TRUE;}
#}else {$has_changed = TRUE;}
if ($has_changed == TRUE) {
my $cmd_add = "enlightenment_remote -binding-key-add ANY
$new_key \"$new_mod\" 0 $new_action \"$new_par\"";
my $cmd_del = "enlightenment_remote -binding-key-del ANY
$init_key[$iter] \"$init_mod[$iter]\" 0 $init_action[$iter]
\"$init_par[$iter]\"";
system ($cmd_del);
print "$iter: $cmd_del \n";
system ($cmd_add);
print "$iter: $cmd_add \n";
#after we have added a key we update the init fields
$init_key[$iter]=$new_key;
$init_mod[$iter]=$new_mod;
$init_action[$iter]=$new_action;
$init_par[$iter]=$new_par;
}
}
}
sub action_delete_key
{
my $id = $_[1];
my $widget = $_[0];
push (@deleted_keys,$id);
#hide the row TODO
$delete[$id]->unmap;
#CONTEXT IS OUT
#$context[$id]->unmap;
$key[$id]->unmap;
$mod_alt[$id]->unmap;
$mod_ctrl[$id]->unmap;
$mod_shift[$id]->unmap;
$action[$id]->unmap;
$par[$id]->unmap;
print "s-a apasat $_[1] in $_[0] nr $i\n";
$window->show_all;
}
sub action_new_keys
{
if ($i > 0) {
$hbox = Gtk2::HBox->new(FALSE, 5);
$vbox_key->pack_start($hbox, TRUE, TRUE, 0);
}
add_field_key(ADD,'a');
add_field_mod_alt(ADD,'NONE');
add_field_mod_ctrl(ADD,'NONE');
add_field_mod_shift(ADD,'NONE');
add_field_action(ADD,'exec');
add_field_par(ADD,'xterm');
add_field_delete();
$i++;
$window->show_all;
}
#################################################################
# MOUSE TAB
#############################################################
sub add_mouse
{
#binding-mouse-list /add del
# CONTEXT BUTTON MODIFIERS ACTION
#
my $pane_box = Gtk2::VBox->new(FALSE,0);
$_[0]->pack_start($pane_box, TRUE, TRUE, 0);
my $hboxk = Gtk2::HBox->new(FALSE, 5);
$pane_box->pack_start($hboxk, FALSE, FALSE,0);
#create table header
my $table_header;
my $vbox_temp;
$table_header = Gtk2::Label->new('Context');
$vbox_temp = Gtk2::VBox->new(FALSE, 5);
$vbox_temp->pack_start($table_header,FALSE,FALSE,5);
$hboxk->pack_start($vbox_temp,FALSE,FALSE,0);
$table_header = Gtk2::Label->new('Button');
$vbox_temp = Gtk2::VBox->new(FALSE, 5);
$vbox_temp->pack_start($table_header,FALSE,FALSE,5);
$hboxk->pack_start($vbox_temp,FALSE,FALSE,0);
$table_header = Gtk2::Label->new('Alt');
$vbox_temp = Gtk2::VBox->new(FALSE, 5);
$vbox_temp->pack_start($table_header,FALSE,FALSE,5);
$hboxk->pack_start($vbox_temp,FALSE,FALSE,0);
$table_header = Gtk2::Label->new('Ctrl');
$vbox_temp = Gtk2::VBox->new(FALSE, 5);
$vbox_temp->pack_start($table_header,FALSE,FALSE,5);
$hboxk->pack_start($vbox_temp,FALSE,FALSE,0);
$table_header = Gtk2::Label->new('Shift');
$vbox_temp = Gtk2::VBox->new(FALSE, 5);
$vbox_temp->pack_start($table_header,FALSE,FALSE,5);
$hboxk->pack_start($vbox_temp,FALSE,FALSE,0);
$table_header = Gtk2::Label->new('Action');
$vbox_temp = Gtk2::VBox->new(FALSE, 5);
$vbox_temp->pack_start($table_header,FALSE,FALSE,5);
$hboxk->pack_start($vbox_temp,FALSE,FALSE,0);
$table_header = Gtk2::Label->new('Parameters');
$vbox_temp = Gtk2::VBox->new(FALSE, 5);
$vbox_temp->pack_start($table_header,FALSE,FALSE,5);
$hboxk->pack_start($vbox_temp,FALSE,FALSE,0);
$table_header = Gtk2::Label->new('');
$vbox_temp = Gtk2::VBox->new(FALSE, 5);
$vbox_temp->pack_start($table_header,FALSE,FALSE,5);
$hboxk->pack_start($vbox_temp,FALSE,FALSE,0);
#end of table header
#define scrooled windows
my $sw = Gtk2::ScrolledWindow->new(undef,undef);
$pane_box->pack_start($sw,TRUE,TRUE, 0);
#define layout
$vbox_mouse = Gtk2::VBox->new(FALSE, 5);
$sw->add_with_viewport ($vbox_mouse);
$hboxk = Gtk2::HBox->new(FALSE, 5);
$vbox_mouse->pack_start($hboxk, FALSE, FALSE,0);
my $context_field;
my $key_i;
my $button_field;
my $mod_alt_i;
my $mod_ctrl_i;
my $mod_field;
my $any_i;
my $action_i;
my $action_field;
my $par_i;
my $par_field;
my $delete_i;
#now parse the output of e_remote -bind-key-list and create the widgets
open(KBL, "enlightenment_remote -binding-mouse-list|");
while (<KBL>){
if (/REPLY: BINDING CONTEXT=(.*) BUTTON=(.*) MODIFIERS=(.*)
ANY_MOD=(.*) ACTION="(.*)" PARAMS="(.*)".*/){
if (DEBUG) {print "context=$1 button=$2 mod=$3 any=$4 action=$5
par=$6\n";}
$context_field=$1;
$mod_field=$3;
$button_field=$2;
$action_field=$5;
$par_field=$6;
#instance variables - created temporarly and then added to the
array - are overwrited
# in the next iteration
$hbox = Gtk2::HBox->new(FALSE, 5);
$vbox_mouse->pack_start($hbox, FALSE, FALSE, 0);
#ADD fields
add_field_mouse_context($context_field);
add_field_mouse_button($button_field);
add_field_mouse_mod_alt($mod_field);
add_field_mouse_mod_ctrl($mod_field);
add_field_mouse_mod_shift($mod_field);
add_field_mouse_action($action_field);
add_field_mouse_par($par_field);
add_field_mouse_delete();
#increment i
$m_i++;
}
}
$init_nr = $i;
}
###
#MOUSE - field - context
sub add_field_mouse_context
{
my $field_content = $_[0];
push(@mouse_init_context,$field_content);
#====context
my $field = Gtk2::Combo->new ();
$field->set_popdown_strings(@mouse_context_vals);
$field->set('enable-arrow-keys',TRUE);
$field->set('value-in-list',TRUE);
$field->set('allow-empty' ,FALSE);
$field->entry->set_text ($field_content);
$hbox->pack_start($field, FALSE, FALSE, 0);
push (@mouse_context, $field);
}
sub add_field_mouse_button
{
my $field_content = $_[0];
push(@mouse_init_button,$field_content);
#====context
my $field = Gtk2::Combo->new ();
$field->set_popdown_strings(@mouse_button_vals);
$field->set('enable-arrow-keys',TRUE);
$field->set('value-in-list',TRUE);
$field->set('allow-empty' ,FALSE);
$field->entry->set_text ($field_content);
$hbox->pack_start($field, FALSE, FALSE, 0);
push (@mouse_button, $field);
}
sub add_field_mouse_mod_alt
{
my $field_content = $_[0];
push(@mouse_init_mod,$field_content);
#====MOD ALT
my $field = Gtk2::CheckButton->new();
if ( $field_content =~ /.*ALT.*/) {$field->set_active (TRUE);}
$hbox->pack_start($field, FALSE, FALSE, 0);
push (@mouse_mod_alt, $field);
}
sub add_field_mouse_mod_ctrl
{
my $field_content = $_[0];
#====MOD CTRL
my $field = Gtk2::CheckButton->new();
if ( $field_content =~ /.*CTRL.*/) {$field->set_active (TRUE);}
$hbox->pack_start($field, FALSE, FALSE, 0);
push (@mouse_mod_ctrl, $field);
}
sub add_field_mouse_mod_shift
{
my $field_content = $_[0];
#====MOD SHIFT
my $field = Gtk2::CheckButton->new();
if ( $field_content =~ /.*SHIFT.*/) {$field->set_active (TRUE);}
$hbox->pack_start($field, FALSE, FALSE, 0);
push (@mouse_mod_shift, $field);
}
sub add_field_mouse_action
{
my $field_content = $_[0];
push(@mouse_init_action,$field_content);
#====context
my $field = Gtk2::Combo->new ();
$field->set_popdown_strings(@action_vals);
$field->set('enable-arrow-keys',TRUE);
$field->set('value-in-list',TRUE);
$field->set('allow-empty' ,FALSE);
$field->entry->set_text ($field_content);
$hbox->pack_start($field, FALSE, FALSE, 0);
push (@mouse_action, $field);
}
sub add_field_mouse_par
{
my $field_content = $_[0];
push(@mouse_init_par,$field_content);
#====context
my $field = Gtk2::Combo->new ();
$field->set_popdown_strings(@par_vals);
$field->set('enable-arrow-keys',TRUE);
$field->set('value-in-list',TRUE);
$field->set('allow-empty' ,FALSE);
$field->entry->set_text ($field_content);
$hbox->pack_start($field, FALSE, FALSE, 0);
push (@mouse_par, $field);
}
sub add_field_mouse_delete
{
#====DETELE button
my $field = Gtk2::Button->new ('Delete');
$field->signal_connect (clicked => \&action_delete_mouse, $m_i);
$hbox->pack_start($field, FALSE, FALSE, 0);
push (@mouse_delete,$field);
}
sub action_delete_mouse
{
my $id = $_[1];
my $widget = $_[0];
push (@mouse_deleted,$id);
#hide the row TODO
$mouse_delete[$id]->unmap;
$mouse_context[$id]->unmap;
$mouse_button[$id]->unmap;
$mouse_mod_alt[$id]->unmap;
$mouse_mod_ctrl[$id]->unmap;
$mouse_mod_shift[$id]->unmap;
$mouse_action[$id]->unmap;
$mouse_par[$id]->unmap;
$window->show_all;
}
sub action_new_button
{
$hbox = Gtk2::HBox->new(FALSE, 5);
$vbox_mouse->pack_start($hbox, FALSE, FALSE, 0);
#ADD fields
add_field_mouse_context("ZONE");
add_field_mouse_button("1");
add_field_mouse_mod_alt("NONE");
add_field_mouse_mod_ctrl("");
add_field_mouse_mod_shift("");
add_field_mouse_action("menu_show");
add_field_mouse_par("clients");
add_field_mouse_delete();
#increment i
$m_i++;
$window->show_all;
}
sub action_apply_mouse
{
my @fields_probably_updated;
my @fields_updated;
my $iter;
#FIRST DELETE ALL KEY FROM @deleted_keys
foreach $iter (@mouse_deleted){
my $cmd_del = "enlightenment_remote -binding-mouse-del
$mouse_init_context[$iter] $mouse_init_button[$iter] \"$mouse_init_mod[$iter]\"
0 $mouse_init_action[$iter] \"$mouse_init_par[$iter]\"";
print "$cmd_del \n";
system ($cmd_del);
}
for (my $j=0; $j<$m_i; $j++){
if (!member(@mouse_deleted,$j)) {push (@fields_probably_updated,$j);}
}
if (DEBUG) {print "Mouse probably updated @fields_probably_updated \n";}
foreach $iter (@fields_probably_updated){
my $has_changed = FALSE;
$has_changed=FALSE;
my $new_mod = "";
my $new_context = $mouse_context[$iter]->entry->get_text();
my $new_button = $mouse_button[$iter]->entry->get_text();
my $new_action = $mouse_action[$iter]->entry->get_text();
my $new_par = $mouse_par[$iter]->entry->get_text();
#if ($iter < $init_nr) {
if ($mouse_init_button[$iter] ne $new_button) {$has_changed=TRUE;}
if ($mouse_init_action[$iter] ne $new_action) {$has_changed=TRUE;}
if ($mouse_init_par[$iter] ne $new_par) {$has_changed=TRUE;}
if ($mouse_init_context[$iter] ne $new_context) {$has_changed=TRUE;}
if ($mouse_mod_shift[$iter]->get_active()) {$new_mod=$new_mod."|SHIFT"};
if ($mouse_mod_ctrl[$iter]->get_active()) {$new_mod=$new_mod."|CTRL"};
if ($mouse_mod_alt[$iter]->get_active()) {$new_mod=$new_mod."|ALT"};
if ($new_mod eq "") {$new_mod="NONE";}
if (substr($new_mod,0,1) eq '|') {$new_mod=substr($new_mod,1);}
if ($mouse_init_mod[$iter] ne $new_mod) {$has_changed=TRUE;}
#}else {$has_changed = TRUE;}
if ($has_changed == TRUE) {
my $cmd_add = "enlightenment_remote -binding-mouse-add $new_context
$new_button \"$new_mod\" 0 $new_action \"$new_par\"";
my $cmd_del = "enlightenment_remote -binding-mouse-del
$mouse_init_context[$iter] $mouse_init_button[$iter] \"$mouse_init_mod[$iter]\"
0 $mouse_init_action[$iter] \"$mouse_init_par[$iter]\"";
system ($cmd_del);
print "$iter: $cmd_del \n";
system ($cmd_add);
print "$iter: $cmd_add \n";
#after we have added a key we update the init fields
$mouse_init_context[$iter]=$new_context;
$mouse_init_button[$iter]=$new_button;
$mouse_init_mod[$iter]=$new_mod;
$mouse_init_action[$iter]=$new_action;
$mouse_init_par[$iter]=$new_par;
}
}
}
###########################################################################
# OPTIONS TAB
############################################################################
sub add_options
{
my $sw = Gtk2::ScrolledWindow->new(undef,undef);
$_[0]->pack_start($sw,TRUE,TRUE, 0);
my $vbox_options = Gtk2::VBox->new(FALSE, 0);
$sw->add_with_viewport($vbox_options);
my $pack;
# FOCUS
$pack = frame_new($vbox_options,"Focus");
add_string($pack,"focus-policy","CLICK,MOUSE,SLOPPY");
add_string($pack,"focus-setting","NONE,NEW_WINDOW,NEW_DIALOG,NEW_DIALOG_IF_OWNER_FOCUSED");
add_bool($pack,"focus-last-focused-per-desktop");
add_bool($pack,"focus-revert-on-hide-or-close");
# EDGE
$pack = frame_new($vbox_options,"Edge");
add_bool($pack,"edge-flip");
add_num($pack,"edge-flip-timeout");
# MENU
$pack = frame_new($vbox_options,"Menu");
add_num($pack,"menus-scroll-speed");
add_num($pack,"menus-fast-move-threshold");
add_num($pack,"menus-click-drag-timeout");
add_num($pack,"menu-autoscroll-margin");
add_bool($pack,"menu-autoscroll-cursor-margin");
# Border shade
$pack = frame_new($vbox_options,"Border shade and raise");
add_bool($pack,"border-shade-animate");
add_string($pack,"border-shade-transition","0,1,2,3");
add_num($pack,"border-shade-speed");
add_bool($pack,"always-click-to-raise");
add_bool($pack,"use-auto-raise");
add_num($pack,"auto-raise-delay");
#transition
$pack = frame_new($vbox_options,"Transition");
add_string_free($pack,"transition-start");
add_string_free($pack,"transition-desk");
add_string_free($pack,"transition-change");
#managed window
$pack = frame_new($vbox_options,"Managed window");
add_bool($pack,"kill-if-close-not-possible");
add_bool($pack,"kill-process");
add_num($pack,"kill-timer-wait");
add_bool($pack,"ping-clients");
add_num($pack,"ping-clients-wait");
#resist
$pack = frame_new($vbox_options,"Resist");
add_bool($pack,"use-resist");
add_num($pack,"drag-resist");
add_num($pack,"window-resist");
add_num($pack,"gadget-resist");
#WINDOWS
$pack = frame_new($vbox_options,"Windows");
add_bool($pack,"resize-info-follows");
add_bool($pack,"move-info-follows");
add_bool($pack,"modal-windows");
#Transient
$pack = frame_new($vbox_options,"Transient");
add_bool($pack,"transient-move");
add_bool($pack,"transient-resize");
add_bool($pack,"transient-raise");
add_bool($pack,"transient-lower");
add_bool($pack,"transient-layer");
add_bool($pack,"transient-desktop");
add_bool($pack,"transient-iconify");
#MISC
$pack = frame_new($vbox_options,"Misc");
add_string($pack,"maximize-policy","FULLSCREEN,SMART,EXPAND,FILL");
add_bool($pack,"pass-click-on");
add_num($pack,"cursor-size");
add_num($pack,"framerate");
}
####################################################################
# WINLIST tab
#####################################################################
sub add_winlist
{
my $sw = Gtk2::ScrolledWindow->new(undef,undef);
$_[0]->pack_start($sw,TRUE,TRUE, 0);
my $vbox_options = Gtk2::VBox->new(FALSE, 0);
$sw->add_with_viewport($vbox_options);
my $pack;
# FOCUS
$pack = frame_new($vbox_options,"Warp");
add_bool($pack,"winlist-warp-while-selecting");
add_bool($pack,"winlist-warp-at-end");
add_num($pack,"winlist-warp-speed");
# Misc
$pack = frame_new($vbox_options,"Misc");
add_bool($pack,"winlist-scroll-animate");
add_num($pack,"winlist-scroll-speed");
# LIST
$pack = frame_new($vbox_options,"List");
add_bool($pack,"winlist-list-show-iconified");
add_bool($pack,"winlist-list-show-other-desk-windows");
add_bool($pack,"winlist-list-show-other-screen-windows");
add_bool($pack,"winlist-list-uncover-while-selecting");
add_bool($pack,"winlist-list-jump-desk-while-selecting");
# Position
$pack = frame_new($vbox_options,"Position");
add_num($pack,"winlist-pos-align-x");
add_num($pack,"winlist-pos-align-y");
add_num($pack,"winlist-pos-size-w");
add_num($pack,"winlist-pos-size-h");
add_num($pack,"winlist-pos-min-w");
add_num($pack,"winlist-pos-min-h");
add_num($pack,"winlist-pos-max-w");
add_num($pack,"winlist-pos-max-h");
}
####################################################################
# DESKTOP tab
#####################################################################
sub add_desktop
{
my $sw = Gtk2::ScrolledWindow->new(undef,undef);
$_[0]->pack_start($sw,TRUE,TRUE, 0);
my $vbox_options = Gtk2::VBox->new(FALSE, 0);
$sw->add_with_viewport($vbox_options);
my $pack;
# FOCUS
$pack = frame_new($vbox_options,"Desktop numbers");
add_string_free($pack,"desks");
#desktop-name-list
}
##################################################################3
# GENERAL APPLY
###################################################################
sub action_apply_options
{
apply_bool();
apply_num();
apply_string();
apply_string_free();
}
sub apply_bool
{
my ($key,$value);
my $cmd;
while (($key,$value) = each(%value_bool)){
if ($widget_bool{$key}->get_active() xor $value){
if ($value){$value="0";}else{$value="1"};
$value_bool{"$key"}=$value;
$cmd = "enlightenment_remote -".$key."-set ".$value;
system ($cmd);
if (VERBOSE){print "$cmd\n";}
}
}
}
sub apply_num
{
my ($key,$prev_value);
my $cmd;
my $cur_value;
while (($key,$prev_value) = each(%value_num)){
$cur_value = $widget_num{$key}->get_text();
if ( $cur_value ne $prev_value){
$value_num{"$key"}=$cur_value;
$cmd = "enlightenment_remote -".$key."-set ".$cur_value;
system ($cmd);
if (VERBOSE){print "$cmd\n"; }
}
}
}
sub apply_string
{
my ($key,$prev_value);
my $cmd;
my $cur_value;
while (($key,$prev_value) = each(%value_string)){
$cur_value = $widget_string{$key}->entry->get_text();
if ( $cur_value ne $prev_value){
$value_string{"$key"}=$cur_value;
$cmd = "enlightenment_remote -".$key."-set ".$cur_value;
system ($cmd);
if (VERBOSE){ print "$cmd\n";}
}
}
}
sub apply_string_free
{
my ($key,$prev_value);
my $cmd;
my $cur_value;
while (($key,$prev_value) = each(%value_string_free)){
$cur_value = $widget_string_free{$key}->get_text();
if ( $cur_value ne $prev_value){
$value_string_free{"$key"}=$cur_value;
$cmd = "enlightenment_remote -".$key."-set ".$cur_value;
system ($cmd);
if (VERBOSE){print "$cmd\n"; };
}
}
}
#######################################################################3
# CALLBACKS
######################################################################
#===CALLBACK===ACTION=
sub action_new{
my $page = $notebook->get_current_page();
action_new_keys() if ($page == 0);
action_new_button() if ($page == 1);
}
#===CALLBACK===OK===
sub action_ok
{
action_apply();
Gtk2->main_quit();
}
#===CALLBACK===APPLY===
sub action_apply
{
action_apply_keys();
action_apply_mouse();
action_apply_options();
}
########################################################
# AUX FUNCTION
#########################
# add a string option
sub add_bool
{
my $pack = shift(@_);
my $name = shift(@_);
my $pack_hbox = Gtk2::HBox->new(FALSE, 1);
$pack->pack_start($pack_hbox,TRUE,TRUE,0);
my $label = Gtk2::Label->new($name);
$pack_hbox->pack_start($label,FALSE,FALSE,0);
my $value = get_value ($name);
#handle exceptions
if ($value =~ /[POLICY|KILL]=(.)/){$value=$1;}
my $check_button = Gtk2::CheckButton->new();
if ( $value eq "1") {$check_button->set_active (TRUE);}
$pack_hbox->pack_start($check_button,FALSE,FALSE,0);
$value_bool{"$name"}=$value;
$widget_bool{"$name"}=$check_button;
}
########################333
# add a string option
sub add_string
{
my $pack = shift(@_);
my $name = shift(@_);
my @options = split(/,/,$_[0]);
my $pack_hbox = Gtk2::HBox->new(FALSE, 1);
$pack->pack_start($pack_hbox,TRUE,TRUE,0);
my $label = Gtk2::Label->new($name);
$pack_hbox->pack_start($label,FALSE,FALSE,0);
my $value = get_value ($name);
#====context
my $field = Gtk2::Combo->new ();
$field->set_popdown_strings(@options);
$field->set('enable-arrow-keys',TRUE);
$field->set('value-in-list',TRUE);
$field->set('allow-empty' ,FALSE);
$field->entry->set_text ($value);
$pack_hbox->pack_start($field, FALSE, FALSE, 0);
$value_string{"$name"}=$value;
$widget_string{"$name"}=$field;
}
########################
# add a free string option (no constrains in value)
sub add_string_free
{
my $pack = shift(@_);
my $name = shift(@_);
my $pack_hbox = Gtk2::HBox->new(FALSE, 1);
$pack->pack_start($pack_hbox,TRUE,TRUE,0);
my $label = Gtk2::Label->new($name);
$pack_hbox->pack_start($label,FALSE,FALSE,0);
my $value = get_value ($name);
#clear quotes
if ($value =~ /"(.*)"/){$value=$1;}
my $field = Gtk2::Entry->new ();
$field->set_text ($value);
$pack_hbox->pack_start($field, FALSE, FALSE, 0);
$value_string_free{"$name"}=$value;
$widget_string_free{"$name"}=$field;
}
########################333
# add a numeric option
sub add_num
{
my $pack = shift(@_);
my $name = shift(@_);
my $pack_hbox = Gtk2::HBox->new(FALSE, 1);
$pack->pack_start($pack_hbox,TRUE,TRUE,0);
my $label = Gtk2::Label->new($name);
$pack_hbox->pack_start($label,FALSE,FALSE,0);
my $value = get_value ($name);
# handle exceptions
if ($value =~ /[DELAY|THRESHOLD]=(.*)/){$value=$1;}
my $field = Gtk2::Entry->new;
$field->set_text($value);
$pack_hbox->pack_start($field, FALSE, FALSE, 0);
# set initial value
$value_num{"$name"}=$value;
$widget_num{"$name"}=$field;
}
################################33
# GET option curren value
sub get_value
{
my $value;
open (ER,"enlightenment_remote -".$_[0]."-get|");
my @buf = <ER>;
$value = shift(@buf);
$value = shift(@buf);
chomp($value);
if ($value=~/REPLY: (.*)/){$value = $1;}else{}
if (DEBUG){ print ("$_[0] $value\n");}
return $value;
}
#################
#CREATE A NEW frame
sub frame_new {
my $frame_focus = Gtk2::Frame->new ($_[1]);
$_[0]->pack_start($frame_focus, FALSE, FALSE, 0);
my $frame_vbox = Gtk2::VBox->new(TRUE, 5);
$frame_focus->add($frame_vbox);
return $frame_vbox;
}
sub member
{
my @set = @_;
my $m = pop (@set);
my $iter;
foreach $iter (@set){
if ($iter == $m) {return TRUE;}
}
return FALSE;
}
##############################
# TODO#
#######
#desktop-bg-add
# -display OPT1 Connect to E running on display 'OPT1'
# -module-load OPT1 Loads the module named 'OPT1' into memory
# -module-unload OPT1 Unloads the module named 'OPT1' from memory
# -module-enable OPT1 Enable the module named 'OPT1'
# -module-disable OPT1 Disable the module named 'OPT1'
# -module-list List all loaded modules
# -default-bg-set OPT1 Set the default background edje to the desktop
background in the file 'OPT1' (must be a full path)
# -default-bg-get Get the default background edje file path
# -font-available-list List all available fonts
# -font-apply Apply font settings changes
# -font-fallback-append OPT1 Append OPT1 to the fontset
# -font-fallback-prepend OPT1 Prepend OPT1 to the fontset
# -font-fallback-list List the fallback fonts in order
# -font-fallback-remove OPT1 Remove OPT1 from the fontset
# -font-default-set OPT1 OPT2 OPT3 Set textclass (OPT1) font (OPT2) and size
(OPT3)
# -font-default-get OPT1 List the default font associated with OPT1
# -font-default-remove OPT1 Remove the default text class OPT1
# -font-default-list List all configured text classes
# -font-fallback-clear Clear list of fallback fonts
# -restart Restart Enlightenment
# -shutdown Shutdown (exit) Enlightenment
# -lang-list List all available languages
# -lang-set OPT1 Set the current language to 'OPT1'
# -lang-get Get the current language
# -dirs-list OPT1 List the directory of type specified by 'OPT1', try 'themes'
# -dirs-list-append OPT1 Append the directory of type specified by 'OPT2 to
the list in 'OPT1'
# -dirs-list-prepend OPT1 Prepend the directory of type specified by 'OPT2 to
the list in 'OPT1'
# -dirs-list-remove OPT1 Remove the directory of type specified by 'OPT2 to
the list in 'OPT1'
#
#-font-cache-set OPT1 Set the font cache size (Kb)
# -font-cache-get Get the speculative font cache size (Kb)
# -image-cache-set OPT1 Set the image cache size (Kb)
# -image-cache-get Ge