Exemplo n.º 1
0
  def __create_left_ui(self, box):
    # Device selector

    frame = BoxFrame('Devices')
    box.pack_start(frame, expand=False)

    self.__device_liststore = gtk.ListStore(str, object)
    self.__device_selector = gtk.ComboBox(self.__device_liststore)
    cell = gtk.CellRendererText()
    self.__device_selector.pack_start(cell, True)
    self.__device_selector.add_attribute(cell, 'text', 0)
    self.__device_selector.connect('changed', self.__on_device_changed)
    frame.pack_start(self.__device_selector)

    # NAND partition selector

    frame = BoxFrame('NAND Partitions')
    box.pack_start(frame, expand=False)

    self.__partition_liststore = gtk.ListStore(str, int, int)
    self.__partition_selector = gtk.ComboBox(self.__partition_liststore)
    cell = gtk.CellRendererText()
    self.__partition_selector.pack_start(cell, True)
    self.__partition_selector.add_attribute(cell, 'text', 0)
    self.__partition_selector.connect('changed', self.__refresh_buttons)
    frame.pack_start(self.__partition_selector)

    # Image file selector

    frame = BoxFrame('Image File to Flash')
    box.pack_start(frame, expand=False)

    self.__image_entry = gtk.Entry()
    self.__image_entry.connect('changed', self.__refresh_buttons)
    frame.pack_start(self.__image_entry)

    self.__image_select_button = gtk.Button('Choose')
    self.__image_select_button.connect('clicked', self.__choose_image_file)
    frame.pack_start(self.__image_select_button, expand=False, fill=False)

    # Action buttons

    frame = BoxFrame('Actions', opt_hbox=False, spacing=20)
    box.pack_start(frame, expand=False)

    self.__flash_button = gtk.Button('Flash image')
    self.__flash_button.connect('clicked', self.__flash_image_file)
    frame.pack_start(self.__flash_button, expand=False, fill=False)

    self.__cmp_button = gtk.Button('Compare partition with image file')
    self.__cmp_button.connect('clicked', self.__cmp_part_with_file)
    frame.pack_start(self.__cmp_button, expand=False, fill=False)

    self.__backup_button = gtk.Button('Backup Partition')
    self.__backup_button.connect('clicked', self.__backup_partition)
    frame.pack_start(self.__backup_button, expand=False, fill=False)

    self.__erase_button = gtk.Button('Erase Partition')
    self.__erase_button.connect('clicked', self.__erase_partition)
    frame.pack_start(self.__erase_button, expand=False, fill=False)

    self.__reboot_button = gtk.Button('Reboot Device')
    self.__reboot_button.connect('clicked', self.__reboot_device)
    frame.pack_start(self.__reboot_button, expand=False, fill=False)

    self.__clear_log_button = gtk.Button('Clear Log')
    self.__clear_log_button.connect('clicked', self.__clear_log)
    frame.pack_start(self.__clear_log_button, expand=False, fill=False)
Exemplo n.º 2
0
def selectInstallNetDeviceDialog(network, devices=None):

    devs = devices or network.netdevices.keys()
    if not devs:
        return None
    devs.sort()

    dialog = gtk.Dialog(_("Select network interface"))
    dialog.add_button('gtk-cancel', gtk.RESPONSE_CANCEL)
    dialog.add_button('gtk-ok', 1)
    dialog.set_position(gtk.WIN_POS_CENTER)
    gui.addFrame(dialog)

    dialog.vbox.pack_start(
        gui.WrappingLabel(
            _("This requires that you have an active "
              "network connection during the installation "
              "process.  Please configure a network interface.")))

    combo = gtk.ComboBox()
    cell = gtk.CellRendererText()
    combo.pack_start(cell, True)
    combo.set_attributes(cell, text=0)
    cell.set_property("wrap-width", 525)
    combo.set_size_request(480, -1)
    store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
    combo.set_model(store)

    ksdevice = network.getKSDevice()
    if ksdevice:
        ksdevice = ksdevice.get('DEVICE')
    preselected = None

    for dev in devices:
        i = store.append(None)
        if not preselected:
            preselected = i

        desc = network.netdevices[dev].description
        if desc:
            desc = "%s - %s" % (dev, desc)
        else:
            desc = "%s" % (dev, )

        hwaddr = network.netdevices[dev].get("HWADDR")

        if hwaddr:
            desc = "%s - %s" % (
                desc,
                hwaddr,
            )

        if ksdevice and ksdevice == dev:
            preselected = i

        store[i] = (desc, dev)

    combo.set_active_iter(preselected)
    dialog.vbox.pack_start(combo)

    dialog.show_all()

    rc = dialog.run()

    if rc in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
        install_device = None
    else:
        active = combo.get_active_iter()
        install_device = combo.get_model().get_value(active, 1)

    dialog.destroy()
    return install_device
Exemplo n.º 3
0
class PyApp(gtk.Window):

    data = pd.read_csv("Crimes_commited_ipc2.csv")
    combobox_district = gtk.ComboBox()
    combobox_year = gtk.ComboBox()
    combobox_state = gtk.ComboBox()
    combobox_crime = gtk.ComboBox()
    combobox_state1 = gtk.ComboBox()
    combobox_state2 = gtk.ComboBox()
    combobox_yearc = gtk.ComboBox()
    button_show_graph = gtk.Button("Show Graph")
    compare_button = gtk.Button("Compare")
    filtered_data = df()

    store_dist = gtk.ListStore(str)

    def __init__(self):
        super(PyApp, self).__init__()

        self.set_title("Crimes in India")
        self.set_size_request(700, 500)
        #self.set_icon_from_file("/home/prasadgadde/BigData/Project/icon.png")

        # Set window background image
        pixbuf = gtk.gdk.pixbuf_new_from_file(
            "vector-grunge-texture-background.jpg")
        pixmap, mask = pixbuf.render_pixmap_and_mask()
        width, height = pixmap.get_size()
        #del pixbuf
        self.set_app_paintable(gtk.TRUE)
        self.resize(width, height)
        self.realize()
        self.window.set_back_pixmap(pixmap, gtk.FALSE)
        #del pixmap

        nb = gtk.Notebook()
        nb.set_tab_pos(gtk.POS_TOP)
        vbox = gtk.VBox(False, 5)

        vb = gtk.VBox()
        hbox = gtk.HBox(True, 3)
        hlabelsbox = gtk.HBox(True, 120)
        hbuttonbox = gtk.HBox(True, 10)

        # Horizontal box for labels
        label_state = gtk.Label("State")
        label_district = gtk.Label("District")
        label_year = gtk.Label("Year")
        label_crime = gtk.Label("Crime")

        hlabelsbox.pack_start(label_state, True, True, 10)
        hlabelsbox.pack_start(label_district, True, True, 10)
        hlabelsbox.pack_start(label_year, True, True, 10)
        hlabelsbox.pack_start(label_crime, True, True, 10)

        valign = gtk.Alignment(0.25, 0.10, 0, 0)
        valign1 = gtk.Alignment(0, 1, 0, 0)
        valign2 = gtk.Alignment(0, 0, 1, 0)

        store = gtk.ListStore(str)
        cell = gtk.CellRendererText()
        self.combobox_state.pack_start(cell)
        self.combobox_state.set_title("States")
        self.combobox_state.add_attribute(cell, 'text', 0)

        hbox.pack_start(self.combobox_state, True, True, 10)

        store.append(["ANDHRA PRADESH"])
        store.append(["ARUNACHAL PRADESH"])
        store.append(["ASSAM"])
        store.append(["BIHAR"])
        store.append(["GOA"])
        store.append(["GUJARAT"])
        store.append(["HARYANA"])
        store.append(["HIMACHAL PRADESH"])
        store.append(["JAMMU & KASHMIR"])
        store.append(["JHARKHAND"])
        store.append(["KARNATAKA"])
        store.append(["KERALA"])
        store.append(["MADHYA PRADESH"])
        store.append(["MAHARASHTRA"])
        store.append(["MANIPUR"])
        store.append(["MEGHALAYA"])
        store.append(["MIZORAM"])
        store.append(["NAGALAND"])
        store.append(["ODISHA"])
        store.append(["MIZORAM"])
        store.append(["PUNJAB"])
        store.append(["RAJASTHAN"])
        store.append(["TAMIL NADU"])
        store.append(["TRIPURA"])
        store.append(["UTTAR PRADESH"])
        store.append(["UTTARAKHAND"])
        store.append(["WEST BENGAL"])
        store.append(["A & N ISLANDS"])
        store.append(["CHANDIGARH"])
        store.append(["D & N HAVELI"])
        store.append(["DAMAN & DIU"])
        store.append(["DELHI UT"])
        store.append(["LAKSHADWEEP"])
        store.append(["PUDUCHERRY"])

        self.combobox_state.set_model(store)
        self.combobox_state.connect('changed', self.on_changed)
        self.combobox_state.set_active(0)

        self.store_dist = gtk.ListStore(str)
        cell_dist = gtk.CellRendererText()
        self.combobox_district.pack_start(cell_dist)
        self.combobox_district.add_attribute(cell_dist, 'text', 0)
        self.combobox_district.connect('changed', self.on_changed_district)
        hbox.pack_start(self.combobox_district, True, True, 10)

        #Year dropbox

        store_year = gtk.ListStore(str)
        cell_year = gtk.CellRendererText()
        self.combobox_year.pack_start(cell_year)
        self.combobox_year.add_attribute(cell_year, 'text', 0)

        hbox.pack_start(self.combobox_year, True, True, 10)

        district = self.data[(self.data['STATEorUT'] == 'ANDHRA PRADESH') | (
            self.data['STATEorUT'] == 'Andhra Pradesh')].filter(
                items=['STATE/UT', 'DISTRICT', 'YEAR'])
        year = s(district['YEAR']).unique().tolist()
        store_year.append(["All"])
        for i in year:
            store_year.append([i])

        self.combobox_year.set_model(store_year)
        #combobox.connect('changed', self.on_changed)
        self.combobox_year.set_active(0)
        self.combobox_year.connect('changed', self.on_changed_year)

        # Crime dropbox

        store_crime = gtk.ListStore(str)
        cell_crime = gtk.CellRendererText()
        self.combobox_crime.pack_start(cell_crime)
        self.combobox_crime.add_attribute(cell_crime, 'text', 0)
        self.combobox_crime.connect('changed', self.on_changed_crime)

        hbox.pack_start(self.combobox_crime, True, True, 10)

        store_crime.append(["MURDER"])
        store_crime.append(["RAPE"])
        store_crime.append(["KIDNAPPING"])
        store_crime.append(["RIOTS"])
        store_crime.append(["ROBBERY"])
        store_crime.append(["BURGLARY"])
        store_crime.append(["DOWRY DEATHS"])
        store_crime.append(["TOTAL IPC CRIMES"])
        self.combobox_crime.set_model(store_crime)
        #combobox.connect('changed', self.on_changed)
        self.combobox_crime.set_active(0)

        valign.add(hbox)
        valign1.add(hlabelsbox)

        button_disp_data = gtk.Button("Display Data")

        button_disp_data.connect("clicked", self.display_data)
        self.button_show_graph.connect("clicked", self.display_graph)

        self.button_show_graph.set_sensitive(False)

        hbuttonbox.pack_start(button_disp_data, True, True, 10)
        hbuttonbox.pack_start(self.button_show_graph, True, True, 10)
        valign2.add(hbuttonbox)
        vbox.pack_start(valign1)
        vbox.pack_start(valign)
        vbox.pack_start(valign2)

        nb.append_page(vbox)
        nb.set_tab_label_text(vbox, "District wise crimes")

        # Code for 2nd TAB

        state1lbl = gtk.Label("State 1")
        state2lbl = gtk.Label("State 2")

        self.compare_button.connect("clicked", self.compare_states)
        self.compare_button.set_sensitive(False)

        table = gtk.Table(8, 4, True)
        table.set_col_spacings(7)

        states = [
            "ANDHRA PRADESH", "ARUNACHAL PRADESH", "ASSAM", "BIHAR",
            "CHHATTISGARH", "GOA", "GUJARAT", "HARYANA", "HIMACHAL PRADESH",
            "JAMMU & KASHMIR", "JHARKHAND", "KARNATAKA", "KERALA",
            "MADHYA PRADESH", "MAHARASHTRA", "MANIPUR", "MEGHALAYA", "MIZORAM",
            "NAGALAND", "ODISHA", "PUNJAB", "RAJASTHAN", "SIKKIM",
            "TAMIL NADU", "TRIPURA", "UTTAR PRADESH", "UTTARAKHAND",
            "WEST BENGAL", "A & N ISLANDS", "CHANDIGARH", "D & N HAVELI",
            "DAMAN & DIU", "DELHI UT", "LAKSHADWEEP", "PUDUCHERRY"
        ]
        storestate1 = gtk.ListStore(str)
        cellstate1 = gtk.CellRendererText()
        self.combobox_state1.pack_start(cellstate1)
        self.combobox_state1.add_attribute(cellstate1, 'text', 0)
        self.combobox_state1.set_active(0)
        for i in states:
            storestate1.append([i])
        self.combobox_state1.set_model(storestate1)

        storestate2 = gtk.ListStore(str)
        cellstate2 = gtk.CellRendererText()
        self.combobox_state2.pack_start(cellstate2)
        self.combobox_state2.add_attribute(cellstate2, 'text', 0)
        self.combobox_state2.set_active(0)
        for i in states:
            storestate2.append([i])
        self.combobox_state2.set_model(storestate2)

        store_yearc = gtk.ListStore(str)
        cell_yearc = gtk.CellRendererText()
        self.combobox_yearc.pack_start(cell_yearc)
        self.combobox_yearc.add_attribute(cell_yearc, 'text', 0)
        self.combobox_yearc.set_active(0)

        for i in year:
            store_yearc.append([i])
        self.combobox_yearc.set_model(store_yearc)

        self.combobox_state1.connect('changed', self.on_changed_state1)
        self.combobox_state2.connect('changed', self.on_changed_state2)
        self.combobox_yearc.connect('changed', self.on_changed_yearc)

        table.attach(state1lbl, 0, 1, 3, 4)
        table.attach(state2lbl, 2, 3, 3, 4)
        table.attach(self.combobox_state1, 0, 1, 4, 5, xpadding=8, ypadding=9)
        table.attach(self.combobox_state2, 2, 3, 4, 5, xpadding=8, ypadding=9)
        table.attach(self.combobox_yearc, 1, 2, 4, 5, xpadding=8, ypadding=9)
        table.attach(self.compare_button, 1, 2, 6, 7, xpadding=8, ypadding=9)

        nb.append_page(table)
        nb.set_tab_label_text(table, "Comparison of states")

        tv = gtk.TextView()
        nb.append_page(tv)
        nb.set_tab_label_text(tv, "About")

        self.add(nb)

        self.connect("destroy", gtk.main_quit)
        self.show_all()

    def on_changed_state1(self, widget):
        if (widget.get_active_text() == self.combobox_state2.get_active_text()
            ):
            self.compare_button.set_sensitive(False)
        else:
            self.compare_button.set_sensitive(True)
        return

    def on_changed_state2(self, widget):
        if (widget.get_active_text() == self.combobox_state1.get_active_text()
            ):
            self.compare_button.set_sensitive(False)
        else:
            self.compare_button.set_sensitive(True)
        return

    def on_changed_yearc(self, widget):
        return

    def on_changed(self, widget):
        #data = pd.read_csv("/home/prasadgadde/BigData/Project/crime-in-india/crime/01_District_wise_crimes_committed_IPC_2013.csv"
        district = s(self.data[
            self.data['STATEorUT'] == widget.get_active_text()].filter(
                items=['DISTRICT'])['DISTRICT']).unique().tolist()
        self.store_dist.clear()
        self.store_dist.append(["All"])
        for i in district:
            self.store_dist.append([i])

        self.combobox_district.set_model(self.store_dist)
        #combobox.connect('changed', self.on_changed)
        self.combobox_district.set_active(0)

    def display_data(self, widget):
        #print self.combobox_state.get_active_text(), self.combobox_year.get_active_text(), self.combobox_district.get_active_text(), self.combobox_crime.get_active_text()
        #filtered_data = self.data[((self.data['STATE.UT']==self.combobox_state.get_active_text()) & (self.data['DISTRICT']==self.combobox_district.get_active_text()) & (self.data['YEAR']==self.combobox_year.get_active_text()))].filter(items=['STATE/UT','DISTRICT','YEAR', self.combobox_crime.get_active_text()])

        dialog = gtk.Dialog("My dialog", self,
                            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                            (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
        dialog.set_size_request(400, 700)

        liststore = gtk.ListStore(str, str, str, str)

        treeview = gtk.TreeView(liststore)

        tvcolumn = gtk.TreeViewColumn("STATE/UT")
        tvcolumn1 = gtk.TreeViewColumn("DISTRICT")
        tvcolumn2 = gtk.TreeViewColumn("YEAR")
        tvcolumn3 = gtk.TreeViewColumn(self.combobox_crime.get_active_text())

        for i in self.filtered_data.values.tolist():
            liststore.append(i)
        #liststore.append(['Open', gtk.STOCK_OPEN, 'Open a File', True])

        treeview.append_column(tvcolumn)
        treeview.append_column(tvcolumn1)
        treeview.append_column(tvcolumn2)
        treeview.append_column(tvcolumn3)

        cell = gtk.CellRendererText()
        cell1 = gtk.CellRendererText()
        cell2 = gtk.CellRendererText()
        cell3 = gtk.CellRendererText()

        cell.set_property('cell-background', 'yellow')
        cell1.set_property('cell-background', 'cyan')
        cell2.set_property('cell-background', 'pink')
        cell3.set_property('cell-background', 'red')

        tvcolumn.pack_start(cell, False)
        tvcolumn1.pack_start(cell1, True)
        tvcolumn2.pack_start(cell2, True)
        tvcolumn3.pack_start(cell3, True)

        tvcolumn.set_attributes(cell, text=0)
        tvcolumn1.set_attributes(cell1, text=1)
        tvcolumn2.set_attributes(cell2, text=2)
        tvcolumn3.set_attributes(cell3, text=3)

        scrolled_window = gtk.ScrolledWindow()
        scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        scrolled_window.add(treeview)
        scrolled_window.set_border_width(10)
        #scrolled_window.set_min_content_height(200)

        scrolled_window.add(treeview)

        treeview.set_search_column(0)
        dialog.vbox.add(scrolled_window)
        treeview.show()
        scrolled_window.show()
        res = dialog.run()
        dialog.destroy()

        return

    def display_graph(self, widget):
        dialog = gtk.Dialog("My dialog", self,
                            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                            (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
        dialog.set_size_request(1300, 500)

        # Crime name filter
        if " " not in self.combobox_crime.get_active_text():
            crime = self.combobox_crime.get_active_text()
        else:
            crime = ".".join(self.combobox_crime.get_active_text().split(" "))

        fig = Figure(figsize=(12, 10), dpi=100)

        sales = [{
            'Groups': '0-9',
            'Counts': 38
        }, {
            'Groups': '10-19',
            'Counts': 41
        }, {
            'Groups': '20-29',
            'Counts': 77
        }, {
            'Groups': '30-39',
            'Counts': 73
        }, {
            'Groups': '40-49',
            'Counts': 77
        }]
        df = pd.DataFrame(sales)

        ax = fig.add_subplot(111)

        if (self.combobox_year.get_active_text() == "All"
                and self.combobox_district.get_active_text() != "All"):

            self.filtered_data = self.filtered_data.reset_index(drop=True)
            ypos = np.arange(len(self.filtered_data['YEAR'].tolist()))
            p1 = ax.bar(ypos, self.filtered_data[crime], width=0.6, color='r')

            ax.set_title(crime.lower() + 's in ' +
                         self.combobox_district.get_active_text() +
                         '  - Yearwise')
            ax.set_xticks(ypos + 0.3)
            ax.set_xticklabels(self.filtered_data.YEAR)
        elif (self.combobox_district.get_active_text() == "All"
              and self.combobox_year.get_active_text() != "All"):
            fd_total_removed = self.filtered_data[
                self.filtered_data.DISTRICT != 'TOTAL']
            ypos = np.arange(len(fd_total_removed['DISTRICT'].tolist()))

            p1 = ax.bar(ypos, fd_total_removed[crime], width=0.3, color='r')
            fontx = {
                'fontsize': 7,
                'fontweight': 2,
                'verticalalignment': 'center',
                'horizontalalignment': 'center'
            }

            ax.set_title(crime + 's in ' +
                         self.combobox_state.get_active_text() + '(' +
                         self.combobox_state.get_active_text() + ' )' +
                         '  - Districtwise')
            ax.set_xticks(ypos + 0.15)
            ax.set_xticklabels(fd_total_removed.DISTRICT, fontdict=fontx)
        else:
            print(df.index)
            p1 = ax.bar(df.index, df.Counts, width=0.8, color='r')

            ax.set_title('Scores by group and gender')
            ax.set_xticks(df.index + 0.4)
            ax.set_xticklabels(df.Groups)

        canvas = FigureCanvas(fig)  # a gtk.DrawingArea
        canvas.set_size_request(800, 600)
        dialog.vbox.pack_start(canvas)
        toolbar = NavigationToolbar(canvas, dialog)
        dialog.vbox.pack_start(toolbar, False, False)
        canvas.show()
        dialog.run()
        dialog.destroy()
        return

    def on_changed_district(self, widget):
        if (self.combobox_year.get_active_text() != 'All'):
            intyear = int(self.combobox_year.get_active_text())

        # Check crime field
        if " " not in self.combobox_crime.get_active_text():
            crime = self.combobox_crime.get_active_text()
        else:
            crime = ".".join(self.combobox_crime.get_active_text().split(" "))

        if (self.combobox_district.get_active_text() == 'All'
                and self.combobox_year.get_active_text() == 'All'):
            self.filtered_data = self.data.query(
                'STATEorUT == @self.combobox_state.get_active_text()').filter(
                    items=['STATEorUT', 'DISTRICT', 'YEAR', crime])
            self.button_show_graph.set_sensitive(False)
        elif (self.combobox_district.get_active_text() == 'All'):
            self.filtered_data = self.data.query(
                'STATEorUT == @self.combobox_state.get_active_text() and YEAR == @intyear'
            ).filter(items=['STATEorUT', 'DISTRICT', 'YEAR', crime])
            self.button_show_graph.set_sensitive(True)
        elif (self.combobox_year.get_active_text() == "All"):
            self.filtered_data = self.data.query(
                'STATEorUT == @self.combobox_state.get_active_text() and DISTRICT == @self.combobox_district.get_active_text()'
            ).filter(items=['STATEorUT', 'DISTRICT', 'YEAR', crime])
            self.button_show_graph.set_sensitive(True)
        else:
            self.button_show_graph.set_sensitive(False)
            self.filtered_data = self.data.query(
                'STATEorUT == @self.combobox_state.get_active_text() and DISTRICT == @self.combobox_district.get_active_text() and YEAR == @intyear'
            ).filter(items=['STATEorUT', 'DISTRICT', 'YEAR', crime])

        return

    def on_changed_year(self, widget):
        if (self.combobox_year.get_active_text() != 'All'):
            intyear = int(self.combobox_year.get_active_text())

        # Check crime field
        if " " not in self.combobox_crime.get_active_text():
            crime = self.combobox_crime.get_active_text()
        else:
            crime = ".".join(self.combobox_crime.get_active_text().split(" "))

        if (self.combobox_district.get_active_text() == 'All'
                and self.combobox_year.get_active_text() == 'All'):
            self.filtered_data = self.data.query(
                'STATEorUT == @self.combobox_state.get_active_text()').filter(
                    items=['STATEorUT', 'DISTRICT', 'YEAR', crime])
            self.button_show_graph.set_sensitive(False)
        elif (self.combobox_district.get_active_text() == 'All'):
            self.filtered_data = self.data.query(
                'STATEorUT == @self.combobox_state.get_active_text() and YEAR == @intyear'
            ).filter(items=['STATEorUT', 'DISTRICT', 'YEAR', crime])
            self.button_show_graph.set_sensitive(True)
        elif (self.combobox_year.get_active_text() == "All"):
            self.filtered_data = self.data.query(
                'STATEorUT == @self.combobox_state.get_active_text() and DISTRICT == @self.combobox_district.get_active_text()'
            ).filter(items=['STATEorUT', 'DISTRICT', 'YEAR', crime])
            self.button_show_graph.set_sensitive(True)
        else:
            self.button_show_graph.set_sensitive(False)
            self.filtered_data = self.data.query(
                'STATEorUT == @self.combobox_state.get_active_text() and DISTRICT == @self.combobox_district.get_active_text() and YEAR == @intyear'
            ).filter(items=['STATEorUT', 'DISTRICT', 'YEAR', crime])

        return

    def on_changed_crime(self, widget):
        if (self.combobox_year.get_active_text() != 'All'):
            intyear = int(self.combobox_year.get_active_text())

        # Check crime field
        if " " not in self.combobox_crime.get_active_text():
            crime = self.combobox_crime.get_active_text()
        else:
            crime = ".".join(self.combobox_crime.get_active_text().split(" "))

        if (self.combobox_district.get_active_text() == 'All'
                and self.combobox_year.get_active_text() == 'All'):
            self.filtered_data = self.data.query(
                'STATEorUT == @self.combobox_state.get_active_text()').filter(
                    items=['STATEorUT', 'DISTRICT', 'YEAR', crime])
        elif (self.combobox_district.get_active_text() == 'All'):
            self.filtered_data = self.data.query(
                'STATEorUT == @self.combobox_state.get_active_text() and YEAR == @intyear'
            ).filter(items=['STATEorUT', 'DISTRICT', 'YEAR', crime])
        elif (self.combobox_year.get_active_text() == "All"):
            self.filtered_data = self.data.query(
                'STATEorUT == @self.combobox_state.get_active_text() and DISTRICT == @self.combobox_district.get_active_text()'
            ).filter(items=['STATEorUT', 'DISTRICT', 'YEAR', crime])
        else:
            self.filtered_data = self.data.query(
                'STATEorUT == @self.combobox_state.get_active_text() and DISTRICT == @self.combobox_district.get_active_text() and YEAR == @intyear'
            ).filter(items=['STATEorUT', 'DISTRICT', 'YEAR', crime])
        return

    def compare_states(self, widget):
        crimes = [
            "MURDER", "RAPE", "KIDNAPPING.ABDUCTION", "RIOTS", "ROBBERY",
            "BURGLARY", "DOWRY.DEATHS"
        ]
        intyear = int(self.combobox_yearc.get_active_text())
        state1_data = self.data.query(
            'STATEorUT == @self.combobox_state1.get_active_text() and YEAR == @intyear'
        ).filter(items=[
            'STATEorUT', 'DISTRICT', 'YEAR', crimes[0], crimes[1], crimes[2],
            crimes[3], crimes[4], crimes[5], crimes[6]
        ])[self.data.DISTRICT == 'TOTAL']
        state2_data = self.data.query(
            'STATEorUT == @self.combobox_state2.get_active_text() and YEAR == @intyear'
        ).filter(items=[
            'STATEorUT', 'DISTRICT', 'YEAR', crimes[0], crimes[1], crimes[2],
            crimes[3], crimes[4], crimes[5], crimes[6]
        ])[self.data.DISTRICT == 'TOTAL']
        print(state1_data.iloc[0]['MURDER'])

        state1_total = [
            state1_data.iloc[0][crimes[0]], state1_data.iloc[0][crimes[1]],
            state1_data.iloc[0][crimes[2]], state1_data.iloc[0][crimes[3]],
            state1_data.iloc[0][crimes[4]], state1_data.iloc[0][crimes[5]],
            state1_data.iloc[0][crimes[6]]
        ]
        state2_total = [
            state2_data.iloc[0][crimes[0]], state2_data.iloc[0][crimes[1]],
            state2_data.iloc[0][crimes[2]], state2_data.iloc[0][crimes[3]],
            state2_data.iloc[0][crimes[4]], state2_data.iloc[0][crimes[5]],
            state2_data.iloc[0][crimes[6]]
        ]
        print(state1_total)

        dialog = gtk.Dialog("My dialog", self,
                            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                            (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
        fig = Figure(figsize=(5, 4), dpi=100)
        dialog.set_size_request(1300, 500)
        ax = fig.add_subplot(111)
        ypos = np.arange(len(crimes))
        print(ypos)
        p1 = ax.bar(ypos - 0.4,
                    state1_total,
                    width=0.4,
                    color='r',
                    align='center')
        p2 = ax.bar(ypos, state2_total, width=0.4, color='b', align='center')

        ax.set_title("Comparison of " +
                     self.combobox_state1.get_active_text() + " and " +
                     self.combobox_state2.get_active_text())
        ax.set_xticks(ypos - 0.2)
        ax.set_xticklabels(crimes)
        ax.set_ylabel('Total Crimes')
        ax.legend((p1[0], p2[0]), (self.combobox_state1.get_active_text(),
                                   self.combobox_state2.get_active_text()))

        canvas = FigureCanvas(fig)  # a gtk.DrawingArea
        canvas.set_size_request(800, 600)
        dialog.vbox.pack_start(canvas)
        toolbar = NavigationToolbar(canvas, dialog)
        dialog.vbox.pack_start(toolbar, False, False)
        canvas.show()
        dialog.run()
        dialog.destroy()

        return
Exemplo n.º 4
0
    def create_ui(self):
        self.set_border_width(5)
        app_vbox = gtk.VBox(spacing=5)

        self.module_hbox = gtk.HBox(spacing=5)
        app_vbox.pack_start(self.module_hbox, fill=False, expand=False)

        label = gtk.Label()
        label.set_markup('<b>%s</b>' % _('Choose Module:'))
        self.module_hbox.pack_start(label, fill=False, expand=False)

        self.module_combo = gtk.ComboBox(self.modules_list_model)
        cell = gtk.CellRendererText()
        self.module_combo.pack_start(cell, True)
        self.module_combo.add_attribute(cell, 'text', 0)
        self.module_combo.changed_signal_id = self.module_combo.connect(
            'changed', self.on_module_selection_changed_cb)

        self.module_combo.set_row_separator_func(lambda x, y: x.get(y, 1)[0])
        self.module_hbox.pack_start(self.module_combo, fill=True)

        separator = gtk.VSeparator()
        self.module_hbox.pack_start(separator, fill=False, expand=False)
        preferences = gtk.Button(stock=gtk.STOCK_PREFERENCES)
        preferences.connect('clicked', self.on_preferences_cb)
        self.module_hbox.pack_start(preferences, fill=False, expand=False)

        self.progressbar = gtk.ProgressBar()
        self.progressbar.set_text(_('Build Progress'))
        app_vbox.pack_start(self.progressbar, fill=False, expand=False)

        expander = gtk.Expander(_('Terminal'))
        expander.set_expanded(False)
        app_vbox.pack_start(expander, fill=False, expand=False)
        sclwin = gtk.ScrolledWindow()
        sclwin.set_size_request(-1, 300)
        sclwin.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
        expander.add(sclwin)
        if vte:
            self.terminal = vte.Terminal()
            self.terminal.connect('child-exited', self.on_vte_child_exit_cb)
        else:
            os.environ['TERM'] = 'dumb'  # avoid commands printing vt sequences
            self.terminal = gtk.TextView()
            self.terminal.set_size_request(800, -1)
            textbuffer = self.terminal.get_buffer()
            terminal_bold_tag = textbuffer.create_tag('bold')
            terminal_bold_tag.set_property('weight', pango.WEIGHT_BOLD)
            terminal_mono_tag = textbuffer.create_tag('mono')
            terminal_mono_tag.set_property('family', 'Monospace')
            terminal_stdout_tag = textbuffer.create_tag('stdout')
            terminal_stdout_tag.set_property('family', 'Monospace')
            terminal_stderr_tag = textbuffer.create_tag('stderr')
            terminal_stderr_tag.set_property('family', 'Monospace')
            terminal_stderr_tag.set_property('foreground', 'red')
            terminal_stdin_tag = textbuffer.create_tag('stdin')
            terminal_stdin_tag.set_property('family', 'Monospace')
            terminal_stdin_tag.set_property('style', pango.STYLE_ITALIC)
            self.terminal.set_editable(False)
            self.terminal.set_wrap_mode(gtk.WRAP_CHAR)
        sclwin.add(self.terminal)
        self.terminal_sclwin = sclwin

        self.error_hbox = self.create_error_hbox()
        app_vbox.pack_start(self.error_hbox, fill=False, expand=False)

        buttonbox = gtk.HButtonBox()
        buttonbox.set_layout(gtk.BUTTONBOX_END)
        app_vbox.pack_start(buttonbox, fill=False, expand=False)

        # Translators: This is a button label (to start build)
        self.build_button = gtk.Button(_('Start'))
        self.build_button.connect('clicked', self.on_build_cb)
        buttonbox.add(self.build_button)

        button = gtk.Button(stock=gtk.STOCK_HELP)
        button.connect('clicked', self.on_help_cb)
        buttonbox.add(button)
        buttonbox.set_child_secondary(button, True)

        app_vbox.show_all()
        self.error_hbox.hide()
        self.add(app_vbox)
Exemplo n.º 5
0
    def __init__(self):

        # Before anything, parse command line options if any present...
        opt_parser = optparse.OptionParser()
        opt_parser.add_option("-H",
                              "--start-hidden",
                              action="store_true",
                              default=False,
                              dest="hidden",
                              help="Start iconified in tray")
        opt_parser.add_option(
            "-F",
            "--favorite",
            dest="favorite",
            help="Load the specified favorite and connect to UPS")

        (cmd_opts, args) = opt_parser.parse_args()

        self.__glade_file = os.path.join(os.path.dirname(sys.argv[0]),
                                         "gui-1.3.glade")

        self.__widgets["interface"] = gtk.glade.XML(self.__glade_file,
                                                    "window1", APP)
        self.__widgets["main_window"] = self.__widgets["interface"].get_widget(
            "window1")
        self.__widgets["status_bar"] = self.__widgets["interface"].get_widget(
            "statusbar2")
        self.__widgets["ups_host_entry"] = self.__widgets[
            "interface"].get_widget("entry1")
        self.__widgets["ups_port_entry"] = self.__widgets[
            "interface"].get_widget("spinbutton1")
        self.__widgets["ups_refresh_button"] = self.__widgets[
            "interface"].get_widget("button1")
        self.__widgets["ups_authentication_check"] = self.__widgets[
            "interface"].get_widget("checkbutton1")
        self.__widgets["ups_authentication_frame"] = self.__widgets[
            "interface"].get_widget("hbox1")
        self.__widgets["ups_authentication_login"] = self.__widgets[
            "interface"].get_widget("entry2")
        self.__widgets["ups_authentication_password"] = self.__widgets[
            "interface"].get_widget("entry3")
        self.__widgets["ups_list_combo"] = self.__widgets[
            "interface"].get_widget("combobox1")
        self.__widgets["ups_commands_button"] = self.__widgets[
            "interface"].get_widget("button8")
        self.__widgets["ups_connect"] = self.__widgets["interface"].get_widget(
            "button2")
        self.__widgets["ups_disconnect"] = self.__widgets[
            "interface"].get_widget("button7")
        self.__widgets["ups_params_box"] = self.__widgets[
            "interface"].get_widget("vbox6")
        self.__widgets["ups_infos"] = self.__widgets["interface"].get_widget(
            "notebook1")
        self.__widgets["ups_vars_tree"] = self.__widgets[
            "interface"].get_widget("treeview1")
        self.__widgets["ups_vars_refresh"] = self.__widgets[
            "interface"].get_widget("button9")
        self.__widgets["ups_status_image"] = self.__widgets[
            "interface"].get_widget("image1")
        self.__widgets["ups_status_left"] = self.__widgets[
            "interface"].get_widget("label10")
        self.__widgets["ups_status_right"] = self.__widgets[
            "interface"].get_widget("label11")
        self.__widgets["ups_status_time"] = self.__widgets[
            "interface"].get_widget("label15")
        self.__widgets["menu_favorites_root"] = self.__widgets[
            "interface"].get_widget("menuitem3")
        self.__widgets["menu_favorites"] = self.__widgets[
            "interface"].get_widget("menu2")
        self.__widgets["menu_favorites_add"] = self.__widgets[
            "interface"].get_widget("menuitem4")
        self.__widgets["menu_favorites_del"] = self.__widgets[
            "interface"].get_widget("menuitem5")
        self.__widgets["progress_battery_charge"] = self.__widgets[
            "interface"].get_widget("progressbar1")
        self.__widgets["progress_battery_load"] = self.__widgets[
            "interface"].get_widget("progressbar2")

        # Create the tray icon and connect it to the show/hide method...
        self.__widgets["status_icon"] = gtk.StatusIcon()
        self.__widgets["status_icon"].set_from_file(
            os.path.join(os.path.dirname(sys.argv[0]), "pixmaps",
                         "on_line.png"))
        self.__widgets["status_icon"].set_visible(True)
        self.__widgets["status_icon"].connect("activate", self.tray_activated)

        self.__widgets["ups_status_image"].set_from_file(
            os.path.join(os.path.dirname(sys.argv[0]), "pixmaps",
                         "on_line.png"))

        # Define interface callbacks actions
        self.__callbacks = {
            "on_window1_destroy": self.quit,
            "on_imagemenuitem1_activate": self.gui_about_dialog,
            "on_imagemenuitem5_activate": self.quit,
            "on_entry1_changed": self.__check_gui_fields,
            "on_entry2_changed": self.__check_gui_fields,
            "on_entry3_changed": self.__check_gui_fields,
            "on_checkbutton1_toggled": self.__check_gui_fields,
            "on_spinbutton1_value_changed": self.__check_gui_fields,
            "on_button1_clicked": self.__update_ups_list,
            "on_button2_clicked": self.connect_to_ups,
            "on_button7_clicked": self.disconnect_from_ups,
            "on_button9_clicked": self.__gui_update_ups_vars_view,
            "on_menuitem4_activate": self.__gui_add_favorite,
            "on_menuitem5_activate": self.__gui_delete_favorite,
            "on_treeview1_button_press_event": self.__gui_ups_vars_selected
        }

        # Connect the callbacks
        self.__widgets["interface"].signal_autoconnect(self.__callbacks)

        # Remove the dummy combobox entry on UPS List and Commands
        self.__widgets["ups_list_combo"].remove_text(0)

        # Set UPS vars treeview properties -----------------------------
        store = gtk.ListStore(gtk.gdk.Pixbuf, gobject.TYPE_STRING,
                              gobject.TYPE_STRING)
        self.__widgets["ups_vars_tree"].set_model(store)
        self.__widgets["ups_vars_tree"].set_headers_visible(True)

        # Column 0
        cr = gtk.CellRendererPixbuf()
        column = gtk.TreeViewColumn('', cr)
        column.add_attribute(cr, 'pixbuf', 0)
        self.__widgets["ups_vars_tree"].append_column(column)

        # Column 1
        cr = gtk.CellRendererText()
        cr.set_property('editable', False)
        column = gtk.TreeViewColumn(_('Var name'), cr)
        column.set_sort_column_id(1)
        column.add_attribute(cr, 'text', 1)
        self.__widgets["ups_vars_tree"].append_column(column)

        # Column 2
        cr = gtk.CellRendererText()
        cr.set_property('editable', False)
        column = gtk.TreeViewColumn(_('Value'), cr)
        column.add_attribute(cr, 'text', 2)
        self.__widgets["ups_vars_tree"].append_column(column)

        self.__widgets["ups_vars_tree"].get_model().set_sort_column_id(
            1, gtk.SORT_ASCENDING)
        self.__widgets["ups_vars_tree_store"] = store

        self.__widgets["ups_vars_tree"].set_size_request(-1, 50)
        #---------------------------------------------------------------

        # UPS Commands combo box creation ------------------------------
        container = self.__widgets["ups_commands_button"].get_parent()
        self.__widgets["ups_commands_button"].destroy()
        self.__widgets["ups_commands_combo"] = gtk.ComboBox()

        list_store = gtk.ListStore(gobject.TYPE_STRING)

        self.__widgets["ups_commands_combo"].set_model(list_store)
        cell_renderer = gtk.CellRendererText()
        cell_renderer.set_property("xalign", 0)
        self.__widgets["ups_commands_combo"].pack_start(cell_renderer, True)
        self.__widgets["ups_commands_combo"].add_attribute(
            cell_renderer, "markup", 0)

        container.pack_start(self.__widgets["ups_commands_combo"], True)
        self.__widgets["ups_commands_combo"].set_active(0)
        self.__widgets["ups_commands_combo"].show_all()

        self.__widgets["ups_commands_button"] = gtk.Button(
            stock=gtk.STOCK_EXECUTE)
        container.pack_start(self.__widgets["ups_commands_button"], True)
        self.__widgets["ups_commands_button"].show()
        self.__widgets["ups_commands_button"].connect(
            "clicked", self.__gui_send_ups_command)

        self.__widgets["ups_commands_combo_store"] = list_store
        #---------------------------------------------------------------

        if (cmd_opts.hidden != True):
            self.__widgets["main_window"].show()

        # Define favorites path and load favorites
        if (platform.system() == "Linux"):
            self.__favorites_path = os.path.join(os.environ.get("HOME"),
                                                 ".nut-monitor")
        elif (platform.system() == "Windows"):
            self.__favorites_path = os.path.join(os.environ.get("USERPROFILE"),
                                                 "Application Data",
                                                 "NUT-Monitor")

        self.__favorites_file = os.path.join(self.__favorites_path,
                                             "favorites.ini")
        self.__parse_favorites()

        self.gui_status_message(_("Welcome to NUT Monitor"))

        if (cmd_opts.favorite != None):
            if (self.__favorites.has_key(cmd_opts.favorite)):
                self.__gui_load_favorite(fav_name=cmd_opts.favorite)
                self.connect_to_ups()
        else:
            # Try to scan localhost for available ups and connect to it if there is only one
            self.__widgets["ups_host_entry"].set_text("localhost")
            self.__update_ups_list()
            if (len(self.__widgets["ups_list_combo"].get_model()) == 1):
                self.connect_to_ups()
Exemplo n.º 6
0
    def __init__(self, parent, profile_store, profiles, callback):
        self.profiles = profiles
        self.current_database = None
        self.old_profile, self.current_profile = None, None
        self.db_cache = None
        self.updating_db = False

        # GTK Stuffs
        self.parent = parent
        self.dialog = gtk.Dialog(title=_(u'Profile Editor'), parent=parent,
            flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
        self.ok_button = self.dialog.add_button(gtk.STOCK_OK,
            gtk.RESPONSE_ACCEPT)
        self.dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        self.dialog.set_icon(TRYTON_ICON)

        hpaned = gtk.HPaned()
        vbox_profiles = gtk.VBox(homogeneous=False, spacing=6)
        self.cell = gtk.CellRendererText()
        self.cell.set_property('editable', True)
        self.cell.connect('editing-started', self.edit_started)
        self.profile_tree = gtk.TreeView()
        self.profile_tree.set_model(profile_store)
        self.profile_tree.insert_column_with_attributes(-1, _(u'Profile'),
            self.cell, text=0)
        self.profile_tree.connect('cursor-changed', self.profile_selected)
        scroll = gtk.ScrolledWindow()
        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scroll.add(self.profile_tree)
        self.add_button = gtk.Button(_(u'_Add'), use_underline=True)
        self.add_button.connect('clicked', self.profile_create)
        add_image = gtk.Image()
        add_image.set_from_stock('gtk-add', gtk.ICON_SIZE_BUTTON)
        self.add_button.set_image(add_image)
        self.remove_button = gtk.Button(_(u'_Remove'), use_underline=True)
        self.remove_button.connect('clicked', self.profile_delete)
        remove_image = gtk.Image()
        remove_image.set_from_stock('gtk-remove', gtk.ICON_SIZE_BUTTON)
        self.remove_button.set_image(remove_image)
        vbox_profiles.pack_start(scroll, expand=True, fill=True)
        vbox_profiles.pack_start(self.add_button, expand=False, fill=True)
        vbox_profiles.pack_start(self.remove_button, expand=False, fill=True)
        hpaned.add1(vbox_profiles)

        table = gtk.Table(4, 2, homogeneous=False)
        table.set_row_spacings(3)
        table.set_col_spacings(3)
        host = gtk.Label(_(u'Host:'))
        host.set_alignment(1, 0.5)
        host.set_padding(3, 3)
        self.host_entry = gtk.Entry()
        self.host_entry.connect('focus-out-event', self.display_dbwidget)
        self.host_entry.connect('changed', self.update_profiles, 'host')
        self.host_entry.set_activates_default(True)
        host.set_mnemonic_widget(self.host_entry)
        table.attach(host, 0, 1, 1, 2, yoptions=False, xoptions=gtk.FILL)
        table.attach(self.host_entry, 1, 2, 1, 2, yoptions=False)
        database = gtk.Label(_(u'Database:'))
        database.set_alignment(1, 0.5)
        database.set_padding(3, 3)
        self.database_entry = gtk.Entry()
        self.database_entry.connect('changed', self.dbentry_changed)
        self.database_entry.connect('changed', self.update_profiles,
            'database')
        self.database_entry.set_activates_default(True)
        self.database_label = gtk.Label()
        self.database_label.set_use_markup(True)
        self.database_label.set_alignment(0, 0.5)
        self.database_combo = gtk.ComboBox()
        dbstore = gtk.ListStore(gobject.TYPE_STRING)
        cell = gtk.CellRendererText()
        self.database_combo.pack_start(cell, True)
        self.database_combo.add_attribute(cell, 'text', 0)
        self.database_combo.set_model(dbstore)
        self.database_combo.connect('changed', self.dbcombo_changed)
        self.database_progressbar = gtk.ProgressBar()
        self.database_progressbar.set_text(_(u'Fetching databases list'))
        image = gtk.Image()
        image.set_from_stock('tryton-new', gtk.ICON_SIZE_BUTTON)
        db_box = gtk.VBox(homogeneous=True)
        db_box.pack_start(self.database_entry)
        db_box.pack_start(self.database_combo)
        db_box.pack_start(self.database_label)
        db_box.pack_start(self.database_progressbar)
        # Compute size_request of box in order to prevent "form jumping"
        width, height = 0, 0
        for child in db_box.get_children():
            cwidth, cheight = child.size_request()
            width, height = max(width, cwidth), max(height, cheight)
        db_box.set_size_request(width, height)
        table.attach(database, 0, 1, 2, 3, yoptions=False, xoptions=gtk.FILL)
        table.attach(db_box, 1, 2, 2, 3, yoptions=False)
        username = gtk.Label(_(u'Username:'******'changed', self.update_profiles,
            'username')
        username.set_mnemonic_widget(self.username_entry)
        self.username_entry.set_activates_default(True)
        table.attach(username, 0, 1, 3, 4, yoptions=False, xoptions=gtk.FILL)
        table.attach(self.username_entry, 1, 2, 3, 4, yoptions=False)
        hpaned.add2(table)
        hpaned.set_position(250)

        self.dialog.vbox.pack_start(hpaned)
        self.dialog.set_default_size(640, 350)
        self.dialog.set_default_response(gtk.RESPONSE_ACCEPT)

        self.dialog.connect('close', lambda *a: False)
        self.dialog.connect('response', self.response)
        self.callback = callback
Exemplo n.º 7
0
    def __init__(self, parent, application):
        SettingsPage.__init__(self, parent, application, 'view_and_edit',
                              _('View & Edit'))

        # viewer options
        frame_view = gtk.Frame(_('View'))

        label_not_implemented = gtk.Label(
            'This option is not implemented yet.')
        label_not_implemented.set_sensitive(False)

        # editor options
        frame_edit = gtk.Frame(_('Edit'))

        vbox_edit = gtk.VBox(False, 0)
        vbox_edit.set_border_width(5)

        # installed application
        self._radio_application = gtk.RadioButton(
            label=_('Use installed application'))
        self._radio_application.connect('toggled', self._parent.enable_save)

        align_application = gtk.Alignment(xscale=1)
        align_application.set_padding(0, 10, 15, 15)
        vbox_application = gtk.VBox(False, 0)
        vbox_application.set_border_width(5)

        self._store = gtk.ListStore(str, str, str)
        self._combobox_application = gtk.ComboBox(model=self._store)
        self._combobox_application.connect('changed', self._parent.enable_save)

        cell_icon = gtk.CellRendererPixbuf()
        cell_name = gtk.CellRendererText()

        self._combobox_application.pack_start(cell_icon, False)
        self._combobox_application.pack_start(cell_name, True)

        self._combobox_application.add_attribute(cell_icon, 'icon-name',
                                                 Column.ICON)
        self._combobox_application.add_attribute(cell_name, 'text',
                                                 Column.NAME)

        # external options
        self._radio_external = gtk.RadioButton(group=self._radio_application,
                                               label=_('Use external command'))
        self._radio_external.connect('toggled', self._parent.enable_save)

        align_external = gtk.Alignment(xscale=1)
        align_external.set_padding(0, 10, 15, 15)
        vbox_external = gtk.VBox(False, 0)
        vbox_external.set_border_width(5)

        label_editor = gtk.Label(_('Command line:'))
        label_editor.set_alignment(0, 0.5)
        label_editor.set_use_markup(True)
        self._entry_editor = gtk.Entry()
        self._entry_editor.connect('changed', self._parent.enable_save)

        self._checkbox_terminal_command = gtk.CheckButton(
            _('Execute command in terminal tab'))
        self._checkbox_terminal_command.connect('toggled',
                                                self._parent.enable_save)

        # pack ui
        vbox_application.pack_start(self._combobox_application, False, False,
                                    0)
        align_application.add(vbox_application)

        vbox_external.pack_start(label_editor, False, False, 0)
        vbox_external.pack_start(self._entry_editor, False, False, 0)
        vbox_external.pack_start(self._checkbox_terminal_command, False, False,
                                 0)
        align_external.add(vbox_external)

        vbox_edit.pack_start(self._radio_application, False, False, 0)
        vbox_edit.pack_start(align_application, False, False, 0)
        vbox_edit.pack_start(self._radio_external, False, False, 0)
        vbox_edit.pack_start(align_external, False, False, 0)

        frame_view.add(label_not_implemented)
        frame_edit.add(vbox_edit)

        self.pack_start(frame_view, False, False, 0)
        self.pack_start(frame_edit, False, False, 0)
Exemplo n.º 8
0
    def __init__(self, parent, application):
        SettingsPage.__init__(self, parent, application, 'terminal',
                              _('Terminal'))

        # create vte terminal options
        align_vte = gtk.Alignment(xscale=1)
        align_vte.set_padding(0, 10, 15, 15)
        self._vbox_vte = gtk.VBox(False, 0)

        self._radio_vte = gtk.RadioButton(label=_('VTE based terminal'))
        self._radio_vte.connect('toggled', self._parent.enable_save)

        # option for showing scrollbars
        self._checkbox_scrollbars_visible = gtk.CheckButton(
            _('Show scrollbars when needed'))
        self._checkbox_scrollbars_visible.connect('toggled',
                                                  self._parent.enable_save)

        # option for custom font
        self._align_font = gtk.Alignment()
        self._align_font.set_padding(0, 0, 15, 15)
        hbox_font = gtk.HBox(False, 5)

        self._checkbox_system_font = gtk.CheckButton(
            _('Use the system fixed width font'))
        self._checkbox_system_font.connect('toggled',
                                           self.__toggled_system_font)

        label_font = gtk.Label(_('Font:'))
        label_font.set_alignment(0, 0.5)

        self._button_font = gtk.FontButton()
        self._button_font.connect('font-set', self._parent.enable_save)

        # option for cursor shape
        hbox_cursor_shape = gtk.HBox(False, 5)

        label_cursor_shape = gtk.Label(_('Cursor shape:'))
        label_cursor_shape.set_alignment(0, 0.5)

        list_cursor_shape = gtk.ListStore(str, int)
        list_cursor_shape.append((_('Block'), CursorShape.BLOCK))
        list_cursor_shape.append((_('I-Beam'), CursorShape.IBEAM))
        list_cursor_shape.append((_('Underline'), CursorShape.UNDERLINE))

        cell_cursor_shape = gtk.CellRendererText()

        self._combobox_cursor_shape = gtk.ComboBox(list_cursor_shape)
        self._combobox_cursor_shape.connect('changed',
                                            self._parent.enable_save)
        self._combobox_cursor_shape.pack_start(cell_cursor_shape)
        self._combobox_cursor_shape.add_attribute(cell_cursor_shape, 'text', 0)

        # option for allowing bold text in terminal
        self._checkbox_allow_bold = gtk.CheckButton(_('Allow bold text'))
        self._checkbox_allow_bold.connect('toggled', self._parent.enable_save)

        # option for automatically hiding mouse when typing
        self._checkbox_autohide_mouse = gtk.CheckButton(
            _('Automatically hide mouse when typing'))
        self._checkbox_autohide_mouse.connect('toggled',
                                              self._parent.enable_save)

        # create external terminal options
        align_external = gtk.Alignment(xscale=1)
        align_external.set_padding(0, 0, 15, 15)
        self._vbox_external = gtk.VBox(False, 5)

        self._radio_external = gtk.RadioButton(group=self._radio_vte,
                                               label=_('External terminal'))

        vbox_command = gtk.VBox(False, 0)
        label_command = gtk.Label(_('Command line:'))
        label_command.set_alignment(0, 0.5)
        self._entry_command = gtk.Entry()
        self._entry_command.connect('changed', self._parent.enable_save)

        vbox_command2 = gtk.VBox(False, 0)
        label_command2 = gtk.Label(
            _('Command line for executing specific program:'))
        label_command2.set_alignment(0, 0.5)
        self._entry_command2 = gtk.Entry()
        self._entry_command2.connect('changed', self._parent.enable_save)

        label_note = gtk.Label(
            _('<small><i>Note:'
              '\n\tOmitting {0} will open new terminal application instead of tab.'
              '\n\t{0} will be replaced with socket/window id.'
              '\n\t{1} will be replaced with specified command and its parameters.'
              '\n\t{2} will be replaced with current working directory.'
              '</i></small>'))
        label_note.set_alignment(0, 0)
        label_note.set_use_markup(True)

        # pack interface
        hbox_font.pack_start(label_font, False, False, 0)
        hbox_font.pack_start(self._button_font, True, True, 0)

        self._align_font.add(hbox_font)

        hbox_cursor_shape.pack_start(label_cursor_shape, False, False, 0)
        hbox_cursor_shape.pack_start(self._combobox_cursor_shape, False, False,
                                     0)

        vbox_command.pack_start(label_command, False, False, 0)
        vbox_command.pack_start(self._entry_command, False, False, 0)
        vbox_command2.pack_start(label_command2, False, False, 0)
        vbox_command2.pack_start(self._entry_command2, False, False, 0)

        self._vbox_vte.pack_start(self._checkbox_scrollbars_visible, False,
                                  False, 0)
        self._vbox_vte.pack_start(self._checkbox_system_font, False, False, 0)
        self._vbox_vte.pack_start(self._align_font, False, False, 0)
        self._vbox_vte.pack_start(hbox_cursor_shape, False, False, 5)
        self._vbox_vte.pack_start(self._checkbox_allow_bold, False, False, 0)
        self._vbox_vte.pack_start(self._checkbox_autohide_mouse, False, False,
                                  0)

        self._vbox_external.pack_start(vbox_command, False, False, 0)
        self._vbox_external.pack_start(vbox_command2, False, False, 0)
        self._vbox_external.pack_start(label_note, False, False, 0)

        align_vte.add(self._vbox_vte)
        align_external.add(self._vbox_external)

        self.pack_start(self._radio_vte, False, False, 0)
        self.pack_start(align_vte, False, False, 0)
        self.pack_start(self._radio_external, False, False, 0)
        self.pack_start(align_external, False, False, 0)
Exemplo n.º 9
0
    def Populate(self):
        """
		Creates all the widgets for intruments and devices that compose the
		InstrumentConnectionsDialog and then adds them to the dialog.
		"""

        self.devices_list = []
        liststore = gtk.ListStore(gobject.TYPE_STRING)

        #Find out how many channels a device offers
        for device, deviceName in AudioBackend.ListCaptureDevices():
            #Don't want the default device twice (once as 'default' and once as its actual hw ref)
            # Default will always be the first one, and have no name.
            if not self.devices_list and not deviceName:
                if device == "default":
                    display = _("Default")
                else:
                    display = _("Default (%s)") % device
                self.devices_list.append((device, display, -1))
                liststore.append((display, ))
            else:
                num_channels = AudioBackend.GetChannelsOffered(device)
                for input in xrange(num_channels):
                    if num_channels > 1:
                        s = _("%(device)s (%(id)s), input %(input)d")
                        display = s % {
                            "device": deviceName,
                            "id": device,
                            "input": input
                        }
                    else:
                        display = _("%(device)s (%(id)s)") % {
                            "device": deviceName,
                            "id": device
                        }
                    self.devices_list.append((device, deviceName, input))
                    liststore.append((display, ))

        if self.devices_list:
            for instr in self.project.instruments:
                instrument = instr
                row = gtk.HBox()
                row.set_spacing(10)
                image = gtk.Image()
                image.set_from_pixbuf(instrument.pixbuf)
                label = gtk.Label(instrument.name)

                combobox = gtk.ComboBox(liststore)
                cell = gtk.CellRendererText()
                combobox.pack_start(cell, True)
                combobox.add_attribute(cell, 'text', 0)

                if instr.input is None:
                    # None means default; default is first in combobox
                    combobox.set_active(0)
                else:
                    currentItem = 0
                    for device, deviceName, input in self.devices_list:
                        if instr.input == device and input == instr.inTrack:
                            combobox.set_active(currentItem)
                        currentItem += 1

                combobox.connect("changed", self.OnSelected, instr)
                row.pack_start(combobox, True, True)
                row.pack_start(image, False, False)
                row.pack_start(label, False, False)

                self.vbox.add(row)
        else:
            audiosrc = Globals.settings.recording["audiosrc"]
            sound_system = None
            for name, element in Globals.CAPTURE_BACKENDS:
                if element == audiosrc:
                    sound_system = name

            if sound_system:
                msg = _(
                    "The %(sound-system-name)s sound system does not support device selection."
                )
                msg %= {"sound-system-name": sound_system}
            else:
                msg = _(
                    'The "%(custom-pipeline)s" sound system does not support device selection.'
                )
                msg %= {"custom-pipeline": audiosrc}
            self.gtk_builder.get_object("explainLabel").set_text(msg)
            self.vbox.hide()
Exemplo n.º 10
0
    def __init__(self):

        self.saved_views = {}

        self.gtk = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.gtk.set_title('Demo of a Mockup of OOF3D Interface')
        self.gtk.set_default_size(initial_width, initial_height)
        self.gtk.connect("destroy", self.destroy)
        self.gtk.connect("delete_event", self.destroy)

        self.cubeActor = None

        # set up areas
        self.panes = gtk.HPaned()
        self.gtk.add(self.panes)

        self.canvas = Canvas3D(self)
        self.panes.add2(self.canvas)

        
        self.toolboxframe = gtk.Frame()
        self.toolboxframe.set_shadow_type(gtk.SHADOW_IN)
        self.panes.add1(self.toolboxframe)

        self.scroll = gtk.ScrolledWindow()
        self.scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.toolboxframe.add(self.scroll)

        self.mainbox = gtk.VBox()
        self.scroll.add_with_viewport(self.mainbox)

        # viewer widgets
        viewerframe = gtk.Frame("Viewer Widgets")
        viewerframe.set_shadow_type(gtk.SHADOW_IN)
        self.mainbox.pack_start(viewerframe)
        viewerbox = gtk.VBox()
        viewerframe.add(viewerbox)

        self.tooltips = gtk.Tooltips()

        # camera position
        infoframe = gtk.Frame("Camera Info")
        infoframe.set_shadow_type(gtk.SHADOW_IN)
        viewerbox.pack_start(infoframe, fill=0, expand=0)
        infobox = gtk.VBox()
        infoframe.add(infobox)
        positionlabel = gtk.Label("Camera Position:")
        #self.tooltips.set_tip(positionlabel, "The position of the camera in world coordinates (pixel units)")
        infobox.pack_start(positionlabel,fill=0, expand=0)
        positiontable = gtk.Table(columns=3, rows=1)
        infobox.pack_start(positiontable,fill=0, expand=0)
        self.camera_x = gtk.Entry()
        self.camera_x.set_size_request(90,-1)
        self.camera_x.set_editable(0)
        positiontable.attach(self.camera_x,0,1,0,1)
        self.camera_y = gtk.Entry()
        self.camera_y.set_size_request(90,-1)
        self.camera_y.set_editable(0)
        positiontable.attach(self.camera_y,1,2,0,1)
        self.camera_z = gtk.Entry()
        self.camera_z.set_size_request(90,-1)
        self.camera_z.set_editable(0)
        positiontable.attach(self.camera_z,2,3,0,1)
        focalpointlabel = gtk.Label("Focal Point:")
        #self.tooltips.set_tip(focalpointlabel, "The position of the focal point in world coordinates (pixel units)")
        infobox.pack_start(focalpointlabel,fill=0, expand=0)
        focalpointtable = gtk.Table(columns=3, rows=1)
        infobox.pack_start(focalpointtable,fill=0, expand=0)
        self.fp_x = gtk.Entry()
        self.fp_x.set_size_request(90,-1)
        self.fp_x.set_editable(0)
        focalpointtable.attach(self.fp_x,0,1,0,1)
        self.fp_y = gtk.Entry()
        self.fp_y.set_size_request(90,-1)
        self.fp_y.set_editable(0)
        focalpointtable.attach(self.fp_y,1,2,0,1)
        self.fp_z = gtk.Entry()
        self.fp_z.set_size_request(90,-1)
        self.fp_z.set_editable(0)
        focalpointtable.attach(self.fp_z,2,3,0,1)
        viewuplabel = gtk.Label("View Up Vector:")
        #self.tooltips.set_tip(viewuplabel, "The vector that points up in the viewport")
        infobox.pack_start(viewuplabel,fill=0, expand=0)
        viewuptable = gtk.Table(columns=3, rows=1)
        infobox.pack_start(viewuptable,fill=0, expand=0)
        self.viewup_x = gtk.Entry()
        self.viewup_x.set_size_request(90,-1)
        self.viewup_x.set_editable(0)
        viewuptable.attach(self.viewup_x,0,1,0,1)
        self.viewup_y = gtk.Entry()
        self.viewup_y.set_size_request(90,-1)
        self.viewup_y.set_editable(0)
        viewuptable.attach(self.viewup_y,1,2,0,1)
        self.viewup_z = gtk.Entry()
        self.viewup_z.set_size_request(90,-1)
        self.viewup_z.set_editable(0)
        viewuptable.attach(self.viewup_z,2,3,0,1)
        distancetable = gtk.Table(columns=2, rows=1)
        infobox.pack_start(distancetable,fill=0, expand=0)
        distancelabel = gtk.Label("Distance:")
        #self.tooltips.set_tip(distancelabel, "The distance from the camera to the focal point")
        distancetable.attach(distancelabel,0,1,0,1)
        self.distance = gtk.Entry()
        self.distance.set_size_request(90,-1)
        self.distance.set_editable(0)
        distancetable.attach(self.distance,1,2,0,1)
        angletable = gtk.Table(columns=2, rows=1)
        infobox.pack_start(angletable,fill=0, expand=0)
        anglelabel = gtk.Label("View Angle:")
        #self.tooltips.set_tip(anglelabel, "The angle between the vectors from the camera to the focal point and from the camera to the top of the microstructure")
        angletable.attach(anglelabel,0,1,0,1)
        self.viewangle = gtk.Entry()
        self.viewangle.set_size_request(90,-1)
        self.viewangle.set_editable(0)
        angletable.attach(self.viewangle,1,2,0,1)
        printinfo = gtk.Button("Print Camera Info")
        gtklogger.connect(printinfo, 'clicked', self.printcam)
        self.tooltips.set_tip(printinfo, "Print the camera information in the console")
        infobox.pack_start(printinfo,fill=0, expand=0)

        # zoom - as in changing the viewing angle
        zoomframe = gtk.Frame("Zoom")
        zoomframe.set_shadow_type(gtk.SHADOW_IN)
        viewerbox.pack_start(zoomframe, fill=0, expand=0)
        zoombox = gtk.VBox()
        zoomframe.add(zoombox)
        buttonrow = gtk.HBox(homogeneous=1, spacing=2)
        zoombox.pack_start(buttonrow, expand=0, fill=1, padding=2)
        zinbutton = gtk.Button('Zoom In')
        self.tooltips.set_tip(zinbutton,"Decrease view angle to by given factor")
        buttonrow.pack_start(zinbutton, expand=0, fill=1)
        gtklogger.connect(zinbutton, 'clicked', self.zoomin)
        zoutbutton = gtk.Button('Zoom Out')
        self.tooltips.set_tip(zoutbutton, "Increase view angle by given factor")
        buttonrow.pack_start(zoutbutton, expand=0, fill=1)
        gtklogger.connect(zoutbutton, 'clicked', self.zoomout)
        zfillbutton = gtk.Button('Fill')
        self.tooltips.set_tip(zfillbutton, "Set view angle such that microstructure approximately fills viewport")
        buttonrow.pack_start(zfillbutton, expand=0, fill=1)
        gtklogger.connect(zfillbutton, 'clicked', self.zoomfill)
        factorrow = gtk.HBox()
        zoombox.pack_start(factorrow, expand=0, fill=0, padding=2)
        factorrow.pack_start(gtk.Label("Factor: "), expand=0, fill=0)
        self.zoomfactor = gtk.Entry()
        self.zoomfactor.set_editable(1)
        self.zoomfactor.set_size_request(80, -1)
        self.zoomfactor.set_text("1.5")
        self.tooltips.set_tip(self.zoomfactor, "Factor by which to shrink or magnify image")
        factorrow.pack_start(self.zoomfactor, expand=1, fill=1)        


        # Translation

        # dolly
        transframe = gtk.Frame("Translation")
        transframe.set_shadow_type(gtk.SHADOW_IN)
        viewerbox.pack_start(transframe, fill=0, expand=0)
        transbox = gtk.VBox()
        transframe.add(transbox)
        dollyrow = gtk.HBox(homogeneous=1, spacing=2)
        transbox.pack_start(dollyrow, expand=0, fill=1, padding=2)
        inbutton = gtk.Button('Dolly In')
        self.tooltips.set_tip(inbutton,"Translate camera towards focal point by given factor")
        dollyrow.pack_start(inbutton, expand=0, fill=1)
        gtklogger.connect(inbutton, 'clicked', self.dollyin)
        outbutton = gtk.Button('Dolly Out')
        self.tooltips.set_tip(outbutton, "Translate camera away from focal point by given factor")
        dollyrow.pack_start(outbutton, expand=0, fill=1)
        gtklogger.connect(outbutton, 'clicked', self.dollyout)
        fillbutton = gtk.Button('Fill')
        self.tooltips.set_tip(fillbutton, "Set camera position such that microstructure approximately fills viewport")
        dollyrow.pack_start(fillbutton, expand=0, fill=1)
        gtklogger.connect(fillbutton, 'clicked', self.dollyfill)
        factorrow = gtk.HBox()
        transbox.pack_start(factorrow, expand=0, fill=0, padding=2)
        factorrow.pack_start(gtk.Label("Factor: "), expand=0, fill=0)
        self.dollyfactor = gtk.Entry()
        self.dollyfactor.set_editable(1)
        self.dollyfactor.set_size_request(80, -1)
        self.dollyfactor.set_text("1.5")
        self.tooltips.set_tip(self.dollyfactor, "Factor by which to multiply distance from camera to focal point")
        factorrow.pack_start(self.dollyfactor, expand=1, fill=1)

        # track
        trackrow = gtk.HBox(homogeneous=1, spacing=2)
        transbox.pack_start(trackrow, expand=0, fill=1, padding=2)
        horizbutton = gtk.Button('Horizontal')
        self.tooltips.set_tip(horizbutton,"Shift camera and focal point horizontally")
        trackrow.pack_start(horizbutton, expand=0, fill=1)
        gtklogger.connect(horizbutton, 'clicked', self.trackh)
        vertbutton = gtk.Button('Vertical')
        self.tooltips.set_tip(vertbutton, "Shift camera and focal point vertically")
        trackrow.pack_start(vertbutton, expand=0, fill=1)
        gtklogger.connect(vertbutton, 'clicked', self.trackv)
        recenterbutton = gtk.Button('Recenter')
        self.tooltips.set_tip(recenterbutton, "Recenter the microstructure in the viewport")
        trackrow.pack_start(recenterbutton, expand=0, fill=1)
        gtklogger.connect(recenterbutton, 'clicked', self.recenter)        
        distrow = gtk.HBox()
        transbox.pack_start(distrow, expand=0, fill=0, padding=2)
        distrow.pack_start(gtk.Label("Distance: "), expand=0, fill=0)
        self.trackdist = gtk.Entry()
        self.trackdist.set_editable(1)
        self.trackdist.set_size_request(80, -1)
        self.trackdist.set_text("10.0")
        self.tooltips.set_tip(self.trackdist, "Distance by which to track camera in units of pixels")
        distrow.pack_start(self.trackdist, expand=1, fill=1)
        label = gtk.Label("Dolly: Right Mouse Button\nTrack: Middle Mouse Button")
        transbox.pack_start(label)

        #rotate
        rotateframe = gtk.Frame("Rotation")
        rotateframe.set_shadow_type(gtk.SHADOW_IN)
        viewerbox.pack_start(rotateframe, fill=0, expand=0)
        rotatebox = gtk.VBox()
        rotateframe.add(rotatebox)
        rotobjrow = gtk.HBox(homogeneous=1, spacing=2)
        rotatebox.pack_start(rotobjrow, expand=0, fill=1, padding=2)
        rollbutton = gtk.Button('Roll')
        self.tooltips.set_tip(rollbutton,"Rotate about direction of projection")
        rotobjrow.pack_start(rollbutton, expand=0, fill=1)
        gtklogger.connect(rollbutton, 'clicked', self.roll)
        azbutton = gtk.Button('Azimuth')
        self.tooltips.set_tip(azbutton, "Rotate about view up vector centered at focal point")
        rotobjrow.pack_start(azbutton, expand=0, fill=1)
        gtklogger.connect(azbutton, 'clicked', self.azimuth)
        elbutton = gtk.Button('Elevation')
        self.tooltips.set_tip(elbutton, "Rotate about cross product of direction of projection and view up vector centered at focal point")
        rotobjrow.pack_start(elbutton, expand=0, fill=1)
        gtklogger.connect(elbutton, 'clicked', self.elevation)
        rotcamrow = gtk.HBox(homogeneous=1, spacing=2)
        rotatebox.pack_start(rotcamrow, expand=0, fill=1, padding=2)
        yawbutton = gtk.Button('Yaw')
        self.tooltips.set_tip(yawbutton,"Rotate about view up vector centered at camera position")
        rotcamrow.pack_start(yawbutton, expand=0, fill=1)
        gtklogger.connect(yawbutton, 'clicked', self.yaw)
        pitchbutton = gtk.Button('Pitch')
        self.tooltips.set_tip(pitchbutton,"Rotate about cross product of direction of projection and view up vector centered at camera position")
        rotcamrow.pack_start(pitchbutton, expand=0, fill=1)
        gtklogger.connect(pitchbutton, 'clicked', self.pitch)
        anglerow = gtk.HBox()
        rotatebox.pack_start(anglerow, expand=0, fill=0, padding=2)
        anglerow.pack_start(gtk.Label("Angle: "), expand=0, fill=0)
        self.angle = gtk.Entry()
        self.angle.set_editable(1)
        self.angle.set_size_request(80, -1)
        self.angle.set_text("10.0")
        self.tooltips.set_tip(self.angle,"Angle in degrees by which to rotate by")
        anglerow.pack_start(self.angle, expand=1, fill=1)


        #clipping planes
        clippingframe = gtk.Frame("Clipping Range")
        clippingframe.set_shadow_type(gtk.SHADOW_IN)
        viewerbox.pack_start(clippingframe, fill=0, expand=0)
        clippingbox = gtk.VBox()
        clippingframe.add(clippingbox)
        self.clippingadj = gtk.Adjustment(value=100, lower=0, upper=100, step_incr=-1, page_incr=-5, page_size=0)
        gtklogger.connect(self.clippingadj, 'value_changed', self.setclipping)
        clippingscale = gtk.HScale(self.clippingadj)
        clippingscale.set_update_policy(gtk.UPDATE_DELAYED)
        self.tooltips.set_tip(clippingscale,"Adjust the near clipping plane to view cross section")
        clippingbox.pack_start(clippingscale)

        #opacity
        opacityframe = gtk.Frame("Opacity")
        opacityframe.set_shadow_type(gtk.SHADOW_IN)
        viewerbox.pack_start(opacityframe, fill=0, expand=0)
        opacitybox = gtk.VBox()
        opacityframe.add(opacitybox)
        self.opacityadj = gtk.Adjustment(value=100, lower=0, upper=100, step_incr=-1, page_incr=-5, page_size=0)
        gtklogger.connect(self.opacityadj, 'value_changed', self.setopacity)
        opacityscale = gtk.HScale(self.opacityadj)
        opacityscale.set_update_policy(gtk.UPDATE_DELAYED)
        self.tooltips.set_tip(opacityscale,"Adjust the opacity of the microstructure")
        opacitybox.pack_start(opacityscale)

        # save and restore
        saverestoreframe = gtk.Frame("Save and Restore Views")
        saverestoreframe.set_shadow_type(gtk.SHADOW_IN)
        viewerbox.pack_start(saverestoreframe, fill=0, expand=0)
        saverestorebox = gtk.VBox()
        saverestoreframe.add(saverestorebox)
        viewtable = gtk.Table(columns=2, rows=2)
        saverestorebox.pack_start(viewtable, fill=0, expand=0)
        saveviewbutton = gtk.Button("Save View:")
        self.tooltips.set_tip(saveviewbutton,"Save the current view settings")
        gtklogger.connect(saveviewbutton, 'clicked', self.saveview)
        viewtable.attach(saveviewbutton, 0,1,0,1)
        self.viewname = gtk.Entry()
        self.viewname.set_editable(1)
        self.viewname.set_size_request(80,-1)
        self.tooltips.set_tip(self.viewname,"Enter a name for the current view")
        viewtable.attach(self.viewname,1,2,0,1)
        setviewlabel = gtk.Label("Set View:")
        viewtable.attach(setviewlabel, 0,1,1,2)
        liststore = gtk.ListStore(gobject.TYPE_STRING)
        self.viewmenu = gtk.ComboBox(liststore)
        cell = gtk.CellRendererText()
        self.viewmenu.pack_start(cell, True)
        self.viewmenu.add_attribute(cell, 'text', 0)
        #self.tooltips.set_tip(self.viewmenu,"Restore a saved view")
        # menu items filled in later when saved_views is initialized
        self.signal = gtklogger.connect(self.viewmenu, 'changed',
                                        self.setview)
        viewtable.attach(self.viewmenu, 1,2,1,2)


        # end viewer widgets

        # voxel info widgets
        voxelinfoframe = gtk.Frame("Voxel Info Widgets")
        voxelinfoframe.set_shadow_type(gtk.SHADOW_IN)
        self.mainbox.pack_start(voxelinfoframe)
        voxelinfobox = gtk.VBox()
        voxelinfoframe.add(voxelinfobox)
        voxelinfotable = gtk.Table(rows=7,columns=2)
        voxelinfobox.pack_start(voxelinfotable)
        label = gtk.Label('x=')
        label.set_alignment(1.0, 0.5)
        voxelinfotable.attach(label, 0,1, 0,1, xpadding=5, xoptions=gtk.FILL)
        self.xtext = gtk.Entry()
        self.xtext.set_size_request(80, -1)
        voxelinfotable.attach(self.xtext, 1,2, 0,1,
                          xpadding=5, xoptions=gtk.EXPAND|gtk.FILL)
        label = gtk.Label('y=')
        label.set_alignment(1.0, 0.5)
        voxelinfotable.attach(label, 0,1, 1,2, xpadding=5, xoptions=gtk.FILL)
        self.ytext = gtk.Entry()
        self.ytext.set_size_request(80, -1)
        voxelinfotable.attach(self.ytext, 1,2, 1,2,
                          xpadding=5, xoptions=gtk.EXPAND|gtk.FILL)
        label = gtk.Label('z=')
        label.set_alignment(1.0, 0.5)
        voxelinfotable.attach(label, 0,1, 2,3, xpadding=5, xoptions=gtk.FILL)
        self.ztext = gtk.Entry()
        self.ztext.set_size_request(80, -1)
        voxelinfotable.attach(self.ztext, 1,2, 2,3,
                          xpadding=5, xoptions=gtk.EXPAND|gtk.FILL)
        self.xtsignal = gtklogger.connect(self.xtext, 'changed',
                                          self.voxinfoChanged)
        self.ytsignal = gtklogger.connect(self.ytext, 'changed',
                                          self.voxinfoChanged)
        self.ztsignal = gtklogger.connect(self.ztext, 'changed',
                                          self.voxinfoChanged)
       
        box = gtk.HBox(homogeneous=True, spacing=2)
        self.updatebutton = gtk.Button(gtk.STOCK_REFRESH) #gtkutils.stockButton(gtk.STOCK_REFRESH, 'Update')
        box.pack_start(self.updatebutton, expand=1, fill=1)
        gtklogger.connect(self.updatebutton, 'clicked', self.updateVoxButtonCB)
        self.clearbutton = gtk.Button(gtk.STOCK_CLEAR) #gtkutils.stockButton(gtk.STOCK_CLEAR, 'Clear')
        box.pack_start(self.clearbutton, expand=1, fill=1)
        gtklogger.setWidgetName(self.clearbutton, "Clear")
        gtklogger.connect(self.clearbutton, 'clicked', self.clearVoxButtonCB)
        voxelinfotable.attach(box, 0,2,3,4,
                          xpadding=5, xoptions=gtk.EXPAND|gtk.FILL, yoptions=0)
        label = gtk.Label('red=')
        label.set_alignment(1.0, 0.5)
        voxelinfotable.attach(label, 0,1, 4,5, xpadding=5, xoptions=gtk.FILL)
        self.redtext = gtk.Entry()
        self.redtext.set_size_request(80, -1)
        voxelinfotable.attach(self.redtext, 1,2, 4,5,
                          xpadding=5, xoptions=gtk.EXPAND|gtk.FILL)
        label = gtk.Label('green=')
        label.set_alignment(1.0, 0.5)
        voxelinfotable.attach(label, 0,1, 5,6, xpadding=5, xoptions=gtk.FILL)
        self.greentext = gtk.Entry()
        self.greentext.set_size_request(80, -1)
        voxelinfotable.attach(self.greentext, 1,2, 5,6,
                          xpadding=5, xoptions=gtk.EXPAND|gtk.FILL)
        label = gtk.Label('blue=')
        label.set_alignment(1.0, 0.5)
        voxelinfotable.attach(label, 0,1, 6,7, xpadding=5, xoptions=gtk.FILL)
        self.bluetext = gtk.Entry()
        self.bluetext.set_size_request(80, -1)
        voxelinfotable.attach(self.bluetext, 1,2, 6,7,
                          xpadding=5, xoptions=gtk.EXPAND|gtk.FILL)
        currentVoxel = None

        
        # voxel select widgets
##         voxelselectframe = gtk.Frame("Voxel Select Widgets")
##         voxelselectframe.set_shadow_type(gtk.SHADOW_IN)
##         self.mainbox.pack_start(voxelselectframe)
##         voxelselectbox = gtk.VBox()
##         voxelselectframe.add(voxelselectbox)
##         button = gtk.Button("Hello World")
##         voxelselectbox.pack_start(button)

        self.saveimage = gtk.Button("save image")
        gtklogger.connect(self.saveimage, 'clicked', self.saveimageCB)
        self.mainbox.pack_start(self.saveimage)
Exemplo n.º 11
0
    def build_storage_entry(self, disk, storage_box):
        origpath = disk[STORAGE_INFO_ORIG_PATH]
        devtype = disk[STORAGE_INFO_DEVTYPE]
        size = disk[STORAGE_INFO_SIZE]
        can_clone = disk[STORAGE_INFO_CAN_CLONE]
        do_clone = disk[STORAGE_INFO_DO_CLONE]
        can_share = disk[STORAGE_INFO_CAN_SHARE]
        is_default = disk[STORAGE_INFO_DO_DEFAULT]
        definfo = disk[STORAGE_INFO_DEFINFO]
        failinfo = disk[STORAGE_INFO_FAILINFO]
        target = disk[STORAGE_INFO_TARGET]

        orig_name = self.orig_vm.get_name()

        disk_label = os.path.basename(origpath)
        info_label = None
        if not can_clone:
            info_label = gtk.Label()
            info_label.set_alignment(0, .5)
            info_label.set_markup("<span size='small'>%s</span>" % failinfo)
        if not is_default:
            disk_label += (definfo and " (%s)" % definfo or "")

        # Build icon
        icon = gtk.Image()
        if devtype == virtinst.VirtualDisk.DEVICE_FLOPPY:
            iconname = "media-floppy"
        elif devtype == virtinst.VirtualDisk.DEVICE_CDROM:
            iconname = "media-optical"
        else:
            iconname = "drive-harddisk"
        icon.set_from_icon_name(iconname, gtk.ICON_SIZE_MENU)
        disk_name_label = gtk.Label(disk_label)
        disk_name_label.set_alignment(0, .5)
        disk_name_box = gtk.HBox(spacing=9)
        disk_name_box.pack_start(icon, False)
        disk_name_box.pack_start(disk_name_label, True)

        def sep_func(model, it, combo):
            ignore = combo
            return model[it][2]

        # [String, sensitive, is sep]
        model = gtk.ListStore(str, bool, bool)
        option_combo = gtk.ComboBox(model)
        text = gtk.CellRendererText()
        option_combo.pack_start(text)
        option_combo.add_attribute(text, "text", 0)
        option_combo.add_attribute(text, "sensitive", 1)
        option_combo.set_row_separator_func(sep_func, option_combo)
        option_combo.connect("changed", self.storage_combo_changed, target)

        vbox = gtk.VBox(spacing=1)
        if can_clone or can_share:
            model.insert(STORAGE_COMBO_CLONE,
                         [(_("Clone this disk") +
                           (size and " (%s)" % size or "")), can_clone, False])
            model.insert(
                STORAGE_COMBO_SHARE,
                [_("Share disk with %s") % orig_name, can_share, False])
            model.insert(STORAGE_COMBO_SEP, ["", False, True])
            model.insert(STORAGE_COMBO_DETAILS, [_("Details..."), True, False])

            if (can_clone and is_default) or do_clone:
                option_combo.set_active(STORAGE_COMBO_CLONE)
            else:
                option_combo.set_active(STORAGE_COMBO_SHARE)
        else:
            model.insert(
                STORAGE_COMBO_CLONE,
                [_("Storage cannot be shared or cloned."), False, False])
            option_combo.set_active(STORAGE_COMBO_CLONE)

        vbox.pack_start(disk_name_box, False, False)
        vbox.pack_start(option_combo, False, False)
        if info_label:
            vbox.pack_start(info_label, False, False)
        storage_box.pack_start(vbox, False, False)

        disk[STORAGE_INFO_COMBO] = option_combo
Exemplo n.º 12
0
    def _create_widgets(self):
        def create_label(label):
            l = gtk.Label(label)
            l.set_alignment(0, 0.5)
            l.set_use_markup(True)
            return l

        self.LP_spinner = gtk.SpinButton()
        self.LP_spinner.set_range(0.0, 10.0)
        self.LP_spinner.set_digits(2)
        self.LP_spinner.set_increments(0.01, 0.1)
        self.C_label = create_label(_("Concentration (mg/ml):"))
        self.C_spinner = gtk.SpinButton()
        self.C_spinner.set_range(0.0, 50.0)
        self.C_spinner.set_digits(4)
        self.C_spinner.set_increments(0.01, 0.1)
        self.MW_spinner = gtk.SpinButton()
        self.MW_spinner.set_range(1.0, 1000000000000.0)
        self.MW_spinner.set_digits(2)
        self.MW_spinner.set_increments(10.0, 100.0)
        self.Rn_spinner = gtk.SpinButton()
        self.Rn_spinner.set_range(1.0, 1000000000000.0)
        self.Rn_spinner.set_digits(0)
        self.Rn_spinner.set_increments(1.0, 10.0)
        self.factor_entry = gtk.Entry()
        self.factor_entry.props.editable = False
        self.factor_entry.set_text("%f" % 0.0)
        self.c_units_list = gtk.ListStore(str)
        self.c_units_list.append(["m:v (mg/ml)"])
        self.c_units_list.append(["micromolar"])
        self.c_units_list.append(["milimolar"])
        cell = gtk.CellRendererText()
        self.c_units_combo = gtk.ComboBox(self.c_units_list)
        self.c_units_combo.pack_start(cell, True)
        self.c_units_combo.add_attribute(cell, 'text', 0)
        self.c_units_combo.set_active(0)

        self.copy_to_clipboard_btn = gtk.Button(stock=gtk.STOCK_COPY)
        self.copy_to_clipboard_btn.connect("clicked",
                                           self._copy_to_clipboard_cb)

        table = gtk.Table(6, 2)
        table.set_row_spacings(3)
        table.set_col_spacings(3)
        table.attach(create_label(_("Light path (cm):")), 0, 1, 0, 1, gtk.FILL,
                     gtk.EXPAND | gtk.FILL)
        table.attach(self.LP_spinner, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL,
                     gtk.EXPAND | gtk.FILL)
        table.attach(self.c_units_combo, 0, 2, 1, 2, gtk.EXPAND | gtk.FILL,
                     gtk.EXPAND | gtk.FILL)
        table.attach(self.C_label, 0, 1, 2, 3, gtk.FILL, gtk.EXPAND | gtk.FILL)
        table.attach(self.C_spinner, 1, 2, 2, 3, gtk.EXPAND | gtk.FILL,
                     gtk.EXPAND | gtk.FILL)
        table.attach(create_label(_("Molecular weight (g/mol):")), 0, 1, 3, 4,
                     gtk.FILL, gtk.EXPAND | gtk.FILL)
        table.attach(self.MW_spinner, 1, 2, 3, 4, gtk.EXPAND | gtk.FILL,
                     gtk.EXPAND | gtk.FILL)
        table.attach(create_label(_("Residue number:")), 0, 1, 4, 5, gtk.FILL,
                     gtk.EXPAND | gtk.FILL)
        table.attach(self.Rn_spinner, 1, 2, 4, 5, gtk.EXPAND | gtk.FILL,
                     gtk.EXPAND | gtk.FILL)
        table.attach(create_label(_("<b>Correction factor:</b>")), 0, 1, 5, 6,
                     gtk.FILL, gtk.EXPAND | gtk.FILL, 0, 5)
        table.attach(self.factor_entry, 1, 2, 5, 6, gtk.EXPAND | gtk.FILL,
                     gtk.EXPAND | gtk.FILL, 0, 5)
        self.vbox.pack_start(table, False, False, 4)
        self.action_area.pack_end(self.copy_to_clipboard_btn, False, False, 0)
        self.set_border_width(2)
        self.show_all()
Exemplo n.º 13
0
    def __init__(self, parent, filename, claimtable=None):
        logging.debug("Launching ClaimTableWizard")

        self.filename = filename
        self.parent = parent
        if not claimtable:
            self.re_import = False
            self.claimtable = self.parent.on_new_table(self,
                                                       data=self.filename)
            _, fil = os.path.split(self.filename)
            self.claimtable.set_tab_text(fil)
        else:
            self.re_import = True
            self.claimtable = claimtable

        # Build the dialog
        self.dialog = gtk.Dialog(title="Import as...")
        self.dialog.connect("delete-event", self.on_cancel)

        # Open the file
        try:
            self.f = open(self.filename, "rb")
        except (OSError, IOError) as e:
            logging.error("ClaimTableWizard: unable to open csv file " +
                          self.filename)
            logging.error(e)
            error_msg = gtk.MessageDialog(self.parent.window, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, \
             "Can not open csv file")
            error_msg.format_secondary_text("Make sure %s is readable and try again." \
             % self.filename)
            error_msg.run()
            error_msg.destroy()
            self.claimtable.destroy()
            return

        # Build the treeview model
        self.reader = csv.reader(self.f)
        try:
            self.liststore = gtk.ListStore(str, str)
            headers = self.reader.next()
            for h in headers:
                self.liststore.append([h, "Not imported"])
            treeview = gtk.TreeView(self.liststore)
            treeview.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_BOTH)
        except StopIteration:
            logging.error("ClaimTableWizard: unable to parse file " +
                          self.filename)
            error_msg = gtk.MessageDialog(self.parent.window, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, \
             "Unable to parse file")
            error_msg.format_secondary_text(
                "Please select another file and try again.")
            error_msg.run()
            error_msg.destroy()
            self.claimtable.destroy()
            return

        # Open the file with the options file mapping settings
        if not claimtable and self.claimtable.options.items("Mapping"):
            self.open_w_mapping()
            return
        else:
            self.open_w_mapping()  # Re-import the table

        # Build column one
        cell = gtk.CellRendererText()
        column_one = gtk.TreeViewColumn("Column", cell, text=0)
        treeview.append_column(column_one)

        # Build column two, a combo box to select the appropriate header
        combo = gtk.CellRendererCombo()
        combolist = gtk.ListStore(
            *[str for t in tables.table_layout["header"]])
        combobox = gtk.ComboBox(combolist)
        combobox.append_text("Not imported")
        for h in tables.table_layout["header"]:
            combobox.append_text(h)
        combo.set_property("editable", True)
        combo.set_property("model", combolist)
        combo.set_property("text-column", 0)
        combo.set_property("has-entry", False)
        combo.connect("edited", self.on_combo_changed)
        column_two = gtk.TreeViewColumn("Import as", combo, text=1)
        treeview.append_column(column_two)

        # Build the province selector radiobuttons
        provinces = list(self.claimtable.claimtable.supported().keys())

        def change_province(button):
            self.claimtable.options.set("Settings", "province",
                                        button.get_label())

        province_frame = gtk.HBox()
        label = gtk.Label("Province/State: ")
        button_zero = gtk.RadioButton(label=provinces[0])
        button_zero.connect("pressed", change_province)
        province_frame.pack_end(button_zero, False, False, 0)
        for p in provinces[1:]:
            button = gtk.RadioButton(label=p, group=button_zero)
            if self.claimtable.options.get("Settings", "province") == p:
                button.set_active(True)
            button.connect("pressed", change_province)
            province_frame.pack_end(button, False, False, 0)
        province_frame.pack_end(label, False, False, 0)

        # Build the bottom frame that holds the apply/cancel buttons and the province radiobuttons
        bottom_frame = gtk.HBox()
        cancel_button = gtk.Button(label="Cancel", stock=gtk.STOCK_CANCEL)
        cancel_button.connect("clicked", self.on_cancel)
        apply_button = gtk.Button(label="Import", stock=gtk.STOCK_APPLY)
        apply_button.connect("clicked", self.on_apply)
        bottom_frame.pack_end(apply_button, False, False, 0)
        bottom_frame.pack_end(cancel_button, False, False, 0)
        bottom_frame.pack_end(province_frame, False, False, 20)

        # Pack the dialog
        self.dialog.vbox.pack_start(treeview, True, True, 0)
        self.dialog.vbox.pack_end(bottom_frame, True, True, 0)
        self.dialog.show_all()
        height = treeview.get_cell_area(0, column_one).height
        self.dialog.resize(320, height * len(headers))

        response = self.dialog.run()
        self.dialog.destroy()
        if response == gtk.RESPONSE_CANCEL:  # Hit the 'Cancel' button...
            if not claimtable:
                self.claimtable.destroy()
Exemplo n.º 14
0
    def __init__(self, data=None, more=None):

        # Load configuration file
        try:
            configfile = open(self.Section, 'r')
            self.section = configfile.readline()
            configfile.close()
        except:
            self.section = ''

        if self.section == '':
            self.section = 'default'

        # Initialize parameters
        self.selectedMac = None
        self.selectedSessionId = None

        self.config = ConfigParser.RawConfigParser()

        if os.path.exists(self.Ini):
            self.config.read(self.Ini)
        else:
            self.config.read(self.DefIni)

        # Setup the sections store and selection boxes
        self.sectionStore = gtk.ListStore(gobject.TYPE_STRING)
        self.sectionBox = gtk.ComboBox(self.sectionStore)
        self.sectionBox2 = gtk.ComboBox(self.sectionStore)
        cell = gtk.CellRendererText()
        self.sectionBox.pack_start(cell, True)
        self.sectionBox.add_attribute(cell, 'text', 0)
        self.sectionBox2.pack_start(cell, True)
        self.sectionBox2.add_attribute(cell, 'text', 0)

        for section in self.config.sections():
            self.sectionStore.append([section])

        self.sessionsStore = gtk.ListStore(gobject.TYPE_STRING,
                                           gobject.TYPE_STRING)

        self.sessionsView = gtk.TreeView(self.sessionsStore)

        cell = gtk.CellRendererText()
        col = gtk.TreeViewColumn("MAC", cell, text=0)
        self.sessionsView.append_column(col)

        cell = gtk.CellRendererText()
        col = gtk.TreeViewColumn("IP", cell, text=1)
        self.sessionsView.append_column(col)

        self.sessionsView.connect("cursor-changed", self.row1,
                                  "cursor-changed")

        self.vboxSessions = gtk.VBox()
        self.vboxSessionBtns = gtk.HBox(homogeneous=True)

        self.sesRefresh = gtk.Button("Refresh")
        self.sesAuth = gtk.Button("Auth")
        self.sesRelease = gtk.Button("Release")
        self.sesBlock = gtk.Button("Block")
        self.sesAuth.set_sensitive(False)
        self.sesRelease.set_sensitive(False)
        self.sesBlock.set_sensitive(False)

        self.sessionView = gtk.Label("")
        self.vboxSessions.pack_start(self.sessionsView)
        self.vboxSessions.pack_start(self.sessionView, False)

        self.vboxSessionBtns.pack_start(self.sesRefresh)
        self.vboxSessionBtns.pack_start(self.sesAuth)
        self.vboxSessionBtns.pack_start(self.sesRelease)
        self.vboxSessionBtns.pack_start(self.sesBlock)

        self.vboxSessions.pack_start(self.vboxSessionBtns, False)

        self.sesRefresh.connect("clicked", self.chilliQuery)
        self.sesRelease.connect("clicked", self.sessionRelease)
        self.sesBlock.connect("clicked", self.sessionBlock)
        self.sesAuth.connect("clicked", self.sessionAuthorize)

        self.vboxSessions.show()
        self.sesRefresh.show()
        self.sesAuth.show()
        self.sesRelease.show()
        self.sesBlock.show()
        self.sessionView.show()
        self.sessionsView.show()
        self.vboxSessionBtns.show()

        self.btnStart = gtk.Button("Start")
        self.btnStop = gtk.Button("Stop")

        self.btnStart.set_sensitive(False)
        self.btnStop.set_sensitive(False)

        self.btnStart.connect("clicked", self.startCoovaChilli)
        self.btnStop.connect("clicked", self.stopCoovaChilli)
Exemplo n.º 15
0
    def __init__(self, prefs):
        melddoc.MeldDoc.__init__(self, prefs)
        gnomeglade.Component.__init__(self, paths.ui_dir("vcview.ui"),
                                      "vcview")

        actions = (
            ("VcCompare", gtk.STOCK_DIALOG_INFO, _("_Compare"), None,
                _("Compare selected files"),
                self.on_button_diff_clicked),
            ("VcCommit", "vc-commit-24", _("Co_mmit..."), None,
                _("Commit changes to version control"),
                self.on_button_commit_clicked),
            ("VcUpdate", "vc-update-24", _("_Update"), None,
                _("Update working copy from version control"),
                self.on_button_update_clicked),
            ("VcPush", "vc-push-24", _("_Push"), None,
                _("Push local changes to remote"),
                self.on_button_push_clicked),
            ("VcAdd", "vc-add-24", _("_Add"), None,
                _("Add to version control"),
                self.on_button_add_clicked),
            ("VcRemove", "vc-remove-24", _("_Remove"), None,
                _("Remove from version control"),
                self.on_button_remove_clicked),
            ("VcResolved", "vc-resolve-24", _("Mar_k as Resolved"), None,
                _("Mark as resolved in version control"),
                self.on_button_resolved_clicked),
            ("VcRevert", gtk.STOCK_REVERT_TO_SAVED, _("Re_vert"), None,
                _("Revert working copy to original state"),
                self.on_button_revert_clicked),
            ("VcDeleteLocally", gtk.STOCK_DELETE, None, None,
                _("Delete from working copy"),
                self.on_button_delete_clicked),
        )

        toggleactions = (
            ("VcFlatten", gtk.STOCK_GOTO_BOTTOM, _("_Flatten"),  None,
                _("Flatten directories"),
                self.on_button_flatten_toggled, False),
            ("VcShowModified", "filter-modified-24", _("_Modified"), None,
                _("Show modified files"),
                self.on_filter_state_toggled, False),
            ("VcShowNormal", "filter-normal-24", _("_Normal"), None,
                _("Show normal files"),
                self.on_filter_state_toggled, False),
            ("VcShowNonVC", "filter-nonvc-24", _("Un_versioned"), None,
                _("Show unversioned files"),
                self.on_filter_state_toggled, False),
            ("VcShowIgnored", "filter-ignored-24", _("Ignored"), None,
                _("Show ignored files"),
                self.on_filter_state_toggled, False),
        )

        self.ui_file = paths.ui_dir("vcview-ui.xml")
        self.actiongroup = gtk.ActionGroup('VcviewActions')
        self.actiongroup.set_translation_domain("meld")
        self.actiongroup.add_actions(actions)
        self.actiongroup.add_toggle_actions(toggleactions)
        for action in ("VcCompare", "VcFlatten", "VcShowModified",
                       "VcShowNormal", "VcShowNonVC", "VcShowIgnored"):
            self.actiongroup.get_action(action).props.is_important = True
        for action in ("VcCommit", "VcUpdate", "VcPush", "VcAdd", "VcRemove",
                       "VcShowModified", "VcShowNormal", "VcShowNonVC",
                       "VcShowIgnored", "VcResolved"):
            button = self.actiongroup.get_action(action)
            button.props.icon_name = button.props.stock_id
        self.model = VcTreeStore()
        self.widget.connect("style-set", self.model.on_style_set)
        self.treeview.set_model(self.model)
        selection = self.treeview.get_selection()
        selection.set_mode(gtk.SELECTION_MULTIPLE)
        selection.connect("changed", self.on_treeview_selection_changed)
        self.treeview.set_headers_visible(1)
        self.treeview.set_search_equal_func(self.model.treeview_search_cb)
        self.current_path, self.prev_path, self.next_path = None, None, None

        self.column_name_map = {}
        column = gtk.TreeViewColumn(_("Name"))
        column.set_resizable(True)
        renicon = emblemcellrenderer.EmblemCellRenderer()
        rentext = gtk.CellRendererText()
        column.pack_start(renicon, expand=0)
        column.pack_start(rentext, expand=1)
        col_index = self.model.column_index
        column.set_attributes(renicon,
                              icon_name=col_index(tree.COL_ICON, 0),
                              icon_tint=col_index(tree.COL_TINT, 0))
        column.set_attributes(rentext,
                    text=col_index(tree.COL_TEXT, 0),
                    foreground_gdk=col_index(tree.COL_FG, 0),
                    style=col_index(tree.COL_STYLE, 0),
                    weight=col_index(tree.COL_WEIGHT, 0),
                    strikethrough=col_index(tree.COL_STRIKE, 0))
        column_index = self.treeview.append_column(column) - 1
        self.column_name_map[vc.DATA_NAME] = column_index

        def addCol(name, num, data_name=None):
            column = gtk.TreeViewColumn(name)
            column.set_resizable(True)
            rentext = gtk.CellRendererText()
            column.pack_start(rentext, expand=0)
            column.set_attributes(rentext,
                                  markup=self.model.column_index(num, 0))
            column_index = self.treeview.append_column(column) - 1
            if data_name:
                self.column_name_map[data_name] = column_index
            return column

        self.treeview_column_location = addCol(_("Location"), COL_LOCATION)
        addCol(_("Status"), COL_STATUS, vc.DATA_STATE)
        addCol(_("Revision"), COL_REVISION, vc.DATA_REVISION)
        addCol(_("Options"), COL_OPTIONS, vc.DATA_OPTIONS)

        self.state_filters = []
        for s in self.state_actions:
            if s in self.prefs.vc_status_filters:
                action_name = self.state_actions[s][0]
                self.state_filters.append(s)
                self.actiongroup.get_action(action_name).set_active(True)

        self.consolestream = ConsoleStream(self.consoleview)
        self.location = None
        self.treeview_column_location.set_visible(self.actiongroup.get_action("VcFlatten").get_active())
        if not self.prefs.vc_console_visible:
            self.on_console_view_toggle(self.console_hide_box)
        self.vc = None
        self.valid_vc_actions = tuple()
        # VC ComboBox
        self.combobox_vcs = gtk.ComboBox()
        self.combobox_vcs.lock = True
        self.combobox_vcs.set_model(gtk.ListStore(str, object, bool))
        cell = gtk.CellRendererText()
        self.combobox_vcs.pack_start(cell, False)
        self.combobox_vcs.add_attribute(cell, 'text', 0)
        self.combobox_vcs.add_attribute(cell, 'sensitive', 2)
        self.combobox_vcs.lock = False
        self.hbox2.pack_end(self.combobox_vcs, expand=False)
        self.combobox_vcs.show()
        self.combobox_vcs.connect("changed", self.on_vc_change)
Exemplo n.º 16
0
    def __init__(self):
        self.sw = gtk.ScrolledWindow()
        self.sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        self.sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.treeView = None
        '''Create a new window'''
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        uimanager = gtk.UIManager()
        accelgroup = uimanager.get_accel_group()
        self.window.add_accel_group(accelgroup)
        self.actiongroup = gtk.ActionGroup("uimanager")
        self.actiongroup.add_actions([
            ("User authentication", None, "_User authentication", "<control>A",
             None, lambda x: self.changeTable(1)),
            ("Save as HTML", gtk.STOCK_SAVE, "_Save as HTML", "<control>S",
             None, self.do_save_as),
            ("Save in a text format", None, "_Save in a text format", None,
             None, self.do_save_as_text),
            ("Close", gtk.STOCK_QUIT, "_Close", None, "Quit the Application",
             lambda w: gtk.main_quit()), ("Report type", None, "_Report type"),
            ("Help", None, "_Help", "F1", None, about_help._help),
            ("About program", None, "_About program", None, None,
             about_help.about_program), ("Reference", None, "_Reference")
        ])
        uimanager.insert_action_group(self.actiongroup, 0)
        uimanager.add_ui_from_string(self.interface)
        menubar = uimanager.get_widget("/MenuBar")

        self.window.set_size_request(1000, 500)
        self.window.set_border_width(10)
        self.window.set_position(gtk.WIN_POS_CENTER_ALWAYS)
        self.window.set_title("The event log")
        self.window.connect("destroy", self.destroy)

        main_vbox = gtk.VBox(False, 10)
        main_hbox = gtk.HBox(False, 10)
        self.window.add(main_hbox)
        main_hbox.pack_start(main_vbox, True, True, 0)

        self.calendar = gtk.Calendar()
        self.calendar2 = gtk.Calendar()
        self._connect_signals()
        self._connect_signals2()

        frame = gtk.Frame("Report time")
        vbox = gtk.VBox(False, 0)
        frame.add(vbox)
        hbox = gtk.HBox(False, 0)
        vbox.pack_start(hbox, False, False, 10)

        label = gtk.Label("with: ")
        label.set_alignment(0, 0.5)
        hbox.pack_start(label, False, False, 10)
        self.entry = gtk.Entry()
        self.entry.set_editable(True)
        hbox.pack_start(self.entry, False, False, 0)
        self.button = gtk.Button(label='^')
        hbox.pack_start(self.button, False, False, 0)
        self.clicked_handle = self.button.connect('clicked', self.show_widget)

        currentDate = datetime.date(year, month, day)
        text = currentDate.strftime("%d.%m.%Y")
        teeext = currentDate.strftime("%Y, %m, %d")
        self.entry.set_text(text)

        label = gtk.Label("time: ")
        label.set_alignment(0, 0.5)
        hbox.pack_start(label, False, False, 10)
        self.entryTime1 = gtk.Entry()
        hbox.pack_start(self.entryTime1, False, False, 0)

        label = gtk.Label("to: ")
        label.set_alignment(0, 0.5)
        hbox.pack_start(label, False, False, 10)
        self.entry2 = gtk.Entry()
        self.entry2.set_editable(False)
        hbox.pack_start(self.entry2, False, False, 0)
        self.button2 = gtk.Button(label='^')
        hbox.pack_start(self.button2, False, False, 0)
        self.clicked_handle = self.button2.connect('clicked',
                                                   self.show_widget2)

        self.entry2.set_text(text)

        label = gtk.Label("time: ")
        label.set_alignment(0, 0.5)
        hbox.pack_start(label, False, False, 10)
        self.entryTime2 = gtk.Entry()
        hbox.pack_start(self.entryTime2, False, False, 10)

        frameUser = gtk.Frame("Users")
        vbox = gtk.VBox(False, 0)
        frameUser.add(vbox)
        hbox = gtk.HBox(False, 0)
        vbox.pack_start(hbox, False, False, 10)

        #User selection
        File = open(file_tmp, "rb")
        self.combobox = gtk.ComboBox()
        self.liststore = gtk.ListStore(str)
        cell = gtk.CellRendererText()
        self.combobox.pack_start(cell)
        self.combobox.add_attribute(cell, 'text', 0)
        self.combobox.set_wrap_width(5)
        for leng in File.xreadlines():
            integ_simple.buf.append(leng)
            m = re.match(
                "type=([\w]+).*msg=audit.(\d+\.\d+\.\d+) (\d+:\d+:\d+).*pid=([\w]+).*uid=([\w]+).*auid=([\w]+).*exe=([^\s]+)",
                leng)
            if m:
                uid = m.group(5)
                syscall = [uid]
                for p in syscall:
                    integ_simple.typesss.append(p)
        for st in ['All users']:
            self.liststore.append([st])
            for l in set(integ_simple.typesss):
                self.liststore.append([l])
        self.combobox.set_model(self.liststore)
        self.combobox.connect('changed', self.changed_cb)
        self.combobox.set_active(0)
        hbox.pack_start(self.combobox, False, False, 20)

        main_vbox.pack_start(menubar, False, True, 0)
        main_vbox.pack_start(frame, False, False, 0)
        main_vbox.pack_start(frameUser, False, False, 0)
        main_vbox.pack_start(self.sw, True, True, 0)

        self.window.show_all()

        #для календаря №1
        self.cwindow = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.cwindow.set_position(gtk.WIN_POS_MOUSE)
        self.cwindow.set_decorated(False)
        self.cwindow.set_modal(True)
        self.cwindow.add(self.calendar)

        #для календаря №2
        self.ccwindow = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.ccwindow.set_position(gtk.WIN_POS_MOUSE)
        self.ccwindow.set_decorated(False)
        self.ccwindow.set_modal(True)
        self.ccwindow.add(self.calendar2)

        menubar.show()
Exemplo n.º 17
0
    def __init__(self, w3af):
        super(VulnAddDialog,
              self).__init__("Add new vulnerability", None,
                             gtk.MESSAGE_QUESTION,
                             (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                              gtk.STOCK_ADD, gtk.RESPONSE_OK))
        self.set_icon_from_file(W3AF_ICON)

        self.w3af = w3af

        # Main hbox
        hbox = gtk.HBox()
        hbox.show()
        image = gtk.Image()
        image.set_from_stock(gtk.STOCK_DIALOG_QUESTION, gtk.ICON_SIZE_DIALOG)
        image.set_padding(20, 20)
        image.show()

        hbox.pack_start(image)

        # Vbox with all the information for the right section of the dialog
        vbox = gtk.VBox()

        # Add a label
        align = gtk.Alignment()
        align.set_padding(10, 0, 0, 10)
        label = gtk.Label('Choose the vulnerability template to use:')
        align.add(label)
        vbox.pack_start(align)

        template_long_names = get_template_long_names()
        template_names = get_template_names()
        self.vuln_template = None

        # A list store with the following columns:
        #    * Long template name (show)
        #    * Template name (code internals)
        liststore = gtk.ListStore(str, str)
        self.combobox = gtk.ComboBox(liststore)
        cell = gtk.CellRendererText()
        self.combobox.pack_start(cell, True)
        self.combobox.add_attribute(cell, 'text', 0)
        self.combobox.connect("changed", self._changed_combo)

        for i, long_name in enumerate(template_long_names):
            liststore.append((long_name, template_names[i]))

        vbox.pack_start(self.combobox, False, False)
        vbox.pack_start(gtk.Label())

        # the Cancel button
        but = self.action_area.get_children()[1]
        but.connect("clicked", lambda x: self.destroy())
        self.connect("delete-event", lambda x, y: self.destroy())

        # the Ok button
        self.ok_but = self.action_area.get_children()[0]
        self.ok_but.connect("clicked", self._ok)
        self.ok_but.set_sensitive(False)

        hbox.pack_start(vbox)

        self.vbox.pack_start(hbox)
        self.show_all()
Exemplo n.º 18
0
def GetArgv(optionlist=None,
            commandlist=None,
            addoldfile=1,
            addnewfile=1,
            addfolder=1,
            id=ARGV_ID):
    dialog = gtk.Dialog(
        "", None, gtk.DIALOG_MODAL,
        (gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))

    # Optionlist panel
    opanel = gtk.Table(4, 2, True)

    olabel = gtk.Label("Option: ")
    olabel.set_justify(gtk.JUSTIFY_LEFT)
    opanel.attach(olabel, 0, 1, 0, 1)

    olabel1 = gtk.Label()
    olabel1.set_name("ARGV_OPTION_EXPLAIN")
    olabel1.set_justify(gtk.JUSTIFY_LEFT)
    opanel.attach(olabel1, 0, 2, 1, 2)

    oentry = gtk.Entry()
    oentry.set_name("ARGV_OPTION_VALUE")
    opanel.attach(oentry, 0, 2, 2, 3)

    obutton = gtk.Button("Add")
    obutton.set_name("ARGV_OPTION_ADD")
    obutton.connect("clicked", _action, dialog, optionlist)
    opanel.attach(obutton, 1, 2, 3, 4, 0, gtk.FILL)

    optionl = gtk.ComboBox()
    ocell = gtk.CellRendererText()
    optionl.pack_start(ocell, True)
    optionl.add_attribute(ocell, 'text', 0)
    opanel.attach(optionl, 1, 2, 0, 1)
    optionl.set_name("ARGV_OPTION_GROUP")

    for i in opanel.get_children():
        if type(i) == gtk.Label:
            i.set_alignment(0.1, 0.5)

    # Commandlist panel
    cpanel = gtk.Table(3, 2, True)

    clabel1 = gtk.Label()
    clabel1.set_name("ARGV_COMMAND_EXPLAIN")
    clabel1.set_justify(gtk.JUSTIFY_LEFT)
    cpanel.attach(clabel1, 0, 1, 1, 2)

    clabel = gtk.Label("Command: ")
    clabel.set_justify(gtk.JUSTIFY_LEFT)
    cpanel.attach(clabel, 0, 1, 0, 1)

    cbutton = gtk.Button("Add")
    cbutton.set_name("ARGV_COMMAND_ADD")
    cbutton.connect("clicked", _action, dialog, commandlist)
    cpanel.attach(cbutton, 1, 2, 2, 3, 0, gtk.FILL)

    cptionl = gtk.ComboBox()
    cptionl.set_name("ARGV_COMMAND_GROUP")
    ccell = gtk.CellRendererText()
    cptionl.pack_start(ccell, True)
    cptionl.add_attribute(ccell, 'text', 0)
    cpanel.attach(cptionl, 1, 2, 0, 1)
    for i in cpanel.get_children():
        if type(i) == gtk.Label:
            i.set_alignment(0.1, 0.5)

    # ButtonBox
    bbox = gtk.Table(2, 2)
    bbox.attach(gtk.Button("Add file..."), 0, 1, 0, 1, gtk.FILL, 0)
    bbox.attach(gtk.Button("Add new file..."), 1, 2, 0, 1, gtk.FILL, 0)
    bbox.attach(gtk.Button("Add folder..."), 0, 1, 1, 2, gtk.FILL, 0)
    bbox.get_children()[0].set_name("ARGV_ADD_FOLDER")
    bbox.get_children()[0].connect("clicked", _action, dialog, None)
    bbox.get_children()[1].set_name("ARGV_ADD_NEWFILE")
    bbox.get_children()[1].connect("clicked", _action, dialog, None)
    bbox.get_children()[2].set_name("ARGV_ADD_OLDFILE")
    bbox.get_children()[2].connect("clicked", _action, dialog, None)

    # Command Line
    cl = gtk.Table(2, 1)

    cllabel = gtk.Label("Command line: ")
    cllabel.set_alignment(0.1, 0.1)
    cl.attach(cllabel, 0, 1, 0, 1, gtk.FILL, 0)

    clentry = gtk.Entry()
    clentry.set_text("")
    clentry.set_name("ARGV_CMDLINE_DATA")
    cl.attach(clentry, 0, 2, 1, 2)

    # Add into dialog
    dialog.vbox.pack_start(opanel, False, False, 5)
    dialog.vbox.pack_start(gtk.HSeparator(), True, True, 10)
    dialog.vbox.pack_start(cpanel, False, False, 5)
    dialog.vbox.pack_start(gtk.HSeparator(), True, True, 10)
    dialog.vbox.pack_start(bbox, False, False, 5)
    dialog.vbox.pack_start(gtk.HSeparator(), True, True, 10)
    dialog.vbox.pack_start(cl, False, False, 5)
    dialog.set_size_request(340, 450)
    dialog.show_all()
    oentry.hide()

    if optionlist:
        _setmenu(optionl, optionlist)
        optionl.set_active(0)
        _action(optionl, dialog, optionlist)
    else:
        opanel.set_state(gtk.STATE_INSENSITIVE)

    optionl.connect("changed", _action, dialog, optionlist)

    if commandlist:
        _setmenu(cptionl, commandlist)
        cptionl.set_active(0)
        if type(commandlist[0]) == type(()) and len(commandlist[0]) > 1:
            help = commandlist[0][-1]
            clabel1.set_label(help)
    else:
        cpanel.set_state(gtk.STATE_INSENSITIVE)
    cptionl.connect("changed", _action, dialog, commandlist)

    if not addoldfile:
        bbox.get_children()[2].set_state(gtk.STATE_INSENSITIVE)
    if not addnewfile:
        bbox.get_children()[1].set_state(gtk.STATE_INSENSITIVE)
    if not addfolder:
        bbox.get_children()[0].set_state(gtk.STATE_INSENSITIVE)

    res = dialog.run()
    dialog.hide()

    if res == gtk.RESPONSE_CANCEL:
        dialog.destroy()
        sys.exit(1)
    if res == gtk.RESPONSE_DELETE_EVENT:
        dialog.destroy()
        sys.exit(1)
    if res == gtk.RESPONSE_OK:
        return _action(clentry, dialog, None)
Exemplo n.º 19
0
    def __init__(self, helper):
        gtk.VBox.__init__(self)

        # ftp params
        ff = gtk.Table(2,4)
        ff.set_row_spacings(2); ff.set_col_spacings(5);
        ff.attach(gtk.Label('Host'),0,1,0,1,False,False);
        ff.attach(gtk.Label('User'),0,1,1,2,False,False);
        ff.attach(gtk.Label('Pass'),2,3,1,2,False,False);
        #ff.attach(gtk.Label('Filter'),0,1,3,4,False,False);
        self.url = gtk.Entry()
        self.url.set_size_request(10,-1)
        self.user = gtk.Entry()
        self.user.set_size_request(10,-1)
        self.pasw = gtk.Entry()
        self.pasw.set_size_request(10,-1)
        self.pasw.set_visibility(False)
        self.filt = gtk.Entry()
        self.filt.set_size_request(10,-1)

        ff.attach(self.url,1,4,0,1);
        ff.attach(self.user,1,2,1,2);
        ff.attach(self.pasw,3,4,1,2);
        #ff.attach(self.filt,1,2,3,4);

        self.pack_start(ff, False, False)

        # buttons
        #b = gtk.HBox(False)
        i=gtk.Image()
        i.set_from_stock('gtk-home',gtk.ICON_SIZE_BUTTON)
        #b.pack_start(i)
        #b.pack_start(gtk.Label('Connect'))
        btn_connect = gtk.Button()
        btn_connect.add(i)
        btn_connect.set_tooltip_text("Connect to FTP server")
        btn_connect.connect("clicked", helper.on_connect)

        #b = gtk.HBox(False)
        i=gtk.Image()
        i.set_from_stock('gtk-refresh',gtk.ICON_SIZE_BUTTON)
        #b.pack_start(i)
        #b.pack_start(gtk.Label('Refresh'))
        btn_refresh = gtk.Button()
        btn_refresh.add(i)
        btn_refresh.set_tooltip_text("Refresh remote directory list")
        btn_refresh.connect("clicked", helper.on_refresh)

        i=gtk.Image()
        i.set_from_stock('gtk-go-up',gtk.ICON_SIZE_BUTTON)
        btn_parent =  gtk.Button()
        btn_parent.add(i)
        btn_parent.set_tooltip_text("Go up to parent directory")
        btn_parent.connect("clicked", helper.on_parent)

        #list for combo box (Active/Passive FTP)
        self.list = gtk.ListStore(int, str)
        iter = self.list.append( (False, "Active FTP",) )
        self.list.set(iter)
        iter = self.list.append( (True, "Passive FTP",) )
        self.list.set(iter)

        # save as button for adding new file
        i=gtk.Image()
        i.set_from_stock('gtk-save-as',gtk.ICON_SIZE_BUTTON)
        btn_save_as = gtk.Button()
        btn_save_as.add(i)
        btn_save_as.set_tooltip_text("Save new file to FTP server")
        btn_save_as.connect("clicked", helper.on_save_as)

        #Combo box
        self.combo_pasv_mode = gtk.ComboBox()
        cell = gtk.CellRendererText()
        self.combo_pasv_mode.pack_start(cell, True)
        self.combo_pasv_mode.add_attribute(cell, 'text', 1)
        self.combo_pasv_mode.set_model(self.list)
        self.combo_pasv_mode.set_active(True) #default: passive mode=True
        

        #pack buttons and combo box (active/passive FTP) on same row
        buttonsAndCombo=gtk.HBox(False)
        buttonsAndCombo.pack_start(btn_connect,False,False)
        buttonsAndCombo.pack_start(btn_refresh,False,False)
        buttonsAndCombo.pack_start(btn_parent,False,False)
        buttonsAndCombo.pack_start(btn_save_as,False,False)
        buttonsAndCombo.pack_start(self.combo_pasv_mode,False,False)
        self.pack_start(buttonsAndCombo,False,False)


        #location label
        self.location = gtk.Label(helper.ftp_cwd)
        self.location.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
        self.location.set_line_wrap(True)
        self.location.set_justify(gtk.JUSTIFY_LEFT)
        self.location.set_alignment(0,0.5)
        self.pack_start(self.location, False, False)

        # add a treeview
        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.set_shadow_type(gtk.SHADOW_IN)
        self.browser_model = gtk.ListStore(gtk.gdk.Pixbuf, str, str)
        self.browser = gtk.TreeView(self.browser_model)
        self.browser.set_headers_visible(True)
        sw.add(self.browser)
        self.pack_start(sw)

        self.dir_icon = self.browser.render_icon('gtk-directory', gtk.ICON_SIZE_MENU)
        self.file_icon = self.browser.render_icon('gtk-file', gtk.ICON_SIZE_MENU)

        # add columns to the treeview
        col = gtk.TreeViewColumn()
        render_pixbuf = gtk.CellRendererPixbuf()
        col.pack_start(render_pixbuf, expand=False)
        col.add_attribute(render_pixbuf, 'pixbuf', 0)
        self.browser.append_column(col)

        col = gtk.TreeViewColumn('Filename')
        render_text = gtk.CellRendererText()
        col.pack_start(render_text, expand=True)
        col.add_attribute(render_text, 'text', 1)
        self.browser.append_column(col)

        # connect stuff
        self.browser.connect("row-activated",helper.on_list_row_activated)
        self.show_all()
Exemplo n.º 20
0
    def __init__(self, image, layer, *args):
        mwin = gtk.Window.__init__(self, *args)
        self.set_border_width(10)

        #internal arguments
        self.img = image
        self.layer = layer
        self.numblursteps = BLURSTEPS
        self.blurdir = 0  #will be reinitialized in GUI construction
        self.savepath = os.getcwd()  #will be updated by user choice
        self.frametime = FRAMETIME
        self.bidblur = BIDIRBLUR

        #Obey the window manager quit signal:
        self.connect("destroy", gtk.main_quit)

        #Designing the interface
        vbx = gtk.VBox(spacing=10, homogeneous=False)
        self.add(vbx)

        hbxini = gtk.HBox(spacing=10, homogeneous=False)
        vbx.add(hbxini)
        topmess = "You should have maximum two layers. The first one will be animated.\n"
        topmess += "If there is a second one, will be the unanimated background.\n"
        topmess += "In this case, be sure that the first one has some transparency."
        labini = gtk.Label(topmess)
        hbxini.add(labini)

        hbxa = gtk.HBox(spacing=10, homogeneous=False)
        vbx.add(hbxa)

        laba = gtk.Label("Blurring steps")
        hbxa.add(laba)

        butaadj = gtk.Adjustment(BLURSTEPS, 2, 10, 1, 5)
        spbuta = gtk.SpinButton(butaadj, 0, 0)
        spbuta.connect("output", self.on_blurstep_change)
        hbxa.add(spbuta)

        hbxc = gtk.HBox(spacing=10, homogeneous=False)
        vbx.add(hbxc)

        labc = gtk.Label("Delay between frames")
        hbxc.add(labc)

        butcadj = gtk.Adjustment(FRAMETIME, 50, 2000, 1, 20)
        spbutc = gtk.SpinButton(butcadj, 0, 0)
        spbutc.connect("output", self.on_frametime_change)
        hbxc.add(spbutc)

        hbxb = gtk.HBox(spacing=10, homogeneous=False)
        vbx.add(hbxb)

        labb = gtk.Label("Blur direction")
        hbxb.add(labb)

        boxmodel = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_INT)

        #filling the model for the combobox
        for i, j in zip(BLURDIR, range(len(BLURDIR))):
            irow = boxmodel.append(None, [i, j])
            if (j == DEFBLURDIR):
                self.blurdir = j

        cbox = gtk.ComboBox(boxmodel)
        rendtext = gtk.CellRendererText()
        cbox.pack_start(rendtext, True)
        cbox.add_attribute(rendtext, "text", 0)
        cbox.set_entry_text_column(0)
        cbox.set_active(self.blurdir)
        cbox.connect("changed", self.on_cbox_changed)
        hbxb.add(cbox)

        butch = gtk.CheckButton("Bidirectional blurring")
        vbx.add(butch)
        butch.set_active(BIDIRBLUR)
        butch.connect("toggled", self.on_butch_toggled)

        butok = gtk.Button("OK")
        vbx.add(butok)
        butok.connect("clicked", self.on_butok_clicked)

        self.show_all()

        return mwin
Exemplo n.º 21
0
    def __init__(self, callback, args=None):
        gtk.Alignment.__init__(self, xalign=0.5, yalign=0.5, xscale=0.0,
            yscale=1.0)

        self.dialog = extension.get_default('dialog')
        Avatar = extension.get_default('avatar')
        NiceBar = extension.get_default('nice bar')

        self.liststore = gtk.ListStore(gobject.TYPE_STRING, gtk.gdk.Pixbuf)
        completion = gtk.EntryCompletion()
        completion.set_model(self.liststore)
        pixbufcell = gtk.CellRendererPixbuf()
        completion.pack_start(pixbufcell)
        completion.add_attribute(pixbufcell, 'pixbuf', 1)
        completion.set_text_column(0)
        completion.set_inline_selection(True)

        self.pixbuf = utils.safe_gtk_pixbuf_load(gui.theme.image_theme.user)

        self.cmb_account = gtk.ComboBoxEntry(self.liststore, 0)
        self.cmb_account.set_tooltip_text(_('Account'))
        self.cmb_account.get_children()[0].set_completion(completion)
        self.cmb_account.get_children()[0].connect('key-press-event',
            self._on_account_key_press)
        self.cmb_account.connect('changed',
            self._on_account_changed)
        self.cmb_account.connect('key-release-event',
            self._on_account_key_release)

        self.btn_status = StatusButton.StatusButton()
        self.btn_status.set_tooltip_text(_('Status'))
        self.btn_status.set_status(e3.status.ONLINE)
        self.btn_status.set_size_request(34, -1)

        self.txt_password = gtk.Entry()
        self.txt_password.set_tooltip_text(_('Password'))
        self.txt_password.set_visibility(False)
        self.txt_password.connect('key-press-event',
            self._on_password_key_press)
        self.txt_password.connect('changed', self._on_password_changed)
        self.txt_password.set_sensitive(False)

        pix_account = utils.safe_gtk_pixbuf_load(gui.theme.image_theme.user)
        pix_password = utils.safe_gtk_pixbuf_load(gui.theme.image_theme.password)

        self.avatar = Avatar()

        self.remember_account = gtk.CheckButton(_('Remember me'))
        self.remember_password = gtk.CheckButton(_('Remember password'))
        self.auto_login = gtk.CheckButton(_('Auto-login'))

        self.remember_account.connect('toggled',
            self._on_remember_account_toggled)
        self.remember_password.connect('toggled',
            self._on_remember_password_toggled)
        self.auto_login.connect('toggled',
            self._on_auto_login_toggled)

        self.remember_account.set_sensitive(False)
        self.remember_password.set_sensitive(False)
        self.auto_login.set_sensitive(False)

        self.forget_me = gtk.Button()
        self.forget_me.set_tooltip_text(_('Delete user'))
        forget_img = gtk.image_new_from_stock(gtk.STOCK_CANCEL, gtk.ICON_SIZE_MENU)
        self.forget_me.set_image(forget_img)
        self.forget_me.set_relief(gtk.RELIEF_NONE)
        self.forget_me.set_border_width(0)
        self.forget_me.set_size_request(34, -1)
        self.forget_me.connect('clicked', self._on_forget_me_clicked)
        self.forget_me.set_sensitive(False)

        hboxremember = gtk.HBox(spacing=2)
        hboxremember.pack_start(self.remember_account, False)

        vbox_remember = gtk.VBox(spacing=4)
        vbox_remember.set_border_width(8)
        vbox_remember.pack_start(hboxremember)
        vbox_remember.pack_start(self.remember_password)
        vbox_remember.pack_start(self.auto_login)
        vbox_remember.pack_start(gtk.Label())

        self.b_connect = gtk.Button(stock=gtk.STOCK_CONNECT)
        self.b_connect.set_sensitive(False)

        self.b_cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
        self.b_cancel.connect('clicked', self._on_cancel_clicked)

        vbuttonbox = gtk.VButtonBox()
        vbuttonbox.set_spacing(8)
        vbuttonbox.pack_start(self.b_connect)
        vbuttonbox.pack_start(self.b_cancel)

        vbox_content = gtk.VBox()

        hbox_account = gtk.HBox(spacing=6)
        img_accountpix = gtk.Image()
        img_accountpix.set_from_pixbuf(utils.scale_nicely(pix_account))
        hbox_account.pack_start(img_accountpix, False)
        hbox_account.pack_start(self.cmb_account)
        hbox_account.pack_start(self.forget_me, False)

        hbox_password = gtk.HBox(spacing=6)
        img_password = gtk.Image()
        img_password.set_from_pixbuf(utils.scale_nicely(pix_password))
        hbox_password.pack_start(img_password, False)
        hbox_password.pack_start(self.txt_password)
        hbox_password.pack_start(self.btn_status, False)

        session_combo_store = gtk.ListStore(gtk.gdk.Pixbuf, str)
        crp = gtk.CellRendererPixbuf()
        crt = gtk.CellRendererText()
        crp.set_property("xalign", 0)
        crt.set_property("xalign", 0)

        self.session_combo = gtk.ComboBox()
        self.session_combo.set_tooltip_text(_('Choose your network'))
        self.session_combo.set_model(session_combo_store)
        self.session_combo.pack_start(crp)
        self.session_combo.pack_start(crt)
        self.session_combo.add_attribute(crp, "pixbuf", 0)
        self.session_combo.add_attribute(crt, "text", 1)

        self.b_preferences = gtk.Button()
        self.b_preferences.set_tooltip_text(_('Preferences'))
        self.img_preferences = gtk.image_new_from_stock(gtk.STOCK_PREFERENCES,
            gtk.ICON_SIZE_MENU)
        self.img_preferences.set_sensitive(False)
        self.b_preferences.set_image(self.img_preferences)
        self.b_preferences.set_relief(gtk.RELIEF_NONE)
        self.b_preferences.connect('enter-notify-event',
            self._on_preferences_enter)
        self.b_preferences.connect('leave-notify-event',
            self._on_preferences_leave)
        self.b_preferences.connect('clicked',
            self._on_preferences_selected)
        self.b_preferences.set_size_request(34, -1)

        img_sessionpix = gtk.image_new_from_stock(gtk.STOCK_CONNECT, gtk.ICON_SIZE_MENU)
        img_sessionpix.set_size_request(20, -1)
        img_sessionpix.set_sensitive(False)
        hbox_session = gtk.HBox(spacing=6)
        hbox_session.pack_start(img_sessionpix, False)
        hbox_session.pack_start(self.session_combo)
        hbox_session.pack_start(self.b_preferences, False)

        vbox_entries = gtk.VBox(spacing=12)
        vbox_entries.set_border_width(8)
        vbox_entries.pack_start(hbox_account)
        vbox_entries.pack_start(hbox_password)
        vbox_entries.pack_start(hbox_session)

        self.nicebar = NiceBar()

        th_pix = utils.safe_gtk_pixbuf_load(gui.theme.image_theme.throbber, None,
                animated=True)
        self.throbber = gtk.image_new_from_animation(th_pix)
        self.label_timer = gtk.Label()
        self.label_timer.set_markup(_('<b>Connection error!\n </b>'))

        al_label_timer = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0,
            yscale=0.0)
        al_throbber = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.1,
            yscale=0.1)
        al_vbox_entries = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.2,
            yscale=0.0)
        al_vbox_remember = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0,
            yscale=0.2)
        al_button = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.2)
        al_account = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0,
            yscale=0.3)

        al_label_timer.add(self.label_timer)
        al_throbber.add(self.throbber)
        al_vbox_entries.add(vbox_entries)
        al_vbox_remember.add(vbox_remember)
        al_button.add(vbuttonbox)
        al_account.add(self.avatar)

        vbox = gtk.VBox()
        vbox_top = gtk.VBox()
        vbox_far_bottom = gtk.VBox()

        vbox_bottom = gtk.VBox(False)
        vbox_content.pack_start(gtk.Label(""), True, True)
        vbox_content.pack_start(al_account, True, False)
        vbox_content.pack_start(gtk.Label(""), True, True)
        vbox_content.pack_start(al_vbox_entries, False)
        vbox_content.pack_start(al_vbox_remember, True, False)
        vbox_bottom.set_size_request(-1, 100)
        vbox_bottom.pack_start(al_label_timer, True, False)
        vbox_bottom.pack_start(al_throbber, False)
        vbox_bottom.pack_start(gtk.Label(""), True, True)
        vbox_bottom.pack_start(al_button)
        vbox_content.pack_start(vbox_bottom)
        vbox_content.pack_start(gtk.Label(""), True, True)

        vbox.pack_start(self.nicebar, False)
        vbox.pack_start(vbox_top)
        vbox.pack_start(vbox_content)
        vbox.pack_start(vbox_far_bottom)

        self.add(vbox)
        vbox.show_all()
Exemplo n.º 22
0
    def __init__(self):
        # GTK Stuffs
        self.parent = common.get_toplevel_window()
        self.dialog = gtk.Dialog(title=_('Login'), parent=self.parent,
            flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT)
        self.dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        self.dialog.set_icon(TRYTON_ICON)

        tooltips = common.Tooltips()
        button_cancel = gtk.Button(_('_Cancel'), use_underline=True)
        img_cancel = gtk.Image()
        img_cancel.set_from_stock('gtk-cancel', gtk.ICON_SIZE_BUTTON)
        button_cancel.set_image(img_cancel)
        tooltips.set_tip(button_cancel,
            _('Cancel connection to the Tryton server'))
        self.dialog.add_action_widget(button_cancel, gtk.RESPONSE_CANCEL)
        self.button_connect = gtk.Button(_('C_onnect'), use_underline=True)
        img_connect = gtk.Image()
        img_connect.set_from_stock('tryton-connect', gtk.ICON_SIZE_BUTTON)
        self.button_connect.set_image(img_connect)
        self.button_connect.set_can_default(True)
        tooltips.set_tip(self.button_connect, _('Connect the Tryton server'))
        self.dialog.add_action_widget(self.button_connect, gtk.RESPONSE_OK)
        self.dialog.set_default_response(gtk.RESPONSE_OK)
        alignment = gtk.Alignment(yalign=0, yscale=0, xscale=1)
        self.table_main = gtk.Table(3, 3, False)
        self.table_main.set_border_width(0)
        self.table_main.set_row_spacings(3)
        self.table_main.set_col_spacings(3)
        alignment.add(self.table_main)
        self.dialog.vbox.pack_start(alignment, True, True, 0)

        image = gtk.Image()
        image.set_from_file(os.path.join(PIXMAPS_DIR, 'tryton.png'))
        image.set_alignment(0.5, 1)
        ebox = gtk.EventBox()
        ebox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#1b2019"))
        ebox.add(image)
        self.table_main.attach(ebox, 0, 3, 0, 1, ypadding=2)

        self.profile_store = gtk.ListStore(gobject.TYPE_STRING,
            gobject.TYPE_BOOLEAN)
        self.combo_profile = gtk.ComboBox()
        cell = gtk.CellRendererText()
        self.combo_profile.pack_start(cell, True)
        self.combo_profile.add_attribute(cell, 'text', 0)
        self.combo_profile.add_attribute(cell, 'sensitive', 1)
        self.combo_profile.set_model(self.profile_store)
        self.combo_profile.connect('changed', self.profile_changed)
        self.profile_label = gtk.Label(_(u'Profile:'))
        self.profile_label.set_justify(gtk.JUSTIFY_RIGHT)
        self.profile_label.set_alignment(1, 0.5)
        self.profile_label.set_padding(3, 3)
        self.profile_button = gtk.Button(_('_Manage profiles'),
            use_underline=True)
        self.profile_button.connect('clicked', self.profile_manage)
        self.table_main.attach(self.profile_label, 0, 1, 1, 2,
            xoptions=gtk.FILL)
        self.table_main.attach(self.combo_profile, 1, 2, 1, 2)
        self.table_main.attach(self.profile_button, 2, 3, 1, 2,
            xoptions=gtk.FILL)
        image = gtk.Image()
        image.set_from_stock('gtk-edit', gtk.ICON_SIZE_BUTTON)
        self.profile_button.set_image(image)
        self.expander = gtk.Expander()
        self.expander.set_label(_('Host / Database information'))
        self.expander.connect('notify::expanded', self.expand_hostspec)
        self.table_main.attach(self.expander, 0, 3, 3, 4)
        self.label_host = gtk.Label(_('Host:'))
        self.label_host.set_justify(gtk.JUSTIFY_RIGHT)
        self.label_host.set_alignment(1, 0.5)
        self.label_host.set_padding(3, 3)
        self.entry_host = gtk.Entry()
        self.entry_host.connect_after('focus-out-event',
            self.clear_profile_combo)
        self.entry_host.set_activates_default(True)
        self.label_host.set_mnemonic_widget(self.entry_host)
        self.table_main.attach(self.label_host, 0, 1, 4, 5, xoptions=gtk.FILL)
        self.table_main.attach(self.entry_host, 1, 3, 4, 5)
        self.label_database = gtk.Label(_('Database:'))
        self.label_database.set_justify(gtk.JUSTIFY_RIGHT)
        self.label_database.set_alignment(1, 0.5)
        self.label_database.set_padding(3, 3)
        self.entry_database = gtk.Entry()
        self.entry_database.connect_after('focus-out-event',
            self.clear_profile_combo)
        self.entry_database.set_activates_default(True)
        self.label_database.set_mnemonic_widget(self.entry_database)
        self.table_main.attach(self.label_database, 0, 1, 5, 6,
            xoptions=gtk.FILL)
        self.table_main.attach(self.entry_database, 1, 3, 5, 6)
        self.entry_login = gtk.Entry()
        self.entry_login.set_activates_default(True)
        self.table_main.attach(self.entry_login, 1, 3, 6, 7)
        label_username = gtk.Label(_("User name:"))
        label_username.set_alignment(1, 0.5)
        label_username.set_padding(3, 3)
        label_username.set_mnemonic_widget(self.entry_login)
        self.table_main.attach(label_username, 0, 1, 6, 7, xoptions=gtk.FILL)

        # Profile informations
        self.profile_cfg = os.path.join(get_config_dir(), 'profiles.cfg')
        self.profiles = ConfigParser.SafeConfigParser({'port': '8000'})
        if not os.path.exists(self.profile_cfg):
            short_version = '.'.join(__version__.split('.', 2)[:2])
            name = 'demo%s.tryton.org' % short_version
            self.profiles.add_section(name)
            self.profiles.set(name, 'host', name)
            self.profiles.set(name, 'port', '8000')
            self.profiles.set(name, 'database', 'demo%s' % short_version)
            self.profiles.set(name, 'username', 'demo')
        else:
            self.profiles.read(self.profile_cfg)
        for section in self.profiles.sections():
            active = all(self.profiles.has_option(section, option)
                for option in ('host', 'port', 'database'))
            self.profile_store.append([section, active])
Exemplo n.º 23
0
    def create_build_gui(self):
        vbox = gtk.VBox(False, 12)
        vbox.set_border_width(6)
        vbox.show()

        hbox = gtk.HBox(False, 12)
        hbox.show()
        vbox.pack_start(hbox, expand=False, fill=False)

        label = gtk.Label("Machine:")
        label.show()
        hbox.pack_start(label, expand=False, fill=False, padding=6)
        self.machine_combo = gtk.combo_box_new_text()
        self.machine_combo.show()
        self.machine_combo.set_tooltip_text(
            "Selects the architecture of the target board for which you would like to build an image."
        )
        hbox.pack_start(self.machine_combo,
                        expand=False,
                        fill=False,
                        padding=6)
        label = gtk.Label("Base image:")
        label.show()
        hbox.pack_start(label, expand=False, fill=False, padding=6)
        self.image_combo = gtk.ComboBox()
        self.image_combo.show()
        self.image_combo.set_tooltip_text(
            "Selects the image on which to base the created image")
        image_combo_cell = gtk.CellRendererText()
        self.image_combo.pack_start(image_combo_cell, True)
        self.image_combo.add_attribute(image_combo_cell, 'text',
                                       self.model.COL_NAME)
        hbox.pack_start(self.image_combo, expand=False, fill=False, padding=6)
        self.progress = gtk.ProgressBar()
        self.progress.set_size_request(250, -1)
        hbox.pack_end(self.progress, expand=False, fill=False, padding=6)

        ins = gtk.Notebook()
        vbox.pack_start(ins, expand=True, fill=True)
        ins.set_show_tabs(True)
        label = gtk.Label("Packages")
        label.show()
        ins.append_page(self.pkgsaz(), tab_label=label)
        label = gtk.Label("Package Collections")
        label.show()
        ins.append_page(self.tasks(), tab_label=label)
        ins.set_current_page(0)
        ins.show_all()

        hbox = gtk.HBox(False, 1)
        hbox.show()
        label = gtk.Label("Estimated image contents:")
        self.model.connect("contents-changed", self.update_package_count_cb,
                           label)
        label.set_property("xalign", 0.00)
        label.show()
        hbox.pack_start(label, expand=False, fill=False, padding=6)
        info = gtk.Button("?")
        info.set_tooltip_text("What does this mean?")
        info.show()
        info.connect("clicked", self.info_button_clicked_cb)
        hbox.pack_start(info, expand=False, fill=False, padding=6)
        vbox.pack_start(hbox, expand=False, fill=False, padding=6)
        con = self.contents()
        con.show()
        vbox.pack_start(con, expand=True, fill=True)

        bbox = gtk.HButtonBox()
        bbox.set_spacing(12)
        bbox.set_layout(gtk.BUTTONBOX_END)
        bbox.show()
        vbox.pack_start(bbox, expand=False, fill=False)
        reset = gtk.Button("Reset")
        reset.connect("clicked", self.reset_clicked_cb)
        reset.show()
        bbox.add(reset)
        bake = gtk.Button("Bake")
        bake.connect("clicked", self.bake_clicked_cb)
        bake.show()
        bbox.add(bake)

        return vbox
Exemplo n.º 24
0
    def __init__(self, core, main):
        super(TopButtons,self).__init__(False, 1)

        self.main = main

        self.uicore = core
        self.toolbox = self
        self.dependency_check = self.main.dependency_check

        self.img_path = os.path.dirname(__file__) + os.sep + 'data' + os.sep
        self.options_dict = {'Hexadecimal':'x', 'String':'s', 'String no case':'i', 'Regexp':'r', 'Unicode':'u', 'Unicode no case':'U'}

        self.main_tb = gtk.Toolbar()
        self.main_tb.set_style(gtk.TOOLBAR_ICONS)

        # New file button
        self.new_tb = gtk.MenuToolButton(gtk.STOCK_NEW)
        self.new_tb.set_label("New")
        self.new_tb.set_tooltip_text('Open new file')
        self.new_tb.connect("clicked", self.new_file)
        self.main_tb.insert(self.new_tb, 0)

        # Rcent files menu
        self.manager = gtk.recent_manager_get_default()
        self.recent_menu = gtk.RecentChooserMenu(self.manager)
        self.new_tb.set_menu(self.recent_menu)
        self.new_tb.set_arrow_tooltip_text('Recent opened files')
        self.recent_menu.connect('item-activated', self.recent_kb)

        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.main_tb.insert(self.sep, 1)

        # PDF Streams search
        self.streams_tb = gtk.ToolButton(gtk.STOCK_INDEX)
        self.streams_tb.set_tooltip_text('Find PDF streams')
        self.streams_tb.connect("clicked", self.search_pdfstreams)
        self.streams_tb.set_sensitive(False)
        self.main_tb.insert(self.streams_tb, 2)
        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.main_tb.insert(self.sep, 3)

        # URL related buttons

        i = gtk.Image()
        pixbuf = gtk.gdk.pixbuf_new_from_file(self.img_path + 'response-headers.png')
        scaled_buf = pixbuf.scale_simple(24,24,gtk.gdk.INTERP_BILINEAR)
        i.set_from_pixbuf(scaled_buf)
        self.urls = gtk.MenuToolButton(i, 'URL')
        #self.urls.set_icon_widget(i)
        self.urls.set_tooltip_text('URL plugins')
        self.urls_menu = gtk.Menu()

        i = gtk.Image()
        pixbuf = gtk.gdk.pixbuf_new_from_file(self.img_path + 'response-headers.png')
        scaled_buf = pixbuf.scale_simple(16,16,gtk.gdk.INTERP_BILINEAR)
        i.set_from_pixbuf(scaled_buf)
        item = gtk.ImageMenuItem('Search for URL')
        item.set_image(i)
        item.connect("activate", self.show_urls)
        self.urls_menu.append(item)

        i = gtk.Image()
        pixbuf = gtk.gdk.pixbuf_new_from_file(self.img_path + 'response-body.png')
        scaled_buf = pixbuf.scale_simple(16,16,gtk.gdk.INTERP_BILINEAR)
        i.set_from_pixbuf(scaled_buf)
        item = gtk.ImageMenuItem('Check URL')
        item.set_image(i)
        item.connect("activate", self.check_urls)
        self.urls_menu.append(item)

        i = gtk.Image()
        pixbuf = gtk.gdk.pixbuf_new_from_file(self.img_path + 'request-body.png')
        scaled_buf = pixbuf.scale_simple(16,16,gtk.gdk.INTERP_BILINEAR)
        i.set_from_pixbuf(scaled_buf)
        item = gtk.ImageMenuItem('Check bad URL')
        item.set_image(i)
        item.connect("activate", self.check_bad_urls)
        self.urls_menu.append(item)

        self.urls_menu.show_all()

        self.urls.set_menu(self.urls_menu)
        self.urls_menu.show_all()
        self.main_tb.insert(self.urls, 4)

        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.main_tb.insert(self.sep, 5)

        # Visualizatin buttons
        self.visbin_tb = gtk.ToolButton(gtk.STOCK_ZOOM_FIT)
        self.visbin_tb.connect("clicked", self.execute, 'binvi')
        self.visbin_tb.set_tooltip_text('Visualize binary')
        self.visbin_tb.set_sensitive(False)
        self.main_tb.insert(self.visbin_tb, 6)
        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.main_tb.insert(self.sep, 7)

        # Binary analysis buttons
        self.vtotal_tb = gtk.ToolButton(gtk.STOCK_CONNECT)
        self.vtotal_tb.connect("clicked", self.send_to_virustotal)
        self.vtotal_tb.set_tooltip_text('Send to VirusTotal')
        self.vtotal_tb.set_sensitive(False)
        self.main_tb.insert(self.vtotal_tb, 8)

        self.threat_tb = gtk.ToolButton(gtk.STOCK_JUMP_TO)
        self.threat_tb.connect("clicked", self.execute, 'threat')
        self.threat_tb.set_tooltip_text('Search in Threat Expert')
        self.threat_tb.set_sensitive(False)
        self.main_tb.insert(self.threat_tb, 9)

        self.shellcode_tb = gtk.ToolButton(gtk.STOCK_FIND)
        self.shellcode_tb.connect("clicked", self.search_shellcode)
        self.shellcode_tb.set_tooltip_text('Search for Shellcode')
        self.shellcode_tb.set_sensitive(False)
        self.main_tb.insert(self.shellcode_tb, 10)

        # not yet working properly
        self.antivm_tb = gtk.ToolButton(gtk.STOCK_FIND_AND_REPLACE)
        self.antivm_tb.connect("clicked", self.search_antivm)
        self.antivm_tb.set_tooltip_text('Search for antivm tricks')
        self.antivm_tb.set_sensitive(False)
        self.main_tb.insert(self.antivm_tb, 11)

        self.packed_tb = gtk.ToolButton(gtk.STOCK_CONVERT)
        self.packed_tb.connect("clicked", self.check_packer)
        self.packed_tb.set_tooltip_text('Check if the PE file is packed')
        self.packed_tb.set_sensitive(False)
        self.main_tb.insert(self.packed_tb, 12)

        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.main_tb.insert(self.sep, 13)

        # Search components
        self.search_combo_tb = gtk.ToolItem()
        self.search_combo_align = gtk.Alignment(yalign=0.5)
        store = gtk.ListStore(gtk.gdk.Pixbuf, str)
        self.search_combo = gtk.ComboBox(store)
        rendererText = gtk.CellRendererText()
        rendererPix = gtk.CellRendererPixbuf()
        self.search_combo.pack_start(rendererPix, False)
        self.search_combo.pack_start(rendererText, True)
        self.search_combo.add_attribute(rendererPix, 'pixbuf', 0)
        self.search_combo.add_attribute(rendererText, 'text', 1)

        options = {
            'String':gtk.gdk.pixbuf_new_from_file(os.path.dirname(__file__) + os.sep + 'data' + os.sep + 'icon_string_16.png'),
            'String no case':gtk.gdk.pixbuf_new_from_file(os.path.dirname(__file__) + os.sep + 'data' + os.sep + 'icon_string_no_case_16.png'),
            'Hexadecimal':gtk.gdk.pixbuf_new_from_file(os.path.dirname(__file__) + os.sep + 'data' + os.sep + 'icon_hexadecimal_16.png'),
            'Regexp':gtk.gdk.pixbuf_new_from_file(os.path.dirname(__file__) + os.sep + 'data' + os.sep + 'icon_regexp_16.png')
        }

        for option in options.keys():
            store.append([options[option], option])
        self.search_combo.set_active(0)
        self.search_combo_align.add(self.search_combo)
        self.search_combo_tb.add(self.search_combo_align)
        self.main_tb.insert(self.search_combo_tb, 14)

        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.sep.set_draw(False)
        self.main_tb.insert(self.sep, 15)

        self.search_entry_tb = gtk.ToolItem()
        self.search_entry = gtk.Entry(100)
        self.search_entry.set_text('Text to search')
        self.search_entry.set_icon_from_stock(1, gtk.STOCK_FIND)
        self.search_entry.set_icon_tooltip_text(1, 'Search')
        self.search_entry.connect("activate", self.search)
        self.search_entry.connect("icon-press", self.search)
        self.search_entry.connect('focus-in-event', self._clean, 'in')
        self.search_entry.connect('focus-out-event', self._clean, 'out')
        self.search_entry_tb.add(self.search_entry)
        self.main_tb.insert(self.search_entry_tb, 16)

        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.main_tb.insert(self.sep, 17)

        # Cheatsheet button
        self.cheatsheet_tb = gtk.ToolButton(gtk.STOCK_JUSTIFY_FILL)
        self.cheatsheet_tb.set_tooltip_text('Show assembler reference sheet')
        self.cheatsheet_tb.connect("clicked", self.create_cheatsheet_dialog)
        self.main_tb.insert(self.cheatsheet_tb, 18)

        # Separator
        self.sep = gtk.SeparatorToolItem()
        self.sep.set_expand(True)
        self.sep.set_draw(False)
        self.main_tb.insert(self.sep, 19)

        # Exit button
        self.exit_tb = gtk.ToolButton(gtk.STOCK_QUIT)
        self.exit_tb.set_label('Quit')
        self.exit_tb.connect("clicked", self.main.quit)
        self.exit_tb.set_tooltip_text('Have a nice day ;-)')
        self.main_tb.insert(self.exit_tb, 20)

        # Throbber
        self.throbber = throbber.Throbber()
        self.throbber_tb = gtk.ToolItem()
        self.throbber_tb.add(self.throbber)
        self.main_tb.insert(self.throbber_tb, 21)

        self.toolbox.pack_start(self.main_tb, True, True)


        self.show_all()
Exemplo n.º 25
0
    def __init__(self):
        logger = logging.getLogger('INIT')
        self.uimanager = gtk.UIManager()
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        gtk.window_set_default_icon_from_file(IMGDIR + "icon.png")
        self.window.set_size_request(490, 420)
        self.window.set_title("leo-lookup Version " + self.__version__)
        self.window.connect("destroy", self.destroyWin)

        self.box = gtk.VBox(False, 5)

        self.menubar_acts = [('File', None, "_File"),
                             ('Quit', gtk.STOCK_QUIT, "_Quit", None,
                              "Close Program", self.destroyWin),
                             ('Extensions', None, "_Extensions"),
                             ('ext_prefs', None, "_Preferences", None,
                              "Set prefereences for extensions", None),
                             ('Help', None, "_Help"),
                             ('aboutdlg', None, "_About", None,
                              "View informations about leo-lookup.", None)]

        self.actgroup = gtk.ActionGroup("LEO_LOOKUP")
        self.actgroup.add_actions(self.menubar_acts)

        accelgroup = self.uimanager.get_accel_group()
        self.window.add_accel_group(accelgroup)
        self.uimanager.add_ui_from_string(self.menubardesc)
        self.uimanager.insert_action_group(self.actgroup, 0)
        self.menubar = self.uimanager.get_widget("/Mainmenu")
        self.box.pack_start(self.menubar, False)

        self.word2lookup = gtk.Entry()
        self.word2lookup.set_text("Enter word to lookup here ...")
        self.box.pack_start(self.word2lookup, False, False, 0)

        self.box2 = gtk.HBox(False, 6)

        self.fromLangLabel = gtk.Label("From ")
        self.box2.pack_start(self.fromLangLabel, False, False, 0)

        # Create combo box for the language to translate from
        self.lstst_fromLang = gtk.ListStore(gtk.gdk.Pixbuf, str)
        self.fromLang = gtk.ComboBox(self.lstst_fromLang)
        cellpb = gtk.CellRendererPixbuf()
        cellt = gtk.CellRendererText()
        self.fromLang.pack_start(cellpb, True)
        self.fromLang.pack_start(cellt, True)
        self.fromLang.add_attribute(cellpb, 'pixbuf', 0)
        self.fromLang.add_attribute(cellt, 'text', 1)

        # add languages to combobox
        for lang in self.supportedLangs:
            self.lstst_fromLang.append(
                [gtk.gdk.pixbuf_new_from_file(IMGDIR + lang + ".png"), lang])
        self.fromLang.set_active(0)
        self.box2.pack_start(self.fromLang, False, False, 0)

        self.swapToFrom = gtk.Button("<>")
        self.swapToFrom.connect("clicked", self.swapToFromClicked)
        self.box2.pack_start(self.swapToFrom, False, False, 0)

        self.toLangLabel = gtk.Label("to ")
        self.box2.pack_start(self.toLangLabel, False, False, 0)

        # Create combo box for the language to translate to
        self.lstst_toLang = gtk.ListStore(gtk.gdk.Pixbuf, str)
        self.toLang = gtk.ComboBox(self.lstst_toLang)
        self.toLang.pack_start(cellpb, True)
        self.toLang.pack_start(cellt, True)
        self.toLang.add_attribute(cellpb, 'pixbuf', 0)
        self.toLang.add_attribute(cellt, 'text', 1)
        for lang in self.supportedLangs:
            self.lstst_toLang.append(
                [gtk.gdk.pixbuf_new_from_file(IMGDIR + lang + ".png"), lang])
        self.toLang.set_active(1)

        self.box2.pack_start(self.toLang, False, False, 0)

        # Create indicator of successes
        self.results = gtk.Label("")
        self.box2.pack_end(self.results, False, False, 0)

        self.box.pack_start(self.box2, False, False, 0)

        self.lookup = gtk.Button("Look up!")
        self.lookup.connect("clicked", self.onTransClick)
        self.box.pack_start(self.lookup, False, False, 0)

        self.scrollcont = gtk.ScrolledWindow()
        self.scrollcont.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)

        self.meanings = gtk.ListStore(str, str)
        self.listOfMeanings = gtk.TreeView(self.meanings)
        self.listOfMeaningsCol = gtk.TreeViewColumn("Foreign Lang.")
        self.listOfMeanings.append_column(self.listOfMeaningsCol)
        cell = gtk.CellRendererText()
        self.listOfMeaningsCol.pack_start(cell, True)
        self.listOfMeaningsCol.add_attribute(cell, 'text', 0)

        self.listOfMeaningsCol2 = gtk.TreeViewColumn("Familiar Lang.")
        self.listOfMeanings.append_column(self.listOfMeaningsCol2)
        cell2 = gtk.CellRendererText()
        self.listOfMeaningsCol2.pack_start(cell2, True)
        self.listOfMeaningsCol2.add_attribute(cell2, 'text', 1)

        self.lom_treesel = self.listOfMeanings.get_selection()
        self.lom_treesel.set_mode(gtk.SELECTION_MULTIPLE)

        self.scrollcont.add(self.listOfMeanings)
        self.box.pack_start(self.scrollcont, True, True, 0)

        self.box.show_all()

        self.window.add(self.box)
        logger.info("window constructed, let's make it visible ...")
        self.window.show_all()

        logger.info("initializing plugin architecture ...")
        pm = plugins.plugin_manager(self.uimanager, self.lom_treesel,
                                    PLUGINDIR)
        pm.load_plugins()
        gtk.main()