16, "keywords1"=>"", "keywords2"=>"", "keywords3"=>"", "keywords4"=>"", "keywords5"=>"", "keywords5"=>"", "tab_size"=>4, "soft_tabs"=>true, "indent_size"=>4, "show_indent"=>1, "auto_indent"=>1, "edge_indicator"=>0, "edge_column"=>80, "edge_color"=>0, "type_type"=>0, "type_rule"=>"", "style_fore"=>0, "style_back"=>0, "style_font"=>"", "rules_list"=>"", // Clist - editable. ); function language_config ($glade) { global $phpmole_Lexers; $this->config_dialog_generic($glade); $this->combotxt = $this->widget->get_widget("lang_name"); $this->combotxt->connect("changed", array(&$this, "language_changed")); $this->btn_ok->connect_object_after('clicked', array(&$this, "callback_ok_clicked")); $this->combolexer = $this->widget->get_widget("lexer_combo"); $this->stylelist = $this->widget->get_widget("styles_list"); $this->ruleslist = $this->widget->get_widget("rules_list"); $this->combolexer->set_popdown_strings(array_keys($phpmole_Lexers)); $e = $this->combolexer->entry; $e->connect_after("changed", array(&$this,"lexer_changed")); $this->stylelist->connect_after("select_row", array(&$this,"load_style")); $this->stylelist->connect("unselect_row", array(&$this,"unselect_style")); $this->ruleslist->connect_after("select_row", array(&$this,"load_rule")); $this->ruleslist->connect("unselect_row", array(&$this,"unselect_rule")); for ($i=0;$i<3;$i++) { $widget = $this->widget->get_widget("type_type_".sprintf("%01d",$i)); $widget->connect("toggled", array(&$this,"rule_type_changed"),$i); } $widget = $this->widget->get_widget("type_rule"); $widget->connect("changed", array(&$this,"rule_changed"),$i); $b = $this->widget->get_widget("new_rule"); $b->connect("pressed", array(&$this,"new_rule")); $b = $this->widget->get_widget("del_rule"); $b->connect("pressed", array(&$this,"del_rule")); } function language_changed() { global $application; // store current if ($this->active_language) { echo "STORING ACTIVE LANGUAGE"; $this->get_results(); $this->languages[$this->active_language] = $this->prefs; } $s= $this->combotxt->get_text(); echo "SETTING ACTIVE LANGUAGE"; $this->active_language=$s; // look in title! if (!@$this->languages[$s]) foreach($this->languages as $k=>$v) if ($v["title"] == $s) { $this->active_language=$k; break; } $this->prefs = $this->languages[$this->active_language]; if (!$this->prefs["keywords5"]) $this->prefs["keywords5"]=""; $this->show(); $this->set_lexer(); $this->unselect_style(); $this->set_rules(); } function show_dialog() { global $application; // load the languages.. $this->languages = $application->langs->langs_ini; $options = array(); $keys = array(); foreach($this->languages as $k=>$v) { $title = $k; if ($v["title"]) $title = $v["title"]; $options[] = $title; $key_to_title[$k] = $title; } $this->active_language=""; $combo = $this->widget->get_widget("lang_name_combo"); $combo->set_popdown_strings($options); $this->active_language=""; $show_lang = $options[0]; if ($a = $application->module_manager->broadcast_get("get_active_document")) { list($b,$url) = $a; $lang = $application->langs->get_language_from_URL($url); if ($lang) $show_lang = $key_to_title[$lang]; } echo "SET TEXT\n"; //$this->combotxt->set_text($show_lang); echo "SHOW VARS\n"; $this->show(); // loads data $this->combotxt->set_text($show_lang); $this->set_lexer(); $this->unselect_style(); $this->set_rules(); $this->window->show(); } function callback_ok_clicked () { global $application; $this->hide(); if ($this->active_language) { $this->get_results(); //echo serialize($this->prefs); $this->languages[$this->active_language] = $this->prefs; } echo "SAVING?"; $application->langs->langs_ini = $this->languages; $application->langs->save_ini(); $application->module_manager->broadcast("configuration_changed"); } /* STYLES */ function set_lexer() { global $phpmole_Lexers; foreach($phpmole_Lexers as $k=>$v) if ($this->prefs["lexer"] == $v) { $e = $this->combolexer->entry; $o = $e->get_text(); $this->stylelist->unselect_all(); if ($o == $k) return; $e->set_text($k); return; } } function lexer_changed() { global $phpmole_Lexers,$phpmole_Styles; $e = $this->combolexer->entry; $l = $e->get_text(); $this->prefs["lexer"] = $phpmole_Lexers[$l]; $list = @$phpmole_Styles[$this->prefs["lexer"]]; $this->stylelist->clear(); if ($list) foreach($list as $k=>$v) $this->stylelist->append(array($k)); $this->unselect_style(); } function unselect_style() { foreach (array("style_fore","style_back") as $wn) { $w = $this->widget->get_widget($wn); $p = $w->parent; $p->set_sensitive(FALSE); } //echo "SETTING FALSE"; $w = $this->widget->get_widget("style_font"); $w->set_sensitive(FALSE); } function merge_font($font) { // """Merge the given X font descripton with the deafult font""" global $application; $df = explode( '-', $application->prefs->get("default style/font")); $sf = $df; if ($font) $sf = explode( '-',$font); for ($i=0;$iprefs->get("default style/font")); $sf = explode( '-',$font); for ($i=0;$icombolexer->entry; $l = $e->get_text(); $this->active_style = $phpmole_Styles[$this->prefs["lexer"]][$widget->get_text($row,0)]; //echo "LEXER: " . $this->prefs["lexer"]; //echo "Active style ". $this->active_style . "\n"; // name = style_94_fore etc. // load colors $def = $application->prefs->get("default style/fore"); if (isset($this->prefs["style_".$this->active_style."_fore"])) $def = $this->prefs["style_".$this->active_style."_fore"]; $this->prefs["style_fore"] = $def; $this->set_buttoncolor("style_fore" , $def); $def = $application->prefs->get("default style/back"); if (isset($this->prefs["style_".$this->active_style."_back"])) $def = $this->prefs["style_".$this->active_style."_back"]; $this->prefs["style_back"] = $def; $this->set_buttoncolor("style_back" , $def); $def = $this->merge_font(@$this->prefs["style_".$this->active_style."_font"]); $this->prefs["style_font"] = $def; $this->set_fontname("style_font" , $def); } function extend_font_change($key) { //echo "FONT: $key changed"; global $application; if (substr($key,0,6) != "style_") continue; $k = "style_".$this->active_style."_font"; if (isset($this->prefs[$k])) unset($this->prefs[$k]); if ($this->prefs[$key] == $application->prefs->get("default style/font")) return; //echo "setting $k to " . $this->diff_font($this->prefs[$key]); $this->prefs[$k] = $this->diff_font($this->prefs[$key]); } function extend_color_change($key) { global $application; if (substr($key,0,6) != "style_") continue; $what = substr($key,6); $k = "style_{$this->active_style}_{$what}"; if (isset($this->prefs[$k])) unset($this->prefs[$k]); $def = $application->prefs->get("default style/what"); if ($def == $this->prefs[$key]) return; $this->prefs[$k] = $this->prefs[$key]; } /* FILE TYPES RULES */ function set_rules() { $types = array("Shell", "Filename", "Text"); $this->ruleslist->clear(); for ($i=0;$i< $this->prefs["rules_count"] ;$i++) $this->ruleslist->append( array( $types[$this->prefs["type_".sprintf("%01d",$i)."_type"]], $this->prefs["type_".sprintf("%01d",$i)."_rule"], ) ); //$this->unselect_rules(); } function load_rule ($widget,$row) { $r = sprintf("%01d",$row); $this->active_rule = $r; $widget = $this->widget->get_widget( "type_type_".sprintf("%01d",@$this->prefs["type_{$r}_type"])); $widget->set_active(TRUE); for ($i=0;$i<3;$i++) { $widget = $this->widget->get_widget("type_type_".sprintf("%01d",$i)); $widget->set_sensitive(TRUE); } $widget = $this->widget->get_widget("type_rule"); $widget->set_text("".@$this->prefs["type_{$r}_rule"]); $widget->set_sensitive(TRUE); $widget = $this->widget->get_widget("del_rule"); $widget->set_sensitive(TRUE); } function rule_type_changed($widget,$i) { if (!$widget->get_active()) return; if ($this->prefs["type_{$this->active_rule}_type"] == $i) return; $this->prefs["type_{$this->active_rule}_type"] = $i; $types = array("Shell", "Filename", "Text"); $this->ruleslist->set_text($this->active_rule,0,$types[$i]); } function rule_changed($widget) { $t = $widget->get_text(); if (@$this->prefs["type_{$this->active_rule}_rule"] == $t) return; $this->prefs["type_{$this->active_rule}_rule"] = $t; $this->ruleslist->set_text($this->active_rule,1,$t); } function new_rule() { $this->prefs["rules_count"]++; $r = $this->ruleslist->append(array("Shell","",)); $this->prefs["type_{$r}_type"] = 0; $this->ruleslist->select_row($r,0); $this->ruleslist->moveto($r,0,0,0); } function del_rule() { $r = $this->active_rule; $this->ruleslist->unselect_row($this->active_rule,0); $this->ruleslist->remove($this->active_rule); $this->prefs["rules_count"]--; for ($i=$this->active_rule;$i<$this->prefs["rules_count"];$i++) { $ii= sprintf("%01d",$i); $in= sprintf("%01d",$i+1); $this->prefs["type_{$ii}_rule"] = $this->prefs["type_{$in}_rule"]; $this->prefs["type_{$ii}_type"] = $this->prefs["type_{$in}_type"]; } unset($this->prefs["type_{$r}_rule"]); unset($this->prefs["type_{$r}_type"]); } function unselect_rule() { foreach(array( "type_type_0","type_type_1","type_type_2", "type_rule","del_rule") as $wn) { $widget = $this->widget->get_widget($wn); $widget->set_sensitive(FALSE); } } } ?>