Now saving selected renderer

This commit is contained in:
Markus Koch 2017-02-19 15:05:09 +01:00
parent 552b1568e3
commit 869cb20eaf
2 changed files with 30 additions and 16 deletions

View File

@ -435,6 +435,21 @@ void mainWindow_renderer_set(struct mainWindow *mainWindow, enum renderer_mode s
if (mainWindow->renderer == state) if (mainWindow->renderer == state)
return; return;
switch (state) {
case RENDERER_TEXT:
gtk_combo_box_set_active_id(GTK_COMBO_BOX(mainWindow->settingsDialog.comboDisplayMode), "text");
break;
case RENDERER_BASIC:
gtk_combo_box_set_active_id(GTK_COMBO_BOX(mainWindow->settingsDialog.comboDisplayMode), "basic");
break;
case RENDERER_HTML:
gtk_combo_box_set_active_id(GTK_COMBO_BOX(mainWindow->settingsDialog.comboDisplayMode), "html");
break;
default:
mainWindow_renderer_set(mainWindow, RENDERER_TEXT);
return;
}
if (state == RENDERER_HTML) { if (state == RENDERER_HTML) {
if (!mainWindow->webkitView) { if (!mainWindow->webkitView) {
mainWindow->webkitView = webkit_web_view_new(); mainWindow->webkitView = webkit_web_view_new();
@ -477,19 +492,6 @@ static gboolean mainWindow_settings_delete_event(GtkWidget *widget, GdkEvent *e
void mainWindow_settings_show(struct mainWindow *mainWindow) void mainWindow_settings_show(struct mainWindow *mainWindow)
{ {
switch (mainWindow->renderer) {
case RENDERER_TEXT:
gtk_combo_box_set_active_id(GTK_COMBO_BOX(mainWindow->settingsDialog.comboDisplayMode), "text");
break;
case RENDERER_BASIC:
gtk_combo_box_set_active_id(GTK_COMBO_BOX(mainWindow->settingsDialog.comboDisplayMode), "basic");
break;
case RENDERER_HTML:
gtk_combo_box_set_active_id(GTK_COMBO_BOX(mainWindow->settingsDialog.comboDisplayMode), "html");
break;
default:
break;
}
gtk_widget_show(mainWindow->settingsDialog.settingsDialog); gtk_widget_show(mainWindow->settingsDialog.settingsDialog);
} }
@ -582,7 +584,7 @@ struct mainWindow *mainWindow_new()
mainWindow_configure_entry_completion(mainWindow); mainWindow_configure_entry_completion(mainWindow);
mainWindow_set_meta_information(mainWindow, 0, 0, TRUE); mainWindow_set_meta_information(mainWindow, 0, 0, TRUE);
mainWindow_renderer_set(mainWindow, RENDERER_HTML); mainWindow_renderer_set(mainWindow, RENDERER_TEXT);
return mainWindow; return mainWindow;
} }

View File

@ -5,14 +5,20 @@ static void mdiary_settings_parse_line(gchar *line, struct mdiary_settings *sett
GRegex *regex; GRegex *regex;
GMatchInfo *match_info; GMatchInfo *match_info;
regex = g_regex_new("workspace = (.*)", G_REGEX_RAW, 0, NULL); regex = g_regex_new("^workspace = (.*)", G_REGEX_RAW, 0, NULL);
if (g_regex_match(regex, line, 0, &match_info) && if (g_regex_match(regex, line, 0, &match_info) &&
g_regex_get_capture_count(regex) > 0 && g_regex_get_capture_count(regex) > 0 &&
g_match_info_matches(match_info)) { g_match_info_matches(match_info)) {
mainWindow_add_recent_workspace(settings->mainWindow, g_match_info_fetch(match_info, 1), TRUE); mainWindow_add_recent_workspace(settings->mainWindow, g_match_info_fetch(match_info, 1), TRUE);
} }
g_regex_unref(regex);
regex = g_regex_new("^renderer = (.*)", G_REGEX_RAW, 0, NULL);
if (g_regex_match(regex, line, 0, &match_info) &&
g_regex_get_capture_count(regex) > 0 &&
g_match_info_matches(match_info)) {
mainWindow_renderer_set(settings->mainWindow, atoi(g_match_info_fetch(match_info, 1)));
}
g_regex_unref(regex); g_regex_unref(regex);
} }
@ -66,6 +72,12 @@ gboolean mdiary_save_settings(gchar *filename, struct mdiary_settings *settings)
G_FILE_CREATE_NONE, G_FILE_CREATE_NONE,
NULL, NULL); NULL, NULL);
output_buffer = g_strdup_printf("renderer = %d\n", settings->mainWindow->renderer);
g_output_stream_write(G_OUTPUT_STREAM(stream),
output_buffer, strlen(output_buffer), NULL, NULL);
g_free(output_buffer);
if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(settings->mainWindow->workspaceListStore), &iter)) { if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(settings->mainWindow->workspaceListStore), &iter)) {
do { do {
gtk_tree_model_get(GTK_TREE_MODEL(settings->mainWindow->workspaceListStore), &iter, gtk_tree_model_get(GTK_TREE_MODEL(settings->mainWindow->workspaceListStore), &iter,