Added new settings parser
This commit is contained in:
parent
85f8c1e783
commit
38c399d685
@ -13,11 +13,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
gtk_init(&argc, &argv);
|
||||
|
||||
mainWindow = mainWindow_new();
|
||||
|
||||
settings_path = g_strdup_printf("%s/.mdiary.conf", g_get_home_dir());
|
||||
settings = mdiary_settings_new();
|
||||
settings = mdiary_settings_new(mainWindow);
|
||||
mdiary_load_settings(settings_path, settings);
|
||||
|
||||
mainWindow = mainWindow_new();
|
||||
gtk_widget_show(mainWindow->mainWindow);
|
||||
gtk_main();
|
||||
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include "mdiary.h"
|
||||
|
||||
#define FILE_LIST_MAX_LEN 5
|
||||
|
||||
struct mainWindow {
|
||||
GtkWidget *mainWindow;
|
||||
GtkWidget *mainPane;
|
||||
@ -59,8 +61,6 @@ void mainWindow_set_meta_information(struct mainWindow *mainWindow,
|
||||
guint time_earliest,
|
||||
guint time_latest,
|
||||
gboolean hide_all);
|
||||
|
||||
/* Slots */
|
||||
void mainWindow_showPopover(GtkWidget *widget, GdkEvent *event, gpointer user_data);
|
||||
void mainWindow_otherWorkspaceClicked(GtkWidget *widget, gpointer user_data);
|
||||
void mainWindow_workspaceListClicked(GtkWidget *widget,
|
||||
@ -74,5 +74,6 @@ void mainWindow_filterChanged(GtkWidget *widget, gpointer user_data);
|
||||
void mainWindow_workspace_search_changed(GtkWidget *widget, 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_add_recent_workspace(struct mainWindow *mainWindow, gchar *path);
|
||||
|
||||
#endif /* MAINWINDOW_H */
|
||||
|
@ -10,8 +10,7 @@ static void mdiary_settings_parse_line(gchar *line, struct mdiary_settings *sett
|
||||
if (g_regex_match(regex, line, 0, &match_info) &&
|
||||
g_regex_get_capture_count(regex) > 0 &&
|
||||
g_match_info_matches(match_info)) {
|
||||
settings->last_workspaces = g_list_append(settings->last_workspaces,
|
||||
g_strdup(g_match_info_fetch(match_info, 1)));
|
||||
mainWindow_add_recent_workspace(settings->mainWindow, g_match_info_fetch(match_info, 1));
|
||||
}
|
||||
|
||||
g_regex_unref(regex);
|
||||
@ -49,17 +48,17 @@ gboolean mdiary_save_settings(gchar *filename, struct mdiary_settings *settings)
|
||||
g_print("SETTINGS: NYI.\n");
|
||||
}
|
||||
|
||||
struct mdiary_settings *mdiary_settings_new()
|
||||
struct mdiary_settings *mdiary_settings_new(struct mainWindow *mainWindow)
|
||||
{
|
||||
struct mdiary_settings *settings;
|
||||
|
||||
settings = malloc(sizeof(struct mdiary_settings));
|
||||
settings->last_workspaces = NULL;
|
||||
settings->mainWindow = mainWindow;
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
void mdiary_settings_free(struct mdiary_settings *settings)
|
||||
{
|
||||
g_list_free_full(settings->last_workspaces, g_free);
|
||||
free(settings);
|
||||
}
|
||||
|
@ -4,14 +4,15 @@
|
||||
#include <glib.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <stdlib.h>
|
||||
#include "mainwindow.h"
|
||||
|
||||
struct mdiary_settings {
|
||||
GList *last_workspaces;
|
||||
struct mainWindow *mainWindow;
|
||||
};
|
||||
|
||||
gboolean mdiary_load_settings(gchar *filename, struct mdiary_settings *settings);
|
||||
gboolean mdiary_save_settings(gchar *filename, struct mdiary_settings *settings);
|
||||
struct mdiary_settings *mdiary_settings_new();
|
||||
struct mdiary_settings *mdiary_settings_new(struct mainWindow *mainWindow);
|
||||
void mdiary_settings_free(struct mdiary_settings *settings);
|
||||
|
||||
#endif // SETTINGS_H
|
||||
|
Loading…
Reference in New Issue
Block a user