aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2013-09-22 20:13:49 +0200
committerThomas White <taw@bitwiz.org.uk>2013-09-22 20:13:49 +0200
commit640cc1df858c1dada82d005930acf730cec21452 (patch)
tree3a88e5b55bef5315f4f7b1d1aa8227c0ad3b04d7 /src
parent197f5b68e85343b2c0229c28b7661a8bbaeb8b04 (diff)
Delete slide after move (broken)
Diffstat (limited to 'src')
-rw-r--r--src/presentation.c28
-rw-r--r--src/presentation.h1
-rw-r--r--src/slide_sorter.c13
3 files changed, 42 insertions, 0 deletions
diff --git a/src/presentation.c b/src/presentation.c
index 786627c..4612f03 100644
--- a/src/presentation.c
+++ b/src/presentation.c
@@ -111,6 +111,34 @@ int insert_slide(struct presentation *p, struct slide *new, int pos)
}
+static void delete_slide_index(struct presentation *p, int pos)
+{
+ int i;
+
+ for ( i=pos; i<p->num_slides-1; i++ ) {
+ p->slides[i] = p->slides[i+1];
+ }
+
+ p->num_slides--;
+
+ /* Don't bother to resize the array */
+
+ renumber_slides(p);
+}
+
+
+void delete_slide(struct presentation *p, struct slide *s)
+{
+ int idx;
+
+ idx = slide_number(p, s);
+ delete_slide_index(p, idx);
+
+ free_slide(s);
+}
+
+
+
struct slide *new_slide()
{
struct slide *new;
diff --git a/src/presentation.h b/src/presentation.h
index 308cb3c..3bb96ed 100644
--- a/src/presentation.h
+++ b/src/presentation.h
@@ -199,6 +199,7 @@ extern struct slide *new_slide(void);
extern struct slide *add_slide(struct presentation *p, int pos);
extern int insert_slide(struct presentation *p, struct slide *s, int pos);
extern void free_slide(struct slide *s);
+extern void delete_slide(struct presentation *p, struct slide *s);
extern void get_titlebar_string(struct presentation *p);
diff --git a/src/slide_sorter.c b/src/slide_sorter.c
index 11412ed..ef77299 100644
--- a/src/slide_sorter.c
+++ b/src/slide_sorter.c
@@ -31,6 +31,7 @@
#include <gtk/gtk.h>
#include "presentation.h"
+#include "render.h"
struct slide_sorter
@@ -47,6 +48,7 @@ struct slide_sorter
int bw;
int selection;
+ struct slide *selected_slide;
int drop_here;
int dragging;
@@ -170,6 +172,7 @@ static gboolean button_press_sig(GtkWidget *da, GdkEventButton *event,
if ( n->selection >= n->p->num_slides ) {
n->selection = n->p->num_slides - 1;
+ n->selected_slide = n->p->slides[n->selection];
}
redraw_slidesorter(n);
@@ -315,6 +318,7 @@ static void dnd_receive(GtkWidget *widget, GdkDragContext *drag_context,
//printf("Got SC: '%s'\n", sc);
printf("Inserting at %i\n", n->drop_here);
+
s = add_slide(n->p, n->drop_here);
if ( s != NULL ) {
@@ -380,6 +384,14 @@ static void dnd_end(GtkWidget *widget, GdkDragContext *drag_context,
}
+static void dnd_delete(GtkWidget *widget, GdkDragContext *drag_context,
+ struct slide_sorter *n)
+{
+ printf("Deleting.\n");
+ delete_slide(n->p, n->selected_slide);
+}
+
+
void open_slidesorter(struct presentation *p)
{
struct slide_sorter *n;
@@ -437,6 +449,7 @@ void open_slidesorter(struct presentation *p)
GDK_ACTION_MOVE);
g_signal_connect(n->da, "drag-data-received",
G_CALLBACK(dnd_receive), n);
+ g_signal_connect(n->da, "drag-data-delete", G_CALLBACK(dnd_delete), n);
g_signal_connect(n->da, "drag-data-get", G_CALLBACK(dnd_get), n);
g_signal_connect(n->da, "drag-motion", G_CALLBACK(dnd_motion), n);
g_signal_connect(n->da, "drag-drop", G_CALLBACK(dnd_drop), n);