Compare commits
No commits in common. "f444d40071fa394a6c8cb433750db7bfe49469cb" and "d066bdde5811057dbe2eb3955ea33a98049b1f8d" have entirely different histories.
f444d40071
...
d066bdde58
@ -33,13 +33,8 @@
|
|||||||
<object class="GtkTreeView" id="treeWorkspace">
|
<object class="GtkTreeView" id="treeWorkspace">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="hscroll_policy">natural</property>
|
|
||||||
<property name="vscroll_policy">natural</property>
|
|
||||||
<property name="headers_visible">False</property>
|
<property name="headers_visible">False</property>
|
||||||
<property name="enable_search">False</property>
|
|
||||||
<property name="fixed_height_mode">True</property>
|
|
||||||
<property name="hover_selection">True</property>
|
<property name="hover_selection">True</property>
|
||||||
<property name="show_expanders">False</property>
|
|
||||||
<property name="enable_grid_lines">horizontal</property>
|
<property name="enable_grid_lines">horizontal</property>
|
||||||
<property name="activate_on_single_click">True</property>
|
<property name="activate_on_single_click">True</property>
|
||||||
<child internal-child="selection">
|
<child internal-child="selection">
|
||||||
@ -390,7 +385,7 @@
|
|||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child type="titlebar">
|
<child type="titlebar">
|
||||||
<object class="GtkHeaderBar" id="headerBar">
|
<object class="GtkHeaderBar">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="title">MDiary</property>
|
<property name="title">MDiary</property>
|
||||||
|
@ -13,12 +13,11 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
gtk_init(&argc, &argv);
|
gtk_init(&argc, &argv);
|
||||||
|
|
||||||
mainWindow = mainWindow_new();
|
|
||||||
|
|
||||||
settings_path = g_strdup_printf("%s/.mdiary.conf", g_get_home_dir());
|
settings_path = g_strdup_printf("%s/.mdiary.conf", g_get_home_dir());
|
||||||
settings = mdiary_settings_new(mainWindow);
|
settings = mdiary_settings_new();
|
||||||
mdiary_load_settings(settings_path, settings);
|
mdiary_load_settings(settings_path, settings);
|
||||||
|
|
||||||
|
mainWindow = mainWindow_new();
|
||||||
gtk_widget_show(mainWindow->mainWindow);
|
gtk_widget_show(mainWindow->mainWindow);
|
||||||
gtk_main();
|
gtk_main();
|
||||||
|
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "mdiary.h"
|
#include "mdiary.h"
|
||||||
|
|
||||||
|
enum {
|
||||||
|
WSCOL_LABEL = 0,
|
||||||
|
WSCOL_PATH,
|
||||||
|
WSCOL_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
static gboolean mainWindow_workspace_entry_visible(GtkTreeModel *model,
|
static gboolean mainWindow_workspace_entry_visible(GtkTreeModel *model,
|
||||||
GtkTreeIter *iter,
|
GtkTreeIter *iter,
|
||||||
struct mainWindow *mainWindow)
|
struct mainWindow *mainWindow)
|
||||||
@ -141,13 +147,12 @@ static gint mainWindow_sort_date_compare_func(GtkTreeModel *model,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mainWindow_add_recent_workspace(struct mainWindow *mainWindow, gchar *path, gboolean append)
|
static void mainWindow_add_recent_workspace(struct mainWindow *mainWindow, gchar *path)
|
||||||
{
|
{
|
||||||
GtkTreeIter iter, iter_delete;
|
GtkTreeIter iter;
|
||||||
GRegex *regex;
|
GRegex *regex;
|
||||||
GMatchInfo *match_info;
|
GMatchInfo *match_info;
|
||||||
gchar *temp;
|
gchar *temp;
|
||||||
gboolean del_iter = FALSE;
|
|
||||||
|
|
||||||
regex = g_regex_new("(.*)\\/(.*)", G_REGEX_RAW, 0, NULL);
|
regex = g_regex_new("(.*)\\/(.*)", G_REGEX_RAW, 0, NULL);
|
||||||
if (g_regex_match(regex, path, 0, &match_info) &&
|
if (g_regex_match(regex, path, 0, &match_info) &&
|
||||||
@ -155,38 +160,15 @@ void mainWindow_add_recent_workspace(struct mainWindow *mainWindow, gchar *path,
|
|||||||
g_match_info_matches(match_info)) {
|
g_match_info_matches(match_info)) {
|
||||||
g_match_info_fetch(match_info, 1);
|
g_match_info_fetch(match_info, 1);
|
||||||
|
|
||||||
if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(mainWindow->workspaceListStore), &iter)) {
|
|
||||||
do {
|
|
||||||
memcpy(&iter_delete, &iter, sizeof(iter)); /* scan for last */
|
|
||||||
gtk_tree_model_get(GTK_TREE_MODEL(mainWindow->workspaceListStore), &iter,
|
|
||||||
WSCOL_PATH, &temp,
|
|
||||||
-1);
|
|
||||||
if (!g_strcmp0(temp, path)) {
|
|
||||||
g_free(temp);
|
|
||||||
gtk_list_store_remove(mainWindow->workspaceListStore, &iter);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
g_free(temp);
|
|
||||||
} while (gtk_tree_model_iter_next(GTK_TREE_MODEL(mainWindow->workspaceListStore), &iter));
|
|
||||||
}
|
|
||||||
|
|
||||||
temp = g_strdup_printf("<b>%s</b>\n<span weight=\"ultralight\">%s</span>",
|
temp = g_strdup_printf("<b>%s</b>\n<span weight=\"ultralight\">%s</span>",
|
||||||
g_match_info_fetch(match_info, 2),
|
g_match_info_fetch(match_info, 2),
|
||||||
g_match_info_fetch(match_info, 1));
|
g_match_info_fetch(match_info, 1));
|
||||||
if (append)
|
gtk_list_store_append(mainWindow->workspaceListStore, &iter);
|
||||||
gtk_list_store_append(mainWindow->workspaceListStore, &iter);
|
|
||||||
else
|
|
||||||
gtk_list_store_prepend(mainWindow->workspaceListStore, &iter);
|
|
||||||
gtk_list_store_set(mainWindow->workspaceListStore, &iter,
|
gtk_list_store_set(mainWindow->workspaceListStore, &iter,
|
||||||
WSCOL_LABEL, temp,
|
WSCOL_LABEL, temp,
|
||||||
WSCOL_PATH, path,
|
WSCOL_PATH, path,
|
||||||
-1);
|
-1);
|
||||||
g_free(temp);
|
g_free(temp);
|
||||||
|
|
||||||
|
|
||||||
if (gtk_tree_model_iter_n_children(GTK_TREE_MODEL(mainWindow->workspaceListStore), NULL)
|
|
||||||
> FILE_LIST_MAX_LEN)
|
|
||||||
gtk_list_store_remove(mainWindow->workspaceListStore, &iter_delete);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_regex_unref(regex);
|
g_regex_unref(regex);
|
||||||
@ -206,9 +188,9 @@ static void mainWindow_configure_workspaceTreeView(struct mainWindow *mainWindow
|
|||||||
G_TYPE_STRING);
|
G_TYPE_STRING);
|
||||||
|
|
||||||
mainWindow->workspaceListFiltered = GTK_TREE_MODEL_FILTER(
|
mainWindow->workspaceListFiltered = GTK_TREE_MODEL_FILTER(
|
||||||
gtk_tree_model_filter_new(
|
gtk_tree_model_filter_new(
|
||||||
GTK_TREE_MODEL(mainWindow->workspaceListStore),
|
GTK_TREE_MODEL(mainWindow->workspaceListStore),
|
||||||
NULL));
|
NULL));
|
||||||
|
|
||||||
gtk_tree_model_filter_set_visible_func(mainWindow->workspaceListFiltered,
|
gtk_tree_model_filter_set_visible_func(mainWindow->workspaceListFiltered,
|
||||||
(GtkTreeModelFilterVisibleFunc) mainWindow_workspace_entry_visible,
|
(GtkTreeModelFilterVisibleFunc) mainWindow_workspace_entry_visible,
|
||||||
@ -219,6 +201,10 @@ static void mainWindow_configure_workspaceTreeView(struct mainWindow *mainWindow
|
|||||||
renderer = gtk_cell_renderer_text_new();
|
renderer = gtk_cell_renderer_text_new();
|
||||||
gtk_tree_view_insert_column_with_attributes(mainWindow->workspaceListView, -1, "", renderer,
|
gtk_tree_view_insert_column_with_attributes(mainWindow->workspaceListView, -1, "", renderer,
|
||||||
"markup", WSCOL_LABEL, NULL);
|
"markup", WSCOL_LABEL, NULL);
|
||||||
|
|
||||||
|
/* Test only */
|
||||||
|
mainWindow_add_recent_workspace(mainWindow, "/home/user/Document/diary");
|
||||||
|
mainWindow_add_recent_workspace(mainWindow, "/home/user/Document/workfoo");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -442,12 +428,13 @@ struct mainWindow *mainWindow_new()
|
|||||||
mainWindow->checkSearchText = GTK_WIDGET(gtk_builder_get_object(builder, "checkSearchText"));
|
mainWindow->checkSearchText = GTK_WIDGET(gtk_builder_get_object(builder, "checkSearchText"));
|
||||||
mainWindow->labelSummary = GTK_WIDGET(gtk_builder_get_object(builder, "labelSummary"));
|
mainWindow->labelSummary = GTK_WIDGET(gtk_builder_get_object(builder, "labelSummary"));
|
||||||
mainWindow->buttonClearSearch = GTK_WIDGET(gtk_builder_get_object(builder, "buttonClearSearch"));
|
mainWindow->buttonClearSearch = GTK_WIDGET(gtk_builder_get_object(builder, "buttonClearSearch"));
|
||||||
mainWindow->headerBar = GTK_WIDGET(gtk_builder_get_object(builder, "headerBar"));
|
|
||||||
mainWindow->entryListView = GTK_TREE_VIEW(gtk_builder_get_object(builder, "entryListView"));
|
mainWindow->entryListView = GTK_TREE_VIEW(gtk_builder_get_object(builder, "entryListView"));
|
||||||
mainWindow->entryListSelection = GTK_TREE_SELECTION(gtk_builder_get_object(builder, "entryListSelection"));
|
mainWindow->entryListSelection = GTK_TREE_SELECTION(gtk_builder_get_object(builder, "entryListSelection"));
|
||||||
mainWindow->textBuffer = GTK_TEXT_BUFFER(gtk_builder_get_object(builder, "entryTextBuffer"));
|
mainWindow->textBuffer = GTK_TEXT_BUFFER(gtk_builder_get_object(builder, "entryTextBuffer"));
|
||||||
mainWindow->searchEntryCompletion = GTK_ENTRY_COMPLETION(gtk_builder_get_object(
|
mainWindow->searchEntryCompletion = GTK_ENTRY_COMPLETION(gtk_builder_get_object(
|
||||||
builder, "searchEntryCompletion"));
|
builder, "searchEntryCompletion"));
|
||||||
|
mainWindow->chooseDirectoryDialog = GTK_FILE_CHOOSER_DIALOG(gtk_builder_get_object(
|
||||||
|
builder, "chooseDirectoryDialog"));
|
||||||
mainWindow->buttonOtherWorkspace = GTK_WIDGET(gtk_builder_get_object(builder, "buttonOtherWorkspace"));
|
mainWindow->buttonOtherWorkspace = GTK_WIDGET(gtk_builder_get_object(builder, "buttonOtherWorkspace"));
|
||||||
mainWindow->workspaceSearch = GTK_WIDGET(gtk_builder_get_object(builder, "searchWorkspace"));
|
mainWindow->workspaceSearch = GTK_WIDGET(gtk_builder_get_object(builder, "searchWorkspace"));
|
||||||
mainWindow->popoverWorkspace = GTK_WIDGET(gtk_builder_get_object(builder, "popoverWorkspace"));
|
mainWindow->popoverWorkspace = GTK_WIDGET(gtk_builder_get_object(builder, "popoverWorkspace"));
|
||||||
@ -615,13 +602,13 @@ void mainWindow_filterChanged(GtkWidget *widget, gpointer user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mainWindow->filterSettings.search_title = gtk_toggle_button_get_active(
|
mainWindow->filterSettings.search_title = gtk_toggle_button_get_active(
|
||||||
GTK_TOGGLE_BUTTON(mainWindow->checkSearchTitle));
|
GTK_TOGGLE_BUTTON(mainWindow->checkSearchTitle));
|
||||||
mainWindow->filterSettings.search_tags = gtk_toggle_button_get_active(
|
mainWindow->filterSettings.search_tags = gtk_toggle_button_get_active(
|
||||||
GTK_TOGGLE_BUTTON(mainWindow->checkSearchTags));
|
GTK_TOGGLE_BUTTON(mainWindow->checkSearchTags));
|
||||||
mainWindow->filterSettings.search_text = gtk_toggle_button_get_active(
|
mainWindow->filterSettings.search_text = gtk_toggle_button_get_active(
|
||||||
GTK_TOGGLE_BUTTON(mainWindow->checkSearchText));
|
GTK_TOGGLE_BUTTON(mainWindow->checkSearchText));
|
||||||
mainWindow->filterSettings.search_summary = gtk_toggle_button_get_active(
|
mainWindow->filterSettings.search_summary = gtk_toggle_button_get_active(
|
||||||
GTK_TOGGLE_BUTTON(mainWindow->checkSearchSummary));
|
GTK_TOGGLE_BUTTON(mainWindow->checkSearchSummary));
|
||||||
|
|
||||||
gtk_tree_model_filter_refilter(mainWindow->entryListFiltered);
|
gtk_tree_model_filter_refilter(mainWindow->entryListFiltered);
|
||||||
}
|
}
|
||||||
@ -706,22 +693,18 @@ static void mainWindow_show_error(struct mainWindow *mainWindow, gchar *text)
|
|||||||
gtk_widget_destroy(dialog);
|
gtk_widget_destroy(dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mainWindow_switch_workspace(struct mainWindow *mainWindow, gchar *path)
|
static 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));
|
||||||
mainWindow_set_meta_information(mainWindow, 0, 0, TRUE);
|
mainWindow_set_meta_information(mainWindow, 0, 0, TRUE);
|
||||||
mdiary_reset_store(mainWindow->entryListStore, mainWindow->completionListStore);
|
mdiary_reset_store(mainWindow->entryListStore, mainWindow->completionListStore);
|
||||||
if (mdiary_scan_to_store(path, mainWindow->entryListStore, mainWindow->completionListStore)) {
|
if (mdiary_scan_to_store(path, mainWindow->entryListStore, mainWindow->completionListStore))
|
||||||
mainWindow_set_meta_information(mainWindow,
|
mainWindow_set_meta_information(mainWindow,
|
||||||
mdiary_get_time_earliest(), mdiary_get_time_latest(),
|
mdiary_get_time_earliest(), mdiary_get_time_latest(),
|
||||||
FALSE);
|
FALSE);
|
||||||
mainWindow_add_recent_workspace(mainWindow, path, FALSE);
|
else
|
||||||
gtk_header_bar_set_subtitle(GTK_HEADER_BAR(mainWindow->headerBar), path);
|
|
||||||
} else {
|
|
||||||
gtk_header_bar_set_subtitle(GTK_HEADER_BAR(mainWindow->headerBar), "No workspace opened.");
|
|
||||||
mainWindow_show_error(mainWindow, "Could not open workspace or no entries were found in it.");
|
mainWindow_show_error(mainWindow, "Could not open workspace or no entries were found in it.");
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -769,9 +752,9 @@ void mainWindow_otherWorkspaceClicked(GtkWidget *widget, gpointer user_data)
|
|||||||
if (res == GTK_RESPONSE_ACCEPT) {
|
if (res == GTK_RESPONSE_ACCEPT) {
|
||||||
char *directory;
|
char *directory;
|
||||||
|
|
||||||
directory = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
|
directory = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(dialog));
|
||||||
mainWindow_switch_workspace(mainWindow, directory);
|
mainWindow_switch_workspace(mainWindow, directory);
|
||||||
g_free(directory);
|
g_free (directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_widget_destroy (dialog);
|
gtk_widget_destroy (dialog);
|
||||||
|
@ -6,14 +6,6 @@
|
|||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include "mdiary.h"
|
#include "mdiary.h"
|
||||||
|
|
||||||
#define FILE_LIST_MAX_LEN 5
|
|
||||||
|
|
||||||
enum {
|
|
||||||
WSCOL_LABEL = 0,
|
|
||||||
WSCOL_PATH,
|
|
||||||
WSCOL_COUNT
|
|
||||||
};
|
|
||||||
|
|
||||||
struct mainWindow {
|
struct mainWindow {
|
||||||
GtkWidget *mainWindow;
|
GtkWidget *mainWindow;
|
||||||
GtkWidget *mainPane;
|
GtkWidget *mainPane;
|
||||||
@ -29,7 +21,7 @@ struct mainWindow {
|
|||||||
GtkWidget *checkSearchText;
|
GtkWidget *checkSearchText;
|
||||||
GtkWidget *labelSummary;
|
GtkWidget *labelSummary;
|
||||||
GtkWidget *buttonClearSearch;
|
GtkWidget *buttonClearSearch;
|
||||||
GtkWidget *headerBar;
|
GtkFileChooserWidget *chooseDirectoryDialog;
|
||||||
GtkTreeView *entryListView;
|
GtkTreeView *entryListView;
|
||||||
GtkTreeSelection *entryListSelection;
|
GtkTreeSelection *entryListSelection;
|
||||||
GtkTextBuffer *textBuffer;
|
GtkTextBuffer *textBuffer;
|
||||||
@ -67,6 +59,8 @@ void mainWindow_set_meta_information(struct mainWindow *mainWindow,
|
|||||||
guint time_earliest,
|
guint time_earliest,
|
||||||
guint time_latest,
|
guint time_latest,
|
||||||
gboolean hide_all);
|
gboolean hide_all);
|
||||||
|
|
||||||
|
/* Slots */
|
||||||
void mainWindow_showPopover(GtkWidget *widget, GdkEvent *event, gpointer user_data);
|
void mainWindow_showPopover(GtkWidget *widget, GdkEvent *event, gpointer user_data);
|
||||||
void mainWindow_otherWorkspaceClicked(GtkWidget *widget, gpointer user_data);
|
void mainWindow_otherWorkspaceClicked(GtkWidget *widget, gpointer user_data);
|
||||||
void mainWindow_workspaceListClicked(GtkWidget *widget,
|
void mainWindow_workspaceListClicked(GtkWidget *widget,
|
||||||
@ -80,7 +74,5 @@ void mainWindow_filterChanged(GtkWidget *widget, gpointer user_data);
|
|||||||
void mainWindow_workspace_search_changed(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_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_switch_workspace(struct mainWindow *mainWindow, gchar *path);
|
|
||||||
|
|
||||||
#endif /* MAINWINDOW_H */
|
#endif /* MAINWINDOW_H */
|
||||||
|
@ -10,7 +10,8 @@ static void mdiary_settings_parse_line(gchar *line, struct mdiary_settings *sett
|
|||||||
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);
|
settings->last_workspaces = g_list_append(settings->last_workspaces,
|
||||||
|
g_strdup(g_match_info_fetch(match_info, 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
g_regex_unref(regex);
|
g_regex_unref(regex);
|
||||||
@ -24,9 +25,6 @@ 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) {
|
||||||
@ -44,60 +42,24 @@ gboolean mdiary_load_settings(gchar *filename, struct mdiary_settings *settings)
|
|||||||
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)
|
||||||
{
|
{
|
||||||
GtkTreeIter iter;
|
g_print("SETTINGS: NYI.\n");
|
||||||
gchar *temp;
|
|
||||||
gchar *output_buffer;
|
|
||||||
GFileOutputStream *stream;
|
|
||||||
GFile *file;
|
|
||||||
|
|
||||||
file = g_file_new_for_path(filename);
|
|
||||||
stream = g_file_replace(
|
|
||||||
file, NULL, FALSE,
|
|
||||||
G_FILE_CREATE_NONE,
|
|
||||||
NULL, NULL);
|
|
||||||
|
|
||||||
if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(settings->mainWindow->workspaceListStore), &iter)) {
|
|
||||||
do {
|
|
||||||
gtk_tree_model_get(GTK_TREE_MODEL(settings->mainWindow->workspaceListStore), &iter,
|
|
||||||
WSCOL_PATH, &temp,
|
|
||||||
-1);
|
|
||||||
|
|
||||||
output_buffer = g_strdup_printf("workspace = %s\n", temp);
|
|
||||||
g_output_stream_write(G_OUTPUT_STREAM(stream),
|
|
||||||
output_buffer, strlen(output_buffer), NULL, NULL);
|
|
||||||
|
|
||||||
g_free(output_buffer);
|
|
||||||
g_free(temp);
|
|
||||||
|
|
||||||
} while (gtk_tree_model_iter_next(GTK_TREE_MODEL(settings->mainWindow->workspaceListStore), &iter));
|
|
||||||
}
|
|
||||||
g_output_stream_close(G_OUTPUT_STREAM(stream),NULL,NULL);
|
|
||||||
g_object_unref(stream);
|
|
||||||
g_object_unref(file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct mdiary_settings *mdiary_settings_new(struct mainWindow *mainWindow)
|
struct mdiary_settings *mdiary_settings_new()
|
||||||
{
|
{
|
||||||
struct mdiary_settings *settings;
|
struct mdiary_settings *settings;
|
||||||
|
|
||||||
settings = malloc(sizeof(struct mdiary_settings));
|
settings = malloc(sizeof(struct mdiary_settings));
|
||||||
settings->mainWindow = mainWindow;
|
settings->last_workspaces = NULL;
|
||||||
|
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mdiary_settings_free(struct mdiary_settings *settings)
|
void mdiary_settings_free(struct mdiary_settings *settings)
|
||||||
{
|
{
|
||||||
free(settings);
|
g_list_free_full(settings->last_workspaces, g_free);
|
||||||
}
|
}
|
||||||
|
@ -4,15 +4,14 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "mainwindow.h"
|
|
||||||
|
|
||||||
struct mdiary_settings {
|
struct mdiary_settings {
|
||||||
struct mainWindow *mainWindow;
|
GList *last_workspaces;
|
||||||
};
|
};
|
||||||
|
|
||||||
gboolean mdiary_load_settings(gchar *filename, struct mdiary_settings *settings);
|
gboolean mdiary_load_settings(gchar *filename, struct mdiary_settings *settings);
|
||||||
gboolean mdiary_save_settings(gchar *filename, struct mdiary_settings *settings);
|
gboolean mdiary_save_settings(gchar *filename, struct mdiary_settings *settings);
|
||||||
struct mdiary_settings *mdiary_settings_new(struct mainWindow *mainWindow);
|
struct mdiary_settings *mdiary_settings_new();
|
||||||
void mdiary_settings_free(struct mdiary_settings *settings);
|
void mdiary_settings_free(struct mdiary_settings *settings);
|
||||||
|
|
||||||
#endif // SETTINGS_H
|
#endif // SETTINGS_H
|
||||||
|
Loading…
Reference in New Issue
Block a user