Updated mainWindow_add_recent_workspace + refactoring
This commit is contained in:
parent
d066bdde58
commit
eef1f96a0a
@ -147,9 +147,9 @@ static gint mainWindow_sort_date_compare_func(GtkTreeModel *model,
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void mainWindow_add_recent_workspace(struct mainWindow *mainWindow, gchar *path)
|
||||
void mainWindow_add_recent_workspace(struct mainWindow *mainWindow, gchar *path)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
GtkTreeIter iter, iter2;
|
||||
GRegex *regex;
|
||||
GMatchInfo *match_info;
|
||||
gchar *temp;
|
||||
@ -163,12 +163,20 @@ static void mainWindow_add_recent_workspace(struct mainWindow *mainWindow, gchar
|
||||
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, 1));
|
||||
gtk_list_store_append(mainWindow->workspaceListStore, &iter);
|
||||
gtk_list_store_prepend(mainWindow->workspaceListStore, &iter);
|
||||
gtk_list_store_set(mainWindow->workspaceListStore, &iter,
|
||||
WSCOL_LABEL, temp,
|
||||
WSCOL_PATH, path,
|
||||
-1);
|
||||
g_free(temp);
|
||||
|
||||
if (gtk_tree_model_iter_n_children(GTK_TREE_MODEL(mainWindow->workspaceListStore), NULL)
|
||||
> FILE_LIST_MAX_LEN) {
|
||||
while (gtk_tree_model_iter_next(GTK_TREE_MODEL(mainWindow->workspaceListStore), &iter)) {
|
||||
memcpy(&iter2, &iter, sizeof(iter)); /* TODO: A bit of a hack if you ask me... */
|
||||
}
|
||||
gtk_list_store_remove(mainWindow->workspaceListStore, &iter2);
|
||||
}
|
||||
}
|
||||
|
||||
g_regex_unref(regex);
|
||||
@ -201,10 +209,6 @@ static void mainWindow_configure_workspaceTreeView(struct mainWindow *mainWindow
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
gtk_tree_view_insert_column_with_attributes(mainWindow->workspaceListView, -1, "", renderer,
|
||||
"markup", WSCOL_LABEL, NULL);
|
||||
|
||||
/* Test only */
|
||||
mainWindow_add_recent_workspace(mainWindow, "/home/user/Document/diary");
|
||||
mainWindow_add_recent_workspace(mainWindow, "/home/user/Document/workfoo");
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user