You can now change page

This commit is contained in:
Romain de Laage 2021-02-15 14:36:19 +01:00
parent 225dbbe45f
commit 63611f46c9
Signed by: rdelaage
GPG Key ID: 534845FADDF0C329
5 changed files with 19 additions and 15 deletions

View File

@ -5,7 +5,7 @@ void addH1 (GtkWidget *root, char *line);
void addH2 (GtkWidget *root, char *line);
void addH3 (GtkWidget *root, char *line);
void addLink (GtkWidget *root, char *url, char *text);
void addCode (GtkWidget *root, char *code, char *meta);
void addCode (GtkWidget *root, const char *code, char *meta);
void addQuote (GtkWidget *root, char *quote);
void addUList (GtkWidget *root, char *text);
void addText (GtkWidget *root, char *text);

View File

@ -1,6 +1,6 @@
#ifndef _GEMPARSE_H
#define _GEMPARSE_H
int parseFile (char *path);
int parseFile (const char *path);
#endif

View File

@ -78,9 +78,9 @@ addLink (GtkWidget *root,
}
void
addCode (GtkWidget *root,
char *code,
char *meta)
addCode (GtkWidget *root,
const char *code,
char *meta)
{
gchar *markup = g_markup_printf_escaped ("<span font_family=\"monospace\">%s</span>", code);
GtkWidget *label = gtk_label_new (NULL);

View File

@ -19,7 +19,7 @@ void addUList (const char *text);
// general functions
int parseFile (char *path);
int parseFile (const char *path);
#else
@ -29,7 +29,7 @@ extern char links[1024][20];
#endif
int
parseFile (char *path)
parseFile (const char *path)
{
FILE *fileToParse = fopen (path, "r");
char line[4096];

View File

@ -7,10 +7,13 @@ GtkWidget *render = NULL;
GtkWidget *scrollbar = NULL;
char links[1024][20];
static void makeRender (const char *path);
static void
loadPage (const char *link)
{
printf("Loading page : %s\n", link);
makeRender (link);
gtk_container_foreach (GTK_CONTAINER (render), (GtkCallback)gtk_widget_show_all, NULL);
}
void
@ -28,16 +31,17 @@ goAction (GtkWidget *widget,
}
static void
makeRender (char *path)
makeRender (const char *path)
{
if (render != NULL)
gtk_widget_destroy (render);
render = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
if (render == NULL)
{
render = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (scrollbar), render);
}
else
gtk_container_foreach (GTK_CONTAINER (render), (GtkCallback)gtk_widget_destroy, NULL);
parseFile (path);
gtk_container_add (GTK_CONTAINER (scrollbar), render);
}
/* This function's goal is to build the main interface */