aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog15
-rw-r--r--lib/widgets/ephy-node-view.c27
-rwxr-xr-xsrc/pdm-dialog.c73
3 files changed, 106 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 9810dd5b6..6487e8f7b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2003-07-14 Xan Lopez <xan@masilla.org>
+
+ * lib/widgets/ephy-node-view.c:
+ (ephy_node_view_select_node_by_key), (ephy_node_view_remove):
+
+ Don't use event->string, is deprecated (#117346).
+ Also improve intelligent selection.
+
+ * src/pdm-dialog.c: (pdm_dialog_remove_button_clicked_cb),
+ (pdm_cmd_delete_selection), (pdm_key_pressed_cb), (setup_action):
+
+ Connect del keys to delete action, also implement intelligent selection
+ after deletion (I want to be known as Mr. Intelligent Selection from now,
+ spread the word).
+
2003-07-14 Christian Persch <chpe@cvs.gnome.org>
* src/pdm-dialog.c: (pdm_dialog_remove_button_clicked_cb),
diff --git a/lib/widgets/ephy-node-view.c b/lib/widgets/ephy-node-view.c
index 4651a738c..6e000358a 100644
--- a/lib/widgets/ephy-node-view.c
+++ b/lib/widgets/ephy-node-view.c
@@ -430,8 +430,11 @@ ephy_node_view_select_node_by_key (EphyNodeView *view, GdkEventKey *event)
gchar *string;
gchar *event_string;
gboolean found = FALSE;
+ gchar outbuf[6];
+ gint length;
- event_string = g_utf8_casefold (event->string, -1);
+ length = g_unichar_to_utf8 (gdk_keyval_to_unicode (event->keyval), outbuf);
+ event_string = g_utf8_casefold (outbuf, length);
if (!gtk_tree_model_get_iter_first (view->priv->sortmodel, &iter))
{
@@ -973,10 +976,11 @@ ephy_node_view_remove (EphyNodeView *view)
EphyNode *node;
GtkTreeIter iter, iter2;
GtkTreePath *path;
+ GtkTreeRowReference *row_ref = NULL;
- /* Before removing we try to select the next node in the view. If that is
+ /* Before removing we try to get a reference to the next node in the view. If that is
* not available we try with the previous one, and if that is absent too,
- * we do not select anything (which equals to select the topic "All")
+ * we will not select anything (which equals to select the topic "All")
*/
list = ephy_node_view_get_selection (view);
@@ -993,18 +997,17 @@ ephy_node_view_remove (EphyNodeView *view)
if (gtk_tree_model_iter_next (GTK_TREE_MODEL (view->priv->sortmodel), &iter))
{
path = gtk_tree_model_get_path (GTK_TREE_MODEL (view->priv->sortmodel), &iter);
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), path, NULL, FALSE);
- gtk_tree_path_free (path);
+ row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (view->priv->sortmodel), path);
}
else
{
path = gtk_tree_model_get_path (GTK_TREE_MODEL (view->priv->sortmodel), &iter2);
if (gtk_tree_path_prev (path))
{
- gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), path, NULL, FALSE);
+ row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (view->priv->sortmodel), path);
}
- gtk_tree_path_free (path);
}
+ gtk_tree_path_free (path);
for (; list != NULL; list = list->next)
{
@@ -1012,6 +1015,16 @@ ephy_node_view_remove (EphyNodeView *view)
}
g_list_free (list);
+
+ /* Select the "next" node */
+
+ if (row_ref != NULL)
+ {
+ path = gtk_tree_row_reference_get_path (row_ref);
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), path, NULL, FALSE);
+ gtk_tree_row_reference_free (row_ref);
+ gtk_tree_path_free (path);
+ }
}
void
diff --git a/src/pdm-dialog.c b/src/pdm-dialog.c
index ec2cd9dfc..dc98e28f5 100755
--- a/src/pdm-dialog.c
+++ b/src/pdm-dialog.c
@@ -14,6 +14,8 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
*/
#ifdef HAVE_CONFIG_H
@@ -42,6 +44,8 @@ static void pdm_dialog_class_init (PdmDialogClass *klass);
static void pdm_dialog_init (PdmDialog *dialog);
static void pdm_dialog_finalize (GObject *object);
+static void pdm_cmd_delete_selection (PdmActionInfo *action);
+
/* Glade callbacks */
void
pdm_dialog_close_button_clicked_cb (GtkWidget *button,
@@ -329,25 +333,60 @@ static void
pdm_dialog_remove_button_clicked_cb (GtkWidget *button,
PdmActionInfo *action)
{
+ pdm_cmd_delete_selection (action);
+}
+
+static void
+pdm_cmd_delete_selection (PdmActionInfo *action)
+{
+
GList *llist, *rlist = NULL, *l, *r;
GList *remove_list = NULL;
GtkTreeModel *model;
GtkTreeSelection *selection;
+ GtkTreePath *path;
+ GtkTreeIter iter, iter2;
+ GtkTreeRowReference *row_ref = NULL;
selection = gtk_tree_view_get_selection
(GTK_TREE_VIEW(action->treeview));
llist = gtk_tree_selection_get_selected_rows (selection, &model);
+
for (l = llist;l != NULL; l = l->next)
{
rlist = g_list_prepend (rlist, gtk_tree_row_reference_new
(model, (GtkTreePath *)l->data));
}
+ /* Intelligent selection logic, no actual selection yet */
+
+ path = gtk_tree_row_reference_get_path
+ ((GtkTreeRowReference *) g_list_last (rlist)->data);
+
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_path_free (path);
+ iter2 = iter;
+
+ if (gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter))
+ {
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter);
+ row_ref = gtk_tree_row_reference_new (model, path);
+ }
+ else
+ {
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter2);
+ if (gtk_tree_path_prev (path))
+ {
+ row_ref = gtk_tree_row_reference_new (model, path);
+ }
+ }
+ gtk_tree_path_free (path);
+
+ /* Removal */
+
for (r = rlist; r != NULL; r = r->next)
{
- GtkTreeIter iter;
gpointer data;
- GtkTreePath *path;
GValue val = {0, };
path = gtk_tree_row_reference_get_path
@@ -378,6 +417,30 @@ pdm_dialog_remove_button_clicked_cb (GtkWidget *button,
g_list_foreach (llist, (GFunc)gtk_tree_path_free, NULL);
g_list_free (llist);
g_list_free (rlist);
+
+ /* Selection */
+
+ if (row_ref != NULL)
+ {
+ path = gtk_tree_row_reference_get_path (row_ref);
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (action->treeview), path, NULL, FALSE);
+ gtk_tree_row_reference_free (row_ref);
+ gtk_tree_path_free (path);
+ }
+}
+
+static gboolean
+pdm_key_pressed_cb (GtkTreeView *treeview,
+ GdkEventKey *event,
+ PdmActionInfo *action)
+{
+ if (event->keyval == GDK_Delete || event->keyval == GDK_KP_Delete)
+ {
+ pdm_cmd_delete_selection (action);
+ return TRUE;
+ }
+
+ return FALSE;
}
static void
@@ -402,6 +465,12 @@ setup_action (PdmActionInfo *action)
g_signal_connect (selection, "changed",
G_CALLBACK(action_treeview_selection_changed_cb),
action);
+
+ g_signal_connect (G_OBJECT (action->treeview),
+ "key_press_event",
+ G_CALLBACK (pdm_key_pressed_cb),
+ action);
+
}
static void