diff options
author | Thomas White <taw@bitwiz.org.uk> | 2013-12-19 22:55:23 +0000 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2013-12-19 22:55:23 +0000 |
commit | 90030e0d42f89a9c4e1137bf0b5f556bfe221dcb (patch) | |
tree | 99749ba1747e0aca4b4525c1e9251b4e7d621e6d /src | |
parent | 487c9dc4d38bb36109555e09449473596ae063e4 (diff) | |
parent | 22288d6bd003576ada6b60917b6527837e2af108 (diff) |
Merge branch 'master' of ssh://git.bitwiz.org.uk/colloquium
Diffstat (limited to 'src')
-rw-r--r-- | src/frame.h | 3 | ||||
-rw-r--r-- | src/mainwindow.c | 2 | ||||
-rw-r--r-- | src/mainwindow.h | 1 | ||||
-rw-r--r-- | src/presentation.c | 11 | ||||
-rw-r--r-- | src/render.c | 9 | ||||
-rw-r--r-- | src/slide_sorter.c | 128 | ||||
-rw-r--r-- | src/wrap.c | 2 |
7 files changed, 143 insertions, 13 deletions
diff --git a/src/frame.h b/src/frame.h index 1535761..2645060 100644 --- a/src/frame.h +++ b/src/frame.h @@ -106,6 +106,9 @@ struct frame /* True if the aspect ratio of this frame should be maintained */ int is_image; + + /* True if wrapping failed for this box */ + int trouble; }; diff --git a/src/mainwindow.c b/src/mainwindow.c index 7704a14..322f2c4 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -129,7 +129,7 @@ static void show_error(struct presentation *p, const char *message) } -static void update_toolbar(struct presentation *p) +void update_toolbar(struct presentation *p) { GtkWidget *d; int cur_slide_number; diff --git a/src/mainwindow.h b/src/mainwindow.h index ae8209a..b406492 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -34,6 +34,7 @@ extern int open_mainwindow(struct presentation *p); extern void change_edit_slide(struct presentation *p, struct slide *np); extern void redraw_editor(struct presentation *p); extern void update_titlebar(struct presentation *p); +extern void update_toolbar(struct presentation *p); #endif /* MAINWINDOW_H */ diff --git a/src/presentation.c b/src/presentation.c index 426783f..13894fa 100644 --- a/src/presentation.c +++ b/src/presentation.c @@ -96,12 +96,17 @@ int insert_slide(struct presentation *p, struct slide *new, int pos) } p->slides = try; p->completely_empty = 0; - p->num_slides++; - for ( i=p->num_slides-1; i>=pos; i-- ) { - p->slides[i] = p->slides[i-1]; + if ( p->num_slides > 0 ) { + int j = pos; + if ( j == 0 ) j = 1; + for ( i=p->num_slides; i>=j; i-- ) { + p->slides[i] = p->slides[i-1]; + } } + p->slides[pos] = new; + p->num_slides++; new->parent = p; diff --git a/src/render.c b/src/render.c index 594bed0..d0a3696 100644 --- a/src/render.c +++ b/src/render.c @@ -309,6 +309,15 @@ static int render_sc(cairo_t *cr, struct frame *fr, ImageStore *is, return 1; } + if ( fr->trouble ) { + cairo_new_path(cr); + cairo_rectangle(cr, 0.0, 0.0, fr->w, fr->h); + cairo_set_source_rgb(cr, 1.0, 0.0, 0.0); + cairo_set_line_width(cr, 2.0); + cairo_stroke(cr); + printf("SC: '%s'\n", fr->sc); + } + /* Actually render the lines */ cairo_translate(cr, fr->lop.pad_l, fr->lop.pad_t); render_lines(fr, cr, is, isz); diff --git a/src/slide_sorter.c b/src/slide_sorter.c index 20823ab..b76721b 100644 --- a/src/slide_sorter.c +++ b/src/slide_sorter.c @@ -32,6 +32,8 @@ #include "presentation.h" #include "render.h" +#include "mainwindow.h" +#include "slideshow.h" struct slide_sorter @@ -47,11 +49,15 @@ struct slide_sorter int th; int bw; + int dragging_cur_edit_slide; + int dragging_cur_proj_slide; + int selection; struct slide *selected_slide; int drop_here; int dragging; + int dragging_in; int drag_preview_pending; int have_drag_data; int drag_highlight; @@ -114,9 +120,16 @@ static gboolean draw_sig(GtkWidget *da, cairo_t *cr, struct slide_sorter *n) cairo_rectangle(cr, 0.0, 0.0, n->tw, n->th); cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); cairo_fill_preserve(cr); - if ( s->rendered_thumb != NULL ) { + if ( (s != NULL) && (s->rendered_thumb != NULL) ) { cairo_set_source_surface(cr, s->rendered_thumb, 0.0, 0.0); + } else { + printf("Slide %i: %p", i, s); + if ( s != NULL ) { + printf(" %p\n", s->rendered_thumb); + } else { + printf("\n"); + } } cairo_fill(cr); @@ -125,7 +138,7 @@ static gboolean draw_sig(GtkWidget *da, cairo_t *cr, struct slide_sorter *n) cairo_set_line_width(cr, 1.0); cairo_stroke(cr); - if ( n->dragging && (i == n->drop_here) ) { + if ( n->dragging_in && (i == n->drop_here) ) { cairo_rectangle(cr, -1.5*n->bw, 0.0, n->bw, n->th); cairo_set_source_rgb(cr, 0.0, 0.0, 0.0); cairo_fill(cr); @@ -195,12 +208,27 @@ static gboolean motion_sig(GtkWidget *da, GdkEventMotion *event, targets[0].flags = 0; targets[0].info = 1; + /* If we are dragging the current editor or projector slide, + * we'd better remember to update when we're finished. */ + if ( n->p->cur_edit_slide == n->selected_slide ) { + n->dragging_cur_edit_slide = 1; + } else { + n->dragging_cur_edit_slide = 0; + } + + if ( n->p->cur_proj_slide == n->selected_slide ) { + n->dragging_cur_proj_slide = 1; + } else { + n->dragging_cur_proj_slide = 0; + } + list = gtk_target_list_new(targets, 1); gtk_drag_begin(da, list, GDK_ACTION_COPY | GDK_ACTION_MOVE, 1, (GdkEvent *)event); gtk_target_list_unref(list); n->dragging = 1; + n->dragging_in = 0; } @@ -267,6 +295,9 @@ static gboolean dnd_motion(GtkWidget *widget, GdkDragContext *drag_context, } n->dragging = 1; /* Because this might be the first signal */ + n->dragging_in = 1; + n->dragging_cur_edit_slide = 0; + n->dragging_cur_proj_slide = 0; redraw_slidesorter(n); @@ -294,6 +325,18 @@ static gboolean dnd_drop(GtkWidget *widget, GdkDragContext *drag_context, } +/* Normally, we don't need to explicitly render proj because the editor always + * gets there first. When re-arranging slides, this might not happen */ +static void fixup_proj(struct presentation *p, struct slide *s) +{ + if ( s->rendered_proj != NULL ) return; + + s->rendered_proj = render_slide(s, s->parent->proj_slide_width, + p->slide_width, p->slide_height, + p->is, ISZ_SLIDESHOW); +} + + static void dnd_receive(GtkWidget *widget, GdkDragContext *drag_context, gint x, gint y, GtkSelectionData *seldata, guint info, guint time, struct slide_sorter *n) @@ -310,7 +353,7 @@ static void dnd_receive(GtkWidget *widget, GdkDragContext *drag_context, } else { const char *sc; - struct slide *s; + struct slide *s = NULL; sc = (const char *)gtk_selection_data_get_data(seldata); @@ -323,8 +366,8 @@ static void dnd_receive(GtkWidget *widget, GdkDragContext *drag_context, if ( s != NULL ) { - /* FIXME: sc_unpack_with_notes() */ - s->top = sc_unpack(sc, n->p->ss); + /* FIXME: sc_unpack_with_notes() */ + s->top = sc_unpack(sc, n->p->ss); s->rendered_thumb = render_slide(s, n->p->thumb_slide_width, @@ -335,6 +378,19 @@ static void dnd_receive(GtkWidget *widget, GdkDragContext *drag_context, /* FIXME: Transfer the notes as well */ + if ( n->dragging_cur_edit_slide ) { + change_edit_slide(n->p, s); + } else { + /* Slide order has changed, so slide change + * buttons might need to be greyed out */ + update_toolbar(n->p); + } + + if ( n->dragging_cur_proj_slide ) { + fixup_proj(n->p, s); + change_proj_slide(n->p, s); + } + redraw_slidesorter(n); } else { @@ -373,6 +429,7 @@ static void dnd_leave(GtkWidget *widget, GdkDragContext *drag_context, guint time, struct slide_sorter *n) { n->have_drag_data = 0; + n->dragging_in = 0; } @@ -380,6 +437,7 @@ static void dnd_end(GtkWidget *widget, GdkDragContext *drag_context, struct slide_sorter *n) { n->dragging = 0; + n->dragging_in = 0; n->have_drag_data = 0; n->drag_preview_pending = 0; } @@ -388,13 +446,64 @@ static void dnd_end(GtkWidget *widget, GdkDragContext *drag_context, static void dnd_delete(GtkWidget *widget, GdkDragContext *drag_context, struct slide_sorter *n) { - if ( slide_number(n->p, n->selected_slide) < n->drop_here ) { - n->drop_here--; + int same; + int sn; + + sn = slide_number(n->p, n->selected_slide); + + same = (gdk_drag_context_get_source_window(drag_context) + == gdk_drag_context_get_dest_window(drag_context)); + + if ( sn < n->drop_here ) n->drop_here--; + + if ( n->p->cur_edit_slide == n->selected_slide ) { + + if ( same ) { + + /* Do nothing - will switch in dnd_receive() */ + + } else { + + /* Switch to previous slide */ + int ct; + + if ( sn == 0 ) { + ct = 1; + } else { + ct = sn - 1; + } + + change_edit_slide(n->p, n->p->slides[ct]); + update_toolbar(n->p); + + } + } - delete_slide(n->p, n->selected_slide); + if ( n->p->cur_proj_slide == n->selected_slide ) { + + if ( same ) { + + /* Do nothing - will switch in dnd_receive() */ - /* FIXME:What if this slide is cur_edit_slide or cur_proj_slide? */ + } else { + + /* Switch to previous slide */ + int ct; + + if ( sn == 0 ) { + ct = 1; + } else { + ct = sn - 1; + } + + change_proj_slide(n->p, n->p->slides[ct]); + + } + + } + + delete_slide(n->p, n->selected_slide); } @@ -419,6 +528,7 @@ void open_slidesorter(struct presentation *p) n->drag_preview_pending = 0; n->have_drag_data = 0; n->dragging = 0; + n->dragging_in = 0; n->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size(GTK_WINDOW(n->window), 500, 500); @@ -1033,6 +1033,7 @@ static void knuth_suboptimal_fit(struct wrap_line *boxes, double line_length, if ( boxes->boxes[j].width > line_length ) { fprintf(stderr, "ERROR: Box %i too long (%i %f)\n", j, boxes->boxes[j].width, line_length); + fr->trouble = 1; reject = 1; } } @@ -1284,6 +1285,7 @@ int wrap_contents(struct frame *fr, PangoContext *pc, fr->n_lines = 0; fr->max_lines = 32; fr->lines = NULL; + fr->trouble = 0; alloc_lines(fr); /* Split text into paragraphs */ |