~lorenzo-carbonell/utext/trunk

« back to all changes in this revision

Viewing changes to src/search_dialog_and_replace.py

  • Committer: Lorenzo Carbonell
  • Date: 2015-03-11 06:57:06 UTC
  • Revision ID: lorenzo.carbonell.cerezo@gmail.com-20150311065706-43xbr1y1c0qc2jl1
New updated version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python3
 
2
# -*- coding: utf-8 -*-
 
3
#
 
4
# preferences_dialog.py
 
5
#
 
6
# This file is part of PushBullet-Indicator
 
7
#
 
8
# Copyright (C) 2014
 
9
# Lorenzo Carbonell Cerezo <lorenzo.carbonell.cerezo@gmail.com>
 
10
#
 
11
# This program is free software: you can redistribute it and/or modify
 
12
# it under the terms of the GNU General Public License as published by
 
13
# the Free Software Foundation, either version 3 of the License, or
 
14
# (at your option) any later version.
 
15
#
 
16
# This program is distributed in the hope that it will be useful,
 
17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
19
# GNU General Public License for more details.
 
20
#
 
21
# You should have received a copy of the GNU General Public License
 
22
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
23
 
 
24
import gi
 
25
gi.require_version('Gtk', '3.0')
 
26
from gi.repository import Gtk
 
27
from gi.repository import Gdk
 
28
import comun
 
29
from comun import _
 
30
 
 
31
class SearchAndReplaceDialog(Gtk.Dialog):
 
32
        def __init__(self):
 
33
                #
 
34
                Gtk.Dialog.__init__(self, 'uText | '+_('Search and replace'),None,Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,(Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))
 
35
                self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
 
36
                #self.set_size_request(400, 230)
 
37
                self.connect('close', self.close_application)
 
38
                self.set_icon_from_file(comun.ICON)
 
39
                #
 
40
                vbox0 = Gtk.VBox(spacing = 5)
 
41
                vbox0.set_border_width(5)
 
42
                self.get_content_area().add(vbox0)
 
43
                #***************************************************************
 
44
                #***************************************************************
 
45
                frame1 = Gtk.Frame()
 
46
                vbox0.pack_start(frame1,False,True,1)
 
47
                table1 = Gtk.Table(2, 2, False)
 
48
                frame1.add(table1)
 
49
                #***************************************************************
 
50
                label1 = Gtk.Label(_('Search')+':')
 
51
                label1.set_alignment(0, 0.5)
 
52
                table1.attach(label1,0,1,0,1, xpadding=5, ypadding=5)
 
53
                self.search_text = Gtk.Entry()
 
54
                table1.attach(self.search_text,1,2,0,1, xpadding=5, ypadding=5)
 
55
                label2 = Gtk.Label(_('Replace with')+':')
 
56
                label2.set_alignment(0, 0.5)
 
57
                table1.attach(label2,0,1,1,2, xpadding=5, ypadding=5)
 
58
                self.replace_text = Gtk.Entry()
 
59
                table1.attach(self.replace_text,1,2,1,2, xpadding=5, ypadding=5)
 
60
                #
 
61
                self.show_all()
 
62
        
 
63
 
 
64
        def close_application(self, widget, event):
 
65
                self.hide()
 
66
 
 
67
if __name__ == "__main__":
 
68
        cm = SearchAndReplaceDialog()
 
69
        if      cm.run() == Gtk.ResponseType.ACCEPT:
 
70
                        print(cm.search_text.get_text())
 
71
                        print(cm.replace_text.get_text())
 
72
        cm.hide()
 
73
        cm.destroy()
 
74
        exit(0)