From c7a86a47001baca65c87d0f060f9a57af8537cf2 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sun, 11 Mar 2018 23:17:06 +0100 Subject: Rename some functions to make them unique Makes things less confusing. Ulterior motive: makes Meson unity builds work. --- meson.build | 1 + src/colloquium.c | 16 +--------------- src/debugger.c | 4 ++-- src/narrative_window.c | 22 ++++++++++----------- src/pr_clock.c | 4 ++-- src/presentation.c | 9 +-------- src/print.c | 16 ++++++++-------- src/render.c | 9 +-------- src/sc_editor.c | 16 +--------------- src/slide_window.c | 10 +++++----- src/slideshow.c | 4 ++-- src/testcard.c | 14 +++++++------- src/utils.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/utils.h | 35 +++++++++++++++++++++++++++++++++ tests/meson.build | 2 +- 15 files changed, 130 insertions(+), 84 deletions(-) create mode 100644 src/utils.c create mode 100644 src/utils.h diff --git a/meson.build b/meson.build index 3aff3f1..bd9a961 100644 --- a/meson.build +++ b/meson.build @@ -32,6 +32,7 @@ executable('colloquium', 'src/imagestore.c', 'src/print.c', 'src/sc_parse.c', + 'src/utils.c', ], dependencies : [gtkdep, mdep], install : true) diff --git a/src/colloquium.c b/src/colloquium.c index 84dc73d..830c2f7 100644 --- a/src/colloquium.c +++ b/src/colloquium.c @@ -36,6 +36,7 @@ #include "colloquium.h" #include "presentation.h" #include "narrative_window.h" +#include "utils.h" struct _colloquium @@ -236,21 +237,6 @@ static void create_config(const char *filename) } -static void chomp(char *s) -{ - size_t i; - - if ( !s ) return; - - for ( i=0; idrawingarea, 100, 8000); g_signal_connect(G_OBJECT(dbgw->drawingarea), "draw", - G_CALLBACK(draw_sig), dbgw); + G_CALLBACK(dbg_draw_sig), dbgw); g_signal_connect(G_OBJECT(dbgw->window), "delete-event", G_CALLBACK(close_sig), dbgw); diff --git a/src/narrative_window.c b/src/narrative_window.c index 3bd066f..e5faffa 100644 --- a/src/narrative_window.c +++ b/src/narrative_window.c @@ -489,8 +489,8 @@ static void exportpdf_sig(GSimpleAction *action, GVariant *parameter, -static gboolean button_press_sig(GtkWidget *da, GdkEventButton *event, - NarrativeWindow *nw) +static gboolean nw_button_press_sig(GtkWidget *da, GdkEventButton *event, + NarrativeWindow *nw) { return 0; } @@ -515,15 +515,15 @@ static void scroll_down(NarrativeWindow *nw) } -static gboolean destroy_sig(GtkWidget *da, NarrativeWindow *nw) +static gboolean nw_destroy_sig(GtkWidget *da, NarrativeWindow *nw) { g_application_release(nw->app); return FALSE; } -static gboolean key_press_sig(GtkWidget *da, GdkEventKey *event, - NarrativeWindow *nw) +static gboolean nw_key_press_sig(GtkWidget *da, GdkEventKey *event, + NarrativeWindow *nw) { switch ( event->keyval ) { @@ -597,7 +597,7 @@ static void start_slideshow_here_sig(GSimpleAction *action, GVariant *parameter, if ( nw->show == NULL ) return; g_signal_connect(G_OBJECT(nw->show), "key-press-event", - G_CALLBACK(key_press_sig), nw); + G_CALLBACK(nw_key_press_sig), nw); g_signal_connect(G_OBJECT(nw->show), "destroy", G_CALLBACK(ss_destroy_sig), nw); sc_slideshow_set_slide(nw->show, bvp); @@ -618,7 +618,7 @@ static void start_slideshow_noslides_sig(GSimpleAction *action, GVariant *parame if ( nw->show == NULL ) return; g_signal_connect(G_OBJECT(nw->show), "key-press-event", - G_CALLBACK(key_press_sig), nw); + G_CALLBACK(nw_key_press_sig), nw); g_signal_connect(G_OBJECT(nw->show), "destroy", G_CALLBACK(ss_destroy_sig), nw); sc_slideshow_set_slide(nw->show, first_slide(nw->p)); @@ -639,7 +639,7 @@ static void start_slideshow_sig(GSimpleAction *action, GVariant *parameter, if ( nw->show == NULL ) return; g_signal_connect(G_OBJECT(nw->show), "key-press-event", - G_CALLBACK(key_press_sig), nw); + G_CALLBACK(nw_key_press_sig), nw); g_signal_connect(G_OBJECT(nw->show), "destroy", G_CALLBACK(ss_destroy_sig), nw); sc_slideshow_set_slide(nw->show, first_slide(nw->p)); @@ -890,13 +890,13 @@ NarrativeWindow *narrative_window_new(struct presentation *p, GApplication *papp sc_editor_set_top_frame_editable(nw->sceditor, 1); g_signal_connect(G_OBJECT(nw->sceditor), "button-press-event", - G_CALLBACK(button_press_sig), nw); + G_CALLBACK(nw_button_press_sig), nw); g_signal_connect(G_OBJECT(nw->sceditor), "changed", G_CALLBACK(changed_sig), nw); g_signal_connect(G_OBJECT(nw->sceditor), "key-press-event", - G_CALLBACK(key_press_sig), nw); + G_CALLBACK(nw_key_press_sig), nw); g_signal_connect(G_OBJECT(nw->window), "destroy", - G_CALLBACK(destroy_sig), nw); + G_CALLBACK(nw_destroy_sig), nw); gtk_window_set_default_size(GTK_WINDOW(nw->window), 768, 768); gtk_box_pack_start(GTK_BOX(vbox), scroll, TRUE, TRUE, 0); diff --git a/src/pr_clock.c b/src/pr_clock.c index 21ed4c7..82b9af5 100644 --- a/src/pr_clock.c +++ b/src/pr_clock.c @@ -222,7 +222,7 @@ static gint close_clock_sig(GtkWidget *w, PRClock *n) } -static gboolean draw_sig(GtkWidget *da, cairo_t *cr, struct pr_clock *n) +static gboolean clock_draw_sig(GtkWidget *da, cairo_t *cr, struct pr_clock *n) { int width, height; double s; @@ -387,7 +387,7 @@ PRClock *pr_clock_new() n->da = gtk_drawing_area_new(); gtk_box_pack_start(GTK_BOX(vbox), n->da, TRUE, TRUE, 0); - g_signal_connect(G_OBJECT(n->da), "draw", G_CALLBACK(draw_sig), n); + g_signal_connect(G_OBJECT(n->da), "draw", G_CALLBACK(clock_draw_sig), n); g_signal_connect(G_OBJECT(n->window), "destroy", G_CALLBACK(close_clock_sig), n); /* FIXME: Uniqueness */ diff --git a/src/presentation.c b/src/presentation.c index 0169f19..3ec00e3 100644 --- a/src/presentation.c +++ b/src/presentation.c @@ -36,6 +36,7 @@ #include "imagestore.h" #include "render.h" #include "sc_interp.h" +#include "utils.h" void free_presentation(struct presentation *p) @@ -203,14 +204,6 @@ static char *fgets_long(FILE *fh, size_t *lp) } -static int safe_strcmp(const char *a, const char *b) -{ - if ( a == NULL ) return 1; - if ( b == NULL ) return 1; - return strcmp(a, b); -} - - int slide_number(struct presentation *p, SCBlock *sl) { SCBlock *bl = p->scblocks; diff --git a/src/print.c b/src/print.c index 250c9da..18402fc 100644 --- a/src/print.c +++ b/src/print.c @@ -149,8 +149,8 @@ static void print_slide_only(GtkPrintOperation *op, GtkPrintContext *ctx, } -static int create_thumbnail(SCInterpreter *scin, SCBlock *bl, - double *w, double *h, void **bvp, void *vp) +static int print_create_thumbnail(SCInterpreter *scin, SCBlock *bl, + double *w, double *h, void **bvp, void *vp) { struct print_stuff *ps = vp; struct presentation *p = ps->p; @@ -166,7 +166,7 @@ static int create_thumbnail(SCInterpreter *scin, SCBlock *bl, } -static cairo_surface_t *render_thumbnail(int w, int h, void *bvp, void *vp) +static cairo_surface_t *print_render_thumbnail(int w, int h, void *bvp, void *vp) { struct print_stuff *ps = vp; struct presentation *p = ps->p; @@ -186,7 +186,7 @@ static cairo_surface_t *render_thumbnail(int w, int h, void *bvp, void *vp) } -static SCBlock *narrative_stylesheet() +static SCBlock *print_narrative_stylesheet() { return sc_parse("\\stylesheet{" "\\ss[slide]{\\callback[sthumb]}" @@ -205,17 +205,17 @@ static void begin_narrative_print(GtkPrintOperation *op, GtkPrintContext *ctx, cbl = sc_callback_list_new(); ps->slide_number = 1; - sc_callback_list_add_callback(cbl, "sthumb", create_thumbnail, - render_thumbnail, NULL, ps); + sc_callback_list_add_callback(cbl, "sthumb", print_create_thumbnail, + print_render_thumbnail, NULL, ps); ps->is = imagestore_new(ps->storename); if ( ps->p->stylesheet != NULL ) { stylesheets[0] = ps->p->stylesheet; - stylesheets[1] = narrative_stylesheet(); + stylesheets[1] = print_narrative_stylesheet(); stylesheets[2] = NULL; } else { - stylesheets[0] = narrative_stylesheet(); + stylesheets[0] = print_narrative_stylesheet(); stylesheets[1] = NULL; } diff --git a/src/render.c b/src/render.c index 40ab78b..f1ff019 100644 --- a/src/render.c +++ b/src/render.c @@ -41,6 +41,7 @@ #include "frame.h" #include "render.h" #include "imagestore.h" +#include "utils.h" static void do_background(cairo_t *cr, struct frame *fr) @@ -274,14 +275,6 @@ cairo_surface_t *render_sc(SCBlock *scblocks, int w, int h, } -static int safe_strcmp(const char *a, const char *b) -{ - if ( a == NULL ) return 1; - if ( b == NULL ) return 1; - return strcmp(a, b); -} - - int export_pdf(struct presentation *p, const char *filename) { double r; diff --git a/src/sc_editor.c b/src/sc_editor.c index 115e7b6..00c626d 100644 --- a/src/sc_editor.c +++ b/src/sc_editor.c @@ -43,6 +43,7 @@ #include "sc_editor.h" #include "slideshow.h" #include "debugger.h" +#include "utils.h" static void scroll_interface_init(GtkScrollable *iface) @@ -1682,21 +1683,6 @@ static gboolean dnd_drop(GtkWidget *widget, GdkDragContext *drag_context, } -static void chomp(char *s) -{ - size_t i; - - if ( !s ) return; - - for ( i=0; ip->slidewindow = NULL; return FALSE; } -static gboolean key_press_sig(GtkWidget *da, GdkEventKey *event, - SlideWindow *sw) +static gboolean sw_key_press_sig(GtkWidget *da, GdkEventKey *event, + SlideWindow *sw) { switch ( event->keyval ) { @@ -244,7 +244,7 @@ SlideWindow *slide_window_open(struct presentation *p, SCBlock *scblocks, G_N_ELEMENTS(sw_entries), sw); g_signal_connect(G_OBJECT(window), "destroy", - G_CALLBACK(close_sig), sw); + G_CALLBACK(sw_close_sig), sw); stylesheets[0] = p->stylesheet; stylesheets[1] = NULL; @@ -263,7 +263,7 @@ SlideWindow *slide_window_open(struct presentation *p, SCBlock *scblocks, // gtk_container_add(GTK_CONTAINER(scroll), GTK_WIDGET(sw->sceditor)); // gtk_window_set_focus(GTK_WINDOW(window), GTK_WIDGET(sw->sceditor)); g_signal_connect(G_OBJECT(sw->sceditor), "key-press-event", - G_CALLBACK(key_press_sig), sw); + G_CALLBACK(sw_key_press_sig), sw); sc_editor_set_logical_size(sw->sceditor, p->slide_width, p->slide_height); diff --git a/src/slideshow.c b/src/slideshow.c index 76f200d..84f1edb 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -78,7 +78,7 @@ static void slideshow_rerender(SCSlideshow *ss) } -static gint ss_destroy_sig(GtkWidget *widget, SCSlideshow *ss) +static gint ssh_destroy_sig(GtkWidget *widget, SCSlideshow *ss) { if ( ss->blank_cursor != NULL ) { g_object_unref(ss->blank_cursor); @@ -192,7 +192,7 @@ SCSlideshow *sc_slideshow_new(struct presentation *p, GtkApplication *app) GDK_KEY_PRESS_MASK); g_signal_connect(G_OBJECT(ss), "destroy", - G_CALLBACK(ss_destroy_sig), ss); + G_CALLBACK(ssh_destroy_sig), ss); g_signal_connect(G_OBJECT(ss), "realize", G_CALLBACK(ss_realize_sig), ss); g_signal_connect(G_OBJECT(ss), "size-allocate", diff --git a/src/testcard.c b/src/testcard.c index 45fc348..5c723a0 100644 --- a/src/testcard.c +++ b/src/testcard.c @@ -44,7 +44,7 @@ struct testcard struct presentation *p; }; -static gint destroy_sig(GtkWidget *widget, struct testcard *tc) +static gint tc_destroy_sig(GtkWidget *widget, struct testcard *tc) { free(tc); return FALSE; @@ -105,7 +105,7 @@ static void colour_box(cairo_t *cr, double x, double y, } -static gboolean draw_sig(GtkWidget *da, cairo_t *cr, struct testcard *tc) +static gboolean tc_draw_sig(GtkWidget *da, cairo_t *cr, struct testcard *tc) { double xoff, yoff; double width, height; @@ -224,8 +224,8 @@ static void size_sig(GtkWidget *widget, GdkRectangle *rect, struct testcard *ss) -static gboolean key_press_sig(GtkWidget *da, GdkEventKey *event, - struct testcard *tc) +static gboolean tc_key_press_sig(GtkWidget *da, GdkEventKey *event, + struct testcard *tc) { if ( !event->is_modifier ) gtk_widget_destroy(tc->window); return FALSE; @@ -252,13 +252,13 @@ void show_testcard(struct presentation *p) gtk_widget_add_events(GTK_WIDGET(tc->drawingarea), GDK_KEY_PRESS_MASK); g_signal_connect(G_OBJECT(tc->drawingarea), "key-press-event", - G_CALLBACK(key_press_sig), tc); + G_CALLBACK(tc_key_press_sig), tc); g_signal_connect(G_OBJECT(tc->window), "destroy", - G_CALLBACK(destroy_sig), tc); + G_CALLBACK(tc_destroy_sig), tc); g_signal_connect(G_OBJECT(tc->window), "size-allocate", G_CALLBACK(size_sig), tc); g_signal_connect(G_OBJECT(tc->drawingarea), "draw", - G_CALLBACK(draw_sig), tc); + G_CALLBACK(tc_draw_sig), tc); gtk_widget_grab_focus(GTK_WIDGET(tc->drawingarea)); diff --git a/src/utils.c b/src/utils.c new file mode 100644 index 0000000..17f9665 --- /dev/null +++ b/src/utils.c @@ -0,0 +1,52 @@ +/* + * utils.c + * + * Copyright © 2013-2018 Thomas White + * + * 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 . + * + */ + + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +void chomp(char *s) +{ + size_t i; + + if ( !s ) return; + + for ( i=0; i + * + * 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 . + * + */ + +#ifndef UTILS_H +#define UTILS_H + +#ifdef HAVE_CONFIG_H +#include +#endif + + +extern void chomp(char *s); +extern int safe_strcmp(const char *a, const char *b); + + +#endif /* UTILS_H */ diff --git a/tests/meson.build b/tests/meson.build index d970f87..0d8b760 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,6 +1,6 @@ basic_rendering = ['../src/render.c', '../src/frame.c', '../src/sc_parse.c', '../src/imagestore.c', - '../src/sc_interp.c'] + '../src/sc_interp.c', '../src/utils.c'] e = executable('storycode_test', 'storycode_test.c', '../src/sc_parse.c', dependencies : [gtkdep]) -- cgit v1.2.3