diff options
author | Thomas White <taw@bitwiz.org.uk> | 2016-05-02 23:03:43 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2016-05-02 23:03:43 +0200 |
commit | ad4109c48275b9e9e011a8b54125e6c93c1de133 (patch) | |
tree | 60775f317a2a166f4405ced4191c264595729912 | |
parent | adb1c0282b9daa7439cb0fa3d9c37864b462e81f (diff) |
Remove old stuff from SlideWindow, and fix action group stuff
-rw-r--r-- | Makefile.am | 4 | ||||
-rw-r--r-- | src/narrative_window.c | 2 | ||||
-rw-r--r-- | src/notes.c | 164 | ||||
-rw-r--r-- | src/notes.h | 38 | ||||
-rw-r--r-- | src/presentation.c | 1 | ||||
-rw-r--r-- | src/slide_window.c | 317 | ||||
-rw-r--r-- | src/slide_window.h | 5 |
7 files changed, 14 insertions, 517 deletions
diff --git a/Makefile.am b/Makefile.am index 4ad7616..c1268a8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -14,14 +14,14 @@ src_colloquium_SOURCES = src/colloquium.c src/render.c \ src/presentation.c \ src/frame.c src/sc_parse.c \ src/slideshow.c src/sc_interp.c \ - src/imagestore.c src/notes.c src/pr_clock.c \ + src/imagestore.c src/pr_clock.c \ src/inhibit_screensaver.c \ src/sc_editor.c src/narrative_window.c \ src/slide_window.c src/testcard.c EXTRA_DIST += src/presentation.h src/render.h \ src/slideshow.h src/sc_parse.h src/sc_interp.h \ - src/imagestore.h src/notes.h src/pr_clock.h \ + src/imagestore.h src/pr_clock.h \ src/inhibit_screensaver.h \ src/sc_editor.h src/slide_window.h src/narrative_window.h diff --git a/src/narrative_window.c b/src/narrative_window.c index 3be8a1d..6d6baf3 100644 --- a/src/narrative_window.c +++ b/src/narrative_window.c @@ -451,7 +451,7 @@ static int click_thumbnail(double x, double y, void *bvp, void *vp) struct presentation *p = vp; SCBlock *scblocks = bvp; - slide_window_open(p, scblocks); + slide_window_open(p, scblocks, p->narrative_window->app); return 0; } diff --git a/src/notes.c b/src/notes.c deleted file mode 100644 index c19cf58..0000000 --- a/src/notes.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - * notes.c - * - * Copyright © 2013 Thomas White <taw@bitwiz.org.uk> - * - * This file is part of Colloquium. - * - * Colloquium is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <stdlib.h> -#include <string.h> -#include <assert.h> -#include <gtk/gtk.h> - -#include "presentation.h" -#include "notes.h" - -struct notes -{ - GtkWidget *window; - GtkWidget *v; - - SCBlock *bl; - SlideWindow *sw; -}; - - -static SCBlock *find_notes_block(SCBlock *s) -{ - SCBlock *bl = s; - while ( bl != NULL ) { - - const char *name = sc_block_name(bl); - - if ( (name != NULL) && (strcmp(name, "notes") == 0) ) { - if ( sc_block_child(bl) == NULL ) { - sc_block_append_inside(s, NULL, NULL, - strdup("")); - } - return bl; - } - - bl = sc_block_next(bl); - - } - - bl = sc_block_append_end(s, "notes", NULL, NULL); - sc_block_append_inside(bl, NULL, NULL, strdup("")); - return bl; -} - - -static void update_notes(struct notes *notes) -{ - GtkTextBuffer *tb; - const char *ntext; - SCBlock *ch; - - if ( notes == NULL ) return; - - ch = sc_block_child(notes->bl); - if ( ch != NULL ) { - ntext = sc_block_contents(ch); - } else { - ntext = "NOTES ERROR"; - } - - tb = gtk_text_view_get_buffer(GTK_TEXT_VIEW(notes->v)); - gtk_text_buffer_set_text(tb, ntext, -1); -} - - -void grab_current_notes(struct notes *n) -{ - gchar *text; - GtkTextBuffer *tb; - GtkTextIter i1, i2; - SCBlock *ch; - - if ( n == NULL ) return; - - tb = gtk_text_view_get_buffer(GTK_TEXT_VIEW(n->v)); - gtk_text_buffer_get_start_iter(tb, &i1); - gtk_text_buffer_get_end_iter(tb, &i2); - text = gtk_text_buffer_get_text(tb, &i1, &i2, TRUE); - - ch = sc_block_child(n->bl); - if ( ch != NULL ) { - sc_block_set_contents(ch, text); - } else { - fprintf(stderr, "NOTES ERROR\n"); - } -} - - -void notes_set_slide(struct notes *notes, SCBlock *np) -{ - if ( notes == NULL ) return; - grab_current_notes(notes); - notes->bl = find_notes_block(np); - update_notes(notes); -} - - -static gint close_notes_sig(GtkWidget *w, struct notes *notes) -{ - grab_current_notes(notes); - slidewindow_notes_closed(notes->sw); - return FALSE; -} - - -struct notes *open_notes(SlideWindow *sw, SCBlock *slide) -{ - struct notes *n; - GtkWidget *sc; - PangoFontDescription *desc; - - n = malloc(sizeof(struct notes)); - if ( n == NULL ) return NULL; - n->sw = sw; - - n->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_default_size(GTK_WINDOW(n->window), 800, 256); - sc = gtk_scrolled_window_new(NULL, NULL); - gtk_container_add(GTK_CONTAINER(n->window), sc); - - n->v = gtk_text_view_new(); - desc = pango_font_description_from_string("Sans 24"); - gtk_widget_override_font(n->v, desc); - pango_font_description_free(desc); - gtk_text_view_set_left_margin(GTK_TEXT_VIEW(n->v), 30); - gtk_text_view_set_right_margin(GTK_TEXT_VIEW(n->v), 30); - gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(n->v), GTK_WRAP_WORD_CHAR); - gtk_container_add(GTK_CONTAINER(sc), n->v); - - g_signal_connect(G_OBJECT(n->v), "destroy", - G_CALLBACK(close_notes_sig), n); - - gtk_window_set_title(GTK_WINDOW(n->window), "Colloquium notes"); - gtk_widget_show_all(n->window); - - update_notes(n); - return n; -} - diff --git a/src/notes.h b/src/notes.h deleted file mode 100644 index 1939d3b..0000000 --- a/src/notes.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * notes.h - * - * Copyright © 2013-2016 Thomas White <taw@bitwiz.org.uk> - * - * This file is part of Colloquium. - * - * Colloquium is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - */ - -#ifndef NOTES_H -#define NOTES_H - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -struct notes; - -extern struct notes *open_notes(SlideWindow *sw, SCBlock *slide); - -extern void notes_set_slide(struct notes *n, SCBlock *np); - -extern void grab_current_notes(struct notes *n); - -#endif /* NOTES_H */ diff --git a/src/presentation.c b/src/presentation.c index 5c2f03e..90a1726 100644 --- a/src/presentation.c +++ b/src/presentation.c @@ -34,7 +34,6 @@ #include "slide_window.h" #include "frame.h" #include "imagestore.h" -#include "notes.h" #include "inhibit_screensaver.h" #include "render.h" #include "sc_interp.h" diff --git a/src/slide_window.c b/src/slide_window.c index c55fd8d..1d49dfa 100644 --- a/src/slide_window.c +++ b/src/slide_window.c @@ -1,7 +1,7 @@ /* * slide_window.c * - * Copyright © 2013-2015 Thomas White <taw@bitwiz.org.uk> + * Copyright © 2013-2016 Thomas White <taw@bitwiz.org.uk> * * This file is part of Colloquium. * @@ -38,7 +38,6 @@ #include "render.h" #include "frame.h" #include "slideshow.h" -#include "notes.h" #include "pr_clock.h" #include "sc_parse.h" #include "sc_interp.h" @@ -65,34 +64,9 @@ struct _slidewindow int n_style_menu; SlideShow *show; - struct notes *notes; }; -static void update_toolbar(SlideWindow *sw) -{ - int cur_slide_number; - - cur_slide_number = slide_number(sw->p, sw->scblocks); - if ( cur_slide_number == 0 ) { - gtk_widget_set_sensitive(GTK_WIDGET(sw->bfirst), FALSE); - gtk_widget_set_sensitive(GTK_WIDGET(sw->bprev), FALSE); - } else { - gtk_widget_set_sensitive(GTK_WIDGET(sw->bfirst), TRUE); - gtk_widget_set_sensitive(GTK_WIDGET(sw->bprev), TRUE); - } - - if ( cur_slide_number == num_slides(sw->p)-1 ) { - gtk_widget_set_sensitive(GTK_WIDGET(sw->bnext), FALSE); - gtk_widget_set_sensitive(GTK_WIDGET(sw->blast), FALSE); - } else { - gtk_widget_set_sensitive(GTK_WIDGET(sw->bnext), TRUE); - gtk_widget_set_sensitive(GTK_WIDGET(sw->blast), TRUE); - } - -} - - /* Inelegance to make furniture selection menus work */ struct menu_pl { @@ -173,62 +147,6 @@ static void UNUSED update_style_menus(SlideWindow *sw) } -static gint saveas_response_sig(GtkWidget *d, gint response, - SlideWindow *sw) -{ - if ( response == GTK_RESPONSE_ACCEPT ) { - - char *filename; - - filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(d)); - - if ( save_presentation(sw->p, filename) ) { - //show_error(sw, "Failed to save presentation"); - } - - g_free(filename); - - } - - gtk_widget_destroy(d); - - return 0; -} - - -static void saveas_sig(GSimpleAction *action, GVariant *parameter, gpointer vp) -{ - GtkWidget *d; - SlideWindow *sw = vp; - - d = gtk_file_chooser_dialog_new("Save Presentation", - GTK_WINDOW(sw->window), - GTK_FILE_CHOOSER_ACTION_SAVE, - "_Cancel", GTK_RESPONSE_CANCEL, - "_Save", GTK_RESPONSE_ACCEPT, - NULL); - gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(d), - TRUE); - - g_signal_connect(G_OBJECT(d), "response", - G_CALLBACK(saveas_response_sig), sw); - - gtk_widget_show_all(d); -} - - -static void save_sig(GSimpleAction *action, GVariant *parameter, gpointer vp) -{ - SlideWindow *sw = vp; - - if ( sw->p->filename == NULL ) { - return saveas_sig(NULL, NULL, sw); - } - - save_presentation(sw->p, sw->p->filename); -} - - static void delete_frame_sig(GSimpleAction *action, GVariant *parameter, gpointer vp) { @@ -237,73 +155,11 @@ static void delete_frame_sig(GSimpleAction *action, GVariant *parameter, } -static void add_slide_sig(GSimpleAction *action, GVariant *parameter, gpointer vp) -{ - SlideWindow *sw = vp; - SCBlock *new; - new = sc_block_insert_after(sw->scblocks, "slide", NULL, NULL); - change_edit_slide(sw, new); -} - - -static gint export_pdf_response_sig(GtkWidget *d, gint response, - SlideWindow *sw) -{ - if ( response == GTK_RESPONSE_ACCEPT ) { - - char *filename; - - filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(d)); - - if ( export_pdf(sw->p, filename) ) { - //show_error(sw, "Failed to export as PDF"); - } - - g_free(filename); - - } - - gtk_widget_destroy(d); - - return 0; -} - - -static void exportpdf_sig(GSimpleAction *action, GVariant *parameter, - gpointer vp) -{ - SlideWindow *sw = vp; - GtkWidget *d; - - d = gtk_file_chooser_dialog_new("Export PDF", - GTK_WINDOW(sw->window), - GTK_FILE_CHOOSER_ACTION_SAVE, - "_Cancel", GTK_RESPONSE_CANCEL, - "_Export", GTK_RESPONSE_ACCEPT, - NULL); - gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(d), - TRUE); - - g_signal_connect(G_OBJECT(d), "response", - G_CALLBACK(export_pdf_response_sig), sw); - - gtk_widget_show_all(d); -} - - -void slidewindow_notes_closed(SlideWindow *sw) -{ - sw->notes = NULL; -} - - /* Change the editor's slide to "np" */ void change_edit_slide(SlideWindow *sw, SCBlock *np) { SCBlock *ch; - update_toolbar(sw); - sc_editor_set_slidenum(sw->sceditor, slide_number(sw->p, np)); ch = sc_block_child(np); @@ -313,8 +169,6 @@ void change_edit_slide(SlideWindow *sw, SCBlock *np) sc_editor_set_scblock(sw->sceditor, ch); sw->scblocks = np; - if ( sw->notes != NULL ) notes_set_slide(sw->notes, np); - if ( slideshow_linked(sw->show) ) { change_proj_slide(sw->show, np); } /* else leave the slideshow alone */ @@ -383,35 +237,8 @@ static void last_slide_sig(GSimpleAction *action, GVariant *parameter, } -static void open_notes_sig(GSimpleAction *action, GVariant *parameter, - gpointer vp) -{ - SlideWindow *sw = vp; - sw->notes = open_notes(sw, sw->scblocks); -} - - -static void open_clock_sig(GSimpleAction *action, GVariant *parameter, - gpointer vp) -{ - SlideWindow *sw = vp; - open_clock(sw->p); -} - - -static void slidewindow_set_background(SlideWindow *sw) -{ - if ( (sw->show != NULL) && !slideshow_linked(sw->show) ) { - sc_editor_set_background(sw->sceditor, 1.0, 0.3, 0.2); - } else { - sc_editor_set_background(sw->sceditor, 0.9, 0.9, 0.9); - } -} - - void slidewindow_redraw(SlideWindow *sw) { - slidewindow_set_background(sw); sc_editor_redraw(sw->sceditor); } @@ -441,57 +268,6 @@ static gboolean close_sig(GtkWidget *w, SlideWindow *sw) } -static void ss_end_show(SlideShow *ss, void *vp) -{ - SlideWindow *sw = vp; - sw->show = NULL; -} - - -static void ss_next_slide(SlideShow *ss, void *vp) -{ - SlideWindow *sw = vp; - change_slide_forwards(sw); -} - - -static void ss_prev_slide(SlideShow *ss, void *vp) -{ - SlideWindow *sw = vp; - change_slide_backwards(sw); -} - - -static void ss_changed_link(SlideShow *ss, void *vp) -{ - SlideWindow *sw = vp; - slidewindow_redraw(sw); -} - - -static SCBlock *ss_cur_slide(SlideShow *ss, void *vp) -{ - SlideWindow *sw = vp; - return sw->scblocks; -} - - -static void start_slideshow_sig(GSimpleAction *action, GVariant *parameter, - gpointer vp) -{ - SlideWindow *sw = vp; - struct sscontrolfuncs ssc; - - ssc.next_slide = ss_next_slide; - ssc.prev_slide = ss_prev_slide; - ssc.current_slide = ss_cur_slide; - ssc.changed_link = ss_changed_link; - ssc.end_show = ss_end_show; - - sw->show = try_start_slideshow(sw->p, ssc, sw); -} - - static gboolean key_press_sig(GtkWidget *da, GdkEventKey *event, SlideWindow *sw) { @@ -505,11 +281,6 @@ static gboolean key_press_sig(GtkWidget *da, GdkEventKey *event, change_slide_forwards(sw); break; - case GDK_KEY_B : - case GDK_KEY_b : - if ( sw->show != NULL ) { - toggle_slideshow_link(sw->show); - } } return FALSE; @@ -518,14 +289,7 @@ static gboolean key_press_sig(GtkWidget *da, GdkEventKey *event, GActionEntry sw_entries[] = { - { "save", save_sig, NULL, NULL, NULL }, - { "saveas", saveas_sig, NULL, NULL, NULL }, - { "exportpdf", exportpdf_sig, NULL, NULL, NULL }, { "deleteframe", delete_frame_sig, NULL, NULL, NULL }, - { "slide", add_slide_sig, NULL, NULL, NULL }, - { "startslideshow", start_slideshow_sig, NULL, NULL, NULL }, - { "notes", open_notes_sig, NULL, NULL, NULL }, - { "clock", open_clock_sig, NULL, NULL, NULL }, { "first", first_slide_sig, NULL, NULL, NULL }, { "prev", prev_slide_sig, NULL, NULL, NULL }, { "next", next_slide_sig, NULL, NULL, NULL }, @@ -533,28 +297,26 @@ GActionEntry sw_entries[] = { }; -SlideWindow *slide_window_open(struct presentation *p, SCBlock *scblocks) +SlideWindow *slide_window_open(struct presentation *p, SCBlock *scblocks, + GApplication *app) { GtkWidget *window; - GtkWidget *vbox; GtkWidget *scroll; - GtkWidget *toolbar; - GtkToolItem *button; SlideWindow *sw; SCBlock *stylesheets[2]; - GtkWidget *image; SCBlock *ch; sw = calloc(1, sizeof(SlideWindow)); if ( sw == NULL ) return NULL; - window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + window = gtk_application_window_new(GTK_APPLICATION(app)); gtk_window_set_role(GTK_WINDOW(window), "slide"); - g_action_map_add_action_entries(G_ACTION_MAP(window), sw_entries, - G_N_ELEMENTS(sw_entries), sw); sw->window = window; sw->p = p; + g_action_map_add_action_entries(G_ACTION_MAP(window), sw_entries, + G_N_ELEMENTS(sw_entries), sw); + sw->show = NULL; update_titlebar(p); @@ -562,63 +324,6 @@ SlideWindow *slide_window_open(struct presentation *p, SCBlock *scblocks) g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(close_sig), sw); - vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); - gtk_container_add(GTK_CONTAINER(window), vbox); - - toolbar = gtk_toolbar_new(); - gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS); - //gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(toolbar), FALSE, FALSE, 0); - - /* Fullscreen */ - image = gtk_image_new_from_icon_name("view-fullscreen", - GTK_ICON_SIZE_LARGE_TOOLBAR); - button = gtk_tool_button_new(image, "Start slideshow"); - gtk_actionable_set_action_name(GTK_ACTIONABLE(button), - "win.startslideshow"); - gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); - - button = gtk_separator_tool_item_new(); - gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); - - /* Add slide */ - image = gtk_image_new_from_icon_name("add", - GTK_ICON_SIZE_LARGE_TOOLBAR); - button = gtk_tool_button_new(image, "Add slide"); - gtk_actionable_set_action_name(GTK_ACTIONABLE(button), - "win.slide"); - gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); - - button = gtk_separator_tool_item_new(); - gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(button)); - - /* Change slide. FIXME: LTR vs RTL */ - image = gtk_image_new_from_icon_name("gtk-goto-first-ltr", - GTK_ICON_SIZE_LARGE_TOOLBAR); - sw->bfirst = gtk_tool_button_new(image, "First slide"); - gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(sw->bfirst)); - gtk_actionable_set_action_name(GTK_ACTIONABLE(sw->bfirst), - "win.first"); - - image = gtk_image_new_from_icon_name("gtk-go-back-ltr", - GTK_ICON_SIZE_LARGE_TOOLBAR); - sw->bprev = gtk_tool_button_new(image, "Previous slide"); - gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(sw->bprev)); - gtk_actionable_set_action_name(GTK_ACTIONABLE(sw->bprev), - "win.prev"); - - image = gtk_image_new_from_icon_name("gtk-go-forward-ltr", - GTK_ICON_SIZE_LARGE_TOOLBAR); - sw->bnext = gtk_tool_button_new(image, "Next slide"); - gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(sw->bnext)); - gtk_actionable_set_action_name(GTK_ACTIONABLE(sw->bnext), - "win.next"); - - image = gtk_image_new_from_icon_name("gtk-goto-last-ltr", - GTK_ICON_SIZE_LARGE_TOOLBAR); - sw->blast = gtk_tool_button_new(image, "Last slide"); - gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(sw->blast)); - gtk_actionable_set_action_name(GTK_ACTIONABLE(sw->blast), - "win.last"); stylesheets[0] = p->stylesheet; stylesheets[1] = NULL; @@ -640,22 +345,16 @@ SlideWindow *slide_window_open(struct presentation *p, SCBlock *scblocks) G_CALLBACK(key_press_sig), sw); /* Size of SCEditor surface in pixels */ - /* FIXME: Somewhat arbitrary. Should come from slide itself */ sc_editor_set_size(sw->sceditor, 1024, 768); sc_editor_set_logical_size(sw->sceditor, 1024.0, 768.0); - gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(scroll), TRUE, TRUE, 0); + gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(scroll)); /* Default size */ gtk_window_set_default_size(GTK_WINDOW(sw->window), 1024, 768); gtk_window_set_resizable(GTK_WINDOW(sw->window), TRUE); - /* Initial background colour */ - slidewindow_set_background(sw); - - update_toolbar(sw); - gtk_widget_show_all(window); return sw; diff --git a/src/slide_window.h b/src/slide_window.h index ddc29af..0d908de 100644 --- a/src/slide_window.h +++ b/src/slide_window.h @@ -1,7 +1,7 @@ /* * slide_window.h * - * Copyright © 2013-2015 Thomas White <taw@bitwiz.org.uk> + * Copyright © 2013-2016 Thomas White <taw@bitwiz.org.uk> * * This file is part of Colloquium. * @@ -29,7 +29,8 @@ typedef struct _slidewindow SlideWindow; -extern SlideWindow *slide_window_open(struct presentation *p, SCBlock *scblocks); +extern SlideWindow *slide_window_open(struct presentation *p, SCBlock *scblocks, + GApplication *app); extern void change_edit_slide(SlideWindow *sw, SCBlock *np); extern void update_titlebar(struct presentation *p); |