1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2025-04-21 12:27:27 +03:00

eeshow/: add online help with h or ? (WIP)

This commit is contained in:
Werner Almesberger
2016-08-19 14:17:00 -03:00
parent e72d476e71
commit ebbb986768
6 changed files with 144 additions and 3 deletions

57
eeshow/gui/help.c Normal file
View File

@@ -0,0 +1,57 @@
/*
* gui/help.c - Online help
*
* Written 2016 by Werner Almesberger
* Copyright 2016 by Werner Almesberger
*
* This program 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 2 of the License, or
* (at your option) any later version.
*/
#include <stdbool.h>
#include <gtk/gtk.h>
#include <webkit2/webkit2.h>
#include "gui/help.h"
static GtkWidget *window = NULL;
static bool visible;
static void new_help_window(void)
{
GtkWidget *view;
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
view = webkit_web_view_new();
gtk_container_add(GTK_CONTAINER(window), view);
gtk_widget_show_all(window);
webkit_web_view_load_html(WEBKIT_WEB_VIEW(view),
#include "../help.inc"
, NULL);
g_signal_connect(window, "destroy",
G_CALLBACK(gtk_main_quit), NULL);
gtk_widget_show_all(window);
}
void help(void)
{
if (!window) {
new_help_window();
visible = 1;
} else {
visible = !visible;
if (visible)
gtk_widget_show(window);
else
gtk_widget_hide(window);
}
}

18
eeshow/gui/help.h Normal file
View File

@@ -0,0 +1,18 @@
/*
* gui/help.h - Online help
*
* Written 2016 by Werner Almesberger
* Copyright 2016 by Werner Almesberger
*
* This program 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 2 of the License, or
* (at your option) any later version.
*/
#ifndef GUI_HELP_H
#define GUI_HELP_H
void help(void);
#endif /* !GUI_HELP_H */

View File

@@ -24,6 +24,7 @@
#include "gui/aoi.h"
#include "gui/over.h"
#include "gui/input.h"
#include "gui/help.h"
#include "gui/common.h"
@@ -515,6 +516,11 @@ static void sheet_key(void *user, int x, int y, int keyval)
redraw(ctx);
break;
case GDK_KEY_h:
case GDK_KEY_question:
help();
break;
case GDK_KEY_q:
gtk_main_quit();
}