diff --git a/ChangeLog b/ChangeLog
index ea3e8912..0153b9b2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
This file is licensed under the terms of the expat license, see the file EXPAT.
+v0.2.8
+ + Re-implement Bookmarks menu and toolbar button
+ + Show transferbar even if statusbar is hidden
+ + Smart case for inline search while typing
+ + Use Alt+Shift+Right instead of Ctrl+Right for Next Page
+ + Adding, edit and delete buttons for user scripts/ styles
+ + Rename 'Minimize Tab' to 'Show Tab Icon Only'
+ + Delete key in completion deletes items
+ + Don't show homepage in bookmarkbar
+ + Fix crash when using location arrow button
+
v0.2.7
+ Multiple word completion in location
+ Database backed bookmarks
diff --git a/extensions/adblock.c b/extensions/adblock.c
index 46a244a0..12a68e5e 100644
--- a/extensions/adblock.c
+++ b/extensions/adblock.c
@@ -1367,7 +1367,6 @@ adblock_activate_cb (MidoriExtension* extension,
#endif
KatzeArray* browsers;
MidoriBrowser* browser;
- guint i;
#if !HAVE_WEBKIT_RESOURCE_REQUEST
SoupSession* session = webkit_get_default_session ();
@@ -1391,8 +1390,7 @@ adblock_activate_cb (MidoriExtension* extension,
adblock_reload_rules (extension, FALSE);
browsers = katze_object_get_object (app, "browsers");
- i = 0;
- while ((browser = katze_array_get_nth_item (browsers, i++)))
+ KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
adblock_app_add_browser_cb (app, browser, extension);
g_signal_connect (app, "add-browser",
G_CALLBACK (adblock_app_add_browser_cb), extension);
diff --git a/extensions/addons.c b/extensions/addons.c
index 2ccd4851..3c62c39a 100644
--- a/extensions/addons.c
+++ b/extensions/addons.c
@@ -99,6 +99,7 @@ midori_addons_button_add_clicked_cb (GtkToolItem* toolitem,
gchar* addons_type;
gchar* path;
GtkWidget* dialog;
+ GtkFileFilter* filter;
if (addons->kind == ADDONS_USER_SCRIPTS)
{
@@ -115,17 +116,310 @@ midori_addons_button_add_clicked_cb (GtkToolItem* toolitem,
else
g_assert_not_reached ();
- dialog = gtk_message_dialog_new (
+ dialog = gtk_file_chooser_dialog_new (_("Choose file"),
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (addons))),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
- _("Copy %s to the folder %s."), addons_type, path);
+ GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
+
+ gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE);
+
+ filter = gtk_file_filter_new ();
+
+ if (addons->kind == ADDONS_USER_SCRIPTS)
+ {
+ gtk_file_filter_set_name (filter, _("Userscripts"));
+ gtk_file_filter_add_pattern (filter, "*.js");
+ }
+ else if (addons->kind == ADDONS_USER_STYLES)
+ {
+ gtk_file_filter_set_name (filter, _("Userstyles"));
+ gtk_file_filter_add_pattern (filter, "*.css");
+ }
+ else
+ g_assert_not_reached ();
+
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
+
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
+ {
+ GSList* files;
+
+ if (!g_file_test (path, G_FILE_TEST_EXISTS))
+ katze_mkdir_with_parents (path, 0700);
+
+ #if !GTK_CHECK_VERSION (2, 14, 0)
+ files = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (dialog));
+ #else
+ files = gtk_file_chooser_get_files (GTK_FILE_CHOOSER (dialog));
+ #endif
+
+ while (files)
+ {
+ GFile* src_file;
+ GError* error = NULL;
+
+ #if !GTK_CHECK_VERSION (2, 14, 0)
+ src_file = g_file_new_for_path (files);
+ #else
+ src_file = files->data;
+ #endif
+
+ if (G_IS_FILE (src_file))
+ {
+ GFile* dest_file;
+ gchar* dest_file_path;
+
+ dest_file_path = g_build_path (G_DIR_SEPARATOR_S, path,
+ g_file_get_basename (src_file), NULL);
+
+ dest_file = g_file_new_for_path (dest_file_path);
+
+ g_file_copy (src_file, dest_file,
+ G_FILE_COPY_OVERWRITE | G_FILE_COPY_BACKUP,
+ NULL, NULL, NULL, &error);
+
+ if (error)
+ {
+ GtkWidget* msg_box;
+ msg_box = gtk_message_dialog_new (
+ GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (addons))),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ "%s", error->message);
+
+ gtk_window_set_title (GTK_WINDOW (msg_box), _("Error"));
+ gtk_dialog_run (GTK_DIALOG (msg_box));
+ gtk_widget_destroy (msg_box);
+ g_error_free (error);
+ }
+
+ g_object_unref (src_file);
+ g_object_unref (dest_file);
+ g_free (dest_file_path);
+ }
+ files = g_slist_next (files);
+ }
+ g_slist_free (files);
+ }
+
g_free (addons_type);
g_free (path);
- gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
}
+static void
+midori_addons_button_delete_clicked_cb (GtkWidget* toolitem,
+ Addons* addons)
+{
+ GtkTreeModel* model;
+ GtkTreeIter iter;
+
+ if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (addons->treeview),
+ &model, &iter))
+ {
+ struct AddonElement* element;
+ gint delete_response;
+ GtkWidget* dialog;
+
+ gtk_tree_model_get (model, &iter, 0, &element, -1);
+ dialog = gtk_message_dialog_new (
+ GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (addons))),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_CANCEL,
+ _("Do you want to delete '%s'?"),
+ element->displayname);
+ gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_DELETE, GTK_RESPONSE_YES);
+
+ gtk_window_set_title (GTK_WINDOW (dialog),
+ addons->kind == ADDONS_USER_SCRIPTS
+ ? _("Delete user script")
+ : _("Delete user style"));
+
+ gtk_message_dialog_format_secondary_markup (
+ GTK_MESSAGE_DIALOG (dialog),
+ _("The file %s will be permanently deleted."),
+ element->fullpath);
+
+ delete_response = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+
+ if (delete_response == GTK_RESPONSE_YES)
+ {
+ GError* error = NULL;
+ GFile* file;
+ gboolean result;
+
+ file = g_file_new_for_path (element->fullpath);
+ result = g_file_delete (file, NULL, &error);
+
+ if (!result && error)
+ {
+ GtkWidget* msg_box;
+ msg_box = gtk_message_dialog_new (
+ GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (addons))),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ "%s", error->message);
+
+ gtk_window_set_title (GTK_WINDOW (msg_box), _("Error"));
+ gtk_dialog_run (GTK_DIALOG (msg_box));
+ gtk_widget_destroy (msg_box);
+ g_error_free (error);
+ }
+
+ if (result)
+ gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+
+ g_object_unref (file);
+ }
+ }
+}
+static void
+midori_addons_open_in_editor_clicked_cb (GtkWidget* toolitem,
+ Addons* addons)
+{
+ GtkTreeModel* model;
+ GtkTreeIter iter;
+
+ if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (addons->treeview),
+ &model, &iter))
+ {
+ struct AddonElement* element;
+ MidoriWebSettings* settings;
+ MidoriBrowser* browser;
+ gchar* text_editor;
+ gchar* element_uri;
+
+ browser = midori_browser_get_for_widget (GTK_WIDGET (addons->treeview));
+ settings = katze_object_get_object (browser, "settings");
+
+ gtk_tree_model_get (model, &iter, 0, &element, -1);
+ element_uri = g_filename_to_uri (element->fullpath, NULL, NULL);
+
+ g_object_get (settings, "text-editor", &text_editor, NULL);
+ if (text_editor && *text_editor)
+ sokoke_spawn_program (text_editor, element_uri, TRUE);
+ else
+ sokoke_show_uri (NULL, element_uri,
+ gtk_get_current_event_time (), NULL);
+
+ g_free (element_uri);
+ g_free (text_editor);
+ }
+}
+
+static void
+midori_addons_open_target_folder_clicked_cb (GtkWidget* toolitem,
+ Addons* addons)
+{
+ GtkTreeModel* model;
+ GtkTreeIter iter;
+ gchar* folder;
+ gchar* folder_uri;
+
+ if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (addons->treeview),
+ &model, &iter))
+ {
+ struct AddonElement* element;
+
+ gtk_tree_model_get (model, &iter, 0, &element, -1);
+ folder = g_path_get_dirname (element->fullpath);
+ }
+ else
+ folder = g_build_path (G_DIR_SEPARATOR_S, g_get_user_data_dir (),
+ PACKAGE_NAME,
+ addons->kind == ADDONS_USER_SCRIPTS
+ ? "scripts" : "styles", NULL);
+ folder_uri = g_filename_to_uri (folder, NULL, NULL);
+ g_free (folder);
+
+ sokoke_show_uri (gtk_widget_get_screen (GTK_WIDGET (addons->treeview)),
+ folder_uri, gtk_get_current_event_time (), NULL);
+ g_free (folder_uri);
+}
+
+static void
+midori_addons_popup_item (GtkMenu* menu,
+ const gchar* stock_id,
+ const gchar* label,
+ struct AddonElement* element,
+ gpointer callback,
+ Addons* addons)
+{
+ GtkWidget* menuitem;
+
+ menuitem = gtk_image_menu_item_new_from_stock (stock_id, NULL);
+ if (label)
+ gtk_label_set_text_with_mnemonic (GTK_LABEL (gtk_bin_get_child (
+ GTK_BIN (menuitem))), label);
+ if (!strcmp (stock_id, GTK_STOCK_EDIT))
+ gtk_widget_set_sensitive (menuitem, element->fullpath !=NULL);
+ else if (strcmp (stock_id, GTK_STOCK_DELETE))
+ gtk_widget_set_sensitive (menuitem, element->fullpath !=NULL);
+ g_object_set_data (G_OBJECT (menuitem), "AddonElement", &element);
+ g_signal_connect (menuitem, "activate", G_CALLBACK(callback), addons);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+ gtk_widget_show (menuitem);
+}
+
+static void
+midori_addons_popup (GtkWidget* widget,
+ GdkEventButton* event,
+ struct AddonElement* element,
+ Addons* addons)
+{
+ GtkWidget* menu;
+
+ menu = gtk_menu_new ();
+ midori_addons_popup_item (GTK_MENU (menu), GTK_STOCK_EDIT, _("Open in Text Editor"),
+ element, midori_addons_open_in_editor_clicked_cb, addons);
+ midori_addons_popup_item (GTK_MENU (menu), GTK_STOCK_OPEN, _("Open Target Folder"),
+ element, midori_addons_open_target_folder_clicked_cb, addons);
+ midori_addons_popup_item (GTK_MENU (menu), GTK_STOCK_DELETE, NULL,
+ element, midori_addons_button_delete_clicked_cb, addons);
+ katze_widget_popup (widget, GTK_MENU (menu), event, KATZE_MENU_POSITION_CURSOR);
+}
+
+static gboolean
+midori_addons_popup_menu_cb (GtkWidget *widget,
+ Addons* addons)
+{
+ GtkTreeModel* model;
+ GtkTreeIter iter;
+
+ if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), &model, &iter))
+ {
+ struct AddonElement* element;
+ gtk_tree_model_get (model, &iter, 0, &element, -1);
+ midori_addons_popup (widget, NULL, element, addons);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static gboolean
+midori_addons_button_release_event_cb (GtkWidget* widget,
+ GdkEventButton* event,
+ Addons* addons)
+{
+ GtkTreeModel* model;
+ GtkTreeIter iter;
+
+ if (event->button != 3)
+ return FALSE;
+ if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (widget), &model, &iter))
+ {
+ struct AddonElement* element;
+ gtk_tree_model_get (model, &iter, 0, &element, -1);
+ midori_addons_popup (widget, NULL, element, addons);
+ return TRUE;
+ }
+ return FALSE;
+}
+
GtkWidget*
addons_get_toolbar (MidoriViewable* viewable)
{
@@ -137,27 +431,46 @@ addons_get_toolbar (MidoriViewable* viewable)
if (!ADDONS (viewable)->toolbar)
{
toolbar = gtk_toolbar_new ();
- gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH_HORIZ);
gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_BUTTON);
toolitem = gtk_tool_item_new ();
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
gtk_widget_show (GTK_WIDGET (toolitem));
- /* separator */
- toolitem = gtk_separator_tool_item_new ();
- gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (toolitem),
- FALSE);
- gtk_tool_item_set_expand (toolitem, TRUE);
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
- gtk_widget_show (GTK_WIDGET (toolitem));
-
/* add button */
toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_ADD);
gtk_tool_item_set_is_important (toolitem, TRUE);
g_signal_connect (toolitem, "clicked",
G_CALLBACK (midori_addons_button_add_clicked_cb), viewable);
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (toolitem), _("Add new addon"));
+ gtk_widget_show (GTK_WIDGET (toolitem));
+ /* Text editor button */
+ toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_EDIT);
+ g_signal_connect (toolitem, "clicked",
+ G_CALLBACK (midori_addons_open_in_editor_clicked_cb), viewable);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (toolitem),
+ _("Open in Text Editor"));
+ gtk_widget_show (GTK_WIDGET (toolitem));
+
+ /* Target folder button */
+ toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_DIRECTORY);
+ g_signal_connect (toolitem, "clicked",
+ G_CALLBACK (midori_addons_open_target_folder_clicked_cb), viewable);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (toolitem),
+ _("Open Target Folder"));
+ gtk_widget_show (GTK_WIDGET (toolitem));
+
+ /* Delete button */
+ toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_DELETE);
+ g_signal_connect (toolitem, "clicked",
+ G_CALLBACK (midori_addons_button_delete_clicked_cb), viewable);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
+ gtk_widget_set_tooltip_text (GTK_WIDGET (toolitem),
+ _("Open target folder for selected addon"));
+ gtk_widget_set_tooltip_text (GTK_WIDGET (toolitem), _("Remove selected addon"));
gtk_widget_show (GTK_WIDGET (toolitem));
ADDONS (viewable)->toolbar = toolbar;
@@ -358,7 +671,6 @@ addons_get_files (AddonsKind kind)
{
GSList* files;
GDir* addon_dir;
- GSList* list;
GSList* directories;
const gchar* filename;
gchar* dirname;
@@ -375,7 +687,6 @@ addons_get_files (AddonsKind kind)
files = NULL;
directories = addons_get_directories (kind);
- list = directories;
while (directories)
{
dirname = directories->data;
@@ -395,7 +706,6 @@ addons_get_files (AddonsKind kind)
directories = g_slist_next (directories);
}
- g_slist_free (list);
g_free (file_extension);
return files;
@@ -671,8 +981,9 @@ addons_update_elements (MidoriExtension* extension,
if (liststore)
gtk_list_store_clear (liststore);
else
- liststore = gtk_list_store_new (3, G_TYPE_POINTER,
+ liststore = gtk_list_store_new (4, G_TYPE_POINTER,
G_TYPE_INT,
+ G_TYPE_STRING,
G_TYPE_STRING);
keyfile = g_key_file_new ();
@@ -686,6 +997,9 @@ addons_update_elements (MidoriExtension* extension,
elements = NULL;
while (addon_files)
{
+ gchar* filename;
+ gchar* tooltip;
+
fullpath = addon_files->data;
element = g_new (struct AddonElement, 1);
element->displayname = g_filename_display_basename (fullpath);
@@ -732,10 +1046,22 @@ addons_update_elements (MidoriExtension* extension,
element->enabled = FALSE;
}
+ filename = g_path_get_basename (element->fullpath);
+ if (element->description)
+ {
+ tooltip = g_strdup_printf ("%s\n\n%s",
+ filename, element->description);
+ g_free (filename);
+ }
+ else
+ tooltip = filename;
+
gtk_list_store_append (liststore, &iter);
gtk_list_store_set (liststore, &iter,
- 0, element, 1, 0, 2, "", -1);
+ 0, element, 1, 0, 2, element->fullpath,
+ 3, tooltip, -1);
+ g_free (tooltip);
addon_files = g_slist_next (addon_files);
elements = g_slist_prepend (elements, element);
}
@@ -780,9 +1106,16 @@ addons_init (Addons* addons)
(GtkTreeCellDataFunc)addons_treeview_render_text_cb,
addons->treeview, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (addons->treeview), column);
+ gtk_tree_view_set_tooltip_column (GTK_TREE_VIEW (addons->treeview), 3);
g_signal_connect (addons->treeview, "row-activated",
G_CALLBACK (addons_treeview_row_activated_cb),
addons);
+ g_signal_connect (addons->treeview, "button-release-event",
+ G_CALLBACK (midori_addons_button_release_event_cb),
+ addons);
+ g_signal_connect (addons->treeview, "popup-menu",
+ G_CALLBACK (midori_addons_popup_menu_cb),
+ addons);
gtk_widget_show (addons->treeview);
gtk_box_pack_start (GTK_BOX (addons), addons->treeview, TRUE, TRUE, 0);
}
@@ -907,6 +1240,7 @@ addons_context_ready_cb (WebKitWebView* web_view,
GSList* scripts, *styles;
struct AddonElement* script, *style;
struct AddonsList* scripts_list, *styles_list;
+
uri = katze_object_get_string (web_view, "uri");
/* Don't run scripts or styles on blank or special pages */
if (!(uri && *uri && strncmp (uri, "about:", 6)))
@@ -944,6 +1278,7 @@ addons_context_ready_cb (WebKitWebView* web_view,
webkit_web_view_execute_script (web_view, style->script_content);
styles = g_slist_next (styles);
}
+ g_free (uri);
}
static void
@@ -1112,13 +1447,12 @@ addons_deactivate_cb (MidoriExtension* extension,
KatzeArray* browsers;
MidoriBrowser* browser;
GSource* source;
- guint i = 0;
addons_disable_monitors (extension);
addons_save_settings (NULL, extension);
browsers = katze_object_get_object (app, "browsers");
- while ((browser = katze_array_get_nth_item (browsers, i++)))
+ KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
addons_browser_destroy (browser, extension);
source = g_object_get_data (G_OBJECT (extension), "monitor-timer");
@@ -1179,7 +1513,6 @@ addons_monitor_directories (MidoriExtension* extension,
AddonsKind kind)
{
GSList* directories;
- GSList* list;
GError* error;
GSList* monitors;
GFileMonitor* monitor;
@@ -1190,7 +1523,6 @@ addons_monitor_directories (MidoriExtension* extension,
monitors = g_object_get_data (G_OBJECT (extension), "monitors");
directories = addons_get_directories (kind);
- list = directories;
while (directories)
{
directory = g_file_new_for_path (directories->data);
@@ -1223,16 +1555,14 @@ addons_activate_cb (MidoriExtension* extension,
{
KatzeArray* browsers;
MidoriBrowser* browser;
- guint i;
browsers = katze_object_get_object (app, "browsers");
addons_update_elements (extension, ADDONS_USER_STYLES);
addons_monitor_directories (extension, ADDONS_USER_STYLES);
addons_update_elements (extension, ADDONS_USER_SCRIPTS);
- addons_monitor_directories (extension, ADDONS_USER_STYLES);
+ addons_monitor_directories (extension, ADDONS_USER_SCRIPTS);
- i = 0;
- while ((browser = katze_array_get_nth_item (browsers, i++)))
+ KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
addons_app_add_browser_cb (app, browser, extension);
g_object_unref (browsers);
diff --git a/extensions/colorful-tabs.c b/extensions/colorful-tabs.c
index d9c108ef..5979f4e6 100644
--- a/extensions/colorful-tabs.c
+++ b/extensions/colorful-tabs.c
@@ -185,11 +185,9 @@ colorful_tabs_activate_cb (MidoriExtension* extension,
{
KatzeArray* browsers;
MidoriBrowser* browser;
- guint i;
browsers = katze_object_get_object (app, "browsers");
- i = 0;
- while ((browser = katze_array_get_nth_item (browsers, i++)))
+ KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
colorful_tabs_app_add_browser_cb (app, browser, extension);
g_signal_connect (app, "add-browser",
G_CALLBACK (colorful_tabs_app_add_browser_cb), extension);
diff --git a/extensions/cookie-manager/cookie-manager.c b/extensions/cookie-manager/cookie-manager.c
index dc256722..70a4f7aa 100644
--- a/extensions/cookie-manager/cookie-manager.c
+++ b/extensions/cookie-manager/cookie-manager.c
@@ -315,7 +315,6 @@ CookieManager *cookie_manager_new(MidoriExtension *extension, MidoriApp *app)
{
CookieManager *cm;
CookieManagerPrivate *priv;
- guint i;
KatzeArray *browsers;
MidoriBrowser *browser;
@@ -327,8 +326,7 @@ CookieManager *cookie_manager_new(MidoriExtension *extension, MidoriApp *app)
/* add the cookie manager panel page to existing browsers */
browsers = katze_object_get_object(app, "browsers");
- i = 0;
- while ((browser = katze_array_get_nth_item(browsers, i++)))
+ KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
cookie_manager_app_add_browser_cb(app, browser, cm);
g_object_unref(browsers);
diff --git a/extensions/copy-tabs.c b/extensions/copy-tabs.c
index 2734ec54..60fe2dbc 100644
--- a/extensions/copy-tabs.c
+++ b/extensions/copy-tabs.c
@@ -80,11 +80,9 @@ copy_tabs_activate_cb (MidoriExtension* extension,
{
KatzeArray* browsers;
MidoriBrowser* browser;
- guint i;
browsers = katze_object_get_object (app, "browsers");
- i = 0;
- while ((browser = katze_array_get_nth_item (browsers, i++)))
+ KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
copy_tabs_app_add_browser_cb (app, browser, extension);
g_object_unref (browsers);
g_signal_connect (app, "add-browser",
diff --git a/extensions/feed-panel/feed-panel.c b/extensions/feed-panel/feed-panel.c
index 26fbb261..2241ad70 100644
--- a/extensions/feed-panel/feed-panel.c
+++ b/extensions/feed-panel/feed-panel.c
@@ -271,7 +271,6 @@ feed_panel_disconnect_feed (FeedPanel* panel,
KatzeArray* feed)
{
KatzeItem* item;
- guint i;
g_return_if_fail (KATZE_IS_ARRAY (feed));
@@ -282,8 +281,7 @@ feed_panel_disconnect_feed (FeedPanel* panel,
g_signal_handlers_disconnect_by_func (feed,
feed_panel_move_item_cb, panel);
- i = 0;
- while ((item = katze_array_get_nth_item (feed, i++)))
+ KATZE_ARRAY_FOREACH_ITEM (item, feed)
{
if (KATZE_IS_ARRAY (item))
feed_panel_disconnect_feed (panel, KATZE_ARRAY (item));
diff --git a/extensions/feed-panel/main.c b/extensions/feed-panel/main.c
index 4695225e..ba9c685b 100644
--- a/extensions/feed-panel/main.c
+++ b/extensions/feed-panel/main.c
@@ -157,18 +157,18 @@ feed_save_items (MidoriExtension* extension,
{
KatzeItem* item;
gchar** sfeeds;
- gint i;
- gint n;
+ gint i, n;
g_return_if_fail (KATZE_IS_ARRAY (feed));
n = katze_array_get_length (feed);
sfeeds = g_new (gchar*, n + 1);
- for (i = 0; i < n; i++)
+ i = 0;
+ KATZE_ARRAY_FOREACH_ITEM (item, feed)
{
- item = katze_array_get_nth_item (feed, i);
sfeeds[i] = (gchar*) katze_item_get_uri (KATZE_ITEM (item));
+ i++;
}
sfeeds[n] = NULL;
@@ -336,7 +336,11 @@ secondary_icon_released_cb (GtkAction* action,
if ((feed = feed_add_item (priv->feeds, uri)))
{
- /* FIXME: Let the user know that a feed was added */
+ MidoriPanel* panel = katze_object_get_object (priv->browser, "panel");
+ gint i = midori_panel_page_num (panel, priv->panel);
+ midori_panel_set_current_page (panel, i);
+ gtk_widget_show (GTK_WIDGET (panel));
+ g_object_unref (panel);
feed_save_items (priv->extension, priv->feeds);
update_feed (priv, KATZE_ITEM (feed));
return TRUE;
@@ -494,11 +498,9 @@ feed_activate_cb (MidoriExtension* extension,
{
KatzeArray* browsers;
MidoriBrowser* browser;
- guint i;
browsers = katze_object_get_object (app, "browsers");
- i = 0;
- while ((browser = katze_array_get_nth_item (browsers, i++)))
+ KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
feed_app_add_browser_cb (app, browser, extension);
g_object_unref (browsers);
diff --git a/extensions/formhistory.c b/extensions/formhistory.c
index 446e534b..44958a3f 100644
--- a/extensions/formhistory.c
+++ b/extensions/formhistory.c
@@ -425,7 +425,6 @@ formhistory_activate_cb (MidoriExtension* extension,
char* errmsg = NULL, *errmsg2 = NULL;
KatzeArray* browsers;
MidoriBrowser* browser;
- guint i;
global_keys = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify)g_free,
@@ -464,8 +463,7 @@ formhistory_activate_cb (MidoriExtension* extension,
}
browsers = katze_object_get_object (app, "browsers");
- i = 0;
- while ((browser = katze_array_get_nth_item (browsers, i++)))
+ KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
formhistory_app_add_browser_cb (app, browser, extension);
g_signal_connect (app, "add-browser",
G_CALLBACK (formhistory_app_add_browser_cb), extension);
diff --git a/extensions/mouse-gestures.c b/extensions/mouse-gestures.c
index c3c93bf0..9a7d738a 100644
--- a/extensions/mouse-gestures.c
+++ b/extensions/mouse-gestures.c
@@ -281,14 +281,12 @@ mouse_gestures_activate_cb (MidoriExtension* extension,
{
KatzeArray* browsers;
MidoriBrowser* browser;
- guint i;
gesture = mouse_gesture_new ();
gesture->button = midori_extension_get_integer (extension, "button");
browsers = katze_object_get_object (app, "browsers");
- i = 0;
- while ((browser = katze_array_get_nth_item (browsers, i++)))
+ KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
mouse_gestures_app_add_browser_cb (app, browser, extension);
g_signal_connect (app, "add-browser",
G_CALLBACK (mouse_gestures_app_add_browser_cb), extension);
diff --git a/extensions/page-holder.c b/extensions/page-holder.c
index 9c6f0f14..b3374421 100644
--- a/extensions/page-holder.c
+++ b/extensions/page-holder.c
@@ -139,11 +139,9 @@ page_holder_activate_cb (MidoriExtension* extension,
{
KatzeArray* browsers;
MidoriBrowser* browser;
- guint i;
browsers = katze_object_get_object (app, "browsers");
- i = 0;
- while ((browser = katze_array_get_nth_item (browsers, i++)))
+ KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
page_holder_app_add_browser_cb (app, browser, extension);
g_object_unref (browsers);
g_signal_connect (app, "add-browser",
diff --git a/extensions/shortcuts.c b/extensions/shortcuts.c
index 3ff55788..12671fa3 100644
--- a/extensions/shortcuts.c
+++ b/extensions/shortcuts.c
@@ -297,11 +297,9 @@ shortcuts_activate_cb (MidoriExtension* extension,
{
KatzeArray* browsers;
MidoriBrowser* browser;
- guint i;
browsers = katze_object_get_object (app, "browsers");
- i = 0;
- while ((browser = katze_array_get_nth_item (browsers, i++)))
+ KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
shortcuts_app_add_browser_cb (app, browser, extension);
g_signal_connect (app, "add-browser",
G_CALLBACK (shortcuts_app_add_browser_cb), extension);
diff --git a/extensions/status-clock.c b/extensions/status-clock.c
index c30f1cf0..68bf1f2c 100644
--- a/extensions/status-clock.c
+++ b/extensions/status-clock.c
@@ -131,10 +131,9 @@ clock_deactivate_cb (MidoriExtension* extension,
KatzeArray* browsers;
MidoriBrowser* browser;
GtkWidget* label;
- guint i = 0;
browsers = katze_object_get_object (app, "browsers");
- while ((browser = katze_array_get_nth_item (browsers, i++)))
+ KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
{
clock_browser_destroy_cb (browser, NULL);
label = g_object_get_data (G_OBJECT (browser), "clock-label");
@@ -155,10 +154,9 @@ clock_activate_cb (MidoriExtension* extension,
{
KatzeArray* browsers;
MidoriBrowser* browser;
- guint i = 0;
browsers = katze_object_get_object (app, "browsers");
- while ((browser = katze_array_get_nth_item (browsers, i++)))
+ KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
clock_app_add_browser_cb (app, browser, extension);
g_signal_connect (app, "add-browser",
G_CALLBACK (clock_app_add_browser_cb), extension);
diff --git a/extensions/statusbar-features.c b/extensions/statusbar-features.c
index 58b99fa4..9a6b0665 100644
--- a/extensions/statusbar-features.c
+++ b/extensions/statusbar-features.c
@@ -131,11 +131,9 @@ statusbar_features_activate_cb (MidoriExtension* extension,
{
KatzeArray* browsers;
MidoriBrowser* browser;
- guint i;
browsers = katze_object_get_object (app, "browsers");
- i = 0;
- while ((browser = katze_array_get_nth_item (browsers, i++)))
+ KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
statusbar_features_app_add_browser_cb (app, browser, extension);
g_signal_connect (app, "add-browser",
G_CALLBACK (statusbar_features_app_add_browser_cb), extension);
diff --git a/extensions/tab-panel.c b/extensions/tab-panel.c
index 2d182d5e..a358818a 100644
--- a/extensions/tab-panel.c
+++ b/extensions/tab-panel.c
@@ -498,6 +498,7 @@ tab_panel_app_add_browser_cb (MidoriApp* app,
GtkCellRenderer* renderer_text;
GtkWidget* panel;
GtkWidget* toolbar;
+ gint i;
/* GtkToolItem* toolitem; */
g_object_set (browser, "show-tabs", FALSE, NULL);
@@ -564,8 +565,10 @@ tab_panel_app_add_browser_cb (MidoriApp* app,
gtk_widget_show (GTK_WIDGET (toolitem));
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1); */
- midori_panel_append_widget (MIDORI_PANEL (panel), treeview,
- STOCK_TAB_PANEL, _("Tab Panel"), toolbar);
+ i = midori_panel_append_widget (MIDORI_PANEL (panel), treeview,
+ STOCK_TAB_PANEL, _("Tab Panel"), toolbar);
+ if (gtk_widget_get_visible (GTK_WIDGET (browser)))
+ midori_panel_set_current_page (MIDORI_PANEL (panel), i);
g_object_unref (panel);
midori_browser_foreach (browser,
@@ -587,11 +590,9 @@ tab_panel_activate_cb (MidoriExtension* extension,
{
KatzeArray* browsers;
MidoriBrowser* browser;
- guint i;
browsers = katze_object_get_object (app, "browsers");
- i = 0;
- while ((browser = katze_array_get_nth_item (browsers, i++)))
+ KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
tab_panel_app_add_browser_cb (app, browser, extension);
g_object_unref (browsers);
g_signal_connect (app, "add-browser",
diff --git a/extensions/tabs-minimized.c b/extensions/tabs-minimized.c
index 0d14dc68..f5130ee3 100644
--- a/extensions/tabs-minimized.c
+++ b/extensions/tabs-minimized.c
@@ -61,11 +61,9 @@ tabs_minimized_activate_cb (MidoriExtension* extension,
{
KatzeArray* browsers;
MidoriBrowser* browser;
- guint i;
browsers = katze_object_get_object (app, "browsers");
- i = 0;
- while ((browser = katze_array_get_nth_item (browsers, i++)))
+ KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
tabs_minimized_app_add_browser_cb (app, browser, extension);
g_object_unref (browsers);
g_signal_connect (app, "add-browser",
@@ -76,8 +74,8 @@ MidoriExtension*
extension_init (void)
{
MidoriExtension* extension = g_object_new (MIDORI_TYPE_EXTENSION,
- "name", _("Minimize new Tabs"),
- "description", _("New tabs open minimized"),
+ "name", _("Only Icons on Tabs by default"),
+ "description", _("New tabs have no label by default"),
"version", "0.1",
"authors", "MonkeyOfDoom ",
NULL);
diff --git a/extensions/toolbar-editor.c b/extensions/toolbar-editor.c
index b8b0e005..d5f1ea85 100644
--- a/extensions/toolbar-editor.c
+++ b/extensions/toolbar-editor.c
@@ -592,11 +592,9 @@ static void tb_editor_activate_cb(MidoriExtension *extension, MidoriApp *app)
{
KatzeArray *browsers;
MidoriBrowser *browser;
- guint i;
browsers = katze_object_get_object(app, "browsers");
- i = 0;
- while ((browser = katze_array_get_nth_item(browsers, i++)))
+ KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
tb_editor_app_add_browser_cb(app, browser, extension);
g_signal_connect(app, "add-browser", G_CALLBACK(tb_editor_app_add_browser_cb), extension);
g_object_unref(browsers);
diff --git a/extensions/web-cache.c b/extensions/web-cache.c
index 33c34299..884e083a 100644
--- a/extensions/web-cache.c
+++ b/extensions/web-cache.c
@@ -438,7 +438,6 @@ web_cache_activate_cb (MidoriExtension* extension,
const gchar* cache_path = midori_extension_get_string (extension, "path");
KatzeArray* browsers;
MidoriBrowser* browser;
- guint i;
SoupSession* session = webkit_get_default_session ();
katze_mkdir_with_parents (cache_path, 0700);
@@ -446,8 +445,7 @@ web_cache_activate_cb (MidoriExtension* extension,
G_CALLBACK (web_cache_session_request_queued_cb), extension);
browsers = katze_object_get_object (app, "browsers");
- i = 0;
- while ((browser = katze_array_get_nth_item (browsers, i++)))
+ KATZE_ARRAY_FOREACH_ITEM (browser, browsers)
web_cache_app_add_browser_cb (app, browser, extension);
g_signal_connect (app, "add-browser",
G_CALLBACK (web_cache_app_add_browser_cb), extension);
diff --git a/katze/katze-array.c b/katze/katze-array.c
index 44b77501..9cf0cbaa 100644
--- a/katze/katze-array.c
+++ b/katze/katze-array.c
@@ -479,6 +479,12 @@ katze_array_get_items (KatzeArray* array)
return g_list_copy (array->items);
}
+GList*
+katze_array_peek_items (KatzeArray* array)
+{
+ return array->items;
+}
+
/**
* katze_array_clear:
* @array: a #KatzeArray
diff --git a/katze/katze-array.h b/katze/katze-array.h
index 17d203d8..f54f66ba 100644
--- a/katze/katze-array.h
+++ b/katze/katze-array.h
@@ -80,6 +80,17 @@ katze_array_move_item (KatzeArray* array,
GList*
katze_array_get_items (KatzeArray* array);
+GList*
+katze_array_peek_items (KatzeArray* array);
+
+GList* kalistglobal;
+#define KATZE_ARRAY_FOREACH_ITEM(kaitem, kaarray) \
+ for (kalistglobal = katze_array_peek_items (kaarray), \
+ kaitem = kalistglobal ? kalistglobal->data : NULL; \
+ kalistglobal != NULL; \
+ kalistglobal = g_list_next (kalistglobal), \
+ kaitem = kalistglobal ? kalistglobal->data : NULL)
+
void
katze_array_clear (KatzeArray* array);
diff --git a/katze/katze-arrayaction.c b/katze/katze-arrayaction.c
index e23e11f8..47fc08e9 100644
--- a/katze/katze-arrayaction.c
+++ b/katze/katze-arrayaction.c
@@ -49,6 +49,7 @@ enum
enum
{
POPULATE_POPUP,
+ POPULATE_FOLDER,
ACTIVATE_ITEM,
ACTIVATE_ITEM_ALT,
LAST_SIGNAL
@@ -104,6 +105,43 @@ katze_array_action_class_init (KatzeArrayActionClass* class)
G_TYPE_NONE, 1,
GTK_TYPE_MENU);
+ /**
+ * KatzeArrayAction::populate-folder:
+ * @array: the object on which the signal is emitted
+ * @menu: the menu shell being opened
+ * @folder: the folder being opened
+ *
+ * A context menu is going to be opened for @folder,
+ * the provided @menu can be populated accordingly.
+ *
+ * Unlike "populate-popup" this signal is emitted for
+ * the toplevel folder and all subfolders.
+ *
+ * Return value: %TRUE if the event was handled. If %FALSE is returned,
+ * the default "populate-popup" signal is emitted.
+ *
+ * Since: 0.2.8
+ **/
+
+ signals[POPULATE_FOLDER] = g_signal_new ("populate-folder",
+ G_TYPE_FROM_CLASS (class),
+ (GSignalFlags) (G_SIGNAL_RUN_LAST),
+ 0,
+ 0,
+ NULL,
+ midori_cclosure_marshal_BOOLEAN__OBJECT_OBJECT,
+ G_TYPE_BOOLEAN, 2,
+ GTK_TYPE_MENU_SHELL, KATZE_TYPE_ITEM);
+
+ /**
+ * KatzeArrayAction::activate-item:
+ * @array: the object on which the signal is emitted
+ * @item: the item being activated
+ *
+ * An item was clicked with the first button.
+ *
+ * Deprecated: 0.2.8: Use "activate-item-alt" instead.
+ **/
signals[ACTIVATE_ITEM] = g_signal_new ("activate-item",
G_TYPE_FROM_CLASS (class),
(GSignalFlags) (G_SIGNAL_RUN_LAST),
@@ -120,8 +158,7 @@ katze_array_action_class_init (KatzeArrayActionClass* class)
* @item: the item being activated
* @button: the mouse button pressed
*
- * An item was clicked with a particular button. Use this if you need
- * to handle middle or right clicks specially.
+ * An item was clicked, with the specified @button.
*
* Return value: %TRUE if the event was handled. If %FALSE is returned,
* the default "activate-item" signal is emitted.
@@ -257,12 +294,24 @@ katze_array_action_activate (GtkAction* action)
GTK_ACTION_CLASS (katze_array_action_parent_class)->activate (action);
}
+static void
+katze_array_action_activate_item (KatzeArrayAction* action,
+ KatzeItem* item,
+ gint button)
+{
+ gboolean handled = FALSE;
+ g_signal_emit (action, signals[ACTIVATE_ITEM_ALT], 0, item,
+ button, &handled);
+ if (!handled)
+ g_signal_emit (action, signals[ACTIVATE_ITEM], 0, item);
+}
+
static void
katze_array_action_menu_activate_cb (GtkWidget* proxy,
KatzeArrayAction* array_action)
{
KatzeItem* item = g_object_get_data (G_OBJECT (proxy), "KatzeItem");
- g_signal_emit (array_action, signals[ACTIVATE_ITEM], 0, item);
+ katze_array_action_activate_item (array_action, item, 1);
}
static gboolean
@@ -271,13 +320,8 @@ katze_array_action_menu_button_press_cb (GtkWidget* proxy,
KatzeArrayAction* array_action)
{
KatzeItem* item = g_object_get_data (G_OBJECT (proxy), "KatzeItem");
- gboolean handled;
- g_signal_emit (array_action, signals[ACTIVATE_ITEM_ALT], 0, item,
- event->button, &handled);
-
- if (!handled)
- g_signal_emit (array_action, signals[ACTIVATE_ITEM], 0, item);
+ katze_array_action_activate_item (array_action, item, event->button);
/* we need to block the 'activate' handler which would be called
* otherwise as well */
@@ -291,10 +335,29 @@ static void
katze_array_action_menu_item_select_cb (GtkWidget* proxy,
KatzeArrayAction* array_action);
-static void
+/**
+ * katze_array_action_generate_menu:
+ * @array_action: a #KatzeArrayAction
+ * @folder: the folder to represent
+ * @menu: the menu shell to populate
+ * @proxy: the proxy, or alternatively a widget in the same window
+ *
+ * Generates menu items according to @folder, in the way they
+ * appear in automatically generated action proxies.
+ * The primary use is for implementing "populate-folder".
+ *
+ * It is worth noting that @folder can be any folder and can
+ * be generated dynamically if needed.
+ *
+ * The @proxy widget must be a related widget on the same screen,
+ * but doesn't have to be a proxy of the action.
+ *
+ * Since: 0.2.8
+ **/
+void
katze_array_action_generate_menu (KatzeArrayAction* array_action,
KatzeArray* array,
- GtkWidget* menu,
+ GtkMenuShell* menu,
GtkWidget* proxy)
{
gint i;
@@ -306,6 +369,9 @@ katze_array_action_generate_menu (KatzeArrayAction* array_action,
GtkWidget* image;
GtkWidget* submenu;
+ if (!KATZE_IS_ARRAY (array))
+ return;
+
if (array_action->reversed)
{
i = katze_array_get_length (array);
@@ -319,11 +385,11 @@ katze_array_action_generate_menu (KatzeArrayAction* array_action,
while ((item = katze_array_get_nth_item (array, i += summand)))
{
/* FIXME: The menu item should reflect changes to the item */
- if (!KATZE_IS_ARRAY (item) && !katze_item_get_uri (item))
+ if (KATZE_ITEM_IS_SEPARATOR (item))
{
menuitem = gtk_separator_menu_item_new ();
gtk_widget_show (menuitem);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+ gtk_menu_shell_append (menu, menuitem);
continue;
}
menuitem = katze_image_menu_item_new_ellipsized (
@@ -332,7 +398,7 @@ katze_array_action_generate_menu (KatzeArrayAction* array_action,
image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
else
{
- if (KATZE_IS_ARRAY (item))
+ if (KATZE_ITEM_IS_FOLDER (item))
icon = gtk_widget_render_icon (menuitem,
GTK_STOCK_DIRECTORY, GTK_ICON_SIZE_MENU, NULL);
else
@@ -345,9 +411,9 @@ katze_array_action_generate_menu (KatzeArrayAction* array_action,
gtk_image_menu_item_set_always_show_image (
GTK_IMAGE_MENU_ITEM (menuitem), TRUE);
#endif
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+ gtk_menu_shell_append (menu, menuitem);
g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item);
- if (KATZE_IS_ARRAY (item))
+ if (KATZE_ITEM_IS_FOLDER (item))
{
submenu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu);
@@ -372,13 +438,15 @@ katze_array_action_menu_item_select_cb (GtkWidget* proxy,
{
GtkWidget* menu;
KatzeArray* array;
+ gboolean handled;
menu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (proxy));
gtk_container_foreach (GTK_CONTAINER (menu),
(GtkCallback)(gtk_widget_destroy), NULL);
array = g_object_get_data (G_OBJECT (proxy), "KatzeItem");
- katze_array_action_generate_menu (array_action, array, menu, proxy);
+ katze_array_action_generate_menu (array_action, array, GTK_MENU_SHELL (menu), proxy);
+ g_signal_emit (array_action, signals[POPULATE_FOLDER], 0, menu, array, &handled);
}
static void
@@ -387,20 +455,25 @@ katze_array_action_proxy_clicked_cb (GtkWidget* proxy,
{
GtkWidget* menu;
KatzeArray* array;
+ gboolean handled = FALSE;
if (GTK_IS_MENU_ITEM (proxy))
{
g_object_set_data (G_OBJECT (proxy), "KatzeItem", array_action->array);
katze_array_action_menu_item_select_cb (proxy, array_action);
- g_signal_emit (array_action, signals[POPULATE_POPUP], 0,
- gtk_menu_item_get_submenu (GTK_MENU_ITEM (proxy)));
+ g_signal_emit (array_action, signals[POPULATE_FOLDER], 0,
+ gtk_menu_item_get_submenu (GTK_MENU_ITEM (proxy)),
+ array_action->array, &handled);
+ if (!handled)
+ g_signal_emit (array_action, signals[POPULATE_POPUP], 0,
+ gtk_menu_item_get_submenu (GTK_MENU_ITEM (proxy)));
return;
}
array = (KatzeArray*)g_object_get_data (G_OBJECT (proxy), "KatzeArray");
if (KATZE_IS_ITEM (array) && katze_item_get_uri ((KatzeItem*)array))
{
- g_signal_emit (array_action, signals[ACTIVATE_ITEM], 0, array);
+ katze_array_action_activate_item (array_action, KATZE_ITEM (array), 1);
return;
}
@@ -408,11 +481,15 @@ katze_array_action_proxy_clicked_cb (GtkWidget* proxy,
if (!array)
array = array_action->array;
- katze_array_action_generate_menu (array_action, array, menu, proxy);
+ katze_array_action_generate_menu (array_action, array, GTK_MENU_SHELL (menu), proxy);
- /* populate-popup should only affect the main proxy */
- if (array == array_action->array)
- g_signal_emit (array_action, signals[POPULATE_POPUP], 0, menu);
+ g_signal_emit (array_action, signals[POPULATE_FOLDER], 0, menu, array, &handled);
+ if (!handled)
+ {
+ /* populate-popup should only affect the main proxy */
+ if (array == array_action->array)
+ g_signal_emit (array_action, signals[POPULATE_POPUP], 0, menu);
+ }
#if HAVE_HILDON
/* Avoid a bug in GTK+ messing up the initial scrolling position */
@@ -497,7 +574,7 @@ katze_array_action_item_notify_cb (KatzeItem* item,
gtk_tool_item_set_tooltip_text (toolitem,
katze_item_get_uri (item));
}
- else if (!KATZE_IS_ARRAY (item) && !strcmp (property, "uri"))
+ else if (KATZE_ITEM_IS_BOOKMARK (item) && !strcmp (property, "uri"))
{
icon = katze_load_cached_icon (katze_item_get_uri (item), GTK_WIDGET (toolitem));
image = gtk_image_new_from_pixbuf (icon);
@@ -531,7 +608,7 @@ katze_array_action_proxy_create_menu_proxy_cb (GtkWidget* proxy,
image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
else
{
- if (KATZE_IS_ARRAY (item))
+ if (KATZE_ITEM_IS_FOLDER (item))
icon = gtk_widget_render_icon (menuitem,
GTK_STOCK_DIRECTORY, GTK_ICON_SIZE_MENU, NULL);
else
@@ -545,7 +622,7 @@ katze_array_action_proxy_create_menu_proxy_cb (GtkWidget* proxy,
GTK_IMAGE_MENU_ITEM (menuitem), TRUE);
#endif
g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item);
- if (KATZE_IS_ARRAY (item))
+ if (KATZE_ITEM_IS_FOLDER (item))
{
GtkWidget* submenu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu);
@@ -604,13 +681,13 @@ katze_array_action_create_tool_item_for (KatzeArrayAction* array_action,
uri = katze_item_get_uri (item);
desc = katze_item_get_text (item);
- if (!KATZE_IS_ARRAY (item) && !uri)
+ if (KATZE_ITEM_IS_SEPARATOR (item))
return gtk_separator_tool_item_new ();
toolitem = gtk_tool_button_new (NULL, "");
g_signal_connect (toolitem, "create-menu-proxy",
G_CALLBACK (katze_array_action_proxy_create_menu_proxy_cb), item);
- if (KATZE_IS_ARRAY (item))
+ if (KATZE_ITEM_IS_FOLDER (item))
icon = gtk_widget_render_icon (GTK_WIDGET (toolitem),
GTK_STOCK_DIRECTORY, GTK_ICON_SIZE_MENU, NULL);
else
diff --git a/katze/katze-arrayaction.h b/katze/katze-arrayaction.h
index 2e8c462a..dc2aaa36 100644
--- a/katze/katze-arrayaction.h
+++ b/katze/katze-arrayaction.h
@@ -48,6 +48,12 @@ GtkToolItem*
katze_array_action_create_tool_item_for (KatzeArrayAction* array_action,
KatzeItem* item);
+void
+katze_array_action_generate_menu (KatzeArrayAction* array_action,
+ KatzeArray* folder,
+ GtkMenuShell* menu,
+ GtkWidget* proxy);
+
G_END_DECLS
#endif /* __KATZE_ARRAY_ACTION_H__ */
diff --git a/katze/katze-net.c b/katze/katze-net.c
index 6467832f..63f7aa82 100644
--- a/katze/katze-net.c
+++ b/katze/katze-net.c
@@ -71,16 +71,7 @@ katze_net_finalize (GObject* object)
G_OBJECT_CLASS (katze_net_parent_class)->finalize (object);
}
-/**
- * katze_net_new:
- *
- * Instantiates a new #KatzeNet instance.
- *
- * Return value: a new #KatzeNet
- *
- * Deprecated: 0.2.7
- **/
-KatzeNet*
+static KatzeNet*
katze_net_new (void)
{
static KatzeNet* net = NULL;
@@ -97,23 +88,6 @@ katze_net_new (void)
return net;
}
-/**
- * katze_net_get_session:
- *
- * Retrieves the session of the net.
- *
- * Return value: a session, or %NULL
- *
- * Deprecated: 0.2.7: Use webkit_get_default_session ().
- **/
-gpointer
-katze_net_get_session (KatzeNet* net)
-{
- g_return_val_if_fail (KATZE_IS_NET (net), NULL);
-
- return webkit_get_default_session ();
-}
-
typedef struct
{
KatzeNet* net;
@@ -149,8 +123,7 @@ katze_net_get_cached_path (KatzeNet* net,
gchar* cached_filename;
gchar* cached_path;
- if (!net)
- net = katze_net_new ();
+ net = katze_net_new ();
if (subfolder)
cache_path = g_build_filename (net->cache_path, subfolder, NULL);
@@ -207,26 +180,11 @@ katze_net_got_body_cb (SoupMessage* msg,
KatzeNetPriv* priv)
{
KatzeNetRequest* request;
- #if 0
- gchar* filename;
- FILE* fp;
- #endif
request = priv->request;
if (msg->response_body->length > 0)
{
- #if 0
- /* FIXME: Caching */
- filename = katze_net_get_cached_path (net, request->uri, NULL);
- if ((fp = fopen (filename, "wb")))
- {
- fwrite (msg->response_body->data,
- 1, msg->response_body->length, fp);
- fclose (fp);
- }
- g_free (filename);
- #endif
request->data = g_memdup (msg->response_body->data,
msg->response_body->length);
request->length = msg->response_body->length;
@@ -340,8 +298,7 @@ katze_net_load_uri (KatzeNet* net,
if (!status_cb && !transfer_cb)
return;
- if (net == NULL)
- net = katze_net_new ();
+ net = katze_net_new ();
request = g_new0 (KatzeNetRequest, 1);
request->uri = g_strdup (uri);
diff --git a/katze/katze-net.h b/katze/katze-net.h
index f26a0ce1..5658ff47 100644
--- a/katze/katze-net.h
+++ b/katze/katze-net.h
@@ -37,12 +37,6 @@ typedef struct _KatzeNetClass KatzeNetClass;
GType
katze_net_get_type (void) G_GNUC_CONST;
-KatzeNet*
-katze_net_new (void);
-
-gpointer
-katze_net_get_session (KatzeNet* net);
-
typedef enum
{
KATZE_NET_VERIFIED,
diff --git a/katze/katze-utils.c b/katze/katze-utils.c
index dc7f7946..134a7d83 100644
--- a/katze/katze-utils.c
+++ b/katze/katze-utils.c
@@ -247,10 +247,14 @@ proxy_combo_box_changed_cb (GtkComboBox* button,
}
else if (value != custom_value && GTK_IS_ENTRY (child))
{
+ g_signal_handlers_block_by_func (
+ button, proxy_combo_box_changed_cb, object);
/* Force the combo to change the item again */
gtk_widget_destroy (child);
gtk_combo_box_set_active (button, value + 1);
gtk_combo_box_set_active (button, value);
+ g_signal_handlers_unblock_by_func (
+ button, proxy_combo_box_changed_cb, object);
}
}
@@ -1132,9 +1136,8 @@ katze_bookmark_populate_tree_view (KatzeArray* array,
KatzeItem* child;
GtkTreeIter iter;
GtkTreeIter root_iter;
- guint i = 0;
- while ((child = katze_array_get_nth_item (KATZE_ARRAY (array), i)))
+ KATZE_ARRAY_FOREACH_ITEM (child, array)
{
if (KATZE_ITEM_IS_BOOKMARK (child))
{
@@ -1151,7 +1154,6 @@ katze_bookmark_populate_tree_view (KatzeArray* array,
gtk_tree_store_insert_with_values (model, &iter, &root_iter,
0, 0, NULL, -1);
}
- i++;
}
}
@@ -1493,6 +1495,8 @@ katze_load_cached_icon (const gchar* uri,
{
GdkPixbuf* icon = NULL;
+ g_return_val_if_fail (uri != NULL, NULL);
+
if (g_str_has_prefix (uri, "http://") || g_str_has_prefix (uri,"https://"))
{
guint i;
@@ -1522,6 +1526,7 @@ katze_load_cached_icon (const gchar* uri,
g_free (checksum);
path = g_build_filename (g_get_user_cache_dir (), PACKAGE_NAME,
"icons", filename, NULL);
+ g_free (filename);
if ((icon = gdk_pixbuf_new_from_file_at_size (path, 16, 16, NULL)))
{
g_free (path);
@@ -1534,95 +1539,3 @@ katze_load_cached_icon (const gchar* uri,
GTK_STOCK_FILE, GTK_ICON_SIZE_MENU, NULL);
}
-/**
- * katze_collfold:
- * @str: a non-NULL UTF-8 string
- *
- * Computes a string without case and decomposited so
- * it can be used for comparison.
- *
- * Return value: a normalized string
- *
- * Since: 0.2.3
- **/
-gchar*
-katze_collfold (const gchar* str)
-{
- GString* result = g_string_new (NULL);
- const gchar* p = str;
-
- while (*p)
- {
- gunichar ch = g_unichar_tolower (g_utf8_get_char (p));
- gsize len;
- gunichar* sch = g_unicode_canonical_decomposition (ch, &len);
- guint i = 0;
- while (i < len)
- g_string_append_unichar (result, sch[i++]);
-
- p = g_utf8_next_char (p);
- }
-
- return g_string_free (result, FALSE);
-}
-
-/**
- * katze_utf8_stristr:
- * @haystack: a non-NULL UTF-8 string
- * @needle: a normalized non-NULL UTF-8 string
- *
- * Determines whether @needle is in @haystack, disregarding
- * differences in case.
- *
- * Return value: %TRUE if @needle is found in @haystack
- *
- * Since: 0.2.3
- **/
-gboolean
-katze_utf8_stristr (const gchar* haystack,
- const gchar* needle)
-{
- #if 0 /* 0,000159 seconds */
- /* Too slow for use in completion */
- gchar* nhaystack = g_utf8_normalize (haystack, -1, G_NORMALIZE_DEFAULT);
- const gchar *p = nhaystack;
- gsize len = strlen (needle);
- gsize i;
-
- while (*p)
- {
- for (i = 0; i < len; i++)
- if (g_unichar_tolower (g_utf8_get_char (p + i))
- != g_unichar_tolower (g_utf8_get_char (needle + i)))
- goto next;
-
- g_free (nhaystack);
- return TRUE;
-
- next:
- p = g_utf8_next_char (p);
- }
-
- g_free (nhaystack);
- return FALSE;
- #else /* 0,000044 seconds */
- /* No unicode matching */
- const gchar *p = haystack;
- gsize len = strlen (needle);
- gsize i;
-
- while (*p)
- {
- for (i = 0; i < len; i++)
- if (g_ascii_tolower (p[i]) != g_ascii_tolower (needle[i]))
- goto next;
-
- return TRUE;
-
- next:
- p++;
- }
-
- return FALSE;
- #endif
-}
diff --git a/katze/katze-utils.h b/katze/katze-utils.h
index 6b811f54..5382173f 100644
--- a/katze/katze-utils.h
+++ b/katze/katze-utils.h
@@ -34,13 +34,7 @@ G_BEGIN_DECLS
*
* Frees @lvalue if needed and assigns it the value of @rvalue.
**/
-#define katze_assign(lvalue, rvalue) \
- do \
- { \
- g_free (lvalue); \
- lvalue = rvalue; \
- } \
- while (0)
+#define katze_assign(lvalue, rvalue) lvalue = (g_free (lvalue), rvalue)
/**
* katze_object_assign:
@@ -50,13 +44,7 @@ G_BEGIN_DECLS
* Unrefs @lvalue if needed and assigns it the value of @rvalue.
**/
#define katze_object_assign(lvalue, rvalue) \
- do \
- { \
- if (lvalue) \
- g_object_unref (lvalue); \
- lvalue = rvalue; \
- } \
- while (0)
+ lvalue = ((lvalue ? g_object_unref (lvalue) : lvalue), rvalue)
/**
* katze_strv_assign:
@@ -67,13 +55,7 @@ G_BEGIN_DECLS
*
* Since: 0.1.7
**/
-#define katze_strv_assign(lvalue, rvalue) \
- do \
- { \
- g_strfreev (lvalue); \
- lvalue = rvalue; \
- } \
- while (0)
+#define katze_strv_assign(lvalue, rvalue) lvalue = (g_strfreev (lvalue), rvalue)
GtkWidget*
katze_property_proxy (gpointer object,
@@ -157,13 +139,6 @@ GdkPixbuf*
katze_load_cached_icon (const gchar* uri,
GtkWidget* widget);
-gchar*
-katze_collfold (const gchar* str);
-
-gboolean
-katze_utf8_stristr (const gchar* haystack,
- const gchar* needle);
-
G_END_DECLS
#endif /* __KATZE_UTILS_H__ */
diff --git a/midori/main.c b/midori/main.c
index 14b97272..ab35fc95 100644
--- a/midori/main.c
+++ b/midori/main.c
@@ -244,8 +244,7 @@ settings_save_to_file (MidoriWebSettings* settings,
if (extensions)
{
- i = 0;
- while ((extension = katze_array_get_nth_item (extensions, i++)))
+ KATZE_ARRAY_FOREACH_ITEM (extension, extensions)
if (midori_extension_is_active (extension))
g_key_file_set_boolean (key_file, "extensions",
g_object_get_data (G_OBJECT (extension), "filename"), TRUE);
@@ -315,7 +314,7 @@ search_engines_save_to_file (KatzeArray* search_engines,
GError** error)
{
GKeyFile* key_file;
- guint i, j, n_properties;
+ guint j, n_properties;
KatzeItem* item;
const gchar* name;
GParamSpec** pspecs;
@@ -326,8 +325,7 @@ search_engines_save_to_file (KatzeArray* search_engines,
key_file = g_key_file_new ();
pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (search_engines),
&n_properties);
- i = 0;
- while ((item = katze_array_get_nth_item (search_engines, i++)))
+ KATZE_ARRAY_FOREACH_ITEM (item, search_engines)
{
name = katze_item_get_name (item);
for (j = 0; j < n_properties; j++)
@@ -508,12 +506,8 @@ static void
midori_session_add_delay (KatzeArray* session)
{
KatzeItem* item;
- gint i = 0;
- while ((item = katze_array_get_nth_item (session, i++)))
- {
- if (katze_item_get_meta_integer (item, "delay") < 0)
- katze_item_set_meta_integer (item, "delay", 1);
- }
+ KATZE_ARRAY_FOREACH_ITEM (item, session)
+ katze_item_set_meta_integer (item, "delay", 1);
}
static void
@@ -1126,7 +1120,7 @@ midori_load_extensions (gpointer data)
GModule* module;
typedef MidoriExtension* (*extension_init_func)(void);
extension_init_func extension_init;
- MidoriExtension* extension;
+ MidoriExtension* extension = NULL;
/* Ignore files which don't have the correct suffix */
if (!g_str_has_suffix (filename, G_MODULE_SUFFIX))
@@ -1199,9 +1193,8 @@ midori_browser_action_last_session_activate_cb (GtkAction* action,
GError* error = NULL;
if (midori_array_from_file (old_session, config_file, "xbel", &error))
{
- guint i = 0;
KatzeItem* item;
- while ((item = katze_array_get_nth_item (old_session, i++)))
+ KATZE_ARRAY_FOREACH_ITEM (item, old_session)
midori_browser_add_item (browser, item);
}
else
@@ -1226,7 +1219,6 @@ midori_load_session (gpointer data)
gchar* config_file;
KatzeArray* session;
KatzeItem* item;
- guint i;
gint64 current;
MidoriStartup load_on_startup;
gchar** command = g_object_get_data (G_OBJECT (app), "execute-command");
@@ -1280,8 +1272,7 @@ midori_load_session (gpointer data)
midori_session_add_delay (_session);
session = midori_browser_get_proxy_array (browser);
- i = 0;
- while ((item = katze_array_get_nth_item (_session, i++)))
+ KATZE_ARRAY_FOREACH_ITEM (item, _session)
{
g_object_set_data (G_OBJECT (item), "midori-view-append", (void*)1);
midori_browser_add_item (browser, item);
@@ -1755,7 +1746,7 @@ main (int argc,
"show-panel", FALSE,
"toolbar-items", "Back,Forward,ReloadStop,Location",
"homepage", NULL,
- "show-statusbar", TRUE,
+ "show-statusbar", FALSE,
"enable-developer-extras", FALSE,
NULL);
g_object_set (browser, "settings", settings, NULL);
@@ -2043,7 +2034,6 @@ main (int argc,
uri_ready = midori_prepare_uri (uri);
katze_item_set_uri (item, uri_ready);
g_free (uri_ready);
- katze_item_set_meta_integer (item, "delay", 0);
katze_array_add_item (_session, item);
uri = strtok (NULL, "|");
}
@@ -2060,8 +2050,7 @@ main (int argc,
G_CALLBACK (midori_search_engines_modify_cb), search_engines);
if (!katze_array_is_empty (search_engines))
{
- i = 0;
- while ((item = katze_array_get_nth_item (search_engines, i++)))
+ KATZE_ARRAY_FOREACH_ITEM (item, search_engines)
g_signal_connect_after (item, "notify",
G_CALLBACK (midori_search_engines_modify_cb), search_engines);
}
@@ -2077,9 +2066,7 @@ main (int argc,
and deleted during normal runtime, but persists in case of a crash. */
katze_assign (config_file, build_config_filename ("running"));
if (g_access (config_file, F_OK) == 0)
- {
back_from_crash = TRUE;
- }
else
g_file_set_contents (config_file, "RUNNING", -1, NULL);
diff --git a/midori/marshal.list b/midori/marshal.list
index 9d0337c8..0b7de0ac 100644
--- a/midori/marshal.list
+++ b/midori/marshal.list
@@ -1,4 +1,5 @@
BOOLEAN:OBJECT
+BOOLEAN:OBJECT,OBJECT
BOOLEAN:OBJECT,UINT
BOOLEAN:VOID
OBJECT:OBJECT
diff --git a/midori/midori-app.c b/midori/midori-app.c
index d4cfd16b..9dddad6c 100644
--- a/midori/midori-app.c
+++ b/midori/midori-app.c
@@ -96,8 +96,7 @@ enum
PROP_HISTORY,
PROP_EXTENSIONS,
PROP_BROWSERS,
- PROP_BROWSER,
- PROP_BROWSER_COUNT
+ PROP_BROWSER
};
enum {
@@ -394,22 +393,6 @@ midori_app_class_init (MidoriAppClass* class)
"The current browser",
MIDORI_TYPE_BROWSER,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-
- /**
- * MidoriApp:browser-count:
- *
- * The number of browsers.
- *
- * Deprecated: 0.1.3 Use MidoriApp:browsers instead.
- */
- g_object_class_install_property (gobject_class,
- PROP_BROWSER_COUNT,
- g_param_spec_uint (
- "browser-count",
- "Browser Count",
- "The current number of browsers",
- 0, G_MAXUINT, 0,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
}
static void
@@ -794,23 +777,18 @@ midori_app_set_property (GObject* object,
break;
case PROP_SETTINGS:
katze_object_assign (app->settings, g_value_dup_object (value));
- /* FIXME: Propagate settings to all browsers */
break;
case PROP_BOOKMARKS:
katze_object_assign (app->bookmarks, g_value_dup_object (value));
- /* FIXME: Propagate bookmarks to all browsers */
break;
case PROP_TRASH:
katze_object_assign (app->trash, g_value_dup_object (value));
- /* FIXME: Propagate trash to all browsers */
break;
case PROP_SEARCH_ENGINES:
katze_object_assign (app->search_engines, g_value_dup_object (value));
- /* FIXME: Propagate search engines to all browsers */
break;
case PROP_HISTORY:
katze_object_assign (app->history, g_value_dup_object (value));
- /* FIXME: Propagate history to all browsers */
break;
case PROP_EXTENSIONS:
katze_object_assign (app->extensions, g_value_dup_object (value));
@@ -858,9 +836,6 @@ midori_app_get_property (GObject* object,
case PROP_BROWSER:
g_value_set_object (value, app->browser);
break;
- case PROP_BROWSER_COUNT:
- g_value_set_uint (value, katze_array_get_length (app->browsers));
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
diff --git a/midori/midori-array.c b/midori/midori-array.c
index e8ca484b..25c68d01 100644
--- a/midori/midori-array.c
+++ b/midori/midori-array.c
@@ -589,7 +589,6 @@ string_append_item (GString* string,
metadata = katze_item_metadata_to_xbel (item);
if (KATZE_IS_ARRAY (item))
{
- guint i = 0;
KatzeItem* _item;
KatzeArray* array = KATZE_ARRAY (item);
@@ -597,7 +596,7 @@ string_append_item (GString* string,
/* FIXME: " folded=\"no\" */
string_append_xml_element (string, "title", katze_item_get_name (item));
string_append_xml_element (string, "desc", katze_item_get_text (item));
- while ((_item = katze_array_get_nth_item (array, i++)))
+ KATZE_ARRAY_FOREACH_ITEM (_item, array)
string_append_item (string, _item);
g_string_append (string, metadata);
g_string_append (string, "\n");
@@ -679,7 +678,6 @@ katze_array_to_xbel (KatzeArray* array,
GError** error)
{
gchar* metadata = katze_item_metadata_to_xbel (KATZE_ITEM (array));
- guint i;
KatzeItem* item;
GString* markup = g_string_new (
@@ -693,8 +691,7 @@ katze_array_to_xbel (KatzeArray* array,
string_append_xml_element (markup, "title", katze_item_get_name (KATZE_ITEM (array)));
string_append_xml_element (markup, "desc", katze_item_get_text (KATZE_ITEM (array)));
g_string_append (markup, metadata);
- i = 0;
- while ((item = katze_array_get_nth_item (array, i++)))
+ KATZE_ARRAY_FOREACH_ITEM (item, array)
string_append_item (markup, item);
g_string_append (markup, "\n");
diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index aed94ed0..c988ae23 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -388,7 +388,7 @@ _midori_browser_set_statusbar_text (MidoriBrowser* browser,
katze_assign (browser->statusbar_text, sokoke_format_uri_for_display (text));
- if (!gtk_widget_get_visible (browser->statusbar) && !is_location)
+ if (!browser->show_statusbar && !is_location)
{
GtkAction* action = _action_by_name (browser, "Location");
MidoriLocationAction* location_action = MIDORI_LOCATION_ACTION (action);
@@ -992,6 +992,11 @@ midori_browser_prepare_download (MidoriBrowser* browser,
}
webkit_download_set_destination_uri (download, uri);
+ if (!browser->show_statusbar && gtk_widget_get_visible (browser->transferbar))
+ {
+ _midori_browser_set_statusbar_text (browser, NULL);
+ gtk_widget_show (browser->statusbar);
+ }
midori_transferbar_add_download_item (MIDORI_TRANSFERBAR (browser->transferbar), download);
return TRUE;
}
@@ -2126,7 +2131,6 @@ _action_private_browsing_activate (GtkAction* action,
const gchar* uri = midori_browser_get_current_uri (browser);
if (uri != NULL)
{
- /* FIXME: Use the same binary that is running right now */
if (*uri != '\0')
midori_browser_spawn_app (uri);
else
@@ -2557,7 +2561,7 @@ midori_browser_get_toolbar_actions (MidoriBrowser* browser)
{
static const gchar* actions[] = {
"WindowNew", "TabNew", "Open", "SaveAs", "Print", "Find",
- "Fullscreen", "Preferences", "Window",
+ "Fullscreen", "Preferences", "Window", "Bookmarks",
"ReloadStop", "ZoomIn", "TabClose",
"ZoomOut", "Separator", "Back", "Forward", "Homepage",
"Panel", "Trash", "Search", "BookmarkAdd", "Previous", "Next", NULL };
@@ -2648,28 +2652,23 @@ midori_browser_menu_item_deselect_cb (GtkWidget* menuitem,
_midori_browser_set_statusbar_text (browser, NULL);
}
-static void
-midori_bookmarkbar_activate_item (GtkAction* action,
- KatzeItem* item,
- MidoriBrowser* browser)
-{
- midori_browser_open_bookmark (browser, item);
-}
-
static gboolean
midori_bookmarkbar_activate_item_alt (GtkAction* action,
KatzeItem* item,
guint button,
MidoriBrowser* browser)
{
- if (button == 2)
+ if (button == 1)
+ {
+ midori_browser_open_bookmark (browser, item);
+ }
+ else if (button == 2)
{
gint n = midori_browser_add_uri (browser, katze_item_get_uri (item));
midori_browser_set_current_page_smartly (browser, n);
- return TRUE;
}
- return FALSE;
+ return TRUE;
}
static void
@@ -2699,33 +2698,28 @@ _action_trash_populate_popup (GtkAction* action,
gtk_widget_show (menuitem);
}
-static void
-_action_trash_activate_item (GtkAction* action,
- KatzeItem* item,
- MidoriBrowser* browser)
-{
- guint n = midori_browser_add_item (browser, item);
- midori_browser_set_current_page (browser, n);
- katze_array_remove_item (browser->trash, item);
- _midori_browser_update_actions (browser);
-}
-
static gboolean
_action_trash_activate_item_alt (GtkAction* action,
KatzeItem* item,
guint button,
MidoriBrowser* browser)
{
- if (button == 2)
+ if (button == 1)
{
- gint n = midori_browser_add_uri (browser, katze_item_get_uri (item));
+ guint n = midori_browser_add_item (browser, item);
+ midori_browser_set_current_page (browser, n);
+ katze_array_remove_item (browser->trash, item);
+ _midori_browser_update_actions (browser);
+ }
+ else if (button == 2)
+ {
+ gint n = midori_browser_add_item (browser, item);
midori_browser_set_current_page_smartly (browser, n);
katze_array_remove_item (browser->trash, item);
_midori_browser_update_actions (browser);
- return TRUE;
}
- return FALSE;
+ return TRUE;
}
/* static */ void
@@ -2743,7 +2737,6 @@ midori_browser_open_bookmark (MidoriBrowser* browser,
if (!uri_fixed)
uri_fixed = g_strdup (uri);
- /* FIXME: Use the same binary that is running right now */
if (katze_item_get_meta_boolean (item, "app"))
midori_browser_spawn_app (uri_fixed);
else
@@ -2817,6 +2810,45 @@ midori_browser_bookmark_popup (GtkWidget* widget,
KatzeItem* item,
MidoriBrowser* browser);
+static gboolean
+_action_bookmarks_populate_folder (GtkAction* action,
+ GtkMenuShell* menu,
+ KatzeArray* folder,
+ MidoriBrowser* browser)
+{
+ const char* sqlcmd = "SELECT uri, title, app, folder "
+ "FROM bookmarks WHERE folder = '%q' ORDER BY uri ASC";
+ sqlite3* db = g_object_get_data (G_OBJECT (browser->bookmarks), "db");
+ const gchar* folder_name;
+ char* sqlcmd_folder;
+ KatzeArray* bookmarks;
+ GtkWidget* menuitem;
+
+ if (!db)
+ return FALSE;
+
+ /* Clear items from dummy array here */
+ gtk_container_foreach (GTK_CONTAINER (menu),
+ (GtkCallback)(gtk_widget_destroy), NULL);
+
+ folder_name = katze_item_get_name (KATZE_ITEM (folder));
+ sqlcmd_folder = sqlite3_mprintf (sqlcmd, folder_name ? folder_name : "");
+ bookmarks = katze_array_from_sqlite (db, sqlcmd_folder);
+ sqlite3_free (sqlcmd_folder);
+ if (!bookmarks || katze_array_is_empty (bookmarks))
+ {
+ menuitem = gtk_image_menu_item_new_with_label (_("Empty"));
+ gtk_widget_set_sensitive (menuitem, FALSE);
+ gtk_menu_shell_append (menu, menuitem);
+ gtk_widget_show (menuitem);
+ return TRUE;
+ }
+
+ katze_array_action_generate_menu (KATZE_ARRAY_ACTION (action), bookmarks,
+ menu, GTK_WIDGET (browser));
+ return TRUE;
+}
+
static void
_action_window_populate_popup (GtkAction* action,
GtkMenu* menu,
@@ -2857,16 +2889,17 @@ _action_window_populate_popup (GtkAction* action,
}
static void
-_action_window_activate_item (GtkAction* action,
- KatzeItem* item,
- MidoriBrowser* browser)
+_action_window_activate_item_alt (GtkAction* action,
+ KatzeItem* item,
+ gint button,
+ MidoriBrowser* browser)
{
- guint i, n;
- GtkWidget* view;
+ guint i;
+ guint n = katze_array_get_length (browser->proxy_array);
- n = katze_array_get_length (browser->proxy_array);
for (i = 0; i < n; i++)
{
+ GtkWidget* view;
view = gtk_notebook_get_nth_page (GTK_NOTEBOOK (browser->notebook), i);
if (midori_view_get_proxy_item (MIDORI_VIEW (view)) == item)
gtk_notebook_set_current_page (GTK_NOTEBOOK (browser->notebook), i);
@@ -3220,7 +3253,6 @@ midori_browser_source_transfer_cb (KatzeNetRequest* request,
fclose (fp);
if ((ret - request->length) != 0)
{
- /* FIXME: Show an error in the graphical interface */
g_warning ("Error writing to file %s "
"in midori_browser_source_transfer_cb()", filename);
}
@@ -3274,7 +3306,6 @@ _action_source_view_activate (GtkAction* action,
#else
GError* error = NULL;
- /* FIXME: Handling http transparently in the function would be nice */
if (g_str_has_prefix (uri, "file://"))
{
if (!sokoke_show_uri_with_mime_type (gtk_widget_get_screen (view),
@@ -3426,26 +3457,6 @@ _action_location_active_changed (GtkAction* action,
}
}
-static gboolean
-midori_browser_bookmark_homepage_button_press_cb (GtkToolItem* button,
- GdkEventButton* event,
- MidoriBrowser* browser)
-{
- if (event->button == 2)
- {
- gchar* homepage;
- guint n;
-
- g_object_get (browser->settings, "homepage", &homepage, NULL);
- n = midori_browser_add_uri (browser, homepage);
- g_free (homepage);
- midori_browser_set_current_page_smartly (browser, n);
- return TRUE;
- }
-
- return FALSE;
-}
-
static void
_action_location_focus_in (GtkAction* action,
MidoriBrowser* browser)
@@ -3784,16 +3795,14 @@ midori_browser_bookmark_open_in_tab_activate_cb (GtkWidget* menuitem,
if (KATZE_IS_ARRAY (item))
{
KatzeItem* child;
- guint i = 0;
- while ((child = katze_array_get_nth_item (KATZE_ARRAY (item), i)))
+ KATZE_ARRAY_FOREACH_ITEM (child, KATZE_ARRAY (item))
{
if ((uri = katze_item_get_uri (child)) && *uri)
{
n = midori_browser_add_item (browser, child);
midori_browser_set_current_page_smartly (browser, n);
}
- i++;
}
}
else
@@ -4036,8 +4045,7 @@ _action_bookmarks_import_activate (GtkAction* action,
db = g_object_get_data (G_OBJECT (browser->bookmarks), "db");
sqlcmd = "SELECT title from bookmarks where uri=''";
bookmarkdirs = katze_array_from_sqlite (db, sqlcmd);
- i = 0;
- while ((item = katze_array_get_nth_item (bookmarkdirs, i++)))
+ KATZE_ARRAY_FOREACH_ITEM (item, bookmarkdirs)
{
const gchar* name = katze_item_get_name (item);
gtk_combo_box_append_text (combobox_folder, name);
@@ -4423,11 +4431,9 @@ _action_tab_duplicate_activate (GtkAction* action,
{
GtkWidget* view = midori_browser_get_current_tab (browser);
MidoriNewView where = MIDORI_NEW_VIEW_TAB;
- GtkWidget* new_view = g_object_new (MIDORI_TYPE_VIEW,
- "settings", browser->settings, NULL);
- midori_view_set_uri (MIDORI_VIEW (new_view),
- midori_view_get_display_uri (MIDORI_VIEW (view)));
- gtk_widget_show (new_view);
+ GtkWidget* new_view = midori_view_new_with_uri (
+ midori_view_get_display_uri (MIDORI_VIEW (view)),
+ NULL, browser->settings);
g_signal_emit_by_name (view, "new-view", new_view, where);
}
@@ -4769,13 +4775,7 @@ midori_browser_notebook_button_press_event_after_cb (GtkNotebook* notebook,
|| */(event->type == GDK_BUTTON_PRESS && event->button == 2))
{
gint n;
- GtkWidget* view;
-
- view = g_object_new (MIDORI_TYPE_VIEW,
- "settings", browser->settings,
- NULL);
- midori_view_set_uri (MIDORI_VIEW (view), "");
- gtk_widget_show (view);
+ GtkWidget* view = midori_view_new_with_uri ("", NULL, browser->settings);
g_object_set_data (G_OBJECT (view), "midori-view-append", (void*)1);
n = midori_browser_add_tab (browser, view);
midori_browser_set_current_page (browser, n);
@@ -4952,11 +4952,11 @@ static const GtkActionEntry entries[] =
NULL, "Right",
N_("Go forward to the next page"), G_CALLBACK (_action_navigation_activate) },
{ "Previous", GTK_STOCK_MEDIA_PREVIOUS,
- NULL, "Left",
+ NULL, "Left",
/* i18n: Visit the previous logical page, ie. in a forum or blog */
N_("Go to the previous sub-page"), G_CALLBACK (_action_navigation_activate) },
{ "Next", GTK_STOCK_MEDIA_NEXT,
- NULL, "Right",
+ NULL, "Right",
/* i18n: Visit the following logical page, ie. in a forum or blog */
N_("Go to the next sub-page"), G_CALLBACK (_action_navigation_activate) },
{ "Homepage", STOCK_HOMEPAGE,
@@ -5268,6 +5268,7 @@ static const gchar* ui_markup =
""
""
""
+ ""
""
""
"