Now automatically resumes last workspace

This commit is contained in:
Markus Koch 2017-02-11 18:41:11 +01:00
parent 98a6c30744
commit e9ca1ce259
3 changed files with 13 additions and 1 deletions

View File

@ -705,7 +705,7 @@ static void mainWindow_show_error(struct mainWindow *mainWindow, gchar *text)
gtk_widget_destroy(dialog); gtk_widget_destroy(dialog);
} }
static void mainWindow_switch_workspace(struct mainWindow *mainWindow, gchar *path) void mainWindow_switch_workspace(struct mainWindow *mainWindow, gchar *path)
{ {
g_print("Switching workspace to %s.\n", path); g_print("Switching workspace to %s.\n", path);
gtk_popover_popdown(GTK_POPOVER(mainWindow->popoverWorkspace)); gtk_popover_popdown(GTK_POPOVER(mainWindow->popoverWorkspace));

View File

@ -80,5 +80,6 @@ void mainWindow_workspace_search_changed(GtkWidget *widget, gpointer user_data);
void mainWindow_checkDate(GtkWidget *widget, gint event, gpointer user_data); void mainWindow_checkDate(GtkWidget *widget, gint event, gpointer user_data);
void mainWindow_dateIconPress(GtkWidget *widget, gint icon_pos, gint event, gpointer user_data); void mainWindow_dateIconPress(GtkWidget *widget, gint icon_pos, gint event, gpointer user_data);
void mainWindow_add_recent_workspace(struct mainWindow *mainWindow, gchar *path, gboolean append); void mainWindow_add_recent_workspace(struct mainWindow *mainWindow, gchar *path, gboolean append);
void mainWindow_switch_workspace(struct mainWindow *mainWindow, gchar *path);
#endif /* MAINWINDOW_H */ #endif /* MAINWINDOW_H */

View File

@ -24,6 +24,9 @@ gboolean mdiary_load_settings(gchar *filename, struct mdiary_settings *settings)
GDataInputStream *dstream; GDataInputStream *dstream;
gchar *line; gchar *line;
GtkTreeIter iter;
gchar *temp;
file = g_file_new_for_path(filename); file = g_file_new_for_path(filename);
stream = g_file_read(file, NULL, &err); stream = g_file_read(file, NULL, &err);
if (err != NULL) { if (err != NULL) {
@ -40,6 +43,14 @@ gboolean mdiary_load_settings(gchar *filename, struct mdiary_settings *settings)
g_input_stream_close(G_INPUT_STREAM(dstream), NULL, NULL); g_input_stream_close(G_INPUT_STREAM(dstream), NULL, NULL);
g_input_stream_close(G_INPUT_STREAM(stream), NULL, NULL); g_input_stream_close(G_INPUT_STREAM(stream), NULL, NULL);
g_object_unref(file); g_object_unref(file);
if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(settings->mainWindow->workspaceListStore), &iter)) {
gtk_tree_model_get(GTK_TREE_MODEL(settings->mainWindow->workspaceListStore), &iter,
WSCOL_PATH, &temp,
-1);
mainWindow_switch_workspace(settings->mainWindow, temp);
g_free(temp);
}
} }
gboolean mdiary_save_settings(gchar *filename, struct mdiary_settings *settings) gboolean mdiary_save_settings(gchar *filename, struct mdiary_settings *settings)