Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- forum_signature.glade 2011-11-17 11:23:19.000000000 +0100
- +++ future/forum_signature_gtk3.glade 2012-02-11 02:51:55.000000000 +0100
- @@ -1,7 +1,6 @@
- <?xml version="1.0" encoding="UTF-8"?>
- <interface>
- - <!-- interface-requires gtk+ 2.12 -->
- - <!-- interface-naming-policy project-wide -->
- + <!-- interface-requires gtk+ 3.0 -->
- <object class="GtkDialog" id="dialog1">
- <property name="can_focus">False</property>
- <property name="border_width">5</property>
- @@ -15,11 +14,12 @@
- <property name="transient_for">window1</property>
- <signal name="delete-event" handler="gtk_false" swapped="no"/>
- <child internal-child="vbox">
- - <object class="GtkVBox" id="dialog-vbox1">
- + <object class="GtkBox" id="dialog-vbox1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- + <property name="orientation">vertical</property>
- <child internal-child="action_area">
- - <object class="GtkHButtonBox" id="dialog-action_area1">
- + <object class="GtkButtonBox" id="dialog-action_area1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="layout_style">end</property>
- @@ -99,8 +99,6 @@
- <property name="invisible_char">•</property>
- <property name="primary_icon_activatable">False</property>
- <property name="secondary_icon_activatable">False</property>
- - <property name="primary_icon_sensitive">True</property>
- - <property name="secondary_icon_sensitive">True</property>
- <signal name="changed" handler="on_entry1_changed" swapped="no"/>
- </object>
- </child>
- @@ -133,8 +131,6 @@
- <property name="invisible_char">•</property>
- <property name="primary_icon_activatable">False</property>
- <property name="secondary_icon_activatable">False</property>
- - <property name="primary_icon_sensitive">True</property>
- - <property name="secondary_icon_sensitive">True</property>
- <signal name="changed" handler="on_entry2_changed" swapped="no"/>
- </object>
- </child>
- @@ -201,12 +197,13 @@
- <property name="use_markup">True</property>
- <property name="secondary_use_markup">True</property>
- <child internal-child="vbox">
- - <object class="GtkVBox" id="dialog-vbox">
- + <object class="GtkBox" id="dialog-vbox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- + <property name="orientation">vertical</property>
- <property name="spacing">2</property>
- <child internal-child="action_area">
- - <object class="GtkHButtonBox" id="dialog-action_area">
- + <object class="GtkButtonBox" id="dialog-action_area">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="layout_style">end</property>
- @@ -253,12 +250,13 @@
- <property name="gravity">center</property>
- <property name="transient_for">window1</property>
- <child internal-child="vbox">
- - <object class="GtkVBox" id="dialog-vbox4">
- + <object class="GtkBox" id="dialog-vbox4">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- + <property name="orientation">vertical</property>
- <property name="spacing">2</property>
- <child internal-child="action_area">
- - <object class="GtkHButtonBox" id="dialog-action_area4">
- + <object class="GtkButtonBox" id="dialog-action_area4">
- <property name="can_focus">False</property>
- <property name="layout_style">end</property>
- <child>
- @@ -321,8 +319,6 @@
- <property name="height_request">200</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- - <property name="hscrollbar_policy">automatic</property>
- - <property name="vscrollbar_policy">automatic</property>
- <child>
- <object class="GtkTextView" id="textview3">
- <property name="visible">True</property>
- @@ -348,7 +344,9 @@
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="title" translatable="yes">Forum signature generator</property>
- - <property name="window_position">center-always</property>
- + <property name="window_position">center</property>
- + <property name="default_width">500</property>
- + <property name="default_height">300</property>
- <property name="destroy_with_parent">True</property>
- <property name="icon_name">applications-utilities</property>
- <property name="gravity">center</property>
- @@ -380,19 +378,14 @@
- </packing>
- </child>
- <child>
- - <object class="GtkComboBoxEntry" id="comboboxentry1">
- + <object class="GtkComboBoxText" id="comboboxtext1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- - <property name="model">liststorecombo1</property>
- - <property name="text_column">0</property>
- + <property name="has_entry">True</property>
- <signal name="changed" handler="on_comboboxentry_changed" swapped="no"/>
- <child internal-child="entry">
- - <object class="GtkEntry" id="comboboxentry-entry2">
- + <object class="GtkEntry" id="comboboxtext1-entry">
- <property name="can_focus">False</property>
- - <property name="primary_icon_activatable">False</property>
- - <property name="secondary_icon_activatable">False</property>
- - <property name="primary_icon_sensitive">True</property>
- - <property name="secondary_icon_sensitive">True</property>
- </object>
- </child>
- </object>
- @@ -423,19 +416,16 @@
- </packing>
- </child>
- <child>
- - <object class="GtkComboBoxEntry" id="comboboxentry2">
- + <object class="GtkComboBoxText" id="comboboxtext2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- - <property name="model">liststorecombo1</property>
- - <property name="text_column">0</property>
- + <property name="has_entry">True</property>
- <signal name="changed" handler="on_comboboxentry_changed" swapped="no"/>
- <child internal-child="entry">
- - <object class="GtkEntry" id="comboboxentry-entry4">
- + <object class="GtkEntry" id="comboboxtext2-entry">
- <property name="can_focus">False</property>
- <property name="primary_icon_activatable">False</property>
- <property name="secondary_icon_activatable">False</property>
- - <property name="primary_icon_sensitive">True</property>
- - <property name="secondary_icon_sensitive">True</property>
- </object>
- </child>
- </object>
- @@ -470,19 +460,16 @@
- </packing>
- </child>
- <child>
- - <object class="GtkComboBoxEntry" id="comboboxentry3">
- + <object class="GtkComboBoxText" id="comboboxtext3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- - <property name="model">liststorecombo1</property>
- - <property name="text_column">0</property>
- + <property name="has_entry">True</property>
- <signal name="changed" handler="on_comboboxentry_changed" swapped="no"/>
- <child internal-child="entry">
- - <object class="GtkEntry" id="comboboxentry-entry6">
- + <object class="GtkEntry" id="comboboxtext3-entry">
- <property name="can_focus">False</property>
- <property name="primary_icon_activatable">False</property>
- <property name="secondary_icon_activatable">False</property>
- - <property name="primary_icon_sensitive">True</property>
- - <property name="secondary_icon_sensitive">True</property>
- </object>
- </child>
- </object>
- @@ -521,8 +508,6 @@
- <object class="GtkScrolledWindow" id="scrolledwindow1">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- - <property name="hscrollbar_policy">automatic</property>
- - <property name="vscrollbar_policy">automatic</property>
- <property name="shadow_type">in</property>
- <child>
- <object class="GtkTextView" id="textview1">
- @@ -619,16 +604,14 @@
- <object class="GtkScrolledWindow" id="scrolledwindow2">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- - <property name="hscrollbar_policy">automatic</property>
- - <property name="vscrollbar_policy">automatic</property>
- <property name="shadow_type">in</property>
- <child>
- <object class="GtkTextView" id="textview2">
- + <property name="width_request">300</property>
- + <property name="height_request">100</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="wrap_mode">char</property>
- - <property name="width_request">300</property>
- - <property name="height_request">100</property>
- </object>
- </child>
- </object>
- --- forum_signature.py 2011-11-15 11:48:24.000000000 +0100
- +++ future/forum_signature_gtk3.py 2012-02-11 03:56:57.000000000 +0100
- @@ -4,7 +4,7 @@
- # Purpose: Proposes a signature with useful hardware/software information to forum newcomers/newbies
- # Requires: python 2.5, python-gtk2, python-mechanize
- -# Copyright (c) 2010-2011 Savvas Radevic <vicedar@gmail.com>
- +# Copyright (c) 2010-2012 Savvas Radevic <vicedar@gmail.com>
- #
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- @@ -21,7 +21,7 @@
- """ Example of signature:
- 1 Linux: � ┃ Προγραμματισμός: � ┃ Αγγλικά: �
- -2 Ubuntu 11.04 natty 64bit (en_GB.utf8), Ubuntu 2.6.38-10-generic, Windows 7
- +2 Ubuntu 11.04 natty 64bit (en_GB.utf8), Windows 7
- 3 Intel Core2 Duo CPU E6550 2.33GHz ‖ RAM 3961 MiB ‖ MSI MS-7235
- 4 nVidia G73 [GeForce 7300 GT] [10de:0393] (rev a1)
- 5 eth0: Realtek RTL-8110SC/8169SC Gigabit Ethernet [10ec:8167] (rev 10) ⋮ eth1: Realtek RTL-8139/8139C/8139C+ [10ec:8139] (rev 10)
- @@ -44,9 +44,11 @@
- textonly = False
- try:
- - import pygtk
- - pygtk.require('2.0')
- - import gtk
- + #import pygtk
- + #pygtk.require('2.0')
- + #import gtk
- + from gi.repository import Gtk, Gdk
- +
- except ImportError:
- sys.stderr.write("ERROR: Could not load gtk module\n")
- sys.stderr.flush()
- @@ -357,8 +359,8 @@
- self.password = ""
- self.sig_charlimit = 500 # Allowed number of characters
- # UI FILE
- - self.uifile = "forum_signature.glade"
- - self.builder = gtk.Builder()
- + self.uifile = "forum_signature_gtk3.glade"
- + self.builder = Gtk.Builder()
- self.builder.add_from_file(self.uifile)
- #SIGNALS
- self.builder.connect_signals(self)
- @@ -371,15 +373,19 @@
- self.textboxbuf.set_text(text)
- self.textbox2 = self.builder.get_object("textview2") # old sig
- self.textboxbuf2 = self.textbox2.get_buffer()
- - self.comboboxlinux = self.builder.get_object("comboboxentry1")
- - self.comboboxprogramming = self.builder.get_object("comboboxentry2")
- - self.comboboxenglish = self.builder.get_object("comboboxentry3")
- + self.liststore = self.builder.get_object("liststorecombo1")
- + self.comboboxlinux = self.builder.get_object("comboboxtext1")
- + self.comboboxlinux.set_model(self.liststore)
- + self.comboboxprogramming = self.builder.get_object("comboboxtext2")
- + self.comboboxprogramming.set_model(self.liststore)
- + self.comboboxenglish = self.builder.get_object("comboboxtext3")
- + self.comboboxenglish.set_model(self.liststore)
- self.statusbar = self.builder.get_object("statusbar1")
- self.statusbarcid = self.statusbar.get_context_id("status")
- self.oldsigpack = self.builder.get_object("expander1")
- # DIALOG
- self.dialog = self.builder.get_object("dialog1")
- - self.dialog.set_default_response(gtk.RESPONSE_CANCEL)
- + self.dialog.set_default_response(Gtk.ResponseType.CANCEL)
- self.entry1 = self.builder.get_object("entry1")
- self.entry2 = self.builder.get_object("entry2")
- # BUG REPORT DIALOG
- @@ -388,15 +394,15 @@
- # ERROR MESSAGE DIALOG
- self.errormsg = self.builder.get_object("messagedialog1")
- # Ubuntu Hardy 8.04 compatibility
- - self.comboboxlinux.set_text_column(0)
- - self.comboboxprogramming.set_text_column(0)
- - self.comboboxenglish.set_text_column(0)
- + self.comboboxlinux.set_entry_text_column(0)
- + self.comboboxprogramming.set_entry_text_column(0)
- + self.comboboxenglish.set_entry_text_column(0)
- # CHECK WUBI
- self.iswubi()
- def on_textboxbuf_changed(self, widget):
- (start, end) = self.textboxbuf.get_bounds()
- - sigtext = self.textboxbuf.get_text(start, end)
- + sigtext = self.textboxbuf.get_text(start, end, include_hidden_chars=False)
- self.sig_size = len(sigtext)
- # Could use this to drop code tags: re.sub(r'\[([^\s]*).*?\](.*?)\[/\1\]', r'\2', text)
- if self.sig_size > self.sig_charlimit:
- @@ -422,7 +428,7 @@
- outlsusb = p.communicate()[0]
- (start, end) = self.textboxbuf.get_bounds()
- - sigtext = self.textboxbuf.get_text(start, end)
- + sigtext = self.textboxbuf.get_text(start, end, include_hidden_chars=False)
- text = "Περιγράψτε το πρόβλημα στη θέση αυτού του κειμένου.\n\
- Επισυνάψτε σφάλμα από το τερματικό ή από το γραφικό περιβάλλον (αν υπάρχει).\n\n\
- @@ -436,8 +442,8 @@
- [/code]".format(outcpu, outmem, outlspci, outlsusb, sigtext)
- # SAVE TO CLIPBOARD
- - clipboard = gtk.clipboard_get()
- - clipboard.set_text(text)
- + clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
- + clipboard.set_text(text, -1)
- clipboard.store()
- buf = self.textboxbuf3.get_buffer()
- @@ -460,10 +466,10 @@
- timeoutid2 = glib.timeout_add_seconds(4, self.statusrefresh, msgid)
- def statusrefresh(self, msgid):
- - self.statusbar.remove_message(self.statusbarcid, msgid)
- + self.statusbar.remove(self.statusbarcid, msgid)
- def gtk_main_quit(self, widget):
- - gtk.main_quit()
- + Gtk.main_quit()
- def on_comboboxentry_changed(self, widget):
- linux = self.comboboxlinux.get_active_text()
- @@ -472,7 +478,7 @@
- self.line = "Linux: %s ┃ Προγραμματισμός: %s ┃ Αγγλικά: %s" % \
- (linux, programming, english)
- (start, end) = self.textboxbuf.get_bounds()
- - oldtext = self.textboxbuf.get_text(start, end) # get all text
- + oldtext = self.textboxbuf.get_text(start, end, include_hidden_chars=False) # get all text
- newtext = re.subn(
- 'Linux:.*┃ Προγραμματισμός:.*┃ Αγγλικά:.*',
- self.line,
- @@ -495,12 +501,12 @@
- else:
- # Submit to forum
- dialogreply = self.dialog.run()
- - if dialogreply == gtk.RESPONSE_APPLY:
- + if dialogreply == Gtk.ResponseType.APPLY:
- #print("REPLY: %s (continue)" % dialogreply)
- #print("User: %s Pass: %s" % (self.username, self.password))
- self.statusmsg("Contacting forum...")
- timeid = glib.timeout_add_seconds(1, self.webwrapper)
- - #elif dialogreply == gtk.RESPONSE_CANCEL or dialogreply == gtk.RESPONSE_DELETE_EVENT:
- + #elif dialogreply == Gtk.ResponseType.CANCEL or dialogreply == Gtk.ResponseType.DELETE_EVENT:
- #print("REPLY: %s (cancel)" % dialogreply)
- self.dialog.hide()
- @@ -515,11 +521,11 @@
- def gtk_false(self, *widget):
- # DIALOG - Cancel
- - self.dialog.response(gtk.RESPONSE_CANCEL)
- + self.dialog.response(Gtk.ResponseType.CANCEL)
- def gtk_true(self, *widget):
- # DIALOG - Continue
- - self.dialog.response(gtk.RESPONSE_APPLY)
- + self.dialog.response(Gtk.ResponseType.APPLY)
- def on_entry1_changed(self, widget):
- # DIALOG - Username
- @@ -537,7 +543,7 @@
- def sendtoweb(self):
- (start, end) = self.textboxbuf.get_bounds()
- - text = self.textboxbuf.get_text(start, end)
- + text = self.textboxbuf.get_text(start, end, include_hidden_chars=False)
- try:
- m = __import__("mechanize")
- @@ -549,7 +555,7 @@
- br = m.Browser()
- #('User-Agent', 'Mozilla/5.0 (X11; Linux x86_64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1'),
- br.addheaders = [
- - ('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'),
- + ('Accept-Charset', 'UTF-8;q=0.7'),
- ('Accept-Language', 'Accept-Language: en-us,en;q=0.7,el;q=0.3'),
- ('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')
- ]
- @@ -571,7 +577,7 @@
- logger.addHandler(logging.FileHandler("http.log"))
- logger.setLevel(logging.DEBUG)
- - br.open("http://forum.ubuntu-gr.org/ucp.php?i=profile&mode=signature")
- + br.open("https://forum.ubuntu-gr.org/ucp.php?i=profile&mode=signature")
- #self.statusmsg("Logging in...")
- br.select_form(nr=1) # Select login form (no name for the form)
- br["username"] = self.username
- @@ -600,7 +606,7 @@
- br.select_form(nr=1)
- oldsig = br["signature"]
- br["signature"] = text
- - #print(br.form)
- + print(br.form)
- r3 = br.submit(name='submit')
- h3 = r3.read()
- @@ -776,7 +782,7 @@
- else:
- print(text)
- siggui(text, o[2], debug=debug_app)
- - gtk.main()
- + Gtk.main()
- def timeit():
- f = 'core(osgrubber().returnall()).returnall()'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement