Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import os
- import sys
- import pygtk
- pygtk.require('2.0')
- import gtk
- import subprocess
- import webkit
- import vte
- import time
- import string
- code = gtk.TextView()
- code2 = gtk.TextView()
- class NotebookExample:
- def checkForConfigDir(self):
- self.tmpPath = '/tmp/wdt'
- if(not os.path.exists(self.tmpPath)):
- os.makedirs(self.tmpPath)
- print "Created dir: "+self.tmpPath
- def quit(self):
- gtk.main_quit()
- def on_close_clicked(self, widget):
- self.quit()
- def on_home_clicked(self, widget):
- homedir = os.path.expanduser("~")
- os.system('xdg-open "%s"' % homedir)
- def on_comp_clicked(self, widget):
- os.system('xdg-open "%s"' % "computer:///")
- def on_filesystem_clicked(self, widget):
- os.system('xdg-open "%s"' % "/")
- def on_css_clicked(self, widget, event):
- g_get_home_dir = os.path.expanduser("~")
- dialog = gtk.FileChooserDialog(title = "Select Css file" ,
- action=gtk.FILE_CHOOSER_ACTION_OPEN,
- buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,gtk.STOCK_OK, gtk.RESPONSE_OK))
- dialog.set_current_folder(g_get_home_dir);
- filter = gtk.FileFilter()
- filter.set_name("All css files")
- filter.add_pattern("*.css")
- dialog.add_filter(filter)
- response = dialog.run()
- if response == gtk.RESPONSE_OK:
- namePath, ext = os.path.splitext(dialog.get_filename())
- nameP = string.split(namePath, '/')[-1]
- subprocess.Popen(self.configpath+"css.py "+ dialog.get_filename()+"> /tmp/wdt/"+ nameP+"_minified.css", shell=True)
- time.sleep(2)
- filename2 = "/tmp/wdt/"+ nameP+"_minified.css"
- textbuffer2 = code2.get_buffer()
- file = open(filename2, "r")
- text2 = file.read()
- textbuffer2.set_text(text2)
- file.close()
- elif response == gtk.RESPONSE_CANCEL:
- print 'Closed, no files selected'
- dialog.destroy()
- def on_cssmin_clicked(self, widget, event):
- filename = "/tmp/wdt/originalcode.css"
- textbuffer = code.get_buffer()
- text = textbuffer.get_text(textbuffer.get_start_iter() , textbuffer.get_end_iter())
- file = open(filename, "w")
- file.write(text)
- file.close()
- subprocess.Popen(self.configpath+"css.py /tmp/wdt/originalcode.css > /tmp/wdt/originalcode_minified.css", shell=True)
- time.sleep(2)
- filename2 = "/tmp/wdt/originalcode_minified.css"
- textbuffer2 = code2.get_buffer()
- file = open(filename2, "r")
- text2 = file.read()
- textbuffer2.set_text(text2)
- file.close()
- def on_cssclear_clicked(self, widget, event):
- textbuffer = code.get_buffer()
- textbuffer.set_text("")
- textbuffer2 = code2.get_buffer()
- textbuffer2.set_text("")
- def on_changed(self, widget):
- g_get_home_dir = os.path.expanduser("~")
- texty = widget.get_active_text()
- dialog = gtk.FileChooserDialog(title = "Select Image" ,
- action=gtk.FILE_CHOOSER_ACTION_OPEN,
- buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,gtk.STOCK_OK, gtk.RESPONSE_OK))
- dialog.set_current_folder(g_get_home_dir);
- filter = gtk.FileFilter()
- filter.set_name("Images")
- filter.add_mime_type("image/png")
- filter.add_mime_type("image/jpeg")
- filter.add_mime_type("image/gif")
- filter.add_pattern("*.png")
- filter.add_pattern("*.jpg")
- filter.add_pattern("*.gif")
- dialog.add_filter(filter)
- response = dialog.run()
- if response == gtk.RESPONSE_OK:
- iconPath, ext = os.path.splitext(dialog.get_filename())
- if texty == "Create Square Style Button 32x32":
- subprocess.Popen(self.configpath+"coolbutton.py "+ dialog.get_filename()+" --shape square32", shell=True)
- time.sleep(2)
- subprocess.Popen("xdg-open " +iconPath+"-square32.png", shell=True)
- elif texty == "Create Square Style Button 48x48":
- subprocess.Popen(self.configpath+"coolbutton.py "+ dialog.get_filename()+" --shape square48", shell=True)
- time.sleep(2)
- subprocess.Popen("xdg-open " +iconPath+"-square48.png", shell=True)
- elif texty == "Create Square Style Button 64x64":
- subprocess.Popen(self.configpath+"coolbutton.py "+ dialog.get_filename()+" --shape square64", shell=True)
- time.sleep(2)
- subprocess.Popen("xdg-open " +iconPath+"-square64.png", shell=True)
- elif texty == "Create Square Style Button 96x96":
- subprocess.Popen(self.configpath+"coolbutton.py "+ dialog.get_filename()+" --shape square96", shell=True)
- time.sleep(2)
- subprocess.Popen("xdg-open " +iconPath+"-square96.png", shell=True)
- elif texty == "Create Square Style Button 128x128":
- subprocess.Popen(self.configpath+"coolbutton.py "+ dialog.get_filename()+" --shape square128", shell=True)
- time.sleep(2)
- subprocess.Popen("xdg-open " +iconPath+"-square128.png", shell=True)
- elif texty == "Create Rounded Style Button 32x32":
- subprocess.Popen(self.configpath+"coolbutton.py "+ dialog.get_filename()+" --shape round32", shell=True)
- time.sleep(2)
- subprocess.Popen("xdg-open " +iconPath+"-round32.png", shell=True)
- elif texty == "Create Rounded Style Button 48x48":
- subprocess.Popen(self.configpath+"coolbutton.py "+ dialog.get_filename()+" --shape round48", shell=True)
- time.sleep(2)
- subprocess.Popen("xdg-open " +iconPath+"-round48.png", shell=True)
- elif texty == "Create Rounded Style Button 64x64":
- subprocess.Popen(self.configpath+"coolbutton.py "+ dialog.get_filename()+" --shape round64", shell=True)
- time.sleep(2)
- subprocess.Popen("xdg-open " +iconPath+"-round64.png", shell=True)
- elif texty == "Create Rounded Style Button 96x96":
- subprocess.Popen(self.configpath+"coolbutton.py "+ dialog.get_filename()+" --shape round96", shell=True)
- time.sleep(2)
- subprocess.Popen("xdg-open " +iconPath+"-round96.png", shell=True)
- elif texty == "Create Rounded Style Button 128x128":
- subprocess.Popen(self.configpath+"coolbutton.py "+ dialog.get_filename()+" --shape round128", shell=True)
- time.sleep(2)
- subprocess.Popen("xdg-open " +iconPath+"-round128.png", shell=True)
- elif response == gtk.RESPONSE_CANCEL:
- print 'Closed, no files selected'
- dialog.destroy()
- def on_dir_changed(self, widget):
- g_get_home_dir = os.path.expanduser("~")
- texty = widget.get_active_text()
- dialog = gtk.FileChooserDialog(title = "Select Folder" ,
- action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
- buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,gtk.STOCK_OK, gtk.RESPONSE_OK))
- dialog.set_current_folder(g_get_home_dir);
- response = dialog.run()
- if response == gtk.RESPONSE_OK:
- iconPath, ext = os.path.splitext(dialog.get_filename())
- if texty == "Create Square Style Button 32x32":
- subprocess.Popen(self.configpath+"masscoolbutton.py -d"+ dialog.get_filename()+" -s square32", shell=True)
- elif texty == "Create Square Style Button 48x48":
- subprocess.Popen(self.configpath+"masscoolbutton.py -d"+ dialog.get_filename()+" -s square48", shell=True)
- elif texty == "Create Square Style Button 64x64":
- subprocess.Popen(self.configpath+"masscoolbutton.py -d"+ dialog.get_filename()+" -s square64", shell=True)
- elif texty == "Create Square Style Button 96x96":
- subprocess.Popen(self.configpath+"masscoolbutton.py -d"+ dialog.get_filename()+" -s square96", shell=True)
- elif texty == "Create Square Style Button 128x128":
- subprocess.Popen(self.configpath+"masscoolbutton.py -d"+ dialog.get_filename()+" -s square128", shell=True)
- elif texty == "Create Rounded Style Button 32x32":
- subprocess.Popen(self.configpath+"masscoolbutton.py -d"+ dialog.get_filename()+" -s round32", shell=True)
- elif texty == "Create Rounded Style Button 48x48":
- subprocess.Popen(self.configpath+"masscoolbutton.py -d"+ dialog.get_filename()+" -s round48", shell=True)
- elif texty == "Create Rounded Style Button 64x64":
- subprocess.Popen(self.configpath+"masscoolbutton.py -d"+ dialog.get_filename()+" -s round64", shell=True)
- elif texty == "Create Rounded Style Button 96x96":
- subprocess.Popen(self.configpath+"masscoolbutton.py -d"+ dialog.get_filename()+" -s round96", shell=True)
- elif texty == "Create Rounded Style Button 128x128":
- subprocess.Popen(self.configpath+"masscoolbutton.py -d"+ dialog.get_filename()+" -s round128", shell=True)
- elif response == gtk.RESPONSE_CANCEL:
- print 'Closed, no files selected'
- dialog.destroy()
- def on_w3c_clicked(self, widget, data=None):
- self.w3ceditor.open("http://validator.w3.org/#validate_by_uri+with_options")
- self.w3c2editor.load_html_string("", "file:///")
- self.w3c3editor.load_html_string("", "file:///")
- def on_w3c2_clicked(self, widget, data=None):
- self.w3c2editor.open("http://jigsaw.w3.org/css-validator/#validate_by_uri+with_options")
- self.w3ceditor.load_html_string("", "file:///")
- self.w3c3editor.load_html_string("", "file:///")
- def on_w3c3_clicked(self, widget, data=None):
- self.w3c3editor.open("http://validator.w3.org/feed/")
- self.w3c2editor.load_html_string("", "file:///")
- self.w3ceditor.load_html_string("", "file:///")
- def init_term(self):
- os.chdir(os.getenv('HOME'))
- self._vte.fork_command()
- realpath = os.path.dirname(os.path.realpath( __file__ ))
- os.chdir(realpath + '/..')
- def changed_cb(self, combobox):
- model = combobox.get_model()
- index = combobox.get_active()
- if index > -1:
- print model[index][0], 'selected'
- return
- def delete(self, widget, event=None):
- gtk.main_quit()
- return False
- def Renderer(self,horizontal, spacing):
- frame = gtk.Frame()
- bbox = gtk.HBox()
- bbox.set_border_width(5)
- frame.add(bbox)
- bbox.set_spacing(spacing)
- width = 620
- height = 560
- self.renderer = webkit.WebView()
- self.renderer.set_size_request(width,height)
- self.renderer.open(self.configpath+"_packer_.html")
- bbox.add(self.renderer)
- return frame
- def BrowserRenderer(self,horizontal, spacing):
- frame = gtk.Frame()
- bbox = gtk.HBox()
- bbox.set_border_width(10)
- frame.add(bbox)
- bbox.set_spacing(spacing)
- self._vte = vte.Terminal()
- self._vte.set_emulation("xterm")
- self._vte.set_allow_bold(True)
- self._vte.set_scrollback_lines(1024)
- self._vte.set_size_request(620,560)
- self._vte.set_opacity(int(65535 * int(80) / 100))
- bbox.add(self._vte)
- self.init_term()
- return frame
- def EditorRenderer(self,horizontal, spacing):
- frame = gtk.Frame()
- bbox = gtk.HBox()
- bbox.set_border_width(10)
- frame.add(bbox)
- bbox.set_spacing(spacing)
- self.filename = None
- self.editor = webkit.WebView()
- self.editor.set_editable(True)
- self.editor.load_html_string("This is a test text", "file:///")
- scroll = gtk.ScrolledWindow()
- scroll.add(self.editor)
- scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
- self.ui = self.generate_ui()
- self.toolbar1 = self.ui.get_widget("/toolbar_main")
- self.toolbar2 = self.ui.get_widget("/toolbar_format")
- self.layout = gtk.VBox()
- self.layout.pack_start(self.toolbar1, False)
- self.layout.pack_start(self.toolbar2, False)
- self.layout.pack_start(scroll, True, True)
- bbox.add(self.layout)
- return frame
- def generate_ui(self):
- ui_def = """
- <ui>
- <toolbar name="toolbar_main">
- <toolitem action="new" />
- <toolitem action="open" />
- <toolitem action="save" />
- <separator />
- <toolitem action="undo" />
- <toolitem action="redo" />
- </toolbar>
- <toolbar name="toolbar_format">
- <toolitem action="bold" />
- <toolitem action="italic" />
- <toolitem action="underline" />
- <toolitem action="strikethrough" />
- <separator />
- <toolitem action="font" />
- <toolitem action="color" />
- <separator />
- <toolitem action="justifyleft" />
- <toolitem action="justifyright" />
- <toolitem action="justifycenter" />
- <toolitem action="justifyfull" />
- <separator />
- <toolitem action="insertimage" />
- <toolitem action="insertlink" />
- </toolbar>
- </ui>
- """
- actions = gtk.ActionGroup("Actions")
- actions.add_actions([
- ("new", gtk.STOCK_NEW, "_New", None, None, self.on_new),
- ("open", gtk.STOCK_OPEN, "_Open", None, None, self.on_open),
- ("save", gtk.STOCK_SAVE, "_Save", None, None, self.on_save),
- ("undo", gtk.STOCK_UNDO, "_Undo", None, None, self.on_action),
- ("redo", gtk.STOCK_REDO, "_Redo", None, None, self.on_action),
- ("bold", gtk.STOCK_BOLD, "_Bold", "<ctrl>B", None, self.on_action),
- ("italic", gtk.STOCK_ITALIC, "_Italic", "<ctrl>I", None, self.on_action),
- ("underline", gtk.STOCK_UNDERLINE, "_Underline", "<ctrl>U", None, self.on_action),
- ("strikethrough", gtk.STOCK_STRIKETHROUGH, "_Strike", "<ctrl>T", None, self.on_action),
- ("font", gtk.STOCK_SELECT_FONT, "Select _Font", "<ctrl>F", None, self.on_select_font),
- ("color", gtk.STOCK_SELECT_COLOR, "Select _Color", None, None, self.on_select_color),
- ("justifyleft", gtk.STOCK_JUSTIFY_LEFT, "Justify _Left", None, None, self.on_action),
- ("justifyright", gtk.STOCK_JUSTIFY_RIGHT, "Justify _Right", None, None, self.on_action),
- ("justifycenter", gtk.STOCK_JUSTIFY_CENTER, "Justify _Center", None, None, self.on_action),
- ("justifyfull", gtk.STOCK_JUSTIFY_FILL, "Justify _Full", None, None, self.on_action),
- ("insertimage", "insert-image", "Insert _Image", None, None, self.on_insert_image),
- ("insertlink", "insert-link", "Insert _Link", None, None, self.on_insert_link),
- ])
- actions.get_action("insertimage").set_property("icon-name", "insert-image")
- actions.get_action("insertlink").set_property("icon-name", "insert-link")
- ui = gtk.UIManager()
- ui.insert_action_group(actions)
- ui.add_ui_from_string(ui_def)
- return ui
- def on_action(self, action):
- self.editor.execute_script(
- "document.execCommand('%s', false, false);" % action.get_name())
- def on_paste(self, action):
- self.editor.paste_clipboard()
- def on_new(self, action):
- self.editor.load_html_string("", "file:///")
- def on_select_font(self, action):
- dialog = gtk.FontSelectionDialog("Select a font")
- if dialog.run() == gtk.RESPONSE_OK:
- fname, fsize = dialog.fontsel.get_family().get_name(), dialog.fontsel.get_size()
- self.editor.execute_script("document.execCommand('fontname', null, '%s');" % fname)
- self.editor.execute_script("document.execCommand('fontsize', null, '%s');" % fsize)
- dialog.destroy()
- def on_select_color(self, action):
- dialog = gtk.ColorSelectionDialog("Select Color")
- if dialog.run() == gtk.RESPONSE_OK:
- gc = str(dialog.colorsel.get_current_color())
- color = "#" + "".join([gc[1:3], gc[5:7], gc[9:11]])
- self.editor.execute_script("document.execCommand('forecolor', null, '%s');" % color)
- dialog.destroy()
- def on_insert_link(self, action):
- dialog = gtk.Dialog("Enter a URL:",
- buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK))
- entry = gtk.Entry()
- dialog.vbox.pack_start(entry)
- dialog.show_all()
- if dialog.run() == gtk.RESPONSE_OK:
- self.editor.execute_script(
- "document.execCommand('createLink', true, '%s');" % entry.get_text())
- dialog.destroy()
- def on_insert_image(self, action):
- dialog = gtk.FileChooserDialog(title = "Select Image" ,
- action=gtk.FILE_CHOOSER_ACTION_OPEN,
- buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,gtk.STOCK_OK, gtk.RESPONSE_OK))
- filter = gtk.FileFilter()
- filter.set_name("Images")
- filter.add_mime_type("image/png")
- filter.add_mime_type("image/jpeg")
- filter.add_mime_type("image/gif")
- filter.add_pattern("*.png")
- filter.add_pattern("*.jpg")
- filter.add_pattern("*.gif")
- filter.add_pattern("*.tif")
- filter.add_pattern("*.xpm")
- filter.add_pattern("*.ico")
- filter.add_pattern("*.svg")
- dialog.add_filter(filter)
- if dialog.run() == gtk.RESPONSE_OK:
- fn = dialog.get_filename()
- if os.path.exists(fn):
- self.editor.execute_script(
- "document.execCommand('insertImage', null, '%s');" % fn)
- dialog.destroy()
- def on_open(self, action):
- dialog = gtk.FileChooserDialog(title = "Select Html File" ,
- action=gtk.FILE_CHOOSER_ACTION_OPEN,
- buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,gtk.STOCK_OK, gtk.RESPONSE_OK))
- if dialog.run() == gtk.RESPONSE_OK:
- fn = dialog.get_filename()
- if os.path.exists(fn):
- self.filename = fn
- with open(fn) as fd:
- self.editor.load_html_string(fd.read(), "file:///")
- dialog.destroy()
- def on_save(self, action):
- if self.filename:
- with open(self.filename) as fd: fd.write(self.get_html())
- else:
- dialog = gtk.FileChooserDialog(title = "Save File" ,
- action=gtk.FILE_CHOOSER_ACTION_SAVE,
- buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,gtk.STOCK_SAVE, gtk.RESPONSE_OK))
- if dialog.run() == gtk.RESPONSE_OK:
- self.filename = dialog.get_filename()
- with open(self.filename, "w+") as fd: fd.write(self.get_html())
- dialog.destroy()
- def get_html(self):
- self.editor.execute_script("document.title=document.documentElement.innerHTML;")
- return self.editor.get_main_frame().get_title()
- def ColorPicker(self,horizontal, spacing):
- frame = gtk.Frame()
- bbox = gtk.HBox()
- bbox.set_border_width(10)
- frame.add(bbox)
- bbox.set_spacing(spacing)
- width = 620
- height = 560
- self.renderer = webkit.WebView()
- self.renderer.set_size_request(width,height)
- self.renderer.open(self.configpath+"view.html")
- bbox.add(self.renderer)
- return frame
- def CssGenerator(self,horizontal, spacing):
- frame = gtk.Frame()
- bbox = gtk.HBox()
- bbox.set_border_width(10)
- frame.add(bbox)
- bbox.set_spacing(spacing)
- width = 700
- height = 560
- self.cbrenderer = webkit.WebView()
- self.cbrenderer.set_size_request(width,height)
- self.cbrenderer.open(self.configpath+"ButtonGenerator.html")
- bbox.add(self.cbrenderer)
- return frame
- def CoolGenerator(self,horizontal, spacing):
- frame = gtk.Frame()
- bbox = gtk.HBox()
- bbox.set_border_width(10)
- frame.add(bbox)
- bbox.set_spacing(spacing)
- width = 620
- height = 490
- self.crenderer = webkit.WebView()
- self.crenderer.set_size_request(width,height)
- self.crenderer.open(self.configpath+"coolbuttons.html")
- bbox.add(self.crenderer)
- return frame
- def create_cbox3(self, horizontal, spacing):
- frame = gtk.Frame("Simple image button generator")
- bbox = gtk.HBox()
- bbox.set_border_width(10)
- frame.add(bbox)
- bbox.set_spacing(spacing)
- self.qLabel = gtk.Label()
- self.qLabel.set_markup("<span font_weight='bold' color='#000000'>Select style which you want to use</span>")
- bbox.add(self.qLabel)
- cb = gtk.combo_box_new_text()
- cb.connect("changed", self.on_changed)
- cb.append_text('Create Square Style Button 32x32')
- cb.append_text('Create Square Style Button 48x48')
- cb.append_text('Create Square Style Button 64x64')
- cb.append_text('Create Square Style Button 96x96')
- cb.append_text('Create Square Style Button 128x128')
- cb.append_text('Create Rounded Style Button 32x32')
- cb.append_text('Create Rounded Style Button 48x48')
- cb.append_text('Create Rounded Style Button 64x64')
- cb.append_text('Create Rounded Style Button 96x96')
- cb.append_text('Create Rounded Style Button 128x128')
- fixed = gtk.Fixed()
- fixed.put(cb, 180, 0)
- self.label = gtk.Label("-")
- fixed.put(self.label, 190, 35)
- bbox.add(fixed)
- return frame
- def create_cbox4(self, horizontal, spacing):
- frame = gtk.Frame("Mass image button generator (applied to all images in selected folder)")
- bbox = gtk.HBox()
- bbox.set_border_width(10)
- frame.add(bbox)
- bbox.set_spacing(spacing)
- self.qLabel = gtk.Label()
- self.qLabel.set_markup("<span font_weight='bold' color='#000000'>Select style which you want to use</span>")
- bbox.add(self.qLabel)
- cb = gtk.combo_box_new_text()
- cb.connect("changed", self.on_dir_changed)
- cb.append_text('Create Square Style Button 32x32')
- cb.append_text('Create Square Style Button 48x48')
- cb.append_text('Create Square Style Button 64x64')
- cb.append_text('Create Square Style Button 96x96')
- cb.append_text('Create Square Style Button 128x128')
- cb.append_text('Create Rounded Style Button 32x32')
- cb.append_text('Create Rounded Style Button 48x48')
- cb.append_text('Create Rounded Style Button 64x64')
- cb.append_text('Create Rounded Style Button 96x96')
- cb.append_text('Create Rounded Style Button 128x128')
- fixed = gtk.Fixed()
- fixed.put(cb, 180, 0)
- self.label = gtk.Label("-")
- fixed.put(self.label, 190, 35)
- bbox.add(fixed)
- return frame
- def AllButtons(self,horizontal, spacing, layout):
- frame = gtk.Frame()
- bbox = gtk.HButtonBox()
- bbox.set_border_width(3)
- frame.add(bbox)
- bbox.set_layout(layout)
- bbox.set_spacing(spacing)
- icon = os.path.join(self.iconpath, "home.png")
- pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon , 24, 24)
- image = gtk.Image()
- image.set_from_pixbuf(pixbuf)
- image.show()
- self.sethome_eventBox = gtk.ToolButton()
- self.sethome_eventBox.set_icon_widget(image)
- self.sethome_eventBox.connect("clicked", self.on_home_clicked)
- bbox.add(self.sethome_eventBox)
- icon = os.path.join(self.iconpath, "drive.png")
- pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon , 24, 24)
- image = gtk.Image()
- image.set_from_pixbuf(pixbuf)
- image.show()
- self.setfile_eventBox = gtk.ToolButton()
- self.setfile_eventBox.set_icon_widget(image)
- self.setfile_eventBox.connect("clicked", self.on_filesystem_clicked)
- bbox.add(self.setfile_eventBox)
- icon = os.path.join(self.iconpath, "computer.png")
- pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon , 24, 24)
- image = gtk.Image()
- image.set_from_pixbuf(pixbuf)
- image.show()
- self.setcomp_eventBox = gtk.ToolButton()
- self.setcomp_eventBox.set_icon_widget(image)
- self.setcomp_eventBox.connect("clicked", self.on_comp_clicked)
- bbox.add(self.setcomp_eventBox)
- icon = os.path.join(self.iconpath, "quit.png")
- pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon , 24, 24)
- image = gtk.Image()
- image.set_from_pixbuf(pixbuf)
- image.show()
- self.setquit_eventBox = gtk.ToolButton()
- self.setquit_eventBox.set_icon_widget(image)
- self.setquit_eventBox.connect("clicked", self.on_close_clicked)
- bbox.add(self.setquit_eventBox)
- return frame
- def CssButton(self,horizontal, spacing, layout):
- frame = gtk.Frame()
- bbox = gtk.HButtonBox()
- bbox.set_border_width(10)
- frame.add(bbox)
- bbox.set_layout(layout)
- bbox.set_spacing(spacing)
- self.setpage_eventBox = gtk.Button()
- self.setpage_eventBox.set_size_request(230,30)
- self.setpageLabel = gtk.Label()
- self.setpageLabel.set_markup("<span font_weight='bold' color='#000000'>Select CSS File and Minify</span>")
- self.setpage_eventBox.connect("button-press-event", self.on_css_clicked)
- self.setpage_eventBox.add(self.setpageLabel)
- bbox.add(self.setpage_eventBox)
- self.minpage_eventBox = gtk.Button()
- self.minpage_eventBox.set_size_request(230,30)
- self.minpageLabel = gtk.Label()
- self.minpageLabel.set_markup("<span font_weight='bold' color='#000000'>Paste CSS to box and minify</span>")
- self.minpage_eventBox.connect("button-press-event", self.on_cssmin_clicked)
- self.minpage_eventBox.add(self.minpageLabel)
- bbox.add(self.minpage_eventBox)
- self.clear_eventBox = gtk.Button()
- self.clear_eventBox.set_size_request(60,30)
- self.clearLabel = gtk.Label()
- self.clearLabel.set_markup("<span font_weight='bold' color='#000000'>Clear</span>")
- self.clear_eventBox.connect("button-press-event", self.on_cssclear_clicked)
- self.clear_eventBox.add(self.clearLabel)
- bbox.add(self.clear_eventBox)
- return frame
- def w3cEntry(self,horizontal, spacing):
- frame = gtk.Frame()
- bbox = gtk.HButtonBox()
- bbox.set_border_width(10)
- frame.add(bbox)
- bbox.set_spacing(spacing)
- self.w3cpage_eventBox = gtk.Button()
- self.w3cpage_eventBox.set_size_request(500,30)
- self.w3cpageLabel = gtk.Label()
- self.w3cpageLabel.set_markup("<span font_weight='bold' color='#000000'>Start W3C Html Validator</span>")
- self.w3cpage_eventBox.connect("button-press-event", self.on_w3c_clicked)
- self.w3cpage_eventBox.add(self.w3cpageLabel)
- bbox.add(self.w3cpage_eventBox)
- return frame
- def w3c2Entry(self,horizontal, spacing):
- frame = gtk.Frame()
- bbox = gtk.HButtonBox()
- bbox.set_border_width(10)
- frame.add(bbox)
- bbox.set_spacing(spacing)
- self.w3c2page_eventBox = gtk.Button()
- self.w3c2page_eventBox.set_size_request(500,30)
- self.w3c2pageLabel = gtk.Label()
- self.w3c2pageLabel.set_markup("<span font_weight='bold' color='#000000'>Start W3C CSS Validator</span>")
- self.w3c2page_eventBox.connect("button-press-event", self.on_w3c2_clicked)
- self.w3c2page_eventBox.add(self.w3c2pageLabel)
- bbox.add(self.w3c2page_eventBox)
- return frame
- def w3c3Entry(self,horizontal, spacing):
- frame = gtk.Frame()
- bbox = gtk.HButtonBox()
- bbox.set_border_width(10)
- frame.add(bbox)
- bbox.set_spacing(spacing)
- self.w3c3page_eventBox = gtk.Button()
- self.w3c3page_eventBox.set_size_request(500,30)
- self.w3c3pageLabel = gtk.Label()
- self.w3c3pageLabel.set_markup("<span font_weight='bold' color='#000000'>Start W3C Feed Validator</span>")
- self.w3c3page_eventBox.connect("button-press-event", self.on_w3c3_clicked)
- self.w3c3page_eventBox.add(self.w3c3pageLabel)
- bbox.add(self.w3c3page_eventBox)
- return frame
- def w3cInfo(self,horizontal, spacing):
- frame = gtk.Frame()
- frame.set_size_request(800, 600)
- bbox = gtk.HBox()
- bbox.set_border_width(10)
- frame.add(bbox)
- bbox.set_spacing(spacing)
- self.filename = None
- self.w3ceditor = webkit.WebView()
- self.w3ceditor.set_editable(True)
- self.w3ceditor.load_html_string("", "file:///")
- w3cscroll = gtk.ScrolledWindow()
- w3cscroll.add(self.w3ceditor)
- w3cscroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
- self.w3clayout = gtk.VBox()
- self.w3clayout.pack_start(w3cscroll, True, True)
- bbox.add(self.w3clayout)
- return frame
- def w3c2Info(self,horizontal, spacing):
- frame = gtk.Frame()
- frame.set_size_request(800, 600)
- bbox = gtk.HBox()
- bbox.set_border_width(10)
- frame.add(bbox)
- bbox.set_spacing(spacing)
- self.filename = None
- self.w3c2editor = webkit.WebView()
- self.w3c2editor.set_editable(True)
- self.w3c2editor.load_html_string("", "file:///")
- w3c2scroll = gtk.ScrolledWindow()
- w3c2scroll.add(self.w3c2editor)
- w3c2scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
- self.w3c2layout = gtk.VBox()
- self.w3c2layout.pack_start(w3c2scroll, True, True)
- bbox.add(self.w3c2layout)
- return frame
- def w3c3Info(self,horizontal, spacing):
- frame = gtk.Frame()
- frame.set_size_request(800, 600)
- bbox = gtk.HBox()
- bbox.set_border_width(10)
- frame.add(bbox)
- bbox.set_spacing(spacing)
- self.filename = None
- self.w3c3editor = webkit.WebView()
- self.w3c3editor.set_editable(True)
- self.w3c3editor.load_html_string("", "file:///")
- w3c3scroll = gtk.ScrolledWindow()
- w3c3scroll.add(self.w3c3editor)
- w3c3scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
- self.w3c3layout = gtk.VBox()
- self.w3c3layout.pack_start(w3c3scroll, True, True)
- bbox.add(self.w3c3layout)
- return frame
- def CssInfo(self,horizontal, spacing):
- frame = gtk.Frame("Input Box")
- frame.set_size_request(800, 290)
- bbox = gtk.HBox()
- bbox.set_border_width(10)
- frame.add(bbox)
- bbox.set_spacing(spacing)
- code.set_editable(True)
- scrolled_area2 = gtk.ScrolledWindow()
- scrolled_area2.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
- scrolled_area2.add_with_viewport(code)
- scrolled_area2.set_size_request(500,290)
- bbox.add(scrolled_area2)
- return frame
- def CssInfo2(self,horizontal, spacing):
- frame = gtk.Frame("Output Box")
- frame.set_size_request(800, 290)
- bbox = gtk.HBox()
- bbox.set_border_width(10)
- frame.add(bbox)
- bbox.set_spacing(spacing)
- code2.set_editable(False)
- scrolled_area = gtk.ScrolledWindow()
- scrolled_area.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
- scrolled_area.add_with_viewport(code2)
- scrolled_area.set_size_request(500,290)
- bbox.add(scrolled_area)
- return frame
- def About(self,horizontal, spacing):
- frame = gtk.Frame()
- frame.set_size_request(800, 580)
- bbox = gtk.HBox()
- bbox.set_border_width(5)
- frame.add(bbox)
- bbox.set_spacing(spacing)
- self.aboutLabel = gtk.Label()
- self.aboutLabel.set_markup("<span font_weight='bold' color='#000000'>Web Developer Tools</span>\n\n"
- "Web Developer Tools is a suite of useful tools for web developers\n\n"
- "<span font_weight='bold' color='#000000'>Offline Tools:</span>\n\n"
- "Javascript Compressor\n"
- "Css Minifier\n"
- "RGB / HEX Color Picker\n"
- "Css Button Generator\n"
- "Cool Button Generator\n"
- "VTE Terminal\n"
- "Wysiwyg Editor\n\n"
- "<span font_weight='bold' color='#000000'>Online Tools:</span>\n\n"
- "W3C Html Validator\n"
- "W3C CSS Validator\n"
- "W3C Feed Validator\n\n\n"
- "For some of applications which has been included or modified we thanks to various people\n\n"
- "<span font_weight='bold' color='#000000'>Credits goes to:</span>\n"
- "<a href='http://dean.edwards.name/'>Dean Edwards for Javascript Compressor</a>\n"
- "<a href='http://stackoverflow.com/users/27388/borgar'>Borgar Porsteinsson for Css Minifier</a>\n"
- "<a href='http://arstechnica.com/author/ryan-paul/'>Ryan Paul for Wysiwyg Editor</a>\n"
- "<a href='http://nadiana.com/pil-tutorial-how-create-button-generator'>Nadia Alramli fro Cool Button Generator</a>\n\n"
- "<span font_weight='bold' color='#000000'>License</span>\n\n"
- "<a href='http://www.gnu.org/licenses/gpl-2.0.html'>Distributed under GPL 2</a>\n\n"
- "<span font_weight='bold' color='#000000'>Author</span>\n\n"
- "(c) 2010 <a href='mailto:thebestdeal1@gmail.com'>Peter Kmet </a>\n\n" )
- bbox.add(self.aboutLabel)
- return frame
- def __init__(self):
- self.checkForConfigDir()
- self.configpath = "/usr/share/wdt/"
- self.iconpath = self.configpath+"icons/"
- window = gtk.Window(gtk.WINDOW_TOPLEVEL)
- window.set_position(gtk.WIN_POS_CENTER)
- window.set_title("Web Developer Tools")
- window.set_icon_from_file(os.path.join(self.iconpath, "wdt.png"))
- window.connect("delete_event", self.delete)
- window.set_border_width(1)
- window.set_size_request(1280,700)
- table = gtk.Table(3,6,False)
- window.add(table)
- notebook = gtk.Notebook()
- notebook.set_tab_pos(gtk.POS_LEFT)
- table.attach(notebook, 0,6,0,1)
- notebook.show()
- self.show_tabs = True
- self.show_border = True
- frame = gtk.Frame("CSS Button Generator")
- frame.set_border_width(10)
- frame.set_size_request(800, 600)
- vbox = gtk.VBox(False, 0)
- vbox.set_border_width(10)
- frame.add(vbox)
- vbox.pack_start(self.CssGenerator(True, 5),True, True, 10)
- tab_box = gtk.HBox(False, 5)
- tab_label = gtk.Label("CSS Button Generator")
- tab_label.set_size_request(170, 25)
- tab_icon = gtk.Image()
- icon_path = os.path.join(self.iconpath, "cssbutton.png")
- pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon_path, 24, 24)
- tab_icon.set_from_pixbuf(pixbuf)
- tab_box.pack_start(tab_icon, False)
- tab_box.pack_start(tab_label, False)
- tab_box.show_all()
- notebook.append_page(frame, tab_box)
- frame = gtk.Frame("Dean Edwards Packer")
- frame.set_border_width(10)
- frame.set_size_request(800, 600)
- vbox = gtk.VBox(False, 0)
- vbox.set_border_width(10)
- frame.add(vbox)
- vbox.pack_start(self.Renderer(True, 5),True, True, 10)
- tab_box = gtk.HBox(False, 5)
- tab_label = gtk.Label("Javascript Compressor")
- tab_label.set_size_request(170, 25)
- tab_icon = gtk.Image()
- icon_path = os.path.join(self.iconpath, "javascript.png")
- pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon_path, 24, 24)
- tab_icon.set_from_pixbuf(pixbuf)
- tab_box.pack_start(tab_icon, False)
- tab_box.pack_start(tab_label, False)
- tab_box.show_all()
- notebook.append_page(frame, tab_box)
- frame = gtk.Frame("CSS Minifier")
- frame.set_border_width(10)
- frame.set_size_request(800, 600)
- vbox = gtk.VBox(False, 0)
- vbox.set_border_width(10)
- frame.add(vbox)
- vbox.pack_start(self.CssButton(True, 20, gtk.BUTTONBOX_SPREAD),True, True, 10)
- vbox.pack_start(self.CssInfo(True, 5),True, True, 10)
- vbox.pack_start(self.CssInfo2(True, 5),True, True, 10)
- tab_box = gtk.HBox(False, 5)
- tab_label = gtk.Label("---- Css Minifier ----")
- tab_label.set_size_request(170, 25)
- tab_icon = gtk.Image()
- icon_path = os.path.join(self.iconpath, "css-icon.png")
- pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon_path, 24, 24)
- tab_icon.set_from_pixbuf(pixbuf)
- tab_box.pack_start(tab_icon, False)
- tab_box.pack_start(tab_label, False)
- tab_box.show_all()
- notebook.append_page(frame, tab_box)
- frame = gtk.Frame("RGB / HEX Color Picker")
- frame.set_border_width(10)
- frame.set_size_request(800, 600)
- vbox = gtk.VBox(False, 0)
- vbox.set_border_width(10)
- frame.add(vbox)
- vbox.pack_start(self.ColorPicker(True, 5),True, True, 10)
- tab_box = gtk.HBox(False, 5)
- tab_label = gtk.Label("RGB / HEX Color Picker")
- tab_label.set_size_request(170, 25)
- tab_icon = gtk.Image()
- icon_path = os.path.join(self.iconpath, "colorchart.png")
- pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon_path, 24, 24)
- tab_icon.set_from_pixbuf(pixbuf)
- tab_box.pack_start(tab_icon, False)
- tab_box.pack_start(tab_label, False)
- tab_box.show_all()
- notebook.append_page(frame, tab_box)
- frame = gtk.Frame("Cool Button Generator")
- frame.set_border_width(10)
- frame.set_size_request(800, 600)
- vbox = gtk.VBox(False, 0)
- vbox.set_border_width(10)
- frame.add(vbox)
- vbox.pack_start(self.create_cbox3(True, 5),True, True, 10)
- vbox.pack_start(self.CoolGenerator(True, 5),True, True, 10)
- vbox.pack_start(self.create_cbox4(True, 5),True, True, 10)
- tab_box = gtk.HBox(False, 5)
- tab_label = gtk.Label("Cool Button Generator")
- tab_label.set_size_request(170, 25)
- tab_icon = gtk.Image()
- icon_path = os.path.join(self.iconpath, "coolbutton.png")
- pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon_path, 24, 24)
- tab_icon.set_from_pixbuf(pixbuf)
- tab_box.pack_start(tab_icon, False)
- tab_box.pack_start(tab_label, False)
- tab_box.show_all()
- notebook.append_page(frame, tab_box)
- frame = gtk.Frame("VTE Terminal")
- frame.set_border_width(10)
- frame.set_size_request(800, 600)
- vbox = gtk.VBox(False, 0)
- vbox.set_border_width(10)
- frame.add(vbox)
- vbox.pack_start(self.BrowserRenderer(True, 5),True, True, 10)
- tab_box = gtk.HBox(False, 5)
- tab_label = gtk.Label("---- VTE Terminal ----")
- tab_label.set_size_request(170, 25)
- tab_icon = gtk.Image()
- icon_path = os.path.join(self.iconpath, "terminal.png")
- pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon_path, 24, 24)
- tab_icon.set_from_pixbuf(pixbuf)
- tab_box.pack_start(tab_icon, False)
- tab_box.pack_start(tab_label, False)
- tab_box.show_all()
- notebook.append_page(frame, tab_box)
- frame = gtk.Frame("Wysiwyg Html 5 Editor")
- frame.set_border_width(10)
- frame.set_size_request(800, 600)
- vbox = gtk.VBox(False, 0)
- vbox.set_border_width(10)
- frame.add(vbox)
- vbox.pack_start(self.EditorRenderer(True, 5),True, True, 10)
- tab_box = gtk.HBox(False, 5)
- tab_label = gtk.Label("Wysiwyg Html5 Editor")
- tab_label.set_size_request(170, 25)
- tab_icon = gtk.Image()
- icon_path = os.path.join(self.iconpath, "editor.png")
- pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon_path, 24, 24)
- tab_icon.set_from_pixbuf(pixbuf)
- tab_box.pack_start(tab_icon, False)
- tab_box.pack_start(tab_label, False)
- tab_box.show_all()
- notebook.append_page(frame, tab_box)
- frame = gtk.Frame("W3C Html Validator")
- frame.set_border_width(10)
- frame.set_size_request(800, 600)
- vbox = gtk.VBox(False, 0)
- vbox.set_border_width(10)
- frame.add(vbox)
- vbox.pack_start(self.w3cEntry(True, 5),True, True, 10)
- vbox.pack_start(self.w3cInfo(True, 5),True, True, 10)
- tab_box = gtk.HBox(False, 5)
- tab_label = gtk.Label("W3C Html Validator")
- tab_label.set_size_request(170, 25)
- tab_icon = gtk.Image()
- icon_path = os.path.join(self.iconpath, "w3c_home.png")
- pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon_path, 24, 24)
- tab_icon.set_from_pixbuf(pixbuf)
- tab_box.pack_start(tab_icon, False)
- tab_box.pack_start(tab_label, False)
- tab_box.show_all()
- notebook.append_page(frame, tab_box)
- frame = gtk.Frame("W3C CSS Validator")
- frame.set_border_width(10)
- frame.set_size_request(800, 600)
- vbox = gtk.VBox(False, 0)
- vbox.set_border_width(10)
- frame.add(vbox)
- vbox.pack_start(self.w3c2Entry(True, 5),True, True, 10)
- vbox.pack_start(self.w3c2Info(True, 5),True, True, 10)
- tab_box = gtk.HBox(False, 5)
- tab_label = gtk.Label("W3C CSS Validator")
- tab_label.set_size_request(170, 25)
- tab_icon = gtk.Image()
- icon_path = os.path.join(self.iconpath, "w3c_home.png")
- pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon_path, 24, 24)
- tab_icon.set_from_pixbuf(pixbuf)
- tab_box.pack_start(tab_icon, False)
- tab_box.pack_start(tab_label, False)
- tab_box.show_all()
- notebook.append_page(frame, tab_box)
- frame = gtk.Frame("W3C Feed Validator")
- frame.set_border_width(10)
- frame.set_size_request(800, 600)
- vbox = gtk.VBox(False, 0)
- vbox.set_border_width(10)
- frame.add(vbox)
- vbox.pack_start(self.w3c3Entry(True, 5),True, True, 10)
- vbox.pack_start(self.w3c3Info(True, 5),True, True, 10)
- tab_box = gtk.HBox(False, 5)
- tab_label = gtk.Label("W3C Feed Validator")
- tab_label.set_size_request(170, 25)
- tab_icon = gtk.Image()
- icon_path = os.path.join(self.iconpath, "w3c_home.png")
- pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon_path, 24, 24)
- tab_icon.set_from_pixbuf(pixbuf)
- tab_box.pack_start(tab_icon, False)
- tab_box.pack_start(tab_label, False)
- tab_box.show_all()
- notebook.append_page(frame, tab_box)
- frame = gtk.Frame("About & Credits")
- frame.set_border_width(10)
- frame.set_size_request(800, 600)
- vbox = gtk.VBox(False, 0)
- vbox.set_border_width(10)
- frame.add(vbox)
- vbox.pack_start(self.About(True, 5),True, True, 10)
- tab_box = gtk.HBox(False, 5)
- tab_label = gtk.Label("--- About & Credits ---")
- tab_label.set_size_request(170, 25)
- tab_icon = gtk.Image()
- icon_path = os.path.join(self.iconpath, "about.png")
- pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon_path, 24, 24)
- tab_icon.set_from_pixbuf(pixbuf)
- tab_box.pack_start(tab_icon, False)
- tab_box.pack_start(tab_label, False)
- tab_box.show_all()
- notebook.append_page(frame, tab_box)
- vbox = gtk.VBox(False, 0)
- vbox.pack_start(self.AllButtons(True, 5, gtk.BUTTONBOX_END),True, True, 10)
- table.attach(vbox, 2,6,1,2)
- table.show_all()
- window.show_all()
- def setProcessName(processName):
- if sys.platform == 'linux2':
- try:
- import ctypes
- libc = ctypes.CDLL('libc.so.6')
- libc.prctl(15, processName, 0, 0, 0)
- except:
- try:
- import dl
- libc = dl.open('/lib/libc.so.6')
- libc.call('prctl', 15, (processName+'\0'), 0, 0, 0)
- except:
- pass
- setProcessName('Web-Devel-Tools')
- if __name__ == "__main__":
- NotebookExample()
- gtk.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement