Resolve helpers and globals into sokoke.
This commit is contained in:
parent
3811549791
commit
68e0e521f4
11 changed files with 187 additions and 282 deletions
|
@ -26,8 +26,5 @@ midori_SOURCES = \
|
|||
midori-websettings.c midori-websettings.h \
|
||||
midori-preferences.c midori-preferences.h \
|
||||
webSearch.c webSearch.h \
|
||||
helpers.c helpers.h \
|
||||
sokoke.c sokoke.h \
|
||||
search.c search.h \
|
||||
global.h \
|
||||
ui.h
|
||||
search.c search.h
|
||||
|
|
65
src/global.h
65
src/global.h
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007 Christian Dywan <christian@twotoasts.de>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
See the file COPYING for the full license text.
|
||||
*/
|
||||
|
||||
#ifndef __GLOBAL_H__
|
||||
#define __GLOBAL_H__ 1
|
||||
|
||||
#include "midori-websettings.h"
|
||||
#include <katze/katze.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <webkit/webkit.h>
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
// FIXME: Remove these globals
|
||||
|
||||
GList* searchEngines; // Items of type 'SearchEngine'
|
||||
KatzeXbelItem* bookmarks;
|
||||
|
||||
// Custom stock items
|
||||
|
||||
// We should distribute these
|
||||
// Names should match with epiphany and/ or xdg spec
|
||||
/* NOTE: Those uncommented were replaced with remotely related icons
|
||||
in order to reduce the amount of warnings :D */
|
||||
|
||||
#define STOCK_BOOKMARK GTK_STOCK_FILE // "stock_bookmark" "bookmark-web"
|
||||
#define STOCK_FORM_FILL GTK_STOCK_JUSTIFY_FILL // "insert-text" "form-fill"
|
||||
#define STOCK_NEWSFEED GTK_STOCK_INDEX
|
||||
|
||||
// We assume that these legacy icon names are usually present
|
||||
|
||||
#define STOCK_BOOKMARK_NEW "stock_add-bookmark"
|
||||
#define STOCK_HOMEPAGE GTK_STOCK_HOME
|
||||
#define STOCK_IMAGE "gnome-mime-image"
|
||||
#define STOCK_LOCK_OPEN "stock_lock-open"
|
||||
#define STOCK_LOCK_SECURE "stock_lock"
|
||||
#define STOCK_LOCK_BROKEN "stock_lock-broken"
|
||||
#define STOCK_NETWORK_OFFLINE "network-offline"
|
||||
#define STOCK_SCRIPT "stock_script"
|
||||
#define STOCK_SEND "stock_mail-send"
|
||||
#define STOCK_TAB_NEW "stock_new-tab"
|
||||
#define STOCK_THEME "gnome-settings-theme"
|
||||
#define STOCK_USER_TRASH "gnome-stock-trash"
|
||||
#define STOCK_WINDOW_NEW "stock_new-window"
|
||||
|
||||
// For backwards compatibility
|
||||
|
||||
#if !GTK_CHECK_VERSION(2, 10, 0)
|
||||
#define GTK_STOCK_SELECT_ALL "gtk-select-all"
|
||||
#endif
|
||||
#if !GTK_CHECK_VERSION(2, 8, 0)
|
||||
#define GTK_STOCK_FULLSCREEN "gtk-fullscreen"
|
||||
#define GTK_STOCK_LEAVE_FULLSCREEN "gtk-leave-fullscreen"
|
||||
#endif
|
||||
|
||||
#endif /* !__GLOBAL_H__ */
|
145
src/helpers.c
145
src/helpers.c
|
@ -1,145 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007 Christian Dywan <christian@twotoasts.de>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
See the file COPYING for the full license text.
|
||||
*/
|
||||
|
||||
#include "helpers.h"
|
||||
|
||||
#include "global.h"
|
||||
#include "search.h"
|
||||
#include "sokoke.h"
|
||||
|
||||
#include "midori-webview.h"
|
||||
#include <katze/katze.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <webkit/webkit.h>
|
||||
|
||||
GtkWidget* check_menu_item_new(const gchar* text
|
||||
, GCallback signal, gboolean sensitive, gboolean active, gpointer userdata)
|
||||
{
|
||||
GtkWidget* menuitem = gtk_check_menu_item_new_with_mnemonic(text);
|
||||
gtk_widget_set_sensitive(menuitem, sensitive && signal);
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), active);
|
||||
if(signal)
|
||||
g_signal_connect(menuitem, "activate", signal, userdata);
|
||||
return menuitem;
|
||||
}
|
||||
|
||||
GtkWidget* radio_button_new(GtkRadioButton* radio_button, const gchar* label)
|
||||
{
|
||||
return gtk_radio_button_new_with_mnemonic_from_widget(radio_button, label);
|
||||
}
|
||||
|
||||
void show_error(const gchar* text, const gchar* text2, MidoriBrowser* browser)
|
||||
{
|
||||
GtkWidget* dialog = gtk_message_dialog_new(
|
||||
browser ? GTK_WINDOW(browser) : NULL
|
||||
, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, text);
|
||||
if(text2)
|
||||
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), text2);
|
||||
gtk_dialog_run(GTK_DIALOG(dialog));
|
||||
gtk_widget_destroy(dialog);
|
||||
}
|
||||
|
||||
GdkPixbuf* load_web_icon(const gchar* icon, GtkIconSize size, GtkWidget* widget)
|
||||
{
|
||||
g_return_val_if_fail(GTK_IS_WIDGET(widget), NULL);
|
||||
GdkPixbuf* pixbuf = NULL;
|
||||
if(icon && *icon)
|
||||
{
|
||||
// TODO: We want to allow http as well, maybe also base64?
|
||||
const gchar* iconReady = g_str_has_prefix(icon, "file://") ? &icon[7] : icon;
|
||||
GtkStockItem stockItem;
|
||||
if(gtk_stock_lookup(icon, &stockItem))
|
||||
pixbuf = gtk_widget_render_icon(widget, iconReady, size, NULL);
|
||||
else
|
||||
{
|
||||
gint width; gint height;
|
||||
gtk_icon_size_lookup(size, &width, &height);
|
||||
pixbuf = gtk_icon_theme_load_icon(gtk_icon_theme_get_default()
|
||||
, icon, MAX(width, height), GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
|
||||
}
|
||||
if(!pixbuf)
|
||||
pixbuf = gdk_pixbuf_new_from_file_at_size(iconReady, 16, 16, NULL);
|
||||
}
|
||||
if(!pixbuf)
|
||||
pixbuf = gtk_widget_render_icon(widget, GTK_STOCK_FIND, size, NULL);
|
||||
return pixbuf;
|
||||
}
|
||||
|
||||
void entry_setup_completion(GtkEntry* entry)
|
||||
{
|
||||
/* TODO: The current behavior works only with the beginning of strings
|
||||
But we want to match "localhost" with "loc" and "hos" */
|
||||
GtkEntryCompletion* completion = gtk_entry_completion_new();
|
||||
gtk_entry_completion_set_model(completion
|
||||
, GTK_TREE_MODEL(gtk_list_store_new(1, G_TYPE_STRING)));
|
||||
gtk_entry_completion_set_text_column(completion, 0);
|
||||
gtk_entry_completion_set_minimum_key_length(completion, 3);
|
||||
gtk_entry_set_completion(entry, completion);
|
||||
gtk_entry_completion_set_popup_completion(completion, FALSE); //...
|
||||
}
|
||||
|
||||
void entry_completion_append(GtkEntry* entry, const gchar* text)
|
||||
{
|
||||
GtkEntryCompletion* completion = gtk_entry_get_completion(entry);
|
||||
GtkTreeModel* completion_store = gtk_entry_completion_get_model(completion);
|
||||
GtkTreeIter iter;
|
||||
gtk_list_store_insert(GTK_LIST_STORE(completion_store), &iter, 0);
|
||||
gtk_list_store_set(GTK_LIST_STORE(completion_store), &iter, 0, text, -1);
|
||||
}
|
||||
|
||||
gchar* magic_uri(const gchar* uri, gboolean search)
|
||||
{
|
||||
// Add file:// if we have a local path
|
||||
if(g_path_is_absolute(uri))
|
||||
return g_strconcat("file://", uri, NULL);
|
||||
// Do we need to add a protocol?
|
||||
if(!strstr(uri, "://"))
|
||||
{
|
||||
// Do we have a domain, ip address or localhost?
|
||||
if(strchr(uri, '.') != NULL || !strcmp(uri, "localhost"))
|
||||
return g_strconcat("http://", uri, NULL);
|
||||
// We don't want to search? So return early.
|
||||
if(!search)
|
||||
return g_strdup(uri);
|
||||
gchar search[256];
|
||||
const gchar* searchUrl = NULL;
|
||||
// Do we have a keyword and a string?
|
||||
gchar** parts = g_strsplit(uri, " ", 2);
|
||||
if(parts[0] && parts[1])
|
||||
{
|
||||
guint n = g_list_length(searchEngines);
|
||||
guint i;
|
||||
for(i = 0; i < n; i++)
|
||||
{
|
||||
SearchEngine* searchEngine = (SearchEngine*)g_list_nth_data(searchEngines, i);
|
||||
if(!strcmp(search_engine_get_keyword(searchEngine), parts[0]))
|
||||
searchUrl = searchEngine->url;
|
||||
}
|
||||
if(searchUrl != NULL)
|
||||
g_snprintf(search, 255, searchUrl, parts[1]);
|
||||
}
|
||||
//g_strfreev(sParts);
|
||||
// We only have a word or there is no matching keyowrd, so search for it
|
||||
if(searchUrl == NULL)
|
||||
g_snprintf(search, 255, ""/*config->locationSearch*/, uri);
|
||||
return g_strdup(search);
|
||||
}
|
||||
return g_strdup(uri);
|
||||
}
|
||||
|
||||
gchar* get_default_font(void)
|
||||
{
|
||||
GtkSettings* gtksettings = gtk_settings_get_default();
|
||||
gchar* defaultFont;
|
||||
g_object_get(gtksettings, "gtk-font-name", &defaultFont, NULL);
|
||||
return defaultFont;
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2007 Christian Dywan <christian@twotoasts.de>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
See the file COPYING for the full license text.
|
||||
*/
|
||||
|
||||
#ifndef __HELPERS_H__
|
||||
#define __HELPERS_H__ 1
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "midori-browser.h"
|
||||
|
||||
GtkWidget*
|
||||
check_menu_item_new(const gchar*, GCallback, gboolean, gboolean, gpointer);
|
||||
|
||||
GtkWidget*
|
||||
radio_button_new(GtkRadioButton*, const gchar*);
|
||||
|
||||
void
|
||||
show_error(const gchar*, const gchar*, MidoriBrowser*);
|
||||
|
||||
GdkPixbuf*
|
||||
load_web_icon(const gchar*, GtkIconSize, GtkWidget*);
|
||||
|
||||
void
|
||||
entry_setup_completion(GtkEntry*);
|
||||
|
||||
void
|
||||
entry_completion_append(GtkEntry*, const gchar*);
|
||||
|
||||
gchar*
|
||||
magic_uri(const gchar*, gboolean bSearch);
|
||||
|
||||
gchar*
|
||||
get_default_font(void);
|
||||
|
||||
#endif /* !__HELPERS_H__ */
|
|
@ -11,8 +11,6 @@
|
|||
|
||||
#include "main.h"
|
||||
|
||||
#include "global.h"
|
||||
#include "helpers.h"
|
||||
#include "sokoke.h"
|
||||
#include "search.h"
|
||||
|
||||
|
@ -409,7 +407,7 @@ int main(int argc, char** argv)
|
|||
while(uri != NULL)
|
||||
{
|
||||
KatzeXbelItem* item = katze_xbel_bookmark_new();
|
||||
gchar* uriReady = magic_uri(uri, FALSE);
|
||||
gchar* uriReady = sokoke_magic_uri (uri, NULL);
|
||||
katze_xbel_bookmark_set_href(item, uriReady);
|
||||
g_free(uriReady);
|
||||
katze_xbel_folder_append_item(_session, item);
|
||||
|
|
58
src/main.h
58
src/main.h
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 2007 Christian Dywan <christian@twotoasts.de>
|
||||
Copyright (C) 2007-2008 Christian Dywan <christian@twotoasts.de>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -9,7 +9,57 @@
|
|||
See the file COPYING for the full license text.
|
||||
*/
|
||||
|
||||
#ifndef __MIDORI_H__
|
||||
#define __MIDORI_H__ 1
|
||||
#ifndef __MAIN_H__
|
||||
#define __MAIN_H__ 1
|
||||
|
||||
#endif /* !__MIDORI_H__ */
|
||||
#include "midori-websettings.h"
|
||||
#include <katze/katze.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <webkit/webkit.h>
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
// FIXME: Remove these globals
|
||||
|
||||
GList* searchEngines; // Items of type 'SearchEngine'
|
||||
KatzeXbelItem* bookmarks;
|
||||
|
||||
// Custom stock items
|
||||
|
||||
// We should distribute these
|
||||
// Names should match with epiphany and/ or xdg spec
|
||||
/* NOTE: Those uncommented were replaced with remotely related icons
|
||||
in order to reduce the amount of warnings :D */
|
||||
|
||||
#define STOCK_BOOKMARK GTK_STOCK_FILE // "stock_bookmark" "bookmark-web"
|
||||
#define STOCK_FORM_FILL GTK_STOCK_JUSTIFY_FILL // "insert-text" "form-fill"
|
||||
#define STOCK_NEWSFEED GTK_STOCK_INDEX
|
||||
|
||||
// We assume that these legacy icon names are usually present
|
||||
|
||||
#define STOCK_BOOKMARK_NEW "stock_add-bookmark"
|
||||
#define STOCK_HOMEPAGE GTK_STOCK_HOME
|
||||
#define STOCK_IMAGE "gnome-mime-image"
|
||||
#define STOCK_LOCK_OPEN "stock_lock-open"
|
||||
#define STOCK_LOCK_SECURE "stock_lock"
|
||||
#define STOCK_LOCK_BROKEN "stock_lock-broken"
|
||||
#define STOCK_NETWORK_OFFLINE "network-offline"
|
||||
#define STOCK_SCRIPT "stock_script"
|
||||
#define STOCK_SEND "stock_mail-send"
|
||||
#define STOCK_TAB_NEW "stock_new-tab"
|
||||
#define STOCK_THEME "gnome-settings-theme"
|
||||
#define STOCK_USER_TRASH "gnome-stock-trash"
|
||||
#define STOCK_WINDOW_NEW "stock_new-window"
|
||||
|
||||
// For backwards compatibility
|
||||
|
||||
#if !GTK_CHECK_VERSION(2, 10, 0)
|
||||
#define GTK_STOCK_SELECT_ALL "gtk-select-all"
|
||||
#endif
|
||||
#if !GTK_CHECK_VERSION(2, 8, 0)
|
||||
#define GTK_STOCK_FULLSCREEN "gtk-fullscreen"
|
||||
#define GTK_STOCK_LEAVE_FULLSCREEN "gtk-leave-fullscreen"
|
||||
#endif
|
||||
|
||||
#endif /* !__MAIN_H__ */
|
||||
|
|
|
@ -13,10 +13,9 @@
|
|||
|
||||
#include "midori-browser.h"
|
||||
|
||||
#include "global.h"
|
||||
#include "helpers.h"
|
||||
#include "webSearch.h"
|
||||
|
||||
#include "main.h"
|
||||
#include "sokoke.h"
|
||||
#include "midori-webview.h"
|
||||
#include "midori-preferences.h"
|
||||
|
@ -1020,6 +1019,9 @@ midori_browser_location_key_press_event_cb (GtkWidget* widget,
|
|||
GdkEventKey* event,
|
||||
MidoriBrowser* browser)
|
||||
{
|
||||
MidoriBrowserPrivate* priv = browser->priv;
|
||||
gchar* location_entry_search;
|
||||
|
||||
switch (event->keyval)
|
||||
{
|
||||
case GDK_ISO_Enter:
|
||||
|
@ -1029,11 +1031,14 @@ midori_browser_location_key_press_event_cb (GtkWidget* widget,
|
|||
const gchar* uri = gtk_entry_get_text (GTK_ENTRY (widget));
|
||||
if (uri)
|
||||
{
|
||||
gchar* new_uri = magic_uri (uri, TRUE);
|
||||
g_object_get (priv->settings, "location-entry-search",
|
||||
&location_entry_search, NULL);
|
||||
gchar* new_uri = sokoke_magic_uri (uri, location_entry_search);
|
||||
g_free (location_entry_search);
|
||||
// TODO: Use new_uri intermediately when completion is better
|
||||
/* TODO Completion should be generated from history, that is
|
||||
the uri as well as the title. */
|
||||
entry_completion_append (GTK_ENTRY (widget), uri);
|
||||
sokoke_entry_append_completion (GTK_ENTRY (widget), uri);
|
||||
GtkWidget* web_view = midori_browser_get_current_web_view (browser);
|
||||
g_object_set (web_view, "uri", new_uri, NULL);
|
||||
g_free (new_uri);
|
||||
|
@ -2359,7 +2364,7 @@ midori_browser_init (MidoriBrowser* browser)
|
|||
|
||||
// Location
|
||||
priv->location = sexy_icon_entry_new();
|
||||
entry_setup_completion (GTK_ENTRY (priv->location));
|
||||
sokoke_entry_setup_completion (GTK_ENTRY (priv->location));
|
||||
priv->location_icon = gtk_image_new ();
|
||||
sexy_icon_entry_set_icon (SEXY_ICON_ENTRY (priv->location)
|
||||
, SEXY_ICON_ENTRY_PRIMARY, GTK_IMAGE (priv->location_icon));
|
||||
|
@ -2381,7 +2386,7 @@ midori_browser_init (MidoriBrowser* browser)
|
|||
// TODO: Make this actively resizable or enlarge to fit contents?
|
||||
// FIXME: The interface is somewhat awkward and ought to be rethought
|
||||
// TODO: Display "show in context menu" search engines as "completion actions"
|
||||
entry_setup_completion (GTK_ENTRY (priv->search));
|
||||
sokoke_entry_setup_completion (GTK_ENTRY (priv->search));
|
||||
g_object_connect (priv->search,
|
||||
"signal::icon-released",
|
||||
on_webSearch_icon_released, browser,
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include "midori-webview.h"
|
||||
|
||||
#include "global.h"
|
||||
#include "main.h"
|
||||
#include "sokoke.h"
|
||||
|
||||
#include <webkit/webkit.h>
|
||||
|
@ -245,14 +245,9 @@ midori_web_view_class_init (MidoriWebViewClass* class)
|
|||
"",
|
||||
flags));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
g_object_class_override_property (gobject_class,
|
||||
PROP_SETTINGS,
|
||||
g_param_spec_object (
|
||||
"settings",
|
||||
"Settings",
|
||||
_("The associated settings"),
|
||||
MIDORI_TYPE_WEB_SETTINGS,
|
||||
G_PARAM_READWRITE));
|
||||
"settings");
|
||||
|
||||
g_type_class_add_private (class, sizeof (MidoriWebViewPrivate));
|
||||
}
|
||||
|
|
69
src/sokoke.c
69
src/sokoke.c
|
@ -11,7 +11,10 @@
|
|||
|
||||
#include "sokoke.h"
|
||||
|
||||
#include "search.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "main.h"
|
||||
|
||||
#include <string.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
|
@ -21,6 +24,72 @@
|
|||
#include <glib/gi18n.h>
|
||||
#include <glib/gprintf.h>
|
||||
|
||||
gchar*
|
||||
sokoke_magic_uri (const gchar* uri, const gchar* default_search_uri)
|
||||
{
|
||||
// Add file:// if we have a local path
|
||||
if (g_path_is_absolute (uri))
|
||||
return g_strconcat ("file://", uri, NULL);
|
||||
// Do we need to add a protocol?
|
||||
if (!strstr (uri, "://"))
|
||||
{
|
||||
// Do we have a domain, ip address or localhost?
|
||||
if (strchr (uri, '.') != NULL || !strcmp (uri, "localhost"))
|
||||
return g_strconcat ("http://", uri, NULL);
|
||||
// We don't want to search? So return early.
|
||||
if (!default_search_uri)
|
||||
return g_strdup (uri);
|
||||
gchar* search;
|
||||
const gchar* search_uri = NULL;
|
||||
// Do we have a keyword and a string?
|
||||
gchar** parts = g_strsplit (uri, " ", 2);
|
||||
if (parts[0] && parts[1])
|
||||
{
|
||||
guint n = g_list_length (searchEngines);
|
||||
guint i;
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
SearchEngine* search_engine = (SearchEngine*)g_list_nth_data (
|
||||
searchEngines, i);
|
||||
if (!strcmp (search_engine_get_keyword (search_engine),
|
||||
parts[0]))
|
||||
search_uri = search_engine->url;
|
||||
}
|
||||
if (search_uri)
|
||||
search = g_strdup_printf (search_uri, parts[1]);
|
||||
}
|
||||
// We only have a word or there is no matching keyword, so search for it
|
||||
if (!search_uri)
|
||||
search = g_strdup_printf (default_search_uri, uri);
|
||||
return search;
|
||||
}
|
||||
return g_strdup (uri);
|
||||
}
|
||||
|
||||
void
|
||||
sokoke_entry_setup_completion (GtkEntry* entry)
|
||||
{
|
||||
/* TODO: The current behavior works only with the beginning of strings
|
||||
But we want to match "localhost" with "loc" and "hos" */
|
||||
GtkEntryCompletion* completion = gtk_entry_completion_new ();
|
||||
gtk_entry_completion_set_model (completion,
|
||||
GTK_TREE_MODEL (gtk_list_store_new (1, G_TYPE_STRING)));
|
||||
gtk_entry_completion_set_text_column (completion, 0);
|
||||
gtk_entry_completion_set_minimum_key_length (completion, 3);
|
||||
gtk_entry_set_completion (entry, completion);
|
||||
gtk_entry_completion_set_popup_completion (completion, FALSE); //...
|
||||
}
|
||||
|
||||
void
|
||||
sokoke_entry_append_completion (GtkEntry* entry, const gchar* text)
|
||||
{
|
||||
GtkEntryCompletion* completion = gtk_entry_get_completion (entry);
|
||||
GtkTreeModel* completion_store = gtk_entry_completion_get_model (completion);
|
||||
GtkTreeIter iter;
|
||||
gtk_list_store_insert (GTK_LIST_STORE (completion_store), &iter, 0);
|
||||
gtk_list_store_set (GTK_LIST_STORE (completion_store), &iter, 0, text, -1);
|
||||
}
|
||||
|
||||
#if SOKOKE_DEBUG > 1
|
||||
#define UNIMPLEMENTED g_print(" * Unimplemented: %s\n", G_STRFUNC);
|
||||
#else
|
||||
|
|
11
src/sokoke.h
11
src/sokoke.h
|
@ -17,6 +17,17 @@
|
|||
// Many themes need this hack for small toolbars to work
|
||||
#define GTK_ICON_SIZE_SMALL_TOOLBAR GTK_ICON_SIZE_BUTTON
|
||||
|
||||
gchar*
|
||||
sokoke_magic_uri (const gchar* uri,
|
||||
const gchar* search);
|
||||
|
||||
void
|
||||
sokoke_entry_setup_completion (GtkEntry* entry);
|
||||
|
||||
void
|
||||
sokoke_entry_append_completion (GtkEntry* entry,
|
||||
const gchar* text);
|
||||
|
||||
typedef enum {
|
||||
SOKOKE_MENU_POSITION_CURSOR = 0,
|
||||
SOKOKE_MENU_POSITION_LEFT,
|
||||
|
|
|
@ -11,15 +11,48 @@
|
|||
|
||||
#include "webSearch.h"
|
||||
|
||||
#include "global.h"
|
||||
#include "helpers.h"
|
||||
#include "search.h"
|
||||
|
||||
#include "main.h"
|
||||
#include "sokoke.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
static GdkPixbuf*
|
||||
load_web_icon (const gchar* icon, GtkIconSize size, GtkWidget* widget)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
||||
GdkPixbuf* pixbuf = NULL;
|
||||
if (icon && *icon)
|
||||
{
|
||||
// TODO: We want to allow http as well, maybe also base64?
|
||||
const gchar* icon_ready = g_str_has_prefix (icon, "file://")
|
||||
? &icon[7] : icon;
|
||||
GtkStockItem stock_id;
|
||||
if (gtk_stock_lookup (icon, &stock_id))
|
||||
pixbuf = gtk_widget_render_icon (widget, icon_ready, size, NULL);
|
||||
else
|
||||
{
|
||||
gint width, height;
|
||||
gtk_icon_size_lookup (size, &width, &height);
|
||||
if (gtk_widget_has_screen (widget))
|
||||
{
|
||||
GdkScreen* screen = gtk_widget_get_screen (widget);
|
||||
pixbuf = gtk_icon_theme_load_icon (
|
||||
gtk_icon_theme_get_for_screen (screen), icon,
|
||||
MAX (width, height), GTK_ICON_LOOKUP_USE_BUILTIN, NULL);
|
||||
}
|
||||
}
|
||||
if (!pixbuf)
|
||||
pixbuf = gdk_pixbuf_new_from_file_at_size (icon_ready, 16, 16, NULL);
|
||||
}
|
||||
if (!pixbuf)
|
||||
pixbuf = gtk_widget_render_icon (widget, GTK_STOCK_FIND, size, NULL);
|
||||
return pixbuf;
|
||||
}
|
||||
|
||||
void update_searchEngine(guint index, GtkWidget* search)
|
||||
{
|
||||
guint n = g_list_length(searchEngines);
|
||||
|
@ -437,7 +470,7 @@ void on_webSearch_activate(GtkWidget* widget, MidoriBrowser* browser)
|
|||
search = g_strdup_printf(url, keywords);
|
||||
else
|
||||
search = g_strconcat(url, " ", keywords, NULL);
|
||||
entry_completion_append(GTK_ENTRY(widget), keywords);
|
||||
sokoke_entry_append_completion(GTK_ENTRY(widget), keywords);
|
||||
GtkWidget* webView = midori_browser_get_current_web_view(browser);
|
||||
webkit_web_view_open(WEBKIT_WEB_VIEW(webView), search);
|
||||
g_free(search);
|
||||
|
|
Loading…
Reference in a new issue