Introduce MidoriWebList, second step of refactoring web search

This commit is contained in:
Christian Dywan 2008-06-14 02:23:33 +02:00
parent 86129a03da
commit 3ac8bdb438
15 changed files with 652 additions and 382 deletions

View file

@ -28,7 +28,11 @@ if bld.env ()['CONVERT']:
'-background', 'transparent', '-background', 'transparent',
'-geometry', format, '-extent', format, '-geometry', format, '-extent', format,
srcdir + '/data/midori.svg', srcdir + '/data/midori.svg',
blddir + '/icons/' + format + '/midori.png']) blddir + '/icons/' + format + '/midori.png'],
stderr=subprocess.PIPE)
if not convert.wait (): if not convert.wait ():
install_files ('DATADIR', 'icons/hicolor/' + format + '/apps', install_files ('DATADIR', 'icons/hicolor/' + format + '/apps',
blddir + '/icons/' + format + '/midori.png') blddir + '/icons/' + format + '/midori.png')
else:
Params.pprint ('BLUE', "Optimized icons could not be created.")
break

View file

@ -19,6 +19,7 @@ bin_PROGRAMS = \
midori_SOURCES = \ midori_SOURCES = \
main.c main.h \ main.c main.h \
midori-webitem.c midori-webitem.h \ midori-webitem.c midori-webitem.h \
midori-weblist.c midori-weblist.h \
midori-app.c midori-app.h \ midori-app.c midori-app.h \
midori-browser.c midori-browser.h \ midori-browser.c midori-browser.h \
midori-panel.c midori-panel.h \ midori-panel.c midori-panel.h \
@ -31,5 +32,4 @@ midori_SOURCES = \
webSearch.c webSearch.h \ webSearch.c webSearch.h \
gjs.c gjs.h \ gjs.c gjs.h \
sokoke.c sokoke.h \ sokoke.c sokoke.h \
search.c search.h \
compat.c compat.h compat.c compat.h

View file

@ -12,26 +12,25 @@
#include "main.h" #include "main.h"
#include "sokoke.h" #include "sokoke.h"
#include "search.h"
#include "midori-app.h" #include "midori-app.h"
#include "midori-websettings.h" #include "midori-websettings.h"
#include "midori-trash.h" #include "midori-trash.h"
#include "midori-browser.h" #include "midori-browser.h"
#include "midori-weblist.h"
#include "gjs.h" #include "gjs.h"
#include <katze/katze.h>
#include <string.h> #include <string.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#if HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
#include <libintl.h> #include <libintl.h>
#endif #endif
// -- stock icons
static void stock_items_init(void) static void stock_items_init(void)
{ {
static GtkStockItem items[] = static GtkStockItem items[] =
@ -57,17 +56,20 @@ static void stock_items_init(void)
{ GTK_STOCK_LEAVE_FULLSCREEN, N_("_Leave Fullscreen"), 0, 0, NULL }, { GTK_STOCK_LEAVE_FULLSCREEN, N_("_Leave Fullscreen"), 0, 0, NULL },
#endif #endif
}; };
GtkIconSource* icon_source;
GtkIconSet* icon_set;
GtkIconFactory* factory = gtk_icon_factory_new (); GtkIconFactory* factory = gtk_icon_factory_new ();
guint i; guint i;
for (i = 0; i < (guint)G_N_ELEMENTS (items); i++) for (i = 0; i < (guint)G_N_ELEMENTS (items); i++)
{ {
GtkIconSource* iconSource = gtk_icon_source_new(); icon_source = gtk_icon_source_new ();
gtk_icon_source_set_icon_name(iconSource, items[i].stock_id); gtk_icon_source_set_icon_name (icon_source, items[i].stock_id);
GtkIconSet* iconSet = gtk_icon_set_new(); icon_set = gtk_icon_set_new ();
gtk_icon_set_add_source(iconSet, iconSource); gtk_icon_set_add_source (icon_set, icon_source);
gtk_icon_source_free(iconSource); gtk_icon_source_free (icon_source);
gtk_icon_factory_add(factory, items[i].stock_id, iconSet); gtk_icon_factory_add (factory, items[i].stock_id, icon_set);
gtk_icon_set_unref(iconSet); gtk_icon_set_unref (icon_set);
} }
gtk_stock_add_static (items, G_N_ELEMENTS (items)); gtk_stock_add_static (items, G_N_ELEMENTS (items));
gtk_icon_factory_add_default (factory); gtk_icon_factory_add_default (factory);
@ -90,6 +92,17 @@ settings_new_from_file (const gchar* filename)
MidoriWebSettings* settings = midori_web_settings_new (); MidoriWebSettings* settings = midori_web_settings_new ();
GKeyFile* key_file = g_key_file_new (); GKeyFile* key_file = g_key_file_new ();
GError* error = NULL; GError* error = NULL;
GObjectClass* class;
guint i, n_properties;
GParamSpec** pspecs;
GParamSpec* pspec;
GType type;
const gchar* property;
gchar* string;
gint integer;
gfloat number;
gboolean boolean;
if (!g_key_file_load_from_file (key_file, filename, if (!g_key_file_load_from_file (key_file, filename,
G_KEY_FILE_KEEP_COMMENTS, &error)) G_KEY_FILE_KEEP_COMMENTS, &error))
{ {
@ -98,19 +111,18 @@ settings_new_from_file (const gchar* filename)
error->message); error->message);
g_error_free (error); g_error_free (error);
} }
GObjectClass* class = G_OBJECT_GET_CLASS (settings); class = G_OBJECT_GET_CLASS (settings);
guint i, n_properties; pspecs = g_object_class_list_properties (class, &n_properties);
GParamSpec** pspecs = g_object_class_list_properties (class, &n_properties);
for (i = 0; i < n_properties; i++) for (i = 0; i < n_properties; i++)
{ {
GParamSpec* pspec = pspecs[i]; pspec = pspecs[i];
if (!(pspec->flags & G_PARAM_WRITABLE)) if (!(pspec->flags & G_PARAM_WRITABLE))
continue; continue;
GType type = G_PARAM_SPEC_TYPE (pspec); type = G_PARAM_SPEC_TYPE (pspec);
const gchar* property = g_param_spec_get_name (pspec); property = g_param_spec_get_name (pspec);
if (type == G_TYPE_PARAM_STRING) if (type == G_TYPE_PARAM_STRING)
{ {
gchar* string = sokoke_key_file_get_string_default (key_file, string = sokoke_key_file_get_string_default (key_file,
"settings", property, "settings", property,
G_PARAM_SPEC_STRING (pspec)->default_value, NULL); G_PARAM_SPEC_STRING (pspec)->default_value, NULL);
g_object_set (settings, property, string, NULL); g_object_set (settings, property, string, NULL);
@ -118,21 +130,21 @@ settings_new_from_file (const gchar* filename)
} }
else if (type == G_TYPE_PARAM_INT) else if (type == G_TYPE_PARAM_INT)
{ {
gint integer = sokoke_key_file_get_integer_default (key_file, integer = sokoke_key_file_get_integer_default (key_file,
"settings", property, "settings", property,
G_PARAM_SPEC_INT (pspec)->default_value, NULL); G_PARAM_SPEC_INT (pspec)->default_value, NULL);
g_object_set (settings, property, integer, NULL); g_object_set (settings, property, integer, NULL);
} }
else if (type == G_TYPE_PARAM_FLOAT) else if (type == G_TYPE_PARAM_FLOAT)
{ {
gfloat number = sokoke_key_file_get_double_default (key_file, number = sokoke_key_file_get_double_default (key_file,
"settings", property, "settings", property,
G_PARAM_SPEC_FLOAT (pspec)->default_value, NULL); G_PARAM_SPEC_FLOAT (pspec)->default_value, NULL);
g_object_set (settings, property, number, NULL); g_object_set (settings, property, number, NULL);
} }
else if (type == G_TYPE_PARAM_BOOLEAN) else if (type == G_TYPE_PARAM_BOOLEAN)
{ {
gboolean boolean = sokoke_key_file_get_boolean_default (key_file, boolean = sokoke_key_file_get_boolean_default (key_file,
"settings", property, "settings", property,
G_PARAM_SPEC_BOOLEAN (pspec)->default_value, NULL); G_PARAM_SPEC_BOOLEAN (pspec)->default_value, NULL);
g_object_set (settings, property, boolean, NULL); g_object_set (settings, property, boolean, NULL);
@ -167,15 +179,22 @@ settings_save_to_file (MidoriWebSettings* settings,
const gchar* filename, const gchar* filename,
GError** error) GError** error)
{ {
GKeyFile* key_file = g_key_file_new (); GKeyFile* key_file;
GObjectClass* class = G_OBJECT_GET_CLASS (settings); GObjectClass* class;
guint i, n_properties; guint i, n_properties;
GParamSpec** pspecs = g_object_class_list_properties (class, &n_properties); GParamSpec** pspecs;
GParamSpec* pspec;
GType type;
const gchar* property;
key_file = g_key_file_new ();
class = G_OBJECT_GET_CLASS (settings);
pspecs = g_object_class_list_properties (class, &n_properties);
for (i = 0; i < n_properties; i++) for (i = 0; i < n_properties; i++)
{ {
GParamSpec* pspec = pspecs[i]; pspec = pspecs[i];
GType type = G_PARAM_SPEC_TYPE (pspec); type = G_PARAM_SPEC_TYPE (pspec);
const gchar* property = g_param_spec_get_name (pspec); property = g_param_spec_get_name (pspec);
if (!(pspec->flags & G_PARAM_WRITABLE)) if (!(pspec->flags & G_PARAM_WRITABLE))
{ {
gchar* comment = g_strdup_printf ("# %s", property); gchar* comment = g_strdup_printf ("# %s", property);
@ -226,25 +245,105 @@ settings_save_to_file (MidoriWebSettings* settings,
return saved; return saved;
} }
int static MidoriWebList*
main (int argc, char** argv) search_engines_new_from_file (const gchar* filename,
GError** error)
{ {
MidoriStartup load_on_startup; MidoriWebList* search_engines;
gchar* homepage; GKeyFile* key_file;
gchar** engines;
guint i, j, n_properties;
MidoriWebItem* web_item;
GParamSpec** pspecs;
const gchar* property;
gchar* value;
locale_init (); search_engines = midori_web_list_new ();
g_set_application_name (_("midori")); key_file = g_key_file_new ();
g_key_file_load_from_file (key_file, filename,
G_KEY_FILE_KEEP_COMMENTS, error);
/*g_key_file_load_from_data_dirs(keyFile, sFilename, NULL
, G_KEY_FILE_KEEP_COMMENTS, error);*/
engines = g_key_file_get_groups (key_file, NULL);
for (i = 0; engines[i] != NULL; i++)
{
web_item = midori_web_item_new ();
pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (web_item),
&n_properties);
for (j = 0; j < n_properties; j++)
{
property = g_param_spec_get_name (pspecs[j]);
value = g_key_file_get_string (key_file, engines[i],
property, NULL);
g_object_set (web_item, property, value, NULL);
g_free (value);
}
midori_web_list_add_item (search_engines, web_item);
}
g_strfreev (engines);
g_key_file_free (key_file);
return search_engines;
}
// Parse cli options static gboolean
gboolean version = FALSE; search_engines_save_to_file (MidoriWebList* search_engines,
const gchar* filename,
GError** error)
{
GKeyFile* key_file;
guint n, i, j, n_properties;
MidoriWebItem* web_item;
const gchar* name;
GParamSpec** pspecs;
const gchar* property;
gchar* value;
gboolean saved;
key_file = g_key_file_new ();
n = midori_web_list_get_length (search_engines);
for (i = 0; i < n; i++)
{
web_item = midori_web_list_get_nth_item (search_engines, i);
name = midori_web_item_get_name (web_item);
pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (web_item),
&n_properties);
for (j = 0; j < n_properties; j++)
{
property = g_param_spec_get_name (pspecs[j]);
g_object_get (web_item, property, &value, NULL);
if (value)
g_key_file_set_string (key_file, name, property, value);
g_free (value);
}
}
saved = sokoke_key_file_save_to_file (key_file, filename, error);
g_key_file_free (key_file);
return saved;
}
int
main (int argc,
char** argv)
{
gboolean version;
GError* error;
GOptionEntry entries[] = GOptionEntry entries[] =
{ {
{ "version", 'v', 0, G_OPTION_ARG_NONE, &version, { "version", 'v', 0, G_OPTION_ARG_NONE, &version,
N_("Display program version"), NULL }, N_("Display program version"), NULL },
{ NULL } { NULL }
}; };
MidoriStartup load_on_startup;
gchar* homepage;
MidoriWebList* search_engines;
GError* error = NULL; locale_init ();
g_set_application_name (_("midori"));
/* Parse cli options */
version = FALSE;
error = NULL;
if (!gtk_init_with_args (&argc, &argv, _("[URL]"), entries, if (!gtk_init_with_args (&argc, &argv, _("[URL]"), entries,
GETTEXT_PACKAGE, &error)) GETTEXT_PACKAGE, &error))
{ {
@ -273,7 +372,7 @@ main (int argc, char** argv)
return 0; return 0;
} }
// Standalone gjs support /* Standalone gjs support */
if (argc > 1 && argv[1] && g_str_has_suffix (argv[1], ".js")) if (argc > 1 && argv[1] && g_str_has_suffix (argv[1], ".js"))
{ {
JSGlobalContextRef js_context = gjs_global_context_new (); JSGlobalContextRef js_context = gjs_global_context_new ();
@ -286,7 +385,7 @@ main (int argc, char** argv)
return 1; return 1;
} }
// Load configuration files /* Load configuration files */
GString* error_messages = g_string_new (NULL); GString* error_messages = g_string_new (NULL);
gchar* config_path = g_build_filename (g_get_user_config_dir (), gchar* config_path = g_build_filename (g_get_user_config_dir (),
PACKAGE_NAME, NULL); PACKAGE_NAME, NULL);
@ -298,11 +397,11 @@ main (int argc, char** argv)
gtk_accel_map_load (config_file); gtk_accel_map_load (config_file);
katze_assign (config_file, g_build_filename (config_path, "search", NULL)); katze_assign (config_file, g_build_filename (config_path, "search", NULL));
error = NULL; error = NULL;
searchEngines = search_engines_new (); search_engines = search_engines_new_from_file (config_file, &error);
if (!search_engines_from_file (&searchEngines, config_file, &error)) if (error)
{ {
// FIXME: We may have a "file empty" error, how do we recognize that? /* FIXME: We may have a "file empty" error, how do we recognize that?
/*if (error->code != G_FILE_ERROR_NOENT) if (error->code != G_FILE_ERROR_NOENT)
g_string_append_printf (error_messages, g_string_append_printf (error_messages,
_("The search engines couldn't be loaded. %s\n"), _("The search engines couldn't be loaded. %s\n"),
error->message); */ error->message); */
@ -347,25 +446,26 @@ main (int argc, char** argv)
} }
g_free (config_file); g_free (config_file);
// In case of errors /* In case of errors */
if (error_messages->len) if (error_messages->len)
{ {
GtkWidget* dialog = gtk_message_dialog_new(NULL GtkWidget* dialog = gtk_message_dialog_new (
, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_NONE NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_NONE,
, _("The following errors occured:")); _("The following errors occured:"));
gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dialog), FALSE); gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dialog), FALSE);
gtk_window_set_title (GTK_WINDOW (dialog), g_get_application_name ()); gtk_window_set_title (GTK_WINDOW (dialog), g_get_application_name ());
// FIXME: Use custom program icon /* FIXME: Use custom program icon */
gtk_window_set_icon_name (GTK_WINDOW (dialog), "web-browser"); gtk_window_set_icon_name (GTK_WINDOW (dialog), "web-browser");
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog) gtk_message_dialog_format_secondary_text (
, "%s", error_messages->str); GTK_MESSAGE_DIALOG (dialog), "%s", error_messages->str);
gtk_dialog_add_buttons(GTK_DIALOG(dialog) gtk_dialog_add_buttons (GTK_DIALOG (dialog),
, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
, "_Ignore", GTK_RESPONSE_ACCEPT "_Ignore", GTK_RESPONSE_ACCEPT,
, NULL); NULL);
if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_ACCEPT) if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_ACCEPT)
{ {
search_engines_free(searchEngines); g_object_unref (settings);
g_object_unref (search_engines);
katze_xbel_item_unref (bookmarks); katze_xbel_item_unref (bookmarks);
katze_xbel_item_unref (_session); katze_xbel_item_unref (_session);
katze_xbel_item_unref (xbel_trash); katze_xbel_item_unref (xbel_trash);
@ -378,8 +478,8 @@ main (int argc, char** argv)
} }
g_string_free (error_messages, TRUE); g_string_free (error_messages, TRUE);
// TODO: Handle any number of separate uris from argv /* TODO: Handle any number of separate uris from argv
// Open as many tabs as we have uris, seperated by pipes Open as many tabs as we have uris, seperated by pipes */
gchar* uri = argc > 1 ? strtok (g_strdup (argv[1]), "|") : NULL; gchar* uri = argc > 1 ? strtok (g_strdup (argv[1]), "|") : NULL;
while (uri != NULL) while (uri != NULL)
{ {
@ -435,15 +535,15 @@ main (int argc, char** argv)
KatzeXbelItem* item = katze_xbel_folder_get_nth_item (_session, i); KatzeXbelItem* item = katze_xbel_folder_get_nth_item (_session, i);
midori_browser_add_xbel_item (browser, item); midori_browser_add_xbel_item (browser, item);
} }
// FIXME: Switch to the last active page /* FIXME: Switch to the last active page */
KatzeXbelItem* item = katze_xbel_folder_get_nth_item (_session, 0); KatzeXbelItem* item = katze_xbel_folder_get_nth_item (_session, 0);
if (!strcmp (katze_xbel_bookmark_get_href (item), "")) if (!strcmp (katze_xbel_bookmark_get_href (item), ""))
midori_browser_activate_action (browser, "Location"); midori_browser_activate_action (browser, "Location");
katze_xbel_item_unref (_session); katze_xbel_item_unref (_session);
// Load extensions /* Load extensions */
JSGlobalContextRef js_context = gjs_global_context_new (); JSGlobalContextRef js_context = gjs_global_context_new ();
// FIXME: We want to honor system installed addons as well /* FIXME: We want to honor system installed addons as well */
gchar* addon_path = g_build_filename (g_get_user_data_dir (), PACKAGE_NAME, gchar* addon_path = g_build_filename (g_get_user_data_dir (), PACKAGE_NAME,
"extensions", NULL); "extensions", NULL);
GDir* addon_dir = g_dir_open (addon_path, 0, NULL); GDir* addon_dir = g_dir_open (addon_path, 0, NULL);
@ -456,8 +556,8 @@ main (int argc, char** argv)
gchar* exception = NULL; gchar* exception = NULL;
gjs_script_from_file (js_context, fullname, &exception); gjs_script_from_file (js_context, fullname, &exception);
if (exception) if (exception)
// FIXME: Do we want to print this somewhere else? /* FIXME: Do we want to print this somewhere else? */
// FIXME Convert the filename to UTF8 /* FIXME Convert the filename to UTF8 */
printf ("%s - Exception: %s\n", filename, exception); printf ("%s - Exception: %s\n", filename, exception);
g_free (fullname); g_free (fullname);
} }
@ -468,18 +568,19 @@ main (int argc, char** argv)
JSGlobalContextRelease (js_context); JSGlobalContextRelease (js_context);
// Save configuration files /* Save configuration files */
config_path = g_build_filename (g_get_user_config_dir(), PACKAGE_NAME, config_path = g_build_filename (g_get_user_config_dir(), PACKAGE_NAME,
NULL); NULL);
g_mkdir_with_parents (config_path, 0755); g_mkdir_with_parents (config_path, 0755);
config_file = g_build_filename (config_path, "search", NULL); config_file = g_build_filename (config_path, "search", NULL);
error = NULL; error = NULL;
if (!search_engines_to_file (searchEngines, config_file, &error)) if (!search_engines_save_to_file (search_engines, config_file, &error))
{ {
g_warning (_("The search engines couldn't be saved. %s"), error->message); g_warning (_("The search engines couldn't be saved. %s"),
error->message);
g_error_free (error); g_error_free (error);
} }
search_engines_free(searchEngines); g_object_unref (search_engines);
g_free (config_file); g_free (config_file);
config_file = g_build_filename (config_path, "bookmarks.xbel", NULL); config_file = g_build_filename (config_path, "bookmarks.xbel", NULL);
error = NULL; error = NULL;

View file

@ -19,23 +19,22 @@
#include <glib/gi18n.h> #include <glib/gi18n.h>
// FIXME: Remove these globals /* FIXME: Remove these globals */
GList* searchEngines; // Items of type 'SearchEngine'
KatzeXbelItem* bookmarks; KatzeXbelItem* bookmarks;
// Custom stock items /* Custom stock items
// We should distribute these We should distribute these
// Names should match with epiphany and/ or xdg spec Names should match with epiphany and/ or xdg spec
/* NOTE: Those uncommented were replaced with remotely related icons NOTE: Those uncommented were replaced with remotely related icons
in order to reduce the amount of warnings :D */ in order to reduce the amount of warnings */
#define STOCK_BOOKMARK GTK_STOCK_FILE // "stock_bookmark" "bookmark-web" #define STOCK_BOOKMARK GTK_STOCK_FILE /* "stock_bookmark" "bookmark-web" */
#define STOCK_FORM_FILL GTK_STOCK_JUSTIFY_FILL // "insert-text" "form-fill" #define STOCK_FORM_FILL GTK_STOCK_JUSTIFY_FILL /* "insert-text" "form-fill" */
#define STOCK_NEWSFEED GTK_STOCK_INDEX #define STOCK_NEWSFEED GTK_STOCK_INDEX
// We assume that these legacy icon names are usually present /* We assume that these legacy icon names are usually present */
#define STOCK_BOOKMARK_ADD "stock_add-bookmark" #define STOCK_BOOKMARK_ADD "stock_add-bookmark"
#define STOCK_HOMEPAGE GTK_STOCK_HOME #define STOCK_HOMEPAGE GTK_STOCK_HOME
@ -51,7 +50,7 @@ KatzeXbelItem* bookmarks;
#define STOCK_USER_TRASH "gnome-stock-trash" #define STOCK_USER_TRASH "gnome-stock-trash"
#define STOCK_WINDOW_NEW "stock_new-window" #define STOCK_WINDOW_NEW "stock_new-window"
// For backwards compatibility /* For backwards compatibility */
#if !GTK_CHECK_VERSION(2, 10, 0) #if !GTK_CHECK_VERSION(2, 10, 0)
#define GTK_STOCK_SELECT_ALL "gtk-select-all" #define GTK_STOCK_SELECT_ALL "gtk-select-all"

View file

@ -414,12 +414,12 @@ midori_web_view_populate_popup_cb (GtkWidget* web_view,
const gchar* uri = midori_web_view_get_link_uri (MIDORI_WEB_VIEW (web_view)); const gchar* uri = midori_web_view_get_link_uri (MIDORI_WEB_VIEW (web_view));
if (uri) if (uri)
{ {
// TODO: bookmark link /* TODO: bookmark link */
} }
if (webkit_web_view_has_selection (WEBKIT_WEB_VIEW (web_view))) if (webkit_web_view_has_selection (WEBKIT_WEB_VIEW (web_view)))
{ {
// TODO: view selection source /* TODO: view selection source */
} }
if (!uri && !webkit_web_view_has_selection (WEBKIT_WEB_VIEW (web_view))) if (!uri && !webkit_web_view_has_selection (WEBKIT_WEB_VIEW (web_view)))
@ -505,7 +505,7 @@ midori_web_view_destroy_cb (GtkWidget* widget,
static void static void
_midori_browser_will_quit (MidoriBrowser* browser) _midori_browser_will_quit (MidoriBrowser* browser)
{ {
// Nothing to do /* Nothing to do */
} }
static void static void
@ -843,7 +843,7 @@ _action_open_activate (GtkAction* action,
gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_OPEN); gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_OPEN);
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (browser)); gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (browser));
// base the start folder on the current web view's uri if it is local /* base the start folder on the current web view's uri if it is local */
GtkWidget* web_view = midori_browser_get_current_web_view (browser); GtkWidget* web_view = midori_browser_get_current_web_view (browser);
if (web_view) if (web_view)
g_object_get (web_view, "uri", &uri, NULL); g_object_get (web_view, "uri", &uri, NULL);
@ -1114,7 +1114,7 @@ static void
midori_browser_menu_trash_item_activate_cb (GtkWidget* menuitem, midori_browser_menu_trash_item_activate_cb (GtkWidget* menuitem,
MidoriBrowser* browser) MidoriBrowser* browser)
{ {
// Create a new web view with an uri which has been closed before /* Create a new web view with an uri which has been closed before */
KatzeXbelItem* item = g_object_get_data (G_OBJECT (menuitem), KatzeXbelItem* item = g_object_get_data (G_OBJECT (menuitem),
"KatzeXbelItem"); "KatzeXbelItem");
const gchar* uri = katze_xbel_bookmark_get_href (item); const gchar* uri = katze_xbel_bookmark_get_href (item);
@ -1139,7 +1139,7 @@ midori_browser_menu_trash_activate_cb (GtkWidget* widget,
const gchar* title = katze_xbel_item_get_title (item); const gchar* title = katze_xbel_item_get_title (item);
const gchar* uri = katze_xbel_bookmark_get_href (item); const gchar* uri = katze_xbel_bookmark_get_href (item);
menuitem = gtk_image_menu_item_new_with_label (title ? title : uri); menuitem = gtk_image_menu_item_new_with_label (title ? title : uri);
// FIXME: Get the real icon /* FIXME: Get the real icon */
GtkWidget* icon = gtk_image_new_from_stock (GTK_STOCK_FILE, GtkWidget* icon = gtk_image_new_from_stock (GTK_STOCK_FILE,
GTK_ICON_SIZE_MENU); GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), icon); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), icon);
@ -1169,7 +1169,7 @@ static void
_action_preferences_activate (GtkAction* action, _action_preferences_activate (GtkAction* action,
MidoriBrowser* browser) MidoriBrowser* browser)
{ {
// Show the preferences dialog. Create it if necessary. /* Show the preferences dialog. Create it if necessary. */
static GtkWidget* dialog = NULL; static GtkWidget* dialog = NULL;
if (GTK_IS_DIALOG (dialog)) if (GTK_IS_DIALOG (dialog))
gtk_window_present (GTK_WINDOW (dialog)); gtk_window_present (GTK_WINDOW (dialog));
@ -1223,7 +1223,7 @@ _action_reload_stop_activate (GtkAction* action,
gchar* stock_id; gchar* stock_id;
g_object_get (action, "stock-id", &stock_id, NULL); g_object_get (action, "stock-id", &stock_id, NULL);
GtkWidget* web_view = midori_browser_get_current_web_view (browser); GtkWidget* web_view = midori_browser_get_current_web_view (browser);
// Refresh or stop, depending on the stock id /* Refresh or stop, depending on the stock id */
if (!strcmp (stock_id, GTK_STOCK_REFRESH)) if (!strcmp (stock_id, GTK_STOCK_REFRESH))
{ {
/*GdkModifierType state = (GdkModifierType)0; /*GdkModifierType state = (GdkModifierType)0;
@ -1334,10 +1334,12 @@ midori_browser_location_key_press_event_cb (GtkWidget* widget,
{ {
g_object_get (priv->settings, "location-entry-search", g_object_get (priv->settings, "location-entry-search",
&location_entry_search, NULL); &location_entry_search, NULL);
gchar* new_uri = sokoke_magic_uri (uri, location_entry_search); gchar* new_uri = sokoke_magic_uri (uri, NULL/*search_engines*/);
if (!new_uri)
new_uri = g_strdup (location_entry_search);
g_free (location_entry_search); g_free (location_entry_search);
// TODO: Use new_uri intermediately when completion is better /* TODO: Use new_uri intermediately when completion is better
/* TODO Completion should be generated from history, that is Completion should be generated from history, that is
the uri as well as the title. */ the uri as well as the title. */
sokoke_entry_append_completion (GTK_ENTRY (widget), uri); sokoke_entry_append_completion (GTK_ENTRY (widget), uri);
GtkWidget* web_view = midori_browser_get_current_web_view (browser); GtkWidget* web_view = midori_browser_get_current_web_view (browser);
@ -1525,7 +1527,7 @@ midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
katze_xbel_bookmark_set_href (bookmark, katze_xbel_bookmark_set_href (bookmark,
gtk_entry_get_text (GTK_ENTRY (entry_uri))); gtk_entry_get_text (GTK_ENTRY (entry_uri)));
// FIXME: We want to choose a folder /* FIXME: We want to choose a folder */
if (new_bookmark) if (new_bookmark)
{ {
katze_xbel_folder_append_item (bookmarks, bookmark); katze_xbel_folder_append_item (bookmarks, bookmark);
@ -1537,8 +1539,8 @@ midori_browser_edit_bookmark_dialog_new (MidoriBrowser* browser,
katze_xbel_item_ref (bookmark); katze_xbel_item_ref (bookmark);
} }
// FIXME: update navigationbar /* FIXME: update navigationbar */
// FIXME: Update panel in other windows /* FIXME: Update panel in other windows */
} }
gtk_widget_destroy (dialog); gtk_widget_destroy (dialog);
} }
@ -1697,7 +1699,7 @@ midori_browser_bookmarks_item_render_icon_cb (GtkTreeViewColumn* column,
return; return;
} }
// TODO: Would it be better to not do this on every redraw? /* TODO: Would it be better to not do this on every redraw? */
GdkPixbuf* pixbuf = NULL; GdkPixbuf* pixbuf = NULL;
if (katze_xbel_item_is_bookmark (item)) if (katze_xbel_item_is_bookmark (item))
pixbuf = gtk_widget_render_icon (treeview, STOCK_BOOKMARK, pixbuf = gtk_widget_render_icon (treeview, STOCK_BOOKMARK,
@ -1746,12 +1748,12 @@ midori_browser_bookmark_menu_folder_activate_cb (GtkWidget* menuitem,
MidoriBrowser* browser) MidoriBrowser* browser)
{ {
GtkWidget* menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menuitem)); GtkWidget* menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menuitem));
gtk_container_foreach (GTK_CONTAINER (menu), (GtkCallback) gtk_widget_destroy, NULL);//... gtk_container_foreach (GTK_CONTAINER (menu), (GtkCallback) gtk_widget_destroy, NULL);
KatzeXbelItem* folder = (KatzeXbelItem*)g_object_get_data(G_OBJECT (menuitem), "KatzeXbelItem"); KatzeXbelItem* folder = (KatzeXbelItem*)g_object_get_data(G_OBJECT (menuitem), "KatzeXbelItem");
_midori_browser_create_bookmark_menu (browser, folder, menu); _midori_browser_create_bookmark_menu (browser, folder, menu);
// Remove all menuitems when the menu is hidden. /* Remove all menuitems when the menu is hidden.
// FIXME: We really *want* the line below, but it won't work like that FIXME: We really *want* the line below, but it won't work like that
//g_signal_connect_after (menu, "hide", G_CALLBACK (gtk_container_foreach), gtk_widget_destroy); g_signal_connect_after (menu, "hide", G_CALLBACK (gtk_container_foreach), gtk_widget_destroy); */
gtk_widget_show (menuitem); gtk_widget_show (menuitem);
} }
@ -1763,9 +1765,9 @@ midori_browser_bookmarkbar_folder_activate_cb (GtkToolItem* toolitem,
KatzeXbelItem* folder = (KatzeXbelItem*)g_object_get_data ( KatzeXbelItem* folder = (KatzeXbelItem*)g_object_get_data (
G_OBJECT (toolitem), "KatzeXbelItem"); G_OBJECT (toolitem), "KatzeXbelItem");
_midori_browser_create_bookmark_menu (browser, folder, menu); _midori_browser_create_bookmark_menu (browser, folder, menu);
// Remove all menuitems when the menu is hidden. /* Remove all menuitems when the menu is hidden.
// FIXME: We really *should* run the line below, but it won't work like that FIXME: We really *should* run the line below, but it won't work like that
/*g_signal_connect (menu, "hide", G_CALLBACK (gtk_container_foreach), g_signal_connect (menu, "hide", G_CALLBACK (gtk_container_foreach),
gtk_widget_destroy); */ gtk_widget_destroy); */
sokoke_widget_popup (GTK_WIDGET (toolitem), GTK_MENU (menu), sokoke_widget_popup (GTK_WIDGET (toolitem), GTK_MENU (menu),
NULL, SOKOKE_MENU_POSITION_LEFT); NULL, SOKOKE_MENU_POSITION_LEFT);
@ -1800,7 +1802,7 @@ _midori_browser_create_bookmark_menu (MidoriBrowser* browser,
switch (katze_xbel_item_get_kind (item)) switch (katze_xbel_item_get_kind (item))
{ {
case KATZE_XBEL_ITEM_KIND_FOLDER: case KATZE_XBEL_ITEM_KIND_FOLDER:
// FIXME: what about katze_xbel_folder_is_folded? /* FIXME: what about katze_xbel_folder_is_folded? */
menuitem = gtk_image_menu_item_new_with_label (title); menuitem = gtk_image_menu_item_new_with_label (title);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem),
gtk_image_new_from_stock (GTK_STOCK_DIRECTORY, gtk_image_new_from_stock (GTK_STOCK_DIRECTORY,
@ -1846,7 +1848,7 @@ static void
_action_manage_search_engines_activate (GtkAction* action, _action_manage_search_engines_activate (GtkAction* action,
MidoriBrowser* browser) MidoriBrowser* browser)
{ {
// Show the Manage search engines dialog. Create it if necessary. /* Show the Manage search engines dialog. Create it if necessary. */
static GtkWidget* dialog; static GtkWidget* dialog;
if (GTK_IS_DIALOG (dialog)) if (GTK_IS_DIALOG (dialog))
gtk_window_present (GTK_WINDOW (dialog)); gtk_window_present (GTK_WINDOW (dialog));
@ -1873,7 +1875,7 @@ _action_tab_next_activate (GtkAction* action,
{ {
MidoriBrowserPrivate* priv = browser->priv; MidoriBrowserPrivate* priv = browser->priv;
// Advance one tab or jump to the first one if we are at the last one /* Advance one tab or jump to the first one if we are at the last one */
gint n = gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->notebook)); gint n = gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->notebook));
if (n == gtk_notebook_get_n_pages (GTK_NOTEBOOK (priv->notebook)) - 1) if (n == gtk_notebook_get_n_pages (GTK_NOTEBOOK (priv->notebook)) - 1)
n = -1; n = -1;
@ -1935,10 +1937,10 @@ static void
midori_browser_location_changed_cb (GtkWidget* widget, midori_browser_location_changed_cb (GtkWidget* widget,
MidoriBrowser* browser) MidoriBrowser* browser)
{ {
// Preserve changes to the uri /* Preserve changes to the uri
/*const gchar* newUri = gtk_entry_get_text(GTK_ENTRY(widget)); const gchar* new_uri = gtk_entry_get_text (GTK_ENTRY (widget));
katze_xbel_bookmark_set_href(browser->sessionItem, newUri);*/ katze_xbel_bookmark_set_href(browser->sessionItem, new_uri);
// FIXME: If we want this feature, this is the wrong approach FIXME: If we want this feature, this is the wrong approach */
} }
static void static void
@ -1960,7 +1962,7 @@ _action_open_in_panel_activate (GtkAction* action,
GtkWidget* web_view = midori_browser_get_current_web_view (browser); GtkWidget* web_view = midori_browser_get_current_web_view (browser);
const gchar* uri = midori_web_view_get_display_uri (MIDORI_WEB_VIEW (web_view)); const gchar* uri = midori_web_view_get_display_uri (MIDORI_WEB_VIEW (web_view));
// FIXME: Don't assign the uri here, update it properly while navigating /* FIXME: Don't assign the uri here, update it properly while navigating */
g_object_set (priv->settings, "last-pageholder-uri", uri, NULL); g_object_set (priv->settings, "last-pageholder-uri", uri, NULL);
gint n = midori_panel_page_num (MIDORI_PANEL (priv->panel), gint n = midori_panel_page_num (MIDORI_PANEL (priv->panel),
priv->panel_pageholder); priv->panel_pageholder);
@ -2111,7 +2113,7 @@ _action_undo_tab_close_activate (GtkAction* action,
{ {
MidoriBrowserPrivate* priv = browser->priv; MidoriBrowserPrivate* priv = browser->priv;
// Reopen the most recent trash item /* Reopen the most recent trash item */
KatzeXbelItem* item = midori_trash_get_nth_xbel_item (priv->trash, 0); KatzeXbelItem* item = midori_trash_get_nth_xbel_item (priv->trash, 0);
gint n = midori_browser_add_xbel_item (browser, item); gint n = midori_browser_add_xbel_item (browser, item);
midori_browser_set_current_page (browser, n); midori_browser_set_current_page (browser, n);
@ -2417,7 +2419,7 @@ midori_browser_destroy_cb (MidoriBrowser* browser)
{ {
MidoriBrowserPrivate* priv = browser->priv; MidoriBrowserPrivate* priv = browser->priv;
// Destroy tabs first, so widgets can still see window elements on destroy /* Destroy tabs first, so widgets can still see window elements on destroy */
gtk_container_foreach (GTK_CONTAINER (priv->notebook), gtk_container_foreach (GTK_CONTAINER (priv->notebook),
(GtkCallback) gtk_widget_destroy, NULL); (GtkCallback) gtk_widget_destroy, NULL);
} }
@ -2485,7 +2487,7 @@ static const gchar* ui_markup =
"<menuitem action='Search'/>" "<menuitem action='Search'/>"
"<menuitem action='OpenInPageholder'/>" "<menuitem action='OpenInPageholder'/>"
"<menu action='Trash'>" "<menu action='Trash'>"
// Closed tabs shall be prepended here /* Closed tabs shall be prepended here */
"<separator/>" "<separator/>"
"<menuitem action='TrashEmpty'/>" "<menuitem action='TrashEmpty'/>"
"</menu>" "</menu>"
@ -2499,18 +2501,18 @@ static const gchar* ui_markup =
"<menuitem action='BookmarkAdd'/>" "<menuitem action='BookmarkAdd'/>"
"<menuitem action='BookmarksManage'/>" "<menuitem action='BookmarksManage'/>"
"<separator/>" "<separator/>"
// Bookmarks shall be appended here /* Bookmarks shall be appended here */
"</menu>" "</menu>"
"<menu action='Tools'>" "<menu action='Tools'>"
"<menuitem action='ManageSearchEngines'/>" "<menuitem action='ManageSearchEngines'/>"
// Panel items shall be appended here /* Panel items shall be appended here */
"</menu>" "</menu>"
"<menu action='Window'>" "<menu action='Window'>"
"<menuitem action='TabPrevious'/>" "<menuitem action='TabPrevious'/>"
"<menuitem action='TabNext'/>" "<menuitem action='TabNext'/>"
"<menuitem action='TabOverview'/>" "<menuitem action='TabOverview'/>"
"<separator/>" "<separator/>"
// All open tabs shall be appended here /* All open tabs shall be appended here */
"</menu>" "</menu>"
"<menu action='Help'>" "<menu action='Help'>"
"<menuitem action='HelpContents'/>" "<menuitem action='HelpContents'/>"
@ -2563,7 +2565,7 @@ midori_browser_init (MidoriBrowser* browser)
MidoriBrowserPrivate* priv = browser->priv; MidoriBrowserPrivate* priv = browser->priv;
// Setup the window metrics /* Setup the window metrics */
g_signal_connect (browser, "realize", g_signal_connect (browser, "realize",
G_CALLBACK (midori_browser_realize_cb), browser); G_CALLBACK (midori_browser_realize_cb), browser);
g_signal_connect (browser, "window-state-event", g_signal_connect (browser, "window-state-event",
@ -2578,7 +2580,7 @@ midori_browser_init (MidoriBrowser* browser)
gtk_container_add (GTK_CONTAINER (browser), vbox); gtk_container_add (GTK_CONTAINER (browser), vbox);
gtk_widget_show (vbox); gtk_widget_show (vbox);
// Let us see some ui manager magic /* Let us see some ui manager magic */
priv->action_group = gtk_action_group_new ("Browser"); priv->action_group = gtk_action_group_new ("Browser");
gtk_action_group_set_translation_domain (priv->action_group, GETTEXT_PACKAGE); gtk_action_group_set_translation_domain (priv->action_group, GETTEXT_PACKAGE);
gtk_action_group_add_actions (priv->action_group, gtk_action_group_add_actions (priv->action_group,
@ -2593,14 +2595,14 @@ midori_browser_init (MidoriBrowser* browser)
GError* error = NULL; GError* error = NULL;
if (!gtk_ui_manager_add_ui_from_string(ui_manager, ui_markup, -1, &error)) if (!gtk_ui_manager_add_ui_from_string(ui_manager, ui_markup, -1, &error))
{ {
// TODO: Should this be a message dialog? When does this happen? /* TODO: Should this be a message dialog? When does this happen? */
g_message ("User interface couldn't be created: %s", error->message); g_message ("User interface couldn't be created: %s", error->message);
g_error_free (error); g_error_free (error);
} }
GtkAction* action; GtkAction* action;
// Make all actions except toplevel menus which lack a callback insensitive /* Make all actions except toplevel menus which lack a callback insensitive
// This will vanish once all actions are implemented This will vanish once all actions are implemented */
guint i; guint i;
for (i = 0; i < entries_n; i++) for (i = 0; i < entries_n; i++)
{ {
@ -2616,9 +2618,9 @@ midori_browser_init (MidoriBrowser* browser)
gtk_action_set_sensitive (action, toggle_entries[i].callback != NULL); gtk_action_set_sensitive (action, toggle_entries[i].callback != NULL);
} }
//_action_set_active(browser, "Transferbar", config->toolbarTransfers); /* _action_set_active(browser, "Transferbar", config->toolbarTransfers); */
// Create the menubar /* Create the menubar */
priv->menubar = gtk_ui_manager_get_widget (ui_manager, "/menubar"); priv->menubar = gtk_ui_manager_get_widget (ui_manager, "/menubar");
GtkWidget* menuitem = gtk_menu_item_new (); GtkWidget* menuitem = gtk_menu_item_new ();
gtk_widget_show (menuitem); gtk_widget_show (menuitem);
@ -2655,10 +2657,10 @@ midori_browser_init (MidoriBrowser* browser)
_action_set_sensitive (browser, "PrivateBrowsing", FALSE); _action_set_sensitive (browser, "PrivateBrowsing", FALSE);
_action_set_sensitive (browser, "WorkOffline", FALSE); _action_set_sensitive (browser, "WorkOffline", FALSE);
// Create the navigationbar /* Create the navigationbar */
priv->navigationbar = gtk_ui_manager_get_widget ( priv->navigationbar = gtk_ui_manager_get_widget (
ui_manager, "/toolbar_navigation"); ui_manager, "/toolbar_navigation");
// FIXME: settings should be connected with screen changes /* FIXME: settings should be connected with screen changes */
GtkSettings* gtk_settings = gtk_widget_get_settings (GTK_WIDGET (browser)); GtkSettings* gtk_settings = gtk_widget_get_settings (GTK_WIDGET (browser));
if (gtk_settings) if (gtk_settings)
g_signal_connect (gtk_settings, "notify::gtk-toolbar-style", g_signal_connect (gtk_settings, "notify::gtk-toolbar-style",
@ -2671,7 +2673,7 @@ midori_browser_init (MidoriBrowser* browser)
priv->button_homepage = gtk_ui_manager_get_widget ( priv->button_homepage = gtk_ui_manager_get_widget (
ui_manager, "/toolbar_navigation/Homepage"); ui_manager, "/toolbar_navigation/Homepage");
// Location /* Location */
priv->location = sexy_icon_entry_new (); priv->location = sexy_icon_entry_new ();
sokoke_entry_setup_completion (GTK_ENTRY (priv->location)); sokoke_entry_setup_completion (GTK_ENTRY (priv->location));
priv->location_icon = gtk_image_new (); priv->location_icon = gtk_image_new ();
@ -2691,13 +2693,13 @@ midori_browser_init (MidoriBrowser* browser)
gtk_container_add (GTK_CONTAINER(toolitem), priv->location); gtk_container_add (GTK_CONTAINER(toolitem), priv->location);
gtk_toolbar_insert (GTK_TOOLBAR (priv->navigationbar), toolitem, -1); gtk_toolbar_insert (GTK_TOOLBAR (priv->navigationbar), toolitem, -1);
// Search /* Search */
priv->search = sexy_icon_entry_new (); priv->search = sexy_icon_entry_new ();
sexy_icon_entry_set_icon_highlight (SEXY_ICON_ENTRY (priv->search), sexy_icon_entry_set_icon_highlight (SEXY_ICON_ENTRY (priv->search),
SEXY_ICON_ENTRY_PRIMARY, TRUE); SEXY_ICON_ENTRY_PRIMARY, TRUE);
// TODO: Make this actively resizable or enlarge to fit contents? /* TODO: Make this actively resizable or enlarge to fit contents?
// FIXME: The interface is somewhat awkward and ought to be rethought The interface is somewhat awkward and ought to be rethought
// TODO: Display "show in context menu" search engines as "completion actions" Display "show in context menu" search engines as "completion actions" */
sokoke_entry_setup_completion (GTK_ENTRY (priv->search)); sokoke_entry_setup_completion (GTK_ENTRY (priv->search));
g_object_connect (priv->search, g_object_connect (priv->search,
"signal::icon-released", "signal::icon-released",
@ -2729,7 +2731,7 @@ midori_browser_init (MidoriBrowser* browser)
gtk_toolbar_insert (GTK_TOOLBAR (priv->navigationbar), gtk_toolbar_insert (GTK_TOOLBAR (priv->navigationbar),
GTK_TOOL_ITEM (priv->button_fullscreen), -1); GTK_TOOL_ITEM (priv->button_fullscreen), -1);
// Bookmarkbar /* Bookmarkbar */
priv->bookmarkbar = gtk_toolbar_new (); priv->bookmarkbar = gtk_toolbar_new ();
gtk_toolbar_set_icon_size (GTK_TOOLBAR (priv->bookmarkbar), gtk_toolbar_set_icon_size (GTK_TOOLBAR (priv->bookmarkbar),
GTK_ICON_SIZE_MENU); GTK_ICON_SIZE_MENU);
@ -2777,12 +2779,12 @@ midori_browser_init (MidoriBrowser* browser)
sokoke_container_show_children (GTK_CONTAINER (priv->bookmarkbar)); sokoke_container_show_children (GTK_CONTAINER (priv->bookmarkbar));
gtk_box_pack_start (GTK_BOX (vbox), priv->bookmarkbar, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), priv->bookmarkbar, FALSE, FALSE, 0);
// Superuser warning /* Superuser warning */
GtkWidget* hbox; GtkWidget* hbox;
if ((hbox = sokoke_superuser_warning_new ())) if ((hbox = sokoke_superuser_warning_new ()))
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
// Create the panel /* Create the panel */
GtkWidget* hpaned = gtk_hpaned_new (); GtkWidget* hpaned = gtk_hpaned_new ();
g_signal_connect (hpaned, "notify::position", g_signal_connect (hpaned, "notify::position",
G_CALLBACK (midori_panel_notify_position_cb), G_CALLBACK (midori_panel_notify_position_cb),
@ -2797,7 +2799,7 @@ midori_browser_init (MidoriBrowser* browser)
G_CALLBACK (midori_panel_close_cb), browser); G_CALLBACK (midori_panel_close_cb), browser);
gtk_paned_pack1 (GTK_PANED (hpaned), priv->panel, FALSE, FALSE); gtk_paned_pack1 (GTK_PANED (hpaned), priv->panel, FALSE, FALSE);
// Bookmarks /* Bookmarks */
GtkWidget* box = gtk_vbox_new (FALSE, 0); GtkWidget* box = gtk_vbox_new (FALSE, 0);
GtkTreeViewColumn* column; GtkTreeViewColumn* column;
GtkCellRenderer* renderer_text; GtkCellRenderer* renderer_text;
@ -2844,14 +2846,14 @@ midori_browser_init (MidoriBrowser* browser)
box, toolbar, box, toolbar,
"vcard", _("Bookmarks")); "vcard", _("Bookmarks"));
// Transfers /* Transfers */
GtkWidget* panel = midori_web_view_new (); GtkWidget* panel = midori_web_view_new ();
gtk_widget_show (panel); gtk_widget_show (panel);
midori_panel_append_page (MIDORI_PANEL (priv->panel), midori_panel_append_page (MIDORI_PANEL (priv->panel),
panel, NULL, panel, NULL,
"package", _("Transfers")); "package", _("Transfers"));
// Console /* Console */
priv->panel_console = midori_console_new (); priv->panel_console = midori_console_new ();
gtk_widget_show (priv->panel_console); gtk_widget_show (priv->panel_console);
toolbar = midori_console_get_toolbar (MIDORI_CONSOLE (priv->panel_console)); toolbar = midori_console_get_toolbar (MIDORI_CONSOLE (priv->panel_console));
@ -2860,14 +2862,14 @@ midori_browser_init (MidoriBrowser* browser)
priv->panel_console, toolbar, priv->panel_console, toolbar,
"terminal", _("Console")); "terminal", _("Console"));
// History /* History */
panel = midori_web_view_new (); panel = midori_web_view_new ();
gtk_widget_show (panel); gtk_widget_show (panel);
midori_panel_append_page (MIDORI_PANEL (priv->panel), midori_panel_append_page (MIDORI_PANEL (priv->panel),
panel, NULL, panel, NULL,
"document-open-recent", _("History")); "document-open-recent", _("History"));
// Pageholder /* Pageholder */
priv->panel_pageholder = g_object_new (MIDORI_TYPE_WEB_VIEW, priv->panel_pageholder = g_object_new (MIDORI_TYPE_WEB_VIEW,
"uri", "", "uri", "",
NULL); NULL);
@ -2876,7 +2878,7 @@ midori_browser_init (MidoriBrowser* browser)
priv->panel_pageholder, NULL, priv->panel_pageholder, NULL,
GTK_STOCK_CONVERT, _("Pageholder")); GTK_STOCK_CONVERT, _("Pageholder"));
// Userscripts /* Userscripts */
panel = midori_addons_new (GTK_WIDGET (browser), MIDORI_ADDON_USER_SCRIPTS); panel = midori_addons_new (GTK_WIDGET (browser), MIDORI_ADDON_USER_SCRIPTS);
gtk_widget_show (panel); gtk_widget_show (panel);
toolbar = midori_addons_get_toolbar (MIDORI_ADDONS (panel)); toolbar = midori_addons_get_toolbar (MIDORI_ADDONS (panel));
@ -2884,7 +2886,7 @@ midori_browser_init (MidoriBrowser* browser)
midori_panel_append_page (MIDORI_PANEL (priv->panel), midori_panel_append_page (MIDORI_PANEL (priv->panel),
panel, toolbar, panel, toolbar,
"", _("Userscripts")); "", _("Userscripts"));
// Userstyles /* Userstyles */
/*panel = midori_addons_new (GTK_WIDGET (browser), MIDORI_ADDON_USER_STYLES); /*panel = midori_addons_new (GTK_WIDGET (browser), MIDORI_ADDON_USER_STYLES);
gtk_widget_show (panel); gtk_widget_show (panel);
toolbar = midori_addons_get_toolbar (MIDORI_ADDONS (panel)); toolbar = midori_addons_get_toolbar (MIDORI_ADDONS (panel));
@ -2893,7 +2895,7 @@ midori_browser_init (MidoriBrowser* browser)
panel, toolbar, panel, toolbar,
"", _("Userstyles"));*/ "", _("Userstyles"));*/
// Notebook, containing all web_views /* Notebook, containing all web_views */
priv->notebook = gtk_notebook_new (); priv->notebook = gtk_notebook_new ();
gtk_notebook_set_scrollable (GTK_NOTEBOOK (priv->notebook), TRUE); gtk_notebook_set_scrollable (GTK_NOTEBOOK (priv->notebook), TRUE);
gtk_paned_pack2 (GTK_PANED (hpaned), priv->notebook, FALSE, FALSE); gtk_paned_pack2 (GTK_PANED (hpaned), priv->notebook, FALSE, FALSE);
@ -2902,7 +2904,7 @@ midori_browser_init (MidoriBrowser* browser)
browser); browser);
gtk_widget_show (priv->notebook); gtk_widget_show (priv->notebook);
// Incremental findbar /* Incremental findbar */
priv->find = gtk_toolbar_new (); priv->find = gtk_toolbar_new ();
gtk_toolbar_set_icon_size (GTK_TOOLBAR (priv->find), GTK_ICON_SIZE_MENU); gtk_toolbar_set_icon_size (GTK_TOOLBAR (priv->find), GTK_ICON_SIZE_MENU);
gtk_toolbar_set_style (GTK_TOOLBAR (priv->find), GTK_TOOLBAR_BOTH_HORIZ); gtk_toolbar_set_style (GTK_TOOLBAR (priv->find), GTK_TOOLBAR_BOTH_HORIZ);
@ -2959,17 +2961,17 @@ midori_browser_init (MidoriBrowser* browser)
sokoke_container_show_children (GTK_CONTAINER (priv->find)); sokoke_container_show_children (GTK_CONTAINER (priv->find));
gtk_box_pack_start (GTK_BOX (vbox), priv->find, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), priv->find, FALSE, FALSE, 0);
// Statusbar /* Statusbar */
// TODO: fix children overlapping statusbar border /* FIXME: children are overlapping the statusbar border */
priv->statusbar = gtk_statusbar_new (); priv->statusbar = gtk_statusbar_new ();
gtk_box_pack_start (GTK_BOX (vbox), priv->statusbar, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), priv->statusbar, FALSE, FALSE, 0);
priv->progressbar = gtk_progress_bar_new (); priv->progressbar = gtk_progress_bar_new ();
// Setting the progressbar's height to 1 makes it fit in the statusbar /* Setting the progressbar's height to 1 makes it fit in the statusbar */
gtk_widget_set_size_request (priv->progressbar, -1, 1); gtk_widget_set_size_request (priv->progressbar, -1, 1);
gtk_box_pack_start (GTK_BOX (priv->statusbar), priv->progressbar, gtk_box_pack_start (GTK_BOX (priv->statusbar), priv->progressbar,
FALSE, FALSE, 3); FALSE, FALSE, 3);
// Extensions /* Extensions */
panel = midori_addons_new (GTK_WIDGET (browser), MIDORI_ADDON_EXTENSIONS); panel = midori_addons_new (GTK_WIDGET (browser), MIDORI_ADDON_EXTENSIONS);
gtk_widget_show (panel); gtk_widget_show (panel);
toolbar = midori_addons_get_toolbar (MIDORI_ADDONS (panel)); toolbar = midori_addons_get_toolbar (MIDORI_ADDONS (panel));
@ -3176,17 +3178,17 @@ midori_browser_set_property (GObject* object,
_midori_browser_update_settings (browser); _midori_browser_update_settings (browser);
g_signal_connect (priv->settings, "notify", g_signal_connect (priv->settings, "notify",
G_CALLBACK (midori_browser_settings_notify), browser); G_CALLBACK (midori_browser_settings_notify), browser);
// FIXME: Assigning settings must be conditional, if web view or not /* FIXME: Assigning settings must be conditional, if web view or not */
// FIXME: Assign settings only if the same settings object was used /* FIXME: Assign settings only if the same settings object was used */
gtk_container_foreach (GTK_CONTAINER (priv->notebook), gtk_container_foreach (GTK_CONTAINER (priv->notebook),
(GtkCallback) midori_web_view_set_settings, (GtkCallback) midori_web_view_set_settings,
priv->settings); priv->settings);
break; break;
case PROP_TRASH: case PROP_TRASH:
; // FIXME: Disconnect handlers ; /* FIXME: Disconnect handlers */
katze_object_assign (priv->trash, g_value_get_object (value)); katze_object_assign (priv->trash, g_value_get_object (value));
g_object_ref (priv->trash); g_object_ref (priv->trash);
// FIXME: Connect to updates /* FIXME: Connect to updates */
_midori_browser_update_actions (browser); _midori_browser_update_actions (browser);
break; break;
default: default:
@ -3382,7 +3384,7 @@ midori_browser_remove_tab (MidoriBrowser* browser,
GtkWidget* scrolled = _midori_browser_scrolled_for_child (browser, widget); GtkWidget* scrolled = _midori_browser_scrolled_for_child (browser, widget);
gtk_container_remove (GTK_CONTAINER (priv->notebook), scrolled); gtk_container_remove (GTK_CONTAINER (priv->notebook), scrolled);
// FIXME: Remove the menuitem if this is a web view /* FIXME: Remove the menuitem if this is a web view */
} }
/** /**
@ -3602,7 +3604,7 @@ midori_browser_get_proxy_xbel_folder (MidoriBrowser* browser)
if (!priv->proxy_xbel_folder) if (!priv->proxy_xbel_folder)
{ {
priv->proxy_xbel_folder = katze_xbel_folder_new (); priv->proxy_xbel_folder = katze_xbel_folder_new ();
// FIXME: Fill in xbel items of all present web views /* FIXME: Fill in xbel items of all present web views */
} }
return priv->proxy_xbel_folder; return priv->proxy_xbel_folder;
} }

194
midori/midori-weblist.c Normal file
View file

@ -0,0 +1,194 @@
/*
Copyright (C) 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
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 "midori-weblist.h"
#include <glib/gi18n.h>
#include <string.h>
struct _MidoriWebList
{
GObject parent_instance;
GList* items;
};
G_DEFINE_TYPE (MidoriWebList, midori_web_list, G_TYPE_OBJECT)
enum {
ADD_ITEM,
REMOVE_ITEM,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL];
static void
midori_web_list_finalize (GObject* object);
static void
midori_web_list_class_init (MidoriWebListClass* class)
{
signals[ADD_ITEM] = g_signal_new (
"add-item",
G_TYPE_FROM_CLASS (class),
(GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
G_STRUCT_OFFSET (MidoriWebListClass, add_item),
0,
NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
MIDORI_TYPE_WEB_ITEM);
signals[REMOVE_ITEM] = g_signal_new (
"remove-item",
G_TYPE_FROM_CLASS (class),
(GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
G_STRUCT_OFFSET (MidoriWebListClass, remove_item),
0,
NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
MIDORI_TYPE_WEB_ITEM);
class->add_item = midori_web_list_add_item;
class->remove_item = midori_web_list_remove_item;
GObjectClass* gobject_class = G_OBJECT_CLASS (class);
gobject_class->finalize = midori_web_list_finalize;
}
static void
midori_web_list_init (MidoriWebList* web_list)
{
web_list->items = NULL;
}
static void
midori_web_list_finalize (GObject* object)
{
MidoriWebList* web_list = MIDORI_WEB_LIST (object);
g_list_foreach (web_list->items, (GFunc)g_object_unref, NULL);
g_list_free (web_list->items);
G_OBJECT_CLASS (midori_web_list_parent_class)->finalize (object);
}
/**
* midori_web_list_new:
*
* Creates a new #MidoriWebList.
*
* Return value: a new #MidoriWebList
**/
MidoriWebList*
midori_web_list_new (void)
{
MidoriWebList* web_list = g_object_new (MIDORI_TYPE_WEB_LIST,
NULL);
return web_list;
}
/**
* midori_web_list_add_item:
* @web_list: a #MidoriWebList
* @web_item: a #MidoriWebItem
*
* Adds an item to the list.
**/
void
midori_web_list_add_item (MidoriWebList* web_list,
MidoriWebItem* web_item)
{
g_object_ref (web_item);
web_list->items = g_list_append (web_list->items, web_item);
}
/**
* midori_web_list_add_item:
* @web_list: a #MidoriWebList
* @web_item: a #MidoriWebItem
*
* Removes an item from the list.
**/
void
midori_web_list_remove_item (MidoriWebList* web_list,
MidoriWebItem* web_item)
{
web_list->items = g_list_remove (web_list->items, web_item);
}
/**
* midori_web_list_get_nth_item:
* @web_list: a #MidoriWebList
* @n: an index in the list
*
* Retrieves the item in @web_list at the index @n.
*
* Return value: an item, or %NULL
**/
MidoriWebItem*
midori_web_list_get_nth_item (MidoriWebList* web_list,
guint n)
{
g_return_val_if_fail (MIDORI_IS_WEB_LIST (web_list), 0);
return g_list_nth_data (web_list->items, n);
}
/**
* midori_web_list_find_token:
* @web_list: a #MidoriWebList
* @token: a token string
*
* Looks up an item in the list which has the specified token.
*
* Note that @token is by definition unique to one item.
*
* Return value: an item, or %NULL
**/
MidoriWebItem*
midori_web_list_find_token (MidoriWebList* web_list,
const gchar* token)
{
guint n, i;
MidoriWebItem* web_item;
g_return_val_if_fail (MIDORI_IS_WEB_LIST (web_list), NULL);
n = g_list_length (web_list->items);
for (i = 0; i < n; i++)
{
web_item = (MidoriWebItem*)g_list_nth_data (web_list->items, i);
if (!strcmp (midori_web_item_get_token (web_item), token))
return web_item;
}
return NULL;
}
/**
* midori_web_list_get_length:
* @web_list: a #MidoriWebList
*
* Retrieves the number of items in @web_list.
*
* Return value: the length of the list
**/
guint
midori_web_list_get_length (MidoriWebList* web_list)
{
g_return_val_if_fail (MIDORI_IS_WEB_LIST (web_list), 0);
return g_list_length (web_list->items);
}

75
midori/midori-weblist.h Normal file
View file

@ -0,0 +1,75 @@
/*
Copyright (C) 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
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 __MIDORI_WEB_LIST_H__
#define __MIDORI_WEB_LIST_H__
#include "midori-webitem.h"
G_BEGIN_DECLS
#define MIDORI_TYPE_WEB_LIST \
(midori_web_list_get_type ())
#define MIDORI_WEB_LIST(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), MIDORI_TYPE_WEB_LIST, MidoriWebList))
#define MIDORI_WEB_LIST_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), MIDORI_TYPE_WEB_LIST, MidoriWebListClass))
#define MIDORI_IS_WEB_LIST(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIDORI_TYPE_WEB_LIST))
#define MIDORI_IS_WEB_LIST_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), MIDORI_TYPE_WEB_LIST))
#define MIDORI_WEB_LIST_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), MIDORI_TYPE_WEB_LIST, MidoriWebListClass))
typedef struct _MidoriWebList MidoriWebList;
typedef struct _MidoriWebListClass MidoriWebListClass;
struct _MidoriWebListClass
{
GObjectClass parent_class;
/* Signals */
void
(*add_item) (MidoriWebList* web_list,
MidoriWebItem* web_item);
void
(*remove_item) (MidoriWebList* web_list,
MidoriWebItem* web_item);
};
GType
midori_web_list_get_type (void);
MidoriWebList*
midori_web_list_new (void);
void
midori_web_list_add_item (MidoriWebList* web_list,
MidoriWebItem* web_item);
void
midori_web_list_remove_item (MidoriWebList* web_list,
MidoriWebItem* web_item);
MidoriWebItem*
midori_web_list_get_nth_item (MidoriWebList* web_list,
guint n);
MidoriWebItem*
midori_web_list_find_token (MidoriWebList* web_list,
const gchar* token);
guint
midori_web_list_get_length (MidoriWebList* web_list);
G_END_DECLS
#endif /* __MIDORI_WEB_LIST_H__ */

View file

@ -1,95 +0,0 @@
/*
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
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 "search.h"
#include "midori-webitem.h"
#include "sokoke.h"
GList* search_engines_new(void)
{
return NULL;
}
void search_engines_free(GList* searchEngines)
{
g_list_foreach(searchEngines, (GFunc)g_object_unref, NULL);
g_list_free(searchEngines);
}
gboolean search_engines_from_file(GList** searchEngines, const gchar* filename
, GError** error)
{
g_return_val_if_fail(!g_list_nth(*searchEngines, 0), FALSE);
GKeyFile* keyFile = g_key_file_new();
g_key_file_load_from_file(keyFile, filename, G_KEY_FILE_KEEP_COMMENTS, error);
/*g_key_file_load_from_data_dirs(keyFile, sFilename, NULL
, G_KEY_FILE_KEEP_COMMENTS, error);*/
gchar** engines = g_key_file_get_groups(keyFile, NULL);
guint i;
for(i = 0; engines[i] != NULL; i++)
{
MidoriWebItem* web_item = midori_web_item_new ();
guint j, n_properties;
GParamSpec** pspecs = g_object_class_list_properties (
G_OBJECT_GET_CLASS (web_item), &n_properties);
for (j = 0; j < n_properties; j++)
{
const gchar* property = g_param_spec_get_name (pspecs[j]);
gchar* value = g_key_file_get_string (keyFile, engines[i],
property, NULL);
g_object_set (web_item, property, value, NULL);
g_free (value);
}
*searchEngines = g_list_prepend(*searchEngines, web_item);
}
*searchEngines = g_list_reverse(*searchEngines);
g_strfreev(engines);
g_key_file_free(keyFile);
return !(error && *error);
}
static void key_file_set_string(GKeyFile* keyFile, const gchar* group
, const gchar* key, const gchar* string)
{
g_return_if_fail(group);
if(string)
g_key_file_set_string(keyFile, group, key, string);
}
gboolean search_engines_to_file(GList* searchEngines, const gchar* filename
, GError** error)
{
GKeyFile* keyFile = g_key_file_new();
guint n = g_list_length(searchEngines);
guint i;
for(i = 0; i < n; i++)
{
MidoriWebItem* web_item = (MidoriWebItem*)g_list_nth_data(searchEngines, i);
const gchar* name = midori_web_item_get_name (web_item);
guint j, n_properties;
GParamSpec** pspecs = g_object_class_list_properties (
G_OBJECT_GET_CLASS (web_item), &n_properties);
for (j = 0; j < n_properties; j++)
{
const gchar* property = g_param_spec_get_name (pspecs[j]);
gchar* value;
g_object_get (web_item, property, &value, NULL);
key_file_set_string (keyFile, name, property, value);
g_free (value);
}
}
gboolean bSaved = sokoke_key_file_save_to_file(keyFile, filename, error);
g_key_file_free(keyFile);
return bSaved;
}

View file

@ -1,30 +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 __SEARCH_H__
#define __SEARCH_H__ 1
#include <glib.h>
#include <glib-object.h>
GList*
search_engines_new(void);
void
search_engines_free(GList*);
gboolean
search_engines_from_file(GList**, const gchar*, GError**);
gboolean
search_engines_to_file(GList*, const gchar*, GError**);
#endif /* !__SEARCH_H__ */

View file

@ -25,49 +25,56 @@
#include <glib/gprintf.h> #include <glib/gprintf.h>
gchar* gchar*
sokoke_magic_uri (const gchar* uri, const gchar* default_search_uri) sokoke_magic_uri (const gchar* uri,
MidoriWebList* search_engines)
{ {
// Add file:// if we have a local path g_return_val_if_fail (uri, NULL);
if (search_engines)
{
g_return_val_if_fail (MIDORI_IS_WEB_LIST (search_engines), NULL);
}
gchar* current_dir;
gchar* result;
gchar* search;
const gchar* search_uri;
gchar** parts;
MidoriWebItem* web_item;
/* Add file:// if we have a local path */
if (g_path_is_absolute (uri)) if (g_path_is_absolute (uri))
return g_strconcat ("file://", uri, NULL); return g_strconcat ("file://", uri, NULL);
// Construct an absolute path if the file is relative /* Construct an absolute path if the file is relative */
if (g_file_test (uri, G_FILE_TEST_EXISTS) && g_file_test (uri, G_FILE_TEST_IS_REGULAR)) if (g_file_test (uri, G_FILE_TEST_EXISTS)
&& g_file_test (uri, G_FILE_TEST_IS_REGULAR))
{ {
gchar* current_dir = g_get_current_dir (); current_dir = g_get_current_dir ();
gchar* result = g_strconcat ("file://", current_dir, G_DIR_SEPARATOR_S, uri, NULL); result = g_strconcat ("file://", current_dir,
G_DIR_SEPARATOR_S, uri, NULL);
g_free (current_dir); g_free (current_dir);
return result; return result;
} }
// Do we need to add a protocol? /* Do we need to add a protocol? */
if (!strstr (uri, "://")) if (!strstr (uri, "://"))
{ {
// Do we have a domain, ip address or localhost? /* Do we have a domain, ip address or localhost? */
if (strchr (uri, '.') != NULL || !strcmp (uri, "localhost")) if (strchr (uri, '.') != NULL || !strcmp (uri, "localhost"))
return g_strconcat ("http://", uri, NULL); return g_strconcat ("http://", uri, NULL);
// We don't want to search? So return early. /* We don't want to search? So return early. */
if (!default_search_uri) if (!search_engines)
return g_strdup (uri); return g_strdup (uri);
gchar* search; search = NULL;
const gchar* search_uri = NULL; search_uri = NULL;
// Do we have a keyword and a string? /* Do we have a keyword and a string? */
gchar** parts = g_strsplit (uri, " ", 2); parts = g_strsplit (uri, " ", 2);
if (parts[0] && parts[1]) if (parts[0] && parts[1])
{ {
guint n = g_list_length (searchEngines); web_item = midori_web_list_find_token (search_engines, parts[0]);
guint i; if (web_item)
for (i = 0; i < n; i++)
{
MidoriWebItem* web_item = (MidoriWebItem*)g_list_nth_data (
searchEngines, i);
if (!strcmp (midori_web_item_get_token (web_item), parts[0]))
search_uri = midori_web_item_get_uri (web_item); search_uri = midori_web_item_get_uri (web_item);
} }
if (search_uri) if (search_uri)
search = g_strdup_printf (search_uri, parts[1]); 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 search;
} }
return g_strdup (uri); return g_strdup (uri);
@ -84,7 +91,8 @@ sokoke_entry_setup_completion (GtkEntry* entry)
gtk_entry_completion_set_text_column (completion, 0); gtk_entry_completion_set_text_column (completion, 0);
gtk_entry_completion_set_minimum_key_length (completion, 3); gtk_entry_completion_set_minimum_key_length (completion, 3);
gtk_entry_set_completion (entry, completion); gtk_entry_set_completion (entry, completion);
gtk_entry_completion_set_popup_completion (completion, FALSE); //... /* FIXME: Completion doesn't work well, so it's disabled */
gtk_entry_completion_set_popup_completion (completion, FALSE);
} }
void void
@ -101,8 +109,8 @@ void
sokoke_combo_box_add_strings (GtkComboBox* combobox, sokoke_combo_box_add_strings (GtkComboBox* combobox,
const gchar* label_first, ...) const gchar* label_first, ...)
{ {
// Add a number of strings to a combobox, terminated with NULL /* Add a number of strings to a combobox, terminated with NULL
// This works only for text comboboxes This works only for text comboboxes */
va_list args; va_list args;
va_start (args, label_first); va_start (args, label_first);
@ -115,7 +123,7 @@ sokoke_combo_box_add_strings (GtkComboBox* combobox,
void sokoke_widget_set_visible (GtkWidget* widget, gboolean visible) void sokoke_widget_set_visible (GtkWidget* widget, gboolean visible)
{ {
// Show or hide the widget /* Show or hide the widget */
if (visible) if (visible)
gtk_widget_show (widget); gtk_widget_show (widget);
else else
@ -125,7 +133,7 @@ void sokoke_widget_set_visible (GtkWidget* widget, gboolean visible)
void void
sokoke_container_show_children (GtkContainer* container) sokoke_container_show_children (GtkContainer* container)
{ {
// Show every child but not the container itself /* Show every child but not the container itself */
gtk_container_foreach (container, (GtkCallback)(gtk_widget_show_all), NULL); gtk_container_foreach (container, (GtkCallback)(gtk_widget_show_all), NULL);
} }
@ -149,7 +157,7 @@ sokoke_widget_popup_position_menu (GtkMenu* menu,
SokokePopupInfo* info = user_data; SokokePopupInfo* info = user_data;
GtkWidget* widget = info->widget; GtkWidget* widget = info->widget;
// Retrieve size and position of both widget and menu /* Retrieve size and position of both widget and menu */
if (GTK_WIDGET_NO_WINDOW (widget)) if (GTK_WIDGET_NO_WINDOW (widget))
{ {
gdk_window_get_position (widget->window, &wx, &wy); gdk_window_get_position (widget->window, &wx, &wy);
@ -161,11 +169,11 @@ sokoke_widget_popup_position_menu (GtkMenu* menu,
gtk_widget_size_request (GTK_WIDGET (menu), &menu_req); gtk_widget_size_request (GTK_WIDGET (menu), &menu_req);
gtk_widget_size_request (widget, &widget_req); gtk_widget_size_request (widget, &widget_req);
menu_width = menu_req.width; menu_width = menu_req.width;
gint widget_height = widget_req.height; // Better than allocation.height gint widget_height = widget_req.height; /* Better than allocation.height */
// Calculate menu position /* Calculate menu position */
if (info->position == SOKOKE_MENU_POSITION_CURSOR) if (info->position == SOKOKE_MENU_POSITION_CURSOR)
; // Do nothing? ; /* Do nothing? */
else if (info->position == SOKOKE_MENU_POSITION_RIGHT) else if (info->position == SOKOKE_MENU_POSITION_RIGHT)
{ {
*x = wx + widget->allocation.width - menu_width; *x = wx + widget->allocation.width - menu_width;
@ -225,7 +233,7 @@ sokoke_get_desktop (void)
static SokokeDesktop desktop = SOKOKE_DESKTOP_UNTESTED; static SokokeDesktop desktop = SOKOKE_DESKTOP_UNTESTED;
if (G_UNLIKELY (desktop == SOKOKE_DESKTOP_UNTESTED)) if (G_UNLIKELY (desktop == SOKOKE_DESKTOP_UNTESTED))
{ {
// Are we running in Xfce? /* Are we running in Xfce? */
gint result; gchar* out; gchar* err; gint result; gchar* out; gchar* err;
gboolean success = g_spawn_command_line_sync ( gboolean success = g_spawn_command_line_sync (
"xprop -root _DT_SAVE_MODE | grep -q xfce4", "xprop -root _DT_SAVE_MODE | grep -q xfce4",
@ -243,8 +251,8 @@ GtkWidget*
sokoke_xfce_header_new (const gchar* icon, sokoke_xfce_header_new (const gchar* icon,
const gchar* title) const gchar* title)
{ {
// Create an xfce header with icon and title /* Create an xfce header with icon and title
// This returns NULL if the desktop is not xfce This returns NULL if the desktop is not xfce */
if (sokoke_get_desktop () == SOKOKE_DESKTOP_XFCE) if (sokoke_get_desktop () == SOKOKE_DESKTOP_XFCE)
{ {
GtkWidget* entry = gtk_entry_new (); GtkWidget* entry = gtk_entry_new ();
@ -274,10 +282,10 @@ sokoke_xfce_header_new (const gchar* icon,
GtkWidget* GtkWidget*
sokoke_superuser_warning_new (void) sokoke_superuser_warning_new (void)
{ {
// Create a horizontal bar with a security warning /* Create a horizontal bar with a security warning
// This returns NULL if the user is no superuser This returns NULL if the user is no superuser */
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
if (G_UNLIKELY (!geteuid ())) // effective superuser? if (G_UNLIKELY (!geteuid ())) /* effective superuser? */
{ {
GtkWidget* hbox = gtk_event_box_new (); GtkWidget* hbox = gtk_event_box_new ();
gtk_widget_modify_bg (hbox, GTK_STATE_NORMAL, gtk_widget_modify_bg (hbox, GTK_STATE_NORMAL,
@ -299,7 +307,7 @@ sokoke_superuser_warning_new (void)
GtkWidget* GtkWidget*
sokoke_hig_frame_new (const gchar* title) sokoke_hig_frame_new (const gchar* title)
{ {
// Create a frame with no actual frame but a bold label and indentation /* Create a frame with no actual frame but a bold label and indentation */
GtkWidget* frame = gtk_frame_new (NULL); GtkWidget* frame = gtk_frame_new (NULL);
gchar* title_bold = g_strdup_printf ("<b>%s</b>", title); gchar* title_bold = g_strdup_printf ("<b>%s</b>", title);
GtkWidget* label = gtk_label_new (NULL); GtkWidget* label = gtk_label_new (NULL);
@ -314,8 +322,8 @@ void
sokoke_widget_set_pango_font_style (GtkWidget* widget, sokoke_widget_set_pango_font_style (GtkWidget* widget,
PangoStyle style) PangoStyle style)
{ {
// Conveniently change the pango font style /* Conveniently change the pango font style
// For some reason we need to reset if we actually want the normal style For some reason we need to reset if we actually want the normal style */
if (style == PANGO_STYLE_NORMAL) if (style == PANGO_STYLE_NORMAL)
gtk_widget_modify_font (widget, NULL); gtk_widget_modify_font (widget, NULL);
else else
@ -368,7 +376,7 @@ void
sokoke_entry_set_default_text (GtkEntry* entry, sokoke_entry_set_default_text (GtkEntry* entry,
const gchar* default_text) const gchar* default_text)
{ {
// Note: The default text initially overwrites any previous text /* Note: The default text initially overwrites any previous text */
gchar* old_value = g_object_get_data (G_OBJECT (entry), gchar* old_value = g_object_get_data (G_OBJECT (entry),
"sokoke_default_text"); "sokoke_default_text");
if (!old_value) if (!old_value)

View file

@ -12,14 +12,16 @@
#ifndef __SOKOKE_H__ #ifndef __SOKOKE_H__
#define __SOKOKE_H__ 1 #define __SOKOKE_H__ 1
#include "midori-weblist.h"
#include <gtk/gtk.h> #include <gtk/gtk.h>
// Many themes need this hack for small toolbars to work /* Many themes need this hack for small toolbars to work */
#define GTK_ICON_SIZE_SMALL_TOOLBAR GTK_ICON_SIZE_BUTTON #define GTK_ICON_SIZE_SMALL_TOOLBAR GTK_ICON_SIZE_BUTTON
gchar* gchar*
sokoke_magic_uri (const gchar* uri, sokoke_magic_uri (const gchar* uri,
const gchar* search); MidoriWebList* search_engines);
void void
sokoke_entry_setup_completion (GtkEntry* entry); sokoke_entry_setup_completion (GtkEntry* entry);

View file

@ -29,7 +29,7 @@ load_web_icon (const gchar* icon, GtkIconSize size, GtkWidget* widget)
GdkPixbuf* pixbuf = NULL; GdkPixbuf* pixbuf = NULL;
if (icon && *icon) if (icon && *icon)
{ {
// TODO: We want to allow http as well, maybe also base64? /* TODO: We want to allow http as well, maybe also base64? */
const gchar* icon_ready = g_str_has_prefix (icon, "file://") const gchar* icon_ready = g_str_has_prefix (icon, "file://")
? &icon[7] : icon; ? &icon[7] : icon;
GtkStockItem stock_id; GtkStockItem stock_id;
@ -57,18 +57,20 @@ load_web_icon (const gchar* icon, GtkIconSize size, GtkWidget* widget)
void update_searchEngine(guint index, GtkWidget* search) void update_searchEngine(guint index, GtkWidget* search)
{ {
guint n = g_list_length(searchEngines); MidoriWebList* search_engines = midori_web_list_new (); /* FIXME */
// Display a default icon in case we have no engines guint n = midori_web_list_get_length (search_engines);
MidoriWebItem* web_item;
/* Display a default icon in case we have no engines */
if(!n) if(!n)
sexy_icon_entry_set_icon(SEXY_ICON_ENTRY(search), SEXY_ICON_ENTRY_PRIMARY sexy_icon_entry_set_icon(SEXY_ICON_ENTRY(search), SEXY_ICON_ENTRY_PRIMARY
, GTK_IMAGE(gtk_image_new_from_stock(GTK_STOCK_FIND, GTK_ICON_SIZE_MENU))); , GTK_IMAGE(gtk_image_new_from_stock(GTK_STOCK_FIND, GTK_ICON_SIZE_MENU)));
// Change the icon and default text according to the chosen engine /* Change the icon and default text according to the chosen engine */
else else
{ {
// Reset in case the index is out of range /* Reset in case the index is out of range */
if(index >= n) if(index >= n)
index = 0; index = 0;
MidoriWebItem* web_item = (MidoriWebItem*)g_list_nth_data (searchEngines, index); web_item = midori_web_list_get_nth_item (search_engines, index);
GdkPixbuf* pixbuf = load_web_icon (midori_web_item_get_icon (web_item), GdkPixbuf* pixbuf = load_web_icon (midori_web_item_get_icon (web_item),
GTK_ICON_SIZE_MENU, search); GTK_ICON_SIZE_MENU, search);
sexy_icon_entry_set_icon(SEXY_ICON_ENTRY(search) sexy_icon_entry_set_icon(SEXY_ICON_ENTRY(search)
@ -76,7 +78,7 @@ void update_searchEngine(guint index, GtkWidget* search)
g_object_unref(pixbuf); g_object_unref(pixbuf);
sokoke_entry_set_default_text (GTK_ENTRY (search), sokoke_entry_set_default_text (GTK_ENTRY (search),
midori_web_item_get_name (web_item)); midori_web_item_get_name (web_item));
// config->searchEngine = index; /* config->searchEngine = index; */
} }
} }
@ -89,15 +91,17 @@ void on_webSearch_engine_activate(GtkWidget* widget, MidoriBrowser* browser)
void on_webSearch_icon_released(GtkWidget* widget, SexyIconEntryPosition* pos void on_webSearch_icon_released(GtkWidget* widget, SexyIconEntryPosition* pos
, gint button, MidoriBrowser* browser) , gint button, MidoriBrowser* browser)
{ {
MidoriWebList* search_engines = midori_web_list_new (); /* FIXME */
GtkWidget* menu = gtk_menu_new(); GtkWidget* menu = gtk_menu_new();
guint n = g_list_length(searchEngines); guint n = midori_web_list_get_length (search_engines);
GtkWidget* menuitem; GtkWidget* menuitem;
MidoriWebItem* web_item;
if(n) if(n)
{ {
guint i; guint i;
for(i = 0; i < n; i++) for(i = 0; i < n; i++)
{ {
MidoriWebItem* web_item = (MidoriWebItem*)g_list_nth_data (searchEngines, i); web_item = midori_web_list_get_nth_item (search_engines, i);
menuitem = gtk_image_menu_item_new_with_label ( menuitem = gtk_image_menu_item_new_with_label (
midori_web_item_get_name (web_item)); midori_web_item_get_name (web_item));
GdkPixbuf* pixbuf = load_web_icon (midori_web_item_get_icon (web_item), GdkPixbuf* pixbuf = load_web_icon (midori_web_item_get_icon (web_item),
@ -139,7 +143,7 @@ static void on_webSearch_engines_render_icon(GtkTreeViewColumn* column
MidoriWebItem* web_item; MidoriWebItem* web_item;
gtk_tree_model_get(model, iter, ENGINES_COL_ENGINE, &web_item, -1); gtk_tree_model_get(model, iter, ENGINES_COL_ENGINE, &web_item, -1);
// TODO: Would it be better to not do this on every redraw? /* TODO: Would it be better to not do this on every redraw? */
const gchar* icon = midori_web_item_get_icon (web_item); const gchar* icon = midori_web_item_get_icon (web_item);
if (icon) if (icon)
{ {
@ -185,6 +189,7 @@ const gchar* STR_NON_NULL(const gchar* string)
static void webSearch_editEngine_dialog_new(gboolean newEngine, CWebSearch* webSearch) static void webSearch_editEngine_dialog_new(gboolean newEngine, CWebSearch* webSearch)
{ {
MidoriWebList* search_engines = midori_web_list_new (); /* FIXME */
GtkWidget* dialog = gtk_dialog_new_with_buttons( GtkWidget* dialog = gtk_dialog_new_with_buttons(
newEngine ? _("Add search engine") : _("Edit search engine") newEngine ? _("Add search engine") : _("Edit search engine")
, GTK_WINDOW(webSearch->window) , GTK_WINDOW(webSearch->window)
@ -304,7 +309,7 @@ static void webSearch_editEngine_dialog_new(gboolean newEngine, CWebSearch* webS
if(newEngine) if(newEngine)
{ {
searchEngines = g_list_append(searchEngines, web_item); midori_web_list_add_item (search_engines, web_item);
liststore = gtk_tree_view_get_model(GTK_TREE_VIEW(webSearch->treeview)); liststore = gtk_tree_view_get_model(GTK_TREE_VIEW(webSearch->treeview));
gtk_list_store_append(GTK_LIST_STORE(liststore), &iter); gtk_list_store_append(GTK_LIST_STORE(liststore), &iter);
} }
@ -327,6 +332,7 @@ static void on_webSearch_edit(GtkWidget* widget, CWebSearch* webSearch)
static void on_webSearch_remove(GtkWidget* widget, CWebSearch* webSearch) static void on_webSearch_remove(GtkWidget* widget, CWebSearch* webSearch)
{ {
MidoriWebList* search_engines = midori_web_list_new (); /* FIXME */
GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(webSearch->treeview)); GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(webSearch->treeview));
GtkTreeModel* liststore; GtkTreeModel* liststore;
GtkTreeIter iter; GtkTreeIter iter;
@ -335,14 +341,15 @@ static void on_webSearch_remove(GtkWidget* widget, CWebSearch* webSearch)
gtk_tree_model_get(liststore, &iter, ENGINES_COL_ENGINE, &web_item, -1); gtk_tree_model_get(liststore, &iter, ENGINES_COL_ENGINE, &web_item, -1);
gtk_list_store_remove(GTK_LIST_STORE(liststore), &iter); gtk_list_store_remove(GTK_LIST_STORE(liststore), &iter);
g_object_unref (web_item); g_object_unref (web_item);
searchEngines = g_list_remove (searchEngines, web_item); midori_web_list_remove_item (search_engines, web_item);
//update_searchEngine(config->searchEngine, webSearch->browser); /*update_searchEngine(config->searchEngine, webSearch->browser); */
webSearch_toggle_edit_buttons(g_list_nth(searchEngines, 0) != NULL, webSearch); webSearch_toggle_edit_buttons(midori_web_list_get_length(search_engines), webSearch);
// FIXME: we want to allow undo of some kind /* FIXME: we want to allow undo of some kind */
} }
GtkWidget* webSearch_manageSearchEngines_dialog_new(MidoriBrowser* browser) GtkWidget* webSearch_manageSearchEngines_dialog_new(MidoriBrowser* browser)
{ {
MidoriWebList* search_engines = midori_web_list_new (); /* FIXME */
const gchar* dialogTitle = _("Manage search engines"); const gchar* dialogTitle = _("Manage search engines");
GtkWidget* dialog = gtk_dialog_new_with_buttons(dialogTitle GtkWidget* dialog = gtk_dialog_new_with_buttons(dialogTitle
, GTK_WINDOW(browser) , GTK_WINDOW(browser)
@ -353,16 +360,16 @@ GtkWidget* webSearch_manageSearchEngines_dialog_new(MidoriBrowser* browser)
, GTK_RESPONSE_CLOSE , GTK_RESPONSE_CLOSE
, NULL); , NULL);
gtk_window_set_icon_name(GTK_WINDOW(dialog), GTK_STOCK_PROPERTIES); gtk_window_set_icon_name(GTK_WINDOW(dialog), GTK_STOCK_PROPERTIES);
// TODO: Implement some kind of help function /* TODO: Implement some kind of help function */
gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog) gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog)
, GTK_RESPONSE_HELP, FALSE); //... , GTK_RESPONSE_HELP, FALSE);
gint iWidth, iHeight; gint iWidth, iHeight;
sokoke_widget_get_text_size(dialog, "M", &iWidth, &iHeight); sokoke_widget_get_text_size(dialog, "M", &iWidth, &iHeight);
gtk_window_set_default_size(GTK_WINDOW(dialog), iWidth * 45, -1); gtk_window_set_default_size(GTK_WINDOW(dialog), iWidth * 45, -1);
g_signal_connect(dialog, "response", G_CALLBACK(gtk_widget_destroy), dialog); g_signal_connect(dialog, "response", G_CALLBACK(gtk_widget_destroy), dialog);
// TODO: Do we want tooltips for explainations or can we omit that? /* TODO: Do we want tooltips for explainations or can we omit that?
// TODO: We need mnemonics We need mnemonics
// TODO: Take multiple windows into account when applying changes Take multiple windows into account when applying changes */
GtkWidget* xfce_heading; GtkWidget* xfce_heading;
if((xfce_heading = sokoke_xfce_header_new( if((xfce_heading = sokoke_xfce_header_new(
gtk_window_get_icon_name(GTK_WINDOW(dialog)), dialogTitle))) gtk_window_get_icon_name(GTK_WINDOW(dialog)), dialogTitle)))
@ -391,11 +398,11 @@ GtkWidget* webSearch_manageSearchEngines_dialog_new(MidoriBrowser* browser)
gtk_container_add(GTK_CONTAINER(scrolled), treeview); gtk_container_add(GTK_CONTAINER(scrolled), treeview);
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_IN);
gtk_box_pack_start(GTK_BOX(hbox), scrolled, TRUE, TRUE, 5); gtk_box_pack_start(GTK_BOX(hbox), scrolled, TRUE, TRUE, 5);
guint n = g_list_length(searchEngines); guint n = midori_web_list_get_length (search_engines);
guint i; guint i;
for(i = 0; i < n; i++) for(i = 0; i < n; i++)
{ {
MidoriWebItem* web_item = (MidoriWebItem*)g_list_nth_data (searchEngines, i); MidoriWebItem* web_item = midori_web_list_get_nth_item (search_engines, i);
gtk_list_store_insert_with_values(GTK_LIST_STORE(liststore), NULL, i gtk_list_store_insert_with_values(GTK_LIST_STORE(liststore), NULL, i
, ENGINES_COL_ENGINE, web_item, -1); , ENGINES_COL_ENGINE, web_item, -1);
} }
@ -418,13 +425,13 @@ GtkWidget* webSearch_manageSearchEngines_dialog_new(MidoriBrowser* browser)
g_signal_connect(button, "clicked", G_CALLBACK(on_webSearch_remove), webSearch); g_signal_connect(button, "clicked", G_CALLBACK(on_webSearch_remove), webSearch);
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
webSearch->remove = button; webSearch->remove = button;
button = gtk_label_new(""); // This is an invisible separator button = gtk_label_new(""); /* This is an invisible separator */
gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, TRUE, 12); gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, TRUE, 12);
button = gtk_button_new_from_stock(GTK_STOCK_GO_DOWN); button = gtk_button_new_from_stock(GTK_STOCK_GO_DOWN);
gtk_widget_set_sensitive(button, FALSE); //... gtk_widget_set_sensitive(button, FALSE);
gtk_box_pack_end(GTK_BOX(vbox), button, FALSE, FALSE, 0); gtk_box_pack_end(GTK_BOX(vbox), button, FALSE, FALSE, 0);
button = gtk_button_new_from_stock(GTK_STOCK_GO_UP); button = gtk_button_new_from_stock(GTK_STOCK_GO_UP);
gtk_widget_set_sensitive(button, FALSE); //... gtk_widget_set_sensitive(button, FALSE);
gtk_box_pack_end(GTK_BOX(vbox), button, FALSE, FALSE, 0); gtk_box_pack_end(GTK_BOX(vbox), button, FALSE, FALSE, 0);
webSearch_toggle_edit_buttons(n > 0, webSearch); webSearch_toggle_edit_buttons(n > 0, webSearch);
gtk_widget_show_all(GTK_DIALOG(dialog)->vbox); gtk_widget_show_all(GTK_DIALOG(dialog)->vbox);
@ -440,10 +447,10 @@ gboolean on_webSearch_key_down(GtkWidget* widget, GdkEventKey* event, MidoriBrow
switch(event->keyval) switch(event->keyval)
{ {
case GDK_Up: case GDK_Up:
//update_searchEngine(config->searchEngine - 1, browser); /* update_searchEngine(config->searchEngine - 1, browser); */
return TRUE; return TRUE;
case GDK_Down: case GDK_Down:
//update_searchEngine(config->searchEngine + 1, browser); /* update_searchEngine(config->searchEngine + 1, browser); */
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
@ -452,21 +459,22 @@ gboolean on_webSearch_key_down(GtkWidget* widget, GdkEventKey* event, MidoriBrow
gboolean on_webSearch_scroll(GtkWidget* webView, GdkEventScroll* event, MidoriBrowser* browser) gboolean on_webSearch_scroll(GtkWidget* webView, GdkEventScroll* event, MidoriBrowser* browser)
{ {
if(event->direction == GDK_SCROLL_DOWN) if(event->direction == GDK_SCROLL_DOWN)
;//update_searchEngine(config->searchEngine + 1, browser); ; /* update_searchEngine(config->searchEngine + 1, browser); */
else if(event->direction == GDK_SCROLL_UP) else if(event->direction == GDK_SCROLL_UP)
;//update_searchEngine(config->searchEngine - 1, browser); ; /* update_searchEngine(config->searchEngine - 1, browser); */
return TRUE; return TRUE;
} }
void on_webSearch_activate(GtkWidget* widget, MidoriBrowser* browser) void on_webSearch_activate(GtkWidget* widget, MidoriBrowser* browser)
{ {
MidoriWebList* search_engines = midori_web_list_new (); /* FIXME */
const gchar* keywords = gtk_entry_get_text(GTK_ENTRY(widget)); const gchar* keywords = gtk_entry_get_text(GTK_ENTRY(widget));
const gchar* url; const gchar* url;
MidoriWebItem* web_item = (MidoriWebItem*)g_list_nth_data (searchEngines, 0/*config->searchEngine*/); MidoriWebItem* web_item = midori_web_list_get_nth_item (search_engines, 0/*config->searchEngine*/);
if (web_item) if (web_item)
url = midori_web_item_get_uri (web_item); url = midori_web_item_get_uri (web_item);
else // The location search is our fallback else /* The location search is our fallback */
url = "";//config->locationSearch; url = ""; /* config->locationSearch; */
gchar* search; gchar* search;
if(strstr(url, "%s")) if(strstr(url, "%s"))
search = g_strdup_printf(url, keywords); search = g_strdup_printf(url, keywords);

View file

@ -18,8 +18,6 @@
#include <libsexy/sexy.h> #include <libsexy/sexy.h>
#include <webkit/webkit.h> #include <webkit/webkit.h>
// -- Types
typedef struct typedef struct
{ {
MidoriBrowser* browser; MidoriBrowser* browser;
@ -35,8 +33,6 @@ enum
ENGINES_COL_N ENGINES_COL_N
}; };
// -- Declarations
void void
update_searchEngine(guint, GtkWidget*); update_searchEngine(guint, GtkWidget*);

View file

@ -2,6 +2,8 @@
midori.desktop.in midori.desktop.in
midori/main.c midori/main.c
midori/midori-app.c
midori/midori-addons.c
midori/midori-console.c midori/midori-console.c
midori/midori-browser.c midori/midori-browser.c
midori/midori-panel.c midori/midori-panel.c
@ -9,9 +11,11 @@ midori/midori-trash.c
midori/midori-websettings.c midori/midori-websettings.c
midori/midori-webview.c midori/midori-webview.c
midori/midori-preferences.c midori/midori-preferences.c
midori/search.c midori/midori-webitem.c
midori/midori-weblist.c
midori/sokoke.c midori/sokoke.c
midori/webSearch.c midori/webSearch.c
midori/gjs.c
katze/katze-throbber.c katze/katze-throbber.c
katze/katze-utils.c katze/katze-utils.c
katze/katze-xbel.c katze/katze-xbel.c

View file

@ -21,6 +21,7 @@ blddir = '_build_'
def configure (conf): def configure (conf):
conf.check_tool ('compiler_cc') conf.check_tool ('compiler_cc')
if not Params.g_options.disable_nls: if not Params.g_options.disable_nls:
conf.check_tool ('intltool') conf.check_tool ('intltool')
if conf.env['INTLTOOL'] and conf.env['POCOM']: if conf.env['INTLTOOL'] and conf.env['POCOM']:
@ -53,6 +54,7 @@ def configure (conf):
conf.define ('GETTEXT_PACKAGE', APPNAME) conf.define ('GETTEXT_PACKAGE', APPNAME)
conf.write_config_header ('config.h') conf.write_config_header ('config.h')
conf.env['CCFLAGS'] += ['-DHAVE_CONFIG_H']
def set_options (opt): def set_options (opt):
opt.tool_options ('compiler_cc') opt.tool_options ('compiler_cc')