Exemple #1
0
    def save_change(self):
        self.conf.launcher[self.ind]['time'] = self.time_format.get_text()
        self.conf.launcher[self.ind]['time_color'] = gtk.color_selection_palette_to_string([self.time_color.get_color()])
        self.conf.launcher[self.ind]['time_font'] = self.time_font.get_font_name()
        self.conf.launcher[self.ind]['date'] = self.date_format.get_text()
        self.conf.launcher[self.ind]['date_color'] = gtk.color_selection_palette_to_string([self.date_color.get_color()])
        self.conf.launcher[self.ind]['date_font'] = self.date_font.get_font_name()
        self.conf.launcher[self.ind]['tooltip'] = self.tooltip_format.get_text()
        self.conf.launcher[self.ind]['mouseover'] = int(self.mouseover_checkbox.get_active())

        str_cfg = '['
        for elem in settings['alarmlist']:
            if elem.__class__ == dict:
                if not elem == {}:
                    str_cfg += '{'
                    for item in elem:
                        str_cfg += '\'%s\': \'%s\', ' % (item, elem[item])
                    str_cfg = str_cfg[:-2]
                    str_cfg += '}, '
                else:
                    str_cfg += '\'%s\', ' % (elem)
        if not settings['alarmlist'] == []:
          str_cfg = str_cfg[:-2]
        str_cfg += ']'

        self.conf.launcher[self.ind]['alarmlist'] = str_cfg
        self.conf.plg_mgr.plugins[self.ind].restart()
Exemple #2
0
    def __set_text_view(self):
        self.text_view.set_wrap_mode(gtk.WRAP_WORD)
        self.text_view.set_editable(False)

        self.tag_font = self.text_view.get_buffer().create_tag(None)
        self.tag_font.set_property("family", "Monospace")
        for property in self.HIGHLIGHT_PROPERTIES:
            settings = self.nmap_highlight.__getattribute__(property)
            tag = self.text_view.get_buffer().create_tag(property)

            if settings[0]:
                tag.set_property("weight", pango.WEIGHT_HEAVY)
            else:
                tag.set_property("weight", pango.WEIGHT_NORMAL)

            if settings[1]:
                tag.set_property("style", pango.STYLE_ITALIC)
            else:
                tag.set_property("style", pango.STYLE_NORMAL)

            if settings[2]:
                tag.set_property("underline", pango.UNDERLINE_SINGLE)
            else:
                tag.set_property("underline", pango.UNDERLINE_NONE)

            text_color = settings[3]
            highlight_color = settings[4]

            tag.set_property(
                    "foreground", gtk.color_selection_palette_to_string(
                        [gtk.gdk.Color(*text_color), ]))
            tag.set_property(
                    "background", gtk.color_selection_palette_to_string(
                        [gtk.gdk.Color(*highlight_color), ]))
Exemple #3
0
    def __set_text_view(self):
        self.text_view.set_wrap_mode(gtk.WRAP_WORD)
        self.text_view.set_editable(False)

        self.tag_font = self.text_view.get_buffer().create_tag(None)
        self.tag_font.set_property("family", "Monospace")
        for property in self.HIGHLIGHT_PROPERTIES:
            settings = self.nmap_highlight.__getattribute__(property)
            tag = self.text_view.get_buffer().create_tag(property)

            if settings[0]:
                tag.set_property("weight", pango.WEIGHT_HEAVY)
            else:
                tag.set_property("weight", pango.WEIGHT_NORMAL)

            if settings[1]:
                tag.set_property("style", pango.STYLE_ITALIC)
            else:
                tag.set_property("style", pango.STYLE_NORMAL)

            if settings[2]:
                tag.set_property("underline", pango.UNDERLINE_SINGLE)
            else:
                tag.set_property("underline", pango.UNDERLINE_NONE)

            text_color = settings[3]
            highlight_color = settings[4]

            tag.set_property(
                    "foreground", gtk.color_selection_palette_to_string(
                        [gtk.gdk.Color(*text_color), ]))
            tag.set_property(
                    "background", gtk.color_selection_palette_to_string(
                        [gtk.gdk.Color(*highlight_color), ]))
Exemple #4
0
    def save_change(self):
        self.conf.launcher[self.ind]['time'] = self.time_format.get_text()
        self.conf.launcher[
            self.ind]['time_color'] = gtk.color_selection_palette_to_string(
                [self.time_color.get_color()])
        self.conf.launcher[
            self.ind]['time_font'] = self.time_font.get_font_name()
        self.conf.launcher[self.ind]['date'] = self.date_format.get_text()
        self.conf.launcher[
            self.ind]['date_color'] = gtk.color_selection_palette_to_string(
                [self.date_color.get_color()])
        self.conf.launcher[
            self.ind]['date_font'] = self.date_font.get_font_name()
        self.conf.launcher[
            self.ind]['tooltip'] = self.tooltip_format.get_text()
        self.conf.launcher[self.ind]['mouseover'] = int(
            self.mouseover_checkbox.get_active())

        str_cfg = '['
        for elem in settings['alarmlist']:
            if elem.__class__ == dict:
                if not elem == {}:
                    str_cfg += '{'
                    for item in elem:
                        str_cfg += '\'%s\': \'%s\', ' % (item, elem[item])
                    str_cfg = str_cfg[:-2]
                    str_cfg += '}, '
                else:
                    str_cfg += '\'%s\', ' % (elem)
        if not settings['alarmlist'] == []:
            str_cfg = str_cfg[:-2]
        str_cfg += ']'

        self.conf.launcher[self.ind]['alarmlist'] = str_cfg
        self.conf.plg_mgr.plugins[self.ind].restart()
 def save_change(self):
     self.conf.launcher[self.ind]['line1'] = self.line1_format.get_text()
     self.conf.launcher[self.ind]['line1_color'] = gtk.color_selection_palette_to_string([self.line1_color.get_color()])
     self.conf.launcher[self.ind]['line1_font'] = self.line1_font.get_font_name()
     self.conf.launcher[self.ind]['line2'] = self.line2_format.get_text()
     self.conf.launcher[self.ind]['line2_color'] = gtk.color_selection_palette_to_string([self.line2_color.get_color()])
     self.conf.launcher[self.ind]['line2_font'] = self.line2_font.get_font_name()
     self.conf.plg_mgr.plugins[self.ind].restart()
Exemple #6
0
 def save_change(self):
     self.conf.launcher[self.ind]['line1'] = self.line1_format.get_text()
     self.conf.launcher[self.ind]['line1_color'] = gtk.color_selection_palette_to_string([self.line1_color.get_color()])
     self.conf.launcher[self.ind]['line1_font'] = self.line1_font.get_font_name()
     self.conf.launcher[self.ind]['line2'] = self.line2_format.get_text()
     self.conf.launcher[self.ind]['line2_color'] = gtk.color_selection_palette_to_string([self.line2_color.get_color()])
     self.conf.launcher[self.ind]['line2_font'] = self.line2_font.get_font_name()
     self.conf.launcher[self.ind]['tooltip'] = self.tooltip_format.get_text()
     self.conf.plg_mgr.plugins[self.ind].restart()
 def save_change(self):
     self.settings['opacity'] = self.active_color.get_alpha()
     self.settings['active_color'] = gtk.color_selection_palette_to_string([self.active_color.get_color()])
     self.settings['padding'] = int(self.padding.get_value())
     self.settings['desktop_color'] = gtk.color_selection_palette_to_string([self.desk_color.get_color()])
     self.settings['desktop_font'] = self.desk_font.get_font_name()
     self.settings['show_desk_pos'] = int(self.show_desk_pos_checkbox.get_active())
     self.settings['show_desk_name'] = int(self.show_desk_name_checkbox.get_active())
     self.settings['show_all_win'] = int(self.show_all_win_checkbox.get_active())
     self.conf.plg_mgr.plugins[self.ind].restart()
Exemple #8
0
  def on_edit_account_save(self, widget=None):
    print "Saving..."
    
    service = self.services[self.account["service"]]
    is_new = "id" not in self.account
      
    if is_new: self.account["id"] = uuid.uuid1().hex
    
    for config in service["config"]:
      is_private = config.startswith("private:")
      config = config.replace("private:", "")
      widget = self.account_widget.ui.get_object(config)


      value = None

      for p in ["text", "active"]:
        if widget and hasattr(widget.props, p):
          value = getattr(widget.props, p)
          self.account[config] = value

      if widget and isinstance(widget, gtk.ColorButton):
        value = widget.get_color ()
        self.account[config] = value

      if is_private and self.account.has_key(config):
        if not self.account[config].startswith(":KEYRING:"):
	  self.account[config] = ":KEYRING:%s" % self.put_in_keyring(
	      self.account["id"], config, self.account[config])

      if value:
        if isinstance(value, gtk.gdk.Color):
          value = gtk.color_selection_palette_to_string(
            gtk.color_selection_palette_from_string(value.to_string()))
          self.account[config] = value

    if not self.verify_account(self.account): return False

    fn = "Create" if is_new else "Update"
    getattr(self.gwibber.accounts, fn)(json.dumps(self.account))

    self.ui.get_object('vbox_save').hide()
    self.ui.get_object('vbox_create').hide()

    # if we just fixed a failure case, hide the infobar
    if self.account["id"] == self.selected_account:
      if hasattr(gtk, "InfoBar"):
        self.infobar.hide()
      self.selected_account = None

    self.populate_account_tree()

    # Set the autostart gsettings key so we get loaded on login
    state = subprocess.Popen(['gsettings', 'get', state_interface, 'run'], stdout=subprocess.PIPE)
    res = state.communicate()[0]
    if "false" in res:
      subprocess.call(['gsettings', 'set', state_interface, 'run', 'true'])
      subprocess.call(['gsettings', 'set', settings_interface, 'autostart', 'true'])

    return True
 def save(self):
     """
     Save the colour to the options database.
     """
     c = self.widget.get_color()
     v = gtk.color_selection_palette_to_string([c])
     self.set_value(v)
Exemple #10
0
 def save(self):
     """
     Save the colour to the options database.
     """
     c = self.widget.get_color()
     v = gtk.color_selection_palette_to_string([c])
     self.set_value(v)
Exemple #11
0
 def save_change(self):
     self.settings['opacity'] = self.active_color.get_alpha()
     self.settings['active_color'] = gtk.color_selection_palette_to_string(
         [self.active_color.get_color()])
     self.settings['padding'] = int(self.padding.get_value())
     self.settings['desktop_color'] = gtk.color_selection_palette_to_string(
         [self.desk_color.get_color()])
     self.settings['desktop_font'] = self.desk_font.get_font_name()
     self.settings['show_desk_pos'] = int(
         self.show_desk_pos_checkbox.get_active())
     self.settings['show_desk_name'] = int(
         self.show_desk_name_checkbox.get_active())
     self.settings['show_all_win'] = int(
         self.show_all_win_checkbox.get_active())
     self.settings['expand'] = int(self.expand_checkbox.get_active())
     self.conf.plg_mgr.plugins[self.ind].restart()
Exemple #12
0
  def on_edit_account_save(self, widget=None):
    print "Saving..."
    
    service = self.services[self.account["service"]]
    is_new = "id" not in self.account
      
    if is_new: self.account["id"] = uuid.uuid1().hex
    
    for config in service["config"]:
      is_private = config.startswith("private:")
      config = config.replace("private:", "")
      widget = self.account_widget.ui.get_object(config)

      value = None

      for p in ["text", "active", "color"]:
        if widget and hasattr(widget.props, p):
          value = getattr(widget.props, p)
          self.account[config] = value

      if is_private and self.account.has_key(config):
        if not self.account[config].startswith(":KEYRING:"):
	  self.account[config] = ":KEYRING:%s" % self.put_in_keyring(
	      self.account["id"], config, self.account[config])

      if value:
        if isinstance(value, gtk.gdk.Color):
          value = gtk.color_selection_palette_to_string(
            gtk.color_selection_palette_from_string(value.to_string()))
          self.account[config] = value

    if not self.verify_account(self.account): return False

    fn = "Create" if is_new else "Update"
    getattr(self.gwibber.accounts, fn)(json.dumps(self.account))

    self.ui.get_object('vbox_save').hide()
    self.ui.get_object('vbox_create').hide()

    # if we just fixed a failure case, hide the infobar
    if self.account["id"] == self.selected_account:
      if hasattr(gtk, "InfoBar"):
        self.infobar.hide()
      self.selected_account = None

    self.populate_account_tree()

    # Set the autostart gconf key so we get loaded on login
    gc = gconf.client_get_default()
    if gc.get("/apps/gwibber/preferences/autostart") is None:
      gc.set_bool("/apps/gwibber/preferences/autostart", True)

    return True
 def openDialog(self, bgcolor):
     self.Dialog.show_all()
     #gdkColor = gtk.gdk.Color()
     gdkColor = gtk.color_selection_palette_from_string(bgcolor)
     self.walkTree.get_widget('color_selection').set_current_color(
         gdkColor[0])
     result = self.Dialog.run()
     if result == gtk.RESPONSE_OK:
         gtkColor = self.walkTree.get_widget(
             'color_selection').get_current_color()
         bgcolor = gtk.color_selection_palette_to_string([gtkColor])
     self.Dialog.destroy()
     return bgcolor
 def on_color_add(self, widget):
     """Callback: when adding a new color, show the color definition
     window, update the model, notifies the parent."""
     color_dialog = gtk.ColorSelectionDialog(_('Choose a color'))
     colorsel = color_dialog.colorsel
     if self.selected_col is not None:
         color = gtk.gdk.color_parse(self.selected_col.color)
         colorsel.set_current_color(color)
     response = color_dialog.run()
     new_color = colorsel.get_current_color()
     # Check response_id and set color if required
     if response == gtk.RESPONSE_OK and new_color:
         strcolor = gtk.color_selection_palette_to_string([new_color])
         # Add the color to the palette and notify
         if strcolor not in self.colors:
             self.add_custom_color(strcolor)
         # Select the new color and notify
         self.set_selected_color(strcolor)
         self.emit("color-changed")
     # Clean up
     color_dialog.destroy()
 def on_color_add(self, widget):
     """Callback: when adding a new color, show the color definition
     window, update the model, notifies the parent."""
     color_dialog = gtk.ColorSelectionDialog(_('Choose a color'))
     colorsel = color_dialog.colorsel
     if self.selected_col is not None:
         color = gtk.gdk.color_parse(self.selected_col.color)
         colorsel.set_current_color(color)
     response = color_dialog.run()
     new_color = colorsel.get_current_color()
     # Check response_id and set color if required
     if response == gtk.RESPONSE_OK and new_color:
         strcolor = gtk.color_selection_palette_to_string([new_color])
         # Add the color to the palette and notify
         if strcolor not in self.colors:
             self.add_custom_color(strcolor)
         # Select the new color and notify
         self.set_selected_color(strcolor)
         self.emit("color-changed")
     # Clean up
     color_dialog.destroy()
Exemple #16
0
    def __create_tags(self):
        tag_table = self.text_buffer.get_tag_table()

        properties = [
            "details", "date", "hostname", "ip", "port_list", "open_port",
            "closed_port", "filtered_port"
        ]

        for name in properties:
            tag = tag_table.lookup(name)
            if tag:
                tag_table.remove(tag)

        for p in xrange(len(properties)):
            settings = self.nmap_highlight.__getattribute__(properties[p])

            # Create a tag name
            tag = gtk.TextTag(properties[p])

            if settings[0]:
                tag.set_property("weight", pango.WEIGHT_HEAVY)
            else:
                tag.set_property("weight", pango.WEIGHT_NORMAL)

            if settings[1]:
                tag.set_property("style", pango.STYLE_ITALIC)
            else:
                tag.set_property("style", pango.STYLE_NORMAL)

            if settings[2]:
                tag.set_property("underline", pango.UNDERLINE_SINGLE)
            else:
                tag.set_property("underline", pango.UNDERLINE_NONE)

            text_color = settings[3]
            highlight_color = settings[4]

            tag.set_property(
                "foreground",
                gtk.color_selection_palette_to_string([
                    gtk.gdk.Color(*text_color),
                ]))
            tag.set_property(
                "background",
                gtk.color_selection_palette_to_string([
                    gtk.gdk.Color(*highlight_color),
                ]))

            tag_table.add(tag)
            tag.set_priority(p)

        # brasil tags
        names = ('brasil1', 'brasil2', 'brasil3')
        prop = ('foreground', 'background', 'weight')
        values = (('#EAFF00', '#21C800', pango.WEIGHT_HEAVY),
                  ('#0006FF', '#21C800', pango.WEIGHT_HEAVY),
                  ('#FFFFFF', '#21C800', pango.WEIGHT_HEAVY))

        for name in names:
            tag = tag_table.lookup(name)
            if tag:
                tag_table.remove(tag)

        for i in xrange(len(names)):
            tag = gtk.TextTag(names[i])
            for tup in zip(prop, values[i]):
                tag.set_property(tup[0], tup[1])
            tag_table.add(tag)

        self.txg_font = gtk.TextTag()
        self.txg_date = gtk.TextTag()
        self.txg_font.set_property("family", "Monospace")

        tag_table.add(self.txg_font)
        tag_table.add(self.txg_date)
    def __create_tags(self):
        tag_table = self.text_buffer.get_tag_table()
        
        properties = ["details",
              "date",
              "hostname",
              "ip",
              "port_list",
              "open_port",
              "closed_port",
              "filtered_port"]

        for name in properties:
            tag = tag_table.lookup(name)
            if tag:
                tag_table.remove(tag)
        
        for p in xrange(len(properties)):
            settings = self.nmap_highlight.__getattribute__(properties[p])
            
            # Create a tag name
            tag = gtk.TextTag(properties[p])
                
            if settings[0]:
                tag.set_property("weight", pango.WEIGHT_HEAVY)
            else:
                tag.set_property("weight", pango.WEIGHT_NORMAL)
                
            if settings[1]:
                tag.set_property("style", pango.STYLE_ITALIC)
            else:
                tag.set_property("style", pango.STYLE_NORMAL)
            
            if settings[2]:
                tag.set_property("underline", pango.UNDERLINE_SINGLE)
            else:
                tag.set_property("underline", pango.UNDERLINE_NONE)

            text_color = settings[3]
            highlight_color = settings[4]

            tag.set_property("foreground",
gtk.color_selection_palette_to_string([gtk.gdk.Color(*text_color),]))
            tag.set_property("background",
gtk.color_selection_palette_to_string([gtk.gdk.Color(*highlight_color),]))

            tag_table.add(tag)
            tag.set_priority(p)
        
        # brasil tags
        names = ('brasil1', 'brasil2', 'brasil3')
        prop = ('foreground', 'background', 'weight')
        values = (('#EAFF00', '#21C800', pango.WEIGHT_HEAVY),
                  ('#0006FF', '#21C800', pango.WEIGHT_HEAVY),
                  ('#FFFFFF', '#21C800', pango.WEIGHT_HEAVY))
        
        for name in names:
            tag = tag_table.lookup(name)
            if tag:
                tag_table.remove(tag)

        for i in xrange(len(names)):
            tag = gtk.TextTag(names[i])
            for tup in zip(prop, values[i]):
                tag.set_property(tup[0], tup[1])
            tag_table.add(tag)

        self.txg_font = gtk.TextTag()
        self.txg_date = gtk.TextTag()
        self.txg_font.set_property("family", "Monospace")

        tag_table.add(self.txg_font)
        tag_table.add(self.txg_date)