aboutsummaryrefslogtreecommitdiffstats
path: root/embed/downloader-view.c
diff options
context:
space:
mode:
authorXan Lopez <xan@src.gnome.org>2003-10-29 07:22:22 +0800
committerXan Lopez <xan@src.gnome.org>2003-10-29 07:22:22 +0800
commit74b29db83dcbae7d8d1f953a4d2f831ef1144c78 (patch)
tree47cab6d9f11742fd5c199fe3c51d4bac21688646 /embed/downloader-view.c
parent55e15cb762ccb0fa32fbab23a6afb59e9770e036 (diff)
downloadgsoc2013-epiphany-74b29db83dcbae7d8d1f953a4d2f831ef1144c78.tar
gsoc2013-epiphany-74b29db83dcbae7d8d1f953a4d2f831ef1144c78.tar.gz
gsoc2013-epiphany-74b29db83dcbae7d8d1f953a4d2f831ef1144c78.tar.bz2
gsoc2013-epiphany-74b29db83dcbae7d8d1f953a4d2f831ef1144c78.tar.lz
gsoc2013-epiphany-74b29db83dcbae7d8d1f953a4d2f831ef1144c78.tar.xz
gsoc2013-epiphany-74b29db83dcbae7d8d1f953a4d2f831ef1144c78.tar.zst
gsoc2013-epiphany-74b29db83dcbae7d8d1f953a4d2f831ef1144c78.zip
Implement smart selection in the downloader view.
* embed/downloader-view.c: (downloader_view_remove_download): Implement smart selection in the downloader view. * data/epiphany.schemas.in: * embed/ephy-embed-popup-control.c: (embed_popup_download_link_cmd): * embed/mozilla/EphyHeaderSniffer.cpp: * lib/ephy-prefs.h: * src/popup-commands.c: (popup_cmd_download_link): Make persist downloads store the files in the download dir automatically without asking the user (key only accessible via gconf atm). CH downloads still need fixing.
Diffstat (limited to 'embed/downloader-view.c')
-rw-r--r--embed/downloader-view.c46
1 files changed, 40 insertions, 6 deletions
diff --git a/embed/downloader-view.c b/embed/downloader-view.c
index e557422ca..d67577989 100644
--- a/embed/downloader-view.c
+++ b/embed/downloader-view.c
@@ -438,24 +438,58 @@ downloader_view_remove_download (DownloaderView *dv, EphyDownload *download)
{
GtkTreeRowReference *row_ref;
GtkTreePath *path = NULL;
- GtkTreeIter iter;
+ GtkTreeIter iter, iter2;
row_ref = get_row_from_download (dv, download);
g_return_if_fail (row_ref);
+ /* Get the row we'll select after removal ("smart" selection) */
+
path = gtk_tree_row_reference_get_path (row_ref);
gtk_tree_model_get_iter (GTK_TREE_MODEL (dv->priv->model),
&iter, path);
+ gtk_tree_path_free (path);
- gtk_list_store_remove (GTK_LIST_STORE (dv->priv->model), &iter);
-
- /* FIXME: smart selection */
+ row_ref = NULL;
+ iter2 = iter;
+ if (gtk_tree_model_iter_next (GTK_TREE_MODEL (dv->priv->model), &iter))
+ {
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (dv->priv->model), &iter);
+ row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (dv->priv->model), path);
+ }
+ else
+ {
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (dv->priv->model), &iter2);
+ if (gtk_tree_path_prev (path))
+ {
+ row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (dv->priv->model),
+ path);
+ }
+ }
+ gtk_tree_path_free (path);
+ /* Removal */
+
+ gtk_list_store_remove (GTK_LIST_STORE (dv->priv->model), &iter2);
g_hash_table_remove (dv->priv->downloads_hash,
download);
- gtk_tree_path_free (path);
-
+ /* Actual selection */
+
+ if (row_ref != NULL)
+ {
+ path = gtk_tree_row_reference_get_path (row_ref);
+ if (path != NULL)
+ {
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (dv->priv->treeview),
+ path, NULL, FALSE);
+ gtk_tree_path_free (path);
+ }
+ gtk_tree_row_reference_free (row_ref);
+ }
+
+ /* Close the dialog if there are no more downloads */
+
if (!g_hash_table_size (dv->priv->downloads_hash))
g_object_unref (G_OBJECT (dv));
}