search: Junk the OpenSearch system
The original design for the overview had buttons for searching for Wikipedia and Google, but in practice this is a bad idea. The buttons are the default activations, meaning that using the overview as a fluent motion of launching something - "firefxo<Enter>", will launch Google/Wikipedia. https://bugzilla.gnome.org/show_bug.cgi?id=670168
This commit is contained in:
132
src/shell-util.c
132
src/shell-util.c
@ -14,10 +14,6 @@
|
||||
#include <langinfo.h>
|
||||
#endif
|
||||
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/xmlmemory.h>
|
||||
|
||||
#ifdef WITH_SYSTEMD
|
||||
#include <systemd/sd-daemon.h>
|
||||
#include <systemd/sd-login.h>
|
||||
@ -646,134 +642,6 @@ shell_get_file_contents_utf8_sync (const char *path,
|
||||
return contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* shell_parse_search_provider:
|
||||
* @data: description of provider
|
||||
* @name: (out): location to store a display name
|
||||
* @url: (out): location to store template of url
|
||||
* @langs: (out) (transfer full) (element-type utf8): list of supported languages
|
||||
* @icon_data_uri: (out): location to store uri
|
||||
* @error: location to store GError
|
||||
*
|
||||
* Returns: %TRUE on success
|
||||
*/
|
||||
gboolean
|
||||
shell_parse_search_provider (const char *data,
|
||||
char **name,
|
||||
char **url,
|
||||
GList **langs,
|
||||
char **icon_data_uri,
|
||||
GError **error)
|
||||
{
|
||||
xmlDocPtr doc = xmlParseMemory (data, strlen (data));
|
||||
xmlNode *root;
|
||||
|
||||
*name = NULL;
|
||||
*url = NULL;
|
||||
*icon_data_uri = NULL;
|
||||
*langs = NULL;
|
||||
|
||||
if (!doc)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Malformed xml");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
root = xmlDocGetRootElement (doc);
|
||||
if (root && root->name && xmlStrcmp (root->name, (const xmlChar *)"OpenSearchDescription") == 0)
|
||||
{
|
||||
xmlNode *child;
|
||||
for (child = root->children; child; child = child->next)
|
||||
{
|
||||
if (!child->name)
|
||||
continue;
|
||||
if (xmlStrcmp (child->name, (const xmlChar *)"Language") == 0)
|
||||
{
|
||||
xmlChar *val = xmlNodeListGetString(doc, child->xmlChildrenNode, 1);
|
||||
if (!val)
|
||||
continue;
|
||||
*langs = g_list_append (*langs, g_strdup ((char *)val));
|
||||
xmlFree (val);
|
||||
}
|
||||
if (!*name && xmlStrcmp (child->name, (const xmlChar *)"ShortName") == 0)
|
||||
{
|
||||
xmlChar *val = xmlNodeListGetString(doc, child->xmlChildrenNode, 1);
|
||||
*name = g_strdup ((char *)val);
|
||||
xmlFree (val);
|
||||
}
|
||||
if (!*icon_data_uri && xmlStrcmp (child->name, (const xmlChar *)"Image") == 0)
|
||||
{
|
||||
xmlChar *val = xmlNodeListGetString(doc, child->xmlChildrenNode, 1);
|
||||
if (val)
|
||||
*icon_data_uri = g_strdup ((char *)val);
|
||||
xmlFree (val);
|
||||
}
|
||||
if (!*url && xmlStrcmp (child->name, (const xmlChar *)"Url") == 0)
|
||||
{
|
||||
xmlChar *template;
|
||||
xmlChar *type;
|
||||
|
||||
type = xmlGetProp(child, (const xmlChar *)"type");
|
||||
if (!type)
|
||||
continue;
|
||||
|
||||
if (xmlStrcmp (type, (const xmlChar *)"text/html") != 0)
|
||||
{
|
||||
xmlFree (type);
|
||||
continue;
|
||||
}
|
||||
xmlFree (type);
|
||||
|
||||
template = xmlGetProp(child, (const xmlChar *)"template");
|
||||
if (!template)
|
||||
continue;
|
||||
*url = g_strdup ((char *)template);
|
||||
xmlFree (template);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Invalid OpenSearch document");
|
||||
xmlFreeDoc (doc);
|
||||
return FALSE;
|
||||
}
|
||||
xmlFreeDoc (doc);
|
||||
if (*icon_data_uri && *name && *url)
|
||||
return TRUE;
|
||||
|
||||
if (*icon_data_uri)
|
||||
g_free (*icon_data_uri);
|
||||
else
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"search provider doesn't have icon");
|
||||
|
||||
if (*name)
|
||||
g_free (*name);
|
||||
else if (error && !*error)
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"search provider doesn't have ShortName");
|
||||
|
||||
if (*url)
|
||||
g_free (*url);
|
||||
else if (error && !*error)
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"search provider doesn't have template for url");
|
||||
|
||||
if (*langs)
|
||||
{
|
||||
g_list_foreach (*langs, (GFunc)g_free, NULL);
|
||||
g_list_free (*langs);
|
||||
}
|
||||
|
||||
*url = NULL;
|
||||
*name = NULL;
|
||||
*icon_data_uri = NULL;
|
||||
*langs = NULL;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* shell_session_is_active_for_systemd:
|
||||
*
|
||||
|
Reference in New Issue
Block a user