aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2018-03-26 23:02:13 +0200
committerThomas White <taw@physics.org>2018-03-26 23:02:13 +0200
commit3978cee519402cd06e658fcf45deca07c806ba52 (patch)
tree59d05d5dfdcae2eb762b80264a5ecefb395377e8
parentbd4c1352535ddb2bc67adc1065a7c1902a3ac86f (diff)
Add option to hide pointer (or not)
-rw-r--r--src/colloquium.c47
-rw-r--r--src/colloquium.h5
-rw-r--r--src/slideshow.c20
3 files changed, 56 insertions, 16 deletions
diff --git a/src/colloquium.c b/src/colloquium.c
index 830c2f7..1963780 100644
--- a/src/colloquium.c
+++ b/src/colloquium.c
@@ -45,6 +45,7 @@ struct _colloquium
char *mydir;
int first_run;
char *imagestore;
+ int hidepointer;
};
@@ -232,11 +233,29 @@ static void create_config(const char *filename)
fprintf(fh, "imagestore: %s\n",
g_get_user_special_dir(G_USER_DIRECTORY_PICTURES));
+ fprintf(fh, "hidepointer: no\n");
fclose(fh);
}
+static int yesno(const char *a)
+{
+ if ( a == NULL ) return 0;
+
+ if ( strcmp(a, "1") == 0 ) return 1;
+ if ( strcasecmp(a, "yes") == 0 ) return 1;
+ if ( strcasecmp(a, "true") == 0 ) return 1;
+
+ if ( strcasecmp(a, "0") == 0 ) return 0;
+ if ( strcasecmp(a, "no") == 0 ) return 0;
+ if ( strcasecmp(a, "false") == 0 ) return 0;
+
+ fprintf(stderr, "Don't understand '%s', assuming false\n", a);
+ return 0;
+}
+
+
static void read_config(const char *filename, Colloquium *app)
{
FILE *fh;
@@ -248,15 +267,19 @@ static void read_config(const char *filename, Colloquium *app)
return;
}
- if ( fgets(line, 1024, fh) == NULL ) {
- fprintf(stderr, "Failed to read from config\n");
- return;
- }
- chomp(line);
+ do {
- if ( strncmp(line, "imagestore: ", 11) == 0 ) {
- app->imagestore = strdup(line+12);
- }
+ if ( fgets(line, 1024, fh) == NULL ) break;
+ chomp(line);
+
+ if ( strncmp(line, "imagestore: ", 11) == 0 ) {
+ app->imagestore = strdup(line+12);
+ }
+
+ if ( strncmp(line, "hidepointer: ", 12) == 0 ) {
+ app->hidepointer = yesno(line+13);
+ }
+ } while ( !feof(fh) );
fclose(fh);
}
@@ -268,6 +291,12 @@ const char *colloquium_get_imagestore(Colloquium *app)
}
+int colloquium_get_hidepointer(Colloquium *app)
+{
+ return app->hidepointer;
+}
+
+
static void colloquium_startup(GApplication *papp)
{
Colloquium *app = COLLOQUIUM(papp);
@@ -510,6 +539,8 @@ static void colloquium_class_init(ColloquiumClass *class)
static void colloquium_init(Colloquium *app)
{
+ app->imagestore = NULL;
+ app->hidepointer = 0;
}
diff --git a/src/colloquium.h b/src/colloquium.h
index ccbb964..beb7ec8 100644
--- a/src/colloquium.h
+++ b/src/colloquium.h
@@ -36,6 +36,9 @@ typedef struct _colloquium Colloquium;
GTK_TYPE_APPLICATION, Colloquium))
-const char *colloquium_get_imagestore(Colloquium *app);
+extern const char *colloquium_get_imagestore(Colloquium *app);
+
+extern int colloquium_get_hidepointer(Colloquium *app);
+
#endif /* COLLOQUIUM_H */
diff --git a/src/slideshow.c b/src/slideshow.c
index 84f1edb..3e33c3d 100644
--- a/src/slideshow.c
+++ b/src/slideshow.c
@@ -31,6 +31,7 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
+#include "colloquium.h"
#include "presentation.h"
#include "render.h"
#include "pr_clock.h"
@@ -86,7 +87,7 @@ static gint ssh_destroy_sig(GtkWidget *widget, SCSlideshow *ss)
if ( ss->surface != NULL ) {
cairo_surface_destroy(ss->surface);
}
- if ( ss->app != NULL ) {
+ if ( ss->inhibit_cookie ) {
gtk_application_uninhibit(ss->app, ss->inhibit_cookie);
}
return FALSE;
@@ -121,13 +122,18 @@ static gboolean ss_draw_sig(GtkWidget *da, cairo_t *cr, SCSlideshow *ss)
static gboolean ss_realize_sig(GtkWidget *w, SCSlideshow *ss)
{
- GdkWindow *win;
+ if ( (ss->app == NULL) || colloquium_get_hidepointer(COLLOQUIUM(ss->app)) ) {
- win = gtk_widget_get_window(w);
+ /* Hide the pointer */
+ GdkWindow *win;
+ win = gtk_widget_get_window(w);
+ ss->blank_cursor = gdk_cursor_new_for_display(gdk_display_get_default(),
+ GDK_BLANK_CURSOR);
+ gdk_window_set_cursor(GDK_WINDOW(win), ss->blank_cursor);
- ss->blank_cursor = gdk_cursor_new_for_display(gdk_display_get_default(),
- GDK_BLANK_CURSOR);
- //gdk_window_set_cursor(GDK_WINDOW(win), ss->blank_cursor);
+ } else {
+ ss->blank_cursor = NULL;
+ }
slideshow_rerender(ss);
@@ -183,6 +189,7 @@ SCSlideshow *sc_slideshow_new(struct presentation *p, GtkApplication *app)
ss->cur_slide = NULL;
ss->blank_cursor = NULL;
ss->surface = NULL;
+ ss->app = app;
ss->drawingarea = gtk_drawing_area_new();
gtk_container_add(GTK_CONTAINER(ss), ss->drawingarea);
@@ -229,7 +236,6 @@ SCSlideshow *sc_slideshow_new(struct presentation *p, GtkApplication *app)
ss->inhibit_cookie = gtk_application_inhibit(app, GTK_WINDOW(ss),
GTK_APPLICATION_INHIBIT_IDLE,
"Presentation slide show is running");
- ss->app = app;
}
return ss;