summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/ui/crumbs/hobpages.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/ui/crumbs/hobpages.py')
-rwxr-xr-xbitbake/lib/bb/ui/crumbs/hobpages.py87
1 files changed, 87 insertions, 0 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/hobpages.py b/bitbake/lib/bb/ui/crumbs/hobpages.py
new file mode 100755
index 0000000000..be76d0db27
--- /dev/null
+++ b/bitbake/lib/bb/ui/crumbs/hobpages.py
@@ -0,0 +1,87 @@
1#!/usr/bin/env python
2#
3# BitBake Graphical GTK User Interface
4#
5# Copyright (C) 2012 Intel Corporation
6#
7# Authored by Dongxiao Xu <dongxiao.xu@intel.com>
8# Authored by Shane Wang <shane.wang@intel.com>
9#
10# This program is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License version 2 as
12# published by the Free Software Foundation.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License along
20# with this program; if not, write to the Free Software Foundation, Inc.,
21# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22
23import gtk
24from bb.ui.crumbs.hobcolor import HobColors
25from bb.ui.crumbs.hobwidget import hwc
26
27#
28# HobPage: the super class for all Hob-related pages
29#
30class HobPage (gtk.VBox):
31
32 def __init__(self, builder, title = None):
33 super(HobPage, self).__init__(False, 0)
34 self.builder = builder
35 self.builder_width, self.builder_height = self.builder.size_request()
36
37 if title == None:
38 self.title = "HOB -- Image Creator"
39 else:
40 self.title = title
41
42 self.box_group_area = gtk.VBox(False, 15)
43 self.box_group_area.set_size_request(self.builder_width - 73 - 73, self.builder_height - 88 - 15 - 15)
44 self.group_align = gtk.Alignment(xalign = 0, yalign=0.5, xscale=1, yscale=1)
45 self.group_align.set_padding(15, 15, 73, 73)
46 self.group_align.add(self.box_group_area)
47 self.box_group_area.set_homogeneous(False)
48
49
50 def add_onto_top_bar(self, widget = None, padding = 0):
51 # the top button occupies 1/7 of the page height
52 # setup an event box
53 eventbox = gtk.EventBox()
54 style = eventbox.get_style().copy()
55 style.bg[gtk.STATE_NORMAL] = eventbox.get_colormap().alloc_color(HobColors.LIGHT_GRAY, False, False)
56 eventbox.set_style(style)
57 eventbox.set_size_request(-1, 88)
58
59 hbox = gtk.HBox()
60
61 label = gtk.Label()
62 label.set_markup("<span font_desc=\'14\'>%s</span>" % self.title)
63 hbox.pack_start(label, expand=False, fill=False, padding=20)
64
65 if widget != None:
66 # add the widget in the event box
67 hbox.pack_end(widget, expand=False, fill=False, padding=padding)
68 eventbox.add(hbox)
69
70 return eventbox
71
72 def span_tag(self, px="12px", weight="normal", forground="#1c1c1c"):
73 span_tag = "weight=\'%s\' foreground=\'%s\' font_desc=\'%s\'" % (weight, forground, px)
74 return span_tag
75
76 def append_toolbar_button(self, toolbar, buttonname, icon_disp, icon_hovor, tip, cb):
77 # Create a button and append it on the toolbar according to button name
78 icon = gtk.Image()
79 icon_display = icon_disp
80 icon_hover = icon_hovor
81 pix_buffer = gtk.gdk.pixbuf_new_from_file(icon_display)
82 icon.set_from_pixbuf(pix_buffer)
83 tip_text = tip
84 button = toolbar.append_element(gtk.TOOLBAR_CHILD_RADIOBUTTON, None,
85 buttonname, tip_text, "Private text", icon,
86 cb, None)
87 return toolbar, button