1 | import gi |
---|
2 | gi.require_version('Gtk', '3.0') |
---|
3 | from gi.repository import Gtk,GdkPixbuf,GLib,GObject, Pango |
---|
4 | |
---|
5 | import os |
---|
6 | import ImageManager |
---|
7 | import Core |
---|
8 | import Screenshot |
---|
9 | |
---|
10 | class SearchBox(Gtk.VBox): |
---|
11 | |
---|
12 | def __init__(self): |
---|
13 | |
---|
14 | Gtk.VBox.__init__(self) |
---|
15 | |
---|
16 | self.core=Core.Core.get_core() |
---|
17 | ui_path=self.core.ui_path |
---|
18 | builder=Gtk.Builder() |
---|
19 | builder.add_from_file(ui_path) |
---|
20 | |
---|
21 | self.label_max_width=65 |
---|
22 | |
---|
23 | |
---|
24 | self.search_box=builder.get_object("search_box") |
---|
25 | self.search_box.set_name("DETAILS_BOX") |
---|
26 | self.results_search_box=builder.get_object("results_search_box") |
---|
27 | |
---|
28 | self.add(self.search_box) |
---|
29 | self.show_all() |
---|
30 | |
---|
31 | #def init |
---|
32 | |
---|
33 | def populate_search_results(self,pkg_list): |
---|
34 | |
---|
35 | for children in self.results_search_box.get_children(): |
---|
36 | self.results_search_box.remove(children) |
---|
37 | |
---|
38 | for pkg in pkg_list: |
---|
39 | |
---|
40 | item_hbox=Gtk.HBox() |
---|
41 | item_hbox.set_size_request(650,100) |
---|
42 | |
---|
43 | print(pkg) |
---|
44 | |
---|
45 | hbox=Gtk.HBox() |
---|
46 | hbox.set_name("PKG_BOX") |
---|
47 | |
---|
48 | vbox=Gtk.VBox() |
---|
49 | |
---|
50 | b=Gtk.Button() |
---|
51 | s=Screenshot.ScreenshotNeo() |
---|
52 | s.set_margin_left(10) |
---|
53 | label=Gtk.Label(pkg["name"]) |
---|
54 | label.set_name("RELATED_LABEL") |
---|
55 | label.set_halign(Gtk.Align.START) |
---|
56 | label.set_valign(Gtk.Align.END) |
---|
57 | label.set_ellipsize(Pango.EllipsizeMode.END) |
---|
58 | label.set_max_width_chars(self.label_max_width) |
---|
59 | |
---|
60 | description=Gtk.Label(pkg["summary"]) |
---|
61 | description.set_halign(Gtk.Align.START) |
---|
62 | description.set_valign(Gtk.Align.START) |
---|
63 | description.set_name("SHORT_DESCRIPTION") |
---|
64 | description.set_ellipsize(Pango.EllipsizeMode.END) |
---|
65 | description.set_max_width_chars(self.label_max_width) |
---|
66 | |
---|
67 | vbox.pack_start(label,False,False,0) |
---|
68 | vbox.pack_start(description,False,False,0) |
---|
69 | vbox.set_valign(Gtk.Align.CENTER) |
---|
70 | |
---|
71 | hbox.pack_start(s,False,False,5) |
---|
72 | hbox.pack_start(vbox,False,False,5) |
---|
73 | |
---|
74 | i={} |
---|
75 | i["x"]=64 |
---|
76 | i["y"]=64 |
---|
77 | i["aspect_ratio"]=True |
---|
78 | i["image_path"]=self.core.resources.get_icon(pkg) |
---|
79 | i["name"]=pkg["name"] |
---|
80 | i["image_id"]=pkg["package"]+"_icon" |
---|
81 | |
---|
82 | |
---|
83 | s.set_from_file(i) |
---|
84 | b.add(hbox) |
---|
85 | |
---|
86 | b.connect("clicked",self.result_clicked,pkg) |
---|
87 | |
---|
88 | b.set_size_request(715,100) |
---|
89 | b.set_halign(Gtk.Align.CENTER) |
---|
90 | b.set_name("RELATED_BUTTON") |
---|
91 | item_hbox.pack_start(b,True,True,0) |
---|
92 | |
---|
93 | |
---|
94 | self.results_search_box.pack_start(item_hbox,False,False,5) |
---|
95 | |
---|
96 | self.results_search_box.show_all() |
---|
97 | |
---|
98 | |
---|
99 | #def populate_search_results |
---|
100 | |
---|
101 | def result_clicked(self,widget,pkg_data): |
---|
102 | |
---|
103 | self.core.main_window.load_pkg_data(pkg_data["package"]) |
---|
104 | |
---|
105 | |
---|
106 | #class SearchBox |
---|