summaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-29 14:28:40 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-29 14:28:40 -0300
commit52484fb3b9caff8b8137cb0ecc92db090207c792 (patch)
tree478fa58165c96a84640a8eb3d7308fb418ea4a7e /gui
parent8ce33e6a9a3ae71ee5837403193cd12ef47ebe0e (diff)
downloadeeshow-52484fb3b9caff8b8137cb0ecc92db090207c792.tar.gz
eeshow-52484fb3b9caff8b8137cb0ecc92db090207c792.tar.bz2
eeshow-52484fb3b9caff8b8137cb0ecc92db090207c792.zip
new option "-E command" to execute commands when the GUI is ready
This is mainly intended for taking screenshots, e.g., with xdotool and xwd.
Diffstat (limited to 'gui')
-rw-r--r--gui/gui.c21
-rw-r--r--gui/gui.h3
2 files changed, 22 insertions, 2 deletions
diff --git a/gui/gui.c b/gui/gui.c
index 48f36d7..5f084c8 100644
--- a/gui/gui.c
+++ b/gui/gui.c
@@ -24,6 +24,7 @@
#include <stdio.h>
#include <string.h>
+#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#include "version.h"
@@ -448,7 +449,8 @@ static void size_allocate_event(GtkWidget *widget, GdkRectangle *allocation,
/* ----- Initialization ---------------------------------------------------- */
-int run_gui(const struct file_names *fn, bool recurse, int limit)
+int run_gui(const struct file_names *fn, bool recurse, int limit,
+ const char **commands, unsigned n_commands)
{
GtkWidget *window;
char *title;
@@ -510,6 +512,23 @@ int run_gui(const struct file_names *fn, bool recurse, int limit)
go_to_sheet(&gui, gui.new_hist->sheets);
gtk_widget_show_all(window);
+ if (n_commands) {
+ long xid =
+ gdk_x11_window_get_xid(gtk_widget_get_window(window));
+ char *s;
+
+ if (asprintf(&s, "0x%lx", xid)) {}
+ setenv("EESHOW_WINDOW_ID", s, 1);
+
+ while (n_commands--) {
+ while (gtk_events_pending())
+ gtk_main_iteration();
+
+ system(*commands);
+ commands++;
+ }
+ }
+
/* for performance testing, use -N-depth */
if (limit >= 0)
gtk_main();
diff --git a/gui/gui.h b/gui/gui.h
index 2d71490..d3f0fab 100644
--- a/gui/gui.h
+++ b/gui/gui.h
@@ -18,6 +18,7 @@
#include "kicad/ext.h"
-int run_gui(const struct file_names *fn, bool recurse, int limit);
+int run_gui(const struct file_names *fn, bool recurse, int limit,
+ const char **commands, unsigned n_commands);
#endif /* !GUI_GUI_H */