Beispiel #1
0
static void
crawler_state_changed (GConfClient *client,
		       guint conn_id,
		       GConfEntry *entry,
		       gpointer user_data)
{
	const GConfValue *value;
	gchar *str_value;
	MafwPlaylist *playlist;
		
	/* Reload current playlist when crawler is done 
	   indexing local content */

	value = gconf_entry_get_value(entry);
	str_value = gconf_value_to_string(value);
	
	if (str_value && 
	    g_ascii_strcasecmp (str_value, "IDLE") == 0) {
		g_print ("Crawler is done indexing."  \
			 "Reloading current playlist\n");
		playlist = MAFW_PLAYLIST(get_current_playlist());
		if (playlist != NULL) {
			display_playlist_contents(playlist);
		}
	}
}
static void
check_unset(GConfEngine* conf)
{
  GError* err = NULL;
  const gchar** keyp = NULL;

  keyp = keys;

  while (*keyp)
    {
      gconf_engine_unset(conf, *keyp, &err);

      if (err != NULL)
        {
          fprintf(stderr, "unset of `%s' failed: %s\n", *keyp, err->message);
          g_error_free(err);
          err = NULL;
        }
      else
        {
          GConfValue* val;
          gchar* valstr;

          sync_and_clear(conf);
          
          val = gconf_engine_get (conf, *keyp, &err);


          if (val)
            valstr = gconf_value_to_string(val);
          else
            valstr = g_strdup("(none)");
          
          check(val == NULL, "unsetting a previously-set value `%s' the value `%s' existed", *keyp, valstr);

          g_free(valstr);
        }
      
      ++keyp;
    }
}
Beispiel #3
0
static void
node_set_value(xmlNodePtr node, GConfValue* value)
{
  const gchar* type;
  gchar* value_str;

  g_return_if_fail(node != NULL);
  g_return_if_fail(value != NULL);
  g_return_if_fail(value->type != GCONF_VALUE_INVALID);
  
  type = gconf_value_type_to_string(value->type);

  g_assert(type != NULL);
  
  my_xmlSetProp(node, "type", type);

  switch (value->type)
    {
    case GCONF_VALUE_INT:
    case GCONF_VALUE_FLOAT:
    case GCONF_VALUE_BOOL:
      free_childs(node);
      
      value_str = gconf_value_to_string(value);
  
      my_xmlSetProp(node, "value", value_str);

      g_free(value_str);
      break;
    case GCONF_VALUE_STRING:
      {
        xmlChar* encoded;
        
        free_childs(node);

        encoded = xmlEncodeEntitiesReentrant(node->doc,
                                             (xmlChar *)gconf_value_get_string(value));
        
        xmlNewChild(node, NULL, (xmlChar *)"stringvalue",
                    encoded);
        xmlFree(encoded);
      }
      break;      
    case GCONF_VALUE_SCHEMA:
      {
        node_set_schema_value(node, value);
      }
      break;
    case GCONF_VALUE_LIST:
      {
        GSList* list;

        free_childs(node);

        my_xmlSetProp(node, "ltype",
                      gconf_value_type_to_string(gconf_value_get_list_type(value)));
        
        /* Add a new child for each node */
        list = gconf_value_get_list(value);

        while (list != NULL)
          {
            xmlNodePtr child;
            /* this is O(1) because libxml saves the list tail */
            child = xmlNewChild(node, NULL, (xmlChar *)"li", NULL);

            g_return_if_fail(list->data != NULL);
            
            node_set_value(child, (GConfValue*)list->data);
            
            list = g_slist_next(list);
          }
      }
      break;
      
    case GCONF_VALUE_PAIR:
      {
        xmlNodePtr car, cdr;

        free_childs(node);

        car = xmlNewChild(node, NULL, (xmlChar *)"car", NULL);
        cdr = xmlNewChild(node, NULL, (xmlChar *)"cdr", NULL);

        g_return_if_fail(gconf_value_get_car(value) != NULL);
        g_return_if_fail(gconf_value_get_cdr(value) != NULL);
        
        node_set_value(car, gconf_value_get_car(value));
        node_set_value(cdr, gconf_value_get_cdr(value));
      }
      break;
      
    default:
      g_assert_not_reached();
      break;
    }
}