00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include "config.h"
00038
00039
00040
00041 #ifdef ENABLE_NLS
00042 # include <libintl.h>
00043 # undef _
00044 # define _(String) dgettext (GETTEXT_PACKAGE, String)
00045 # ifdef gettext_noop
00046 # define N_(String) gettext_noop (String)
00047 # else
00048 # define N_(String) (String)
00049 # endif
00050 #else
00051 # define textdomain(String) (String)
00052 # define gettext(String) (String)
00053 # define dgettext(Domain,Message) (Message)
00054 # define dcgettext(Domain,Message,Type) (Message)
00055 # define bindtextdomain(Domain,Directory) (Domain)
00056 # define _(String) (String)
00057 # define N_(String) (String)
00058 #endif
00059 #include <gtkmmconfig.h>
00060 #if GTKMM_MAJOR_VERSION==2 && GTKMM_MINOR_VERSION>2
00061 #define GMM_GTKMM_22_24(a,b) b
00062 #else //gtkmm 2.2
00063 #define GMM_GTKMM_22_24(a,b) a
00064 #endif //
00065 #include "window3_glade.hh"
00066 #include <gdk/gdkkeysyms.h>
00067 #include <gtkmm/accelgroup.h>
00068 #include <gtkmm/alignment.h>
00069 #include <gtkmm/label.h>
00070 #include <gtkmm/frame.h>
00071 #if GTKMM_MAJOR_VERSION==2 && GTKMM_MINOR_VERSION>2
00072 #include <gtkmm/expander.h>
00073 #else //
00074 #include <gtkmm/handlebox.h>
00075 #endif //
00076 #include "window3.hh"
00077 #include <vte-0.0/vte/vte.h>
00078 #include <ostream>
00079 #include <sys/types.h>
00080 #include <sys/wait.h>
00081
00082 void func(GtkWidget *widget, gpointer * data){
00083
00084 }
00085
00086 void window3::die(){
00087 char txt[]={3,0};
00088 for (int i=0;i<nn;i++){
00089 vte_terminal_feed_child(VTE_TERMINAL(vtes[i]), txt, strlen(txt));
00090 }
00091 return;
00092
00093
00094 }
00095
00096 void window3::compile_and_execute(bool docompile, bool doexecute, bool dolog,int nn,std::string command,std::string args){
00097 this->nn = nn;
00098 this->command = command;
00099 this->doexecute = doexecute;
00100 this->dolog = dolog;
00101 this->args = args;
00102 int pos = command.find_last_of("/");
00103 s = command.substr(0, pos + 1);
00104 std::string cd("cd"), touch("touch");
00105 cd = cd + " " + s + "\n";
00106 touch = touch + " " + s;
00107 std::string alias = "";
00108 if (docompile){
00109 int ret = system(touch.c_str());
00110 if (ret !=0){
00111 fprintf(stderr,"Error executing %s\n",touch.c_str());
00112 }
00113 vte_terminal_feed_child(VTE_TERMINAL(vte), cd.c_str(), strlen(cd.c_str()));
00114 std::string alias = "alias make=\"touch lock && make && sleep 2 && rm lock\"\n";
00115 vte_terminal_feed_child(VTE_TERMINAL(vte), alias.c_str(), strlen(alias.c_str()));
00116 vte_terminal_feed_child(VTE_TERMINAL(vte), "make\n", strlen("make\n"));
00117 }
00118 if (doexecute){
00119 alias = "alias wce=\"while test -f lock ; do echo waiting compilation; sleep 1 ; done\"\n";
00120 for (int i=0;i<used;i++){
00121 std::string cmd = command;
00122 std::ostringstream s1,s2;
00123 s1 << i;
00124 s2 << nn;
00125 std::string rep = args;
00126 int pos = rep.find_first_of("%i",0);
00127 rep.replace(pos,2,s1.str());
00128 pos = rep.find_first_of("%n",0);
00129 rep.replace(pos,2,s2.str());
00130 cmd = "wce && " + cmd + " " + rep + "\n";
00131 vte_terminal_feed_child(VTE_TERMINAL(vtes[i]), alias.c_str(), strlen(alias.c_str()));
00132 vte_terminal_feed_child(VTE_TERMINAL(vtes[i]), cd.c_str(), strlen(cd.c_str()));
00133 vte_terminal_feed_child(VTE_TERMINAL(vtes[i]), cmd.c_str(), strlen(cmd.c_str()));
00134 }
00135 }
00136 }
00137
00138 void window3::execute(){
00139 }
00140
00141 window3::window3() : window3_glade(){
00142 vte = vte_terminal_new();
00143 vte_terminal_set_background_transparent(VTE_TERMINAL(vte), FALSE);
00144 vte_terminal_set_size(VTE_TERMINAL(vte), 80, 25);
00145 vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL (vte), TRUE);
00146 gtk_container_add(GTK_CONTAINER(align->gobj()), vte);
00147 gtk_widget_show(vte);
00148
00149 vte_terminal_fork_command(VTE_TERMINAL(vte), NULL, NULL, NULL,
00150 NULL, FALSE, FALSE, FALSE);
00151 created = used = 0;
00152 for (int i=0;i<20;i++){
00153 vtes[i] = vte_terminal_new();
00154 vte_terminal_fork_command(VTE_TERMINAL(vtes[i]), NULL, NULL, NULL,
00155 NULL, FALSE, FALSE, FALSE);
00156 }
00157
00158 }
00159
00160
00161 void window3::create(int nn) {
00162 for (int i = created; i < nn ; i++){
00163
00164 std::ostringstream oss;
00165 oss << "N#" << i;
00166
00167 Gtk::Alignment * align;
00168 Gtk::Label * label;
00169 Gtk::Label * nblabel;
00170
00171 align = Gtk::manage(new class Gtk::Alignment(0.5, 0.5, 1, 1));
00172 label = Gtk::manage(new class Gtk::Label(_("")));
00173 Gtk::Frame *frame15 = Gtk::manage(new class Gtk::Frame());
00174 nblabel = Gtk::manage(new class Gtk::Label(_(oss.str())));
00175 label->set_alignment(0.5, 0.5);
00176 label->set_padding(0, 0);
00177 label->set_justify(Gtk::JUSTIFY_LEFT);
00178 label->set_line_wrap(false);
00179 label->set_use_markup(true);
00180 label->set_selectable(false);
00181 frame15->set_shadow_type(Gtk::SHADOW_NONE);
00182 frame15->set_label_align(0, 0.5);
00183 frame15->add(*align);
00184 frame15->set_label_widget(*label);
00185 nblabel->set_alignment(0.5, 0.5);
00186 nblabel->set_padding(0, 0);
00187 nblabel->set_justify(Gtk::JUSTIFY_LEFT);
00188 nblabel->set_line_wrap(false);
00189 nblabel->set_use_markup(false);
00190 nblabel->set_selectable(false);
00191 notebook1->set_flags(Gtk::CAN_FOCUS);
00192 notebook1->set_show_tabs(true);
00193 notebook1->set_show_border(true);
00194 notebook1->set_tab_pos(Gtk::POS_TOP);
00195 notebook1->set_scrollable(false);
00196 notebook1->append_page(*frame15, *nblabel);
00197 notebook1->pages().back().set_tab_label_packing(false, true,
00198 Gtk::PACK_START);
00199 align->show();
00200 label->show();
00201 frame15->show();
00202 nblabel->show();
00203 notebook1->show();
00204
00205
00206 vte_terminal_set_background_transparent(VTE_TERMINAL(vtes[i]), FALSE);
00207 vte_terminal_set_size(VTE_TERMINAL(vtes[i]), 80, 25);
00208 vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL (vtes[i]), TRUE);
00209 gtk_container_add(GTK_CONTAINER(align->gobj()), vtes[i]);
00210 gtk_widget_show(vtes[i]);
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238 }
00239 used = nn;
00240 created = nn;
00241 }