Ejemplo n.º 1
0
def show_preferences(parent, driver, gconf_client, gconf_key):
    widget_tree = gtk.Builder()
    widget_tree.add_from_file(os.path.join(os.path.dirname(__file__), "trafficstats.ui"))
    dialog = widget_tree.get_object("TrafficStats")

    # Resets the value of the use_vnstat flag if vnstat is not installed
    vnstat_installed = g15os.is_program_in_path('vnstat')
    if not vnstat_installed:
        gconf_client.set_bool("%s/use_vnstat" % gconf_key, False)

    # Displays a warning message to the user if vnstat is not installed
    warning = widget_tree.get_object("NoVnstatMessage")
    warning.set_visible(not vnstat_installed)

    # Disables the vnstat checkbox if vnstat is not installed
    use_vnstat = widget_tree.get_object('UseVnstat')
    use_vnstat.set_sensitive(vnstat_installed)

    g15uigconf.configure_checkbox_from_gconf(gconf_client, gconf_key + "/use_vnstat", "UseVnstat", vnstat_installed, widget_tree)
    ndevice = widget_tree.get_object("NetDevice")
    for netdev in gtop.netlist():
        ndevice.append([netdev])
    g15uigconf.configure_combo_from_gconf(gconf_client, gconf_key + "/networkdevice", "NetworkDevice", "lo", widget_tree)
    g15uigconf.configure_adjustment_from_gconf(gconf_client, gconf_key + "/refresh_interval", "RefreshingScale", 10.0, widget_tree)
    dialog.set_transient_for(parent)
    dialog.run()
    dialog.hide()
Ejemplo n.º 2
0
    def __init__(self, parent, driver, gconf_client, gconf_key):
        self.gconf_client = gconf_client
        self.gconf_key = gconf_key
        widget_tree = gtk.Builder()
        widget_tree.add_from_file(
            os.path.join(os.path.dirname(__file__), "lcdshot.ui"))
        dialog = widget_tree.get_object("LCDShotDialog")
        dialog.set_transient_for(parent)
        chooser = gtk.FileChooserDialog("Open..", None,
                                        gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
                                        (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                         gtk.STOCK_OPEN, gtk.RESPONSE_OK))
        chooser.set_default_response(gtk.RESPONSE_OK)
        chooser_button = widget_tree.get_object("FileChooserButton")
        chooser_button.dialog = chooser
        chooser_button.connect("file-set", self._file_set)
        chooser_button.connect("file-activated", self._file_activated)
        chooser_button.connect("current-folder-changed", self._file_activated)
        bg_img = g15gconf.get_string_or_default(
            self.gconf_client, "%s/folder" % self.gconf_key,
            os.path.expanduser("~/Desktop"))
        chooser_button.set_current_folder(bg_img)

        # Reset the value of the mode setting to 'still' if mencoder is not installed
        mencoder_is_installed = g15os.is_program_in_path('mencoder')
        if not mencoder_is_installed:
            gconf_client.set_string("%s/mode" % self.gconf_key, "still")

        # Initialize the mode combobox content
        modes = widget_tree.get_object("ModeModel")
        modes.clear()
        modes.append(('still', 'Still', True))
        modes.append(('video', 'Video', mencoder_is_installed))

        # Display a warning message to the user if mencoder is not installed
        warning = widget_tree.get_object("NoVideoMessage")
        warning.set_visible(not mencoder_is_installed)

        g15uigconf.configure_combo_from_gconf(self.gconf_client,
                                              "%s/mode" % self.gconf_key,
                                              "Mode", "still", widget_tree)
        mode = widget_tree.get_object("Mode")
        mode.connect("changed", self._mode_changed)

        g15uigconf.configure_spinner_from_gconf(self.gconf_client,
                                                "%s/fps" % gconf_key, "FPS",
                                                10, widget_tree, False)
        self._spinner = widget_tree.get_object("FPS")
        self._mode_changed(mode)

        dialog.run()
        dialog.hide()
Ejemplo n.º 3
0
    def __init__(self, parent, driver, gconf_client, gconf_key):
        self.gconf_client = gconf_client
        self.gconf_key = gconf_key
        widget_tree = gtk.Builder()
        widget_tree.add_from_file(os.path.join(os.path.dirname(__file__), "lcdshot.ui"))
        dialog = widget_tree.get_object("LCDShotDialog")
        dialog.set_transient_for(parent)        
        chooser = gtk.FileChooserDialog("Open..",
                               None,
                               gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
                               (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                gtk.STOCK_OPEN, gtk.RESPONSE_OK))
        chooser.set_default_response(gtk.RESPONSE_OK)
        chooser_button = widget_tree.get_object("FileChooserButton")        
        chooser_button.dialog = chooser 
        chooser_button.connect("file-set", self._file_set)
        chooser_button.connect("file-activated", self._file_activated)
        chooser_button.connect("current-folder-changed", self._file_activated)
        bg_img = g15gconf.get_string_or_default(self.gconf_client, "%s/folder" % self.gconf_key, os.path.expanduser("~/Desktop"))
        chooser_button.set_current_folder(bg_img)

        # Reset the value of the mode setting to 'still' if mencoder is not installed
        mencoder_is_installed = g15os.is_program_in_path('mencoder')
        if not mencoder_is_installed:
            gconf_client.set_string("%s/mode" % self.gconf_key, "still")

        # Initialize the mode combobox content
        modes = widget_tree.get_object("ModeModel")
        modes.clear()
        modes.append(('still','Still', True))
        modes.append(('video','Video', mencoder_is_installed))

        # Display a warning message to the user if mencoder is not installed
        warning = widget_tree.get_object("NoVideoMessage")
        warning.set_visible(not mencoder_is_installed)

        g15uigconf.configure_combo_from_gconf(self.gconf_client, "%s/mode" % self.gconf_key, "Mode", "still", widget_tree)
        mode = widget_tree.get_object("Mode")
        mode.connect("changed", self._mode_changed)

        g15uigconf.configure_spinner_from_gconf(self.gconf_client, "%s/fps" % gconf_key, "FPS", 10, widget_tree, False)
        self._spinner = widget_tree.get_object("FPS")
        self._mode_changed(mode)

        dialog.run()
        dialog.hide()
Ejemplo n.º 4
0
def show_preferences(parent, driver, gconf_client, gconf_key):
    widget_tree = gtk.Builder()
    widget_tree.add_from_file(
        os.path.join(os.path.dirname(__file__), "trafficstats.ui"))
    dialog = widget_tree.get_object("TrafficStats")

    # Resets the value of the use_vnstat flag if vnstat is not installed
    vnstat_installed = g15os.is_program_in_path('vnstat')
    if not vnstat_installed:
        gconf_client.set_bool("%s/use_vnstat" % gconf_key, False)

    # Displays a warning message to the user if vnstat is not installed
    warning = widget_tree.get_object("NoVnstatMessage")
    warning.set_visible(not vnstat_installed)

    # Disables the vnstat checkbox if vnstat is not installed
    use_vnstat = widget_tree.get_object('UseVnstat')
    use_vnstat.set_sensitive(vnstat_installed)

    g15uigconf.configure_checkbox_from_gconf(gconf_client,
                                             gconf_key + "/use_vnstat",
                                             "UseVnstat", vnstat_installed,
                                             widget_tree)
    ndevice = widget_tree.get_object("NetDevice")
    for netdev in gtop.netlist():
        ndevice.append([netdev])
    g15uigconf.configure_combo_from_gconf(gconf_client,
                                          gconf_key + "/networkdevice",
                                          "NetworkDevice", "lo", widget_tree)
    g15uigconf.configure_adjustment_from_gconf(gconf_client,
                                               gconf_key + "/refresh_interval",
                                               "RefreshingScale", 10.0,
                                               widget_tree)
    dialog.set_transient_for(parent)
    dialog.run()
    dialog.hide()