Skip to content

Commit

Permalink
improved config file formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
nadvornik committed Mar 19, 2009
1 parent 5cd0768 commit 75ad70e
Show file tree
Hide file tree
Showing 12 changed files with 183 additions and 189 deletions.
8 changes: 3 additions & 5 deletions src/bar.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,10 @@ void bar_write_config(GtkWidget *bar, GString *outstr, gint indent)
bd = g_object_get_data(G_OBJECT(bar), "bar_data");
if (!bd) return;

WRITE_STRING("<bar\n");
indent++;
WRITE_NL(); WRITE_STRING("<bar ");
write_bool_option(outstr, indent, "enabled", GTK_WIDGET_VISIBLE(bar));
write_uint_option(outstr, indent, "width", bd->width);
indent--;
WRITE_STRING(">\n");
WRITE_STRING(">");

list = gtk_container_get_children(GTK_CONTAINER(bd->vbox));
work = list;
Expand All @@ -186,7 +184,7 @@ void bar_write_config(GtkWidget *bar, GString *outstr, gint indent)
}
g_list_free(list);

WRITE_STRING("</bar>\n");
WRITE_NL(); WRITE_STRING("</bar>");
}


Expand Down
6 changes: 2 additions & 4 deletions src/bar_comment.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,12 @@ static void bar_pane_comment_write_config(GtkWidget *pane, GString *outstr, gint
pcd = g_object_get_data(G_OBJECT(pane), "pane_data");
if (!pcd) return;

WRITE_STRING("<pane_comment\n");
indent++;
WRITE_NL(); WRITE_STRING("<pane_comment ");
write_char_option(outstr, indent, "pane.title", gtk_label_get_text(GTK_LABEL(pcd->pane.title)));
WRITE_BOOL(*pcd, pane.expanded);
WRITE_CHAR(*pcd, key);
WRITE_INT(*pcd, height);
indent--;
WRITE_STRING("/>\n");
WRITE_STRING("/>");
}

static void bar_pane_comment_notify_cb(FileData *fd, NotifyType type, gpointer data)
Expand Down
14 changes: 5 additions & 9 deletions src/bar_exif.c
Original file line number Diff line number Diff line change
Expand Up @@ -636,14 +636,12 @@ static void bar_pane_exif_entry_write_config(GtkWidget *entry, GString *outstr,
ExifEntry *ee = g_object_get_data(G_OBJECT(entry), "entry_data");
if (!ee) return;

WRITE_STRING("<entry\n");
indent++;
WRITE_NL(); WRITE_STRING("<entry ");
WRITE_CHAR(*ee, key);
if (!ee->auto_title) WRITE_CHAR(*ee, title);
WRITE_BOOL(*ee, if_set);
WRITE_BOOL(*ee, editable);
indent--;
WRITE_STRING("/>\n");
WRITE_STRING("/>");
}

static void bar_pane_exif_write_config(GtkWidget *pane, GString *outstr, gint indent)
Expand All @@ -654,12 +652,10 @@ static void bar_pane_exif_write_config(GtkWidget *pane, GString *outstr, gint in
ped = g_object_get_data(G_OBJECT(pane), "pane_data");
if (!ped) return;

WRITE_STRING("<pane_exif\n");
indent++;
WRITE_NL(); WRITE_STRING("<pane_exif ");
write_char_option(outstr, indent, "pane.title", gtk_label_get_text(GTK_LABEL(ped->pane.title)));
WRITE_BOOL(*ped, pane.expanded);
indent--;
WRITE_STRING(">\n");
WRITE_STRING(">");
indent++;

list = gtk_container_get_children(GTK_CONTAINER(ped->vbox));
Expand All @@ -673,7 +669,7 @@ static void bar_pane_exif_write_config(GtkWidget *pane, GString *outstr, gint in
}
g_list_free(list);
indent--;
WRITE_STRING("</pane_exif>\n");
WRITE_NL(); WRITE_STRING("</pane_exif>");
}


Expand Down
6 changes: 2 additions & 4 deletions src/bar_histogram.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,12 @@ static void bar_pane_histogram_write_config(GtkWidget *pane, GString *outstr, gi
phd = g_object_get_data(G_OBJECT(pane), "pane_data");
if (!phd) return;

WRITE_STRING("<pane_histogram\n");
indent++;
WRITE_NL(); WRITE_STRING("<pane_histogram ");
write_char_option(outstr, indent, "pane.title", gtk_label_get_text(GTK_LABEL(phd->pane.title)));
WRITE_BOOL(*phd, pane.expanded);
WRITE_INT(*phd->histogram, histogram_channel);
WRITE_INT(*phd->histogram, histogram_mode);
indent--;
WRITE_STRING("/>\n");
WRITE_STRING("/>");
}

static void bar_pane_histogram_notify_cb(FileData *fd, NotifyType type, gpointer data)
Expand Down
6 changes: 2 additions & 4 deletions src/bar_keywords.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,11 @@ static void bar_pane_keywords_write_config(GtkWidget *pane, GString *outstr, gin
pkd = g_object_get_data(G_OBJECT(pane), "pane_data");
if (!pkd) return;

WRITE_STRING("<pane_keywords\n");
indent++;
WRITE_NL(); WRITE_STRING("<pane_keywords ");
write_char_option(outstr, indent, "pane.title", gtk_label_get_text(GTK_LABEL(pkd->pane.title)));
WRITE_BOOL(*pkd, pane.expanded);
WRITE_CHAR(*pkd, key);
indent--;
WRITE_STRING("/>\n");
WRITE_STRING("/>");
}

gint bar_pane_keywords_event(GtkWidget *bar, GdkEvent *event)
Expand Down
6 changes: 2 additions & 4 deletions src/bar_sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,15 +723,13 @@ void bar_sort_write_config(GtkWidget *bar, GString *outstr, gint indent)
sd = g_object_get_data(G_OBJECT(bar), "bar_sort_data");
if (!sd) return;

WRITE_STRING("<bar_sort\n");
indent++;
WRITE_NL(); WRITE_STRING("<bar_sort ");
write_bool_option(outstr, indent, "enabled", GTK_WIDGET_VISIBLE(bar));
WRITE_INT(*sd, mode);
WRITE_INT(*sd, action);
WRITE_INT(*sd, selection);
WRITE_CHAR(*sd, filter_key);
indent--;
WRITE_STRING("/>\n");
WRITE_STRING("/>");
}


Expand Down
10 changes: 4 additions & 6 deletions src/filefilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ void filter_write_list(GString *outstr, gint indent)
{
GList *work;

WRITE_STRING("<filter>\n");
WRITE_NL(); WRITE_STRING("<filter>");
indent++;

work = filter_list;
Expand All @@ -427,20 +427,18 @@ void filter_write_list(GString *outstr, gint indent)
FilterEntry *fe = work->data;
work = work->next;

WRITE_STRING("<file_type\n");
indent++;
WRITE_NL(); WRITE_STRING("<file_type ");
WRITE_CHAR(*fe, key);
WRITE_BOOL(*fe, enabled);
WRITE_CHAR(*fe, extensions);
WRITE_CHAR(*fe, description);
WRITE_UINT(*fe, file_class);
WRITE_BOOL(*fe, writable);
WRITE_BOOL(*fe, allow_sidecar);
indent--;
WRITE_STRING("/>\n");
WRITE_STRING("/>");
}
indent--;
WRITE_STRING("</filter>\n");
WRITE_NL(); WRITE_STRING("</filter>");
}

void filter_load_file_type(const gchar **attribute_names, const gchar **attribute_values)
Expand Down
64 changes: 32 additions & 32 deletions src/layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -2328,62 +2328,62 @@ LayoutWindow *layout_new_with_geometry(FileData *dir_fd, LayoutOptions *lop,

void layout_write_attributes(LayoutOptions *layout, GString *outstr, gint indent)
{
WRITE_INT(*layout, style);
WRITE_CHAR(*layout, order);
WRITE_UINT(*layout, dir_view_type);
WRITE_UINT(*layout, file_view_type);
WRITE_BOOL(*layout, show_marks);
WRITE_BOOL(*layout, show_thumbnails);
WRITE_BOOL(*layout, show_directory_date);
WRITE_CHAR(*layout, home_path);
WRITE_NL(); WRITE_INT(*layout, style);
WRITE_NL(); WRITE_CHAR(*layout, order);
WRITE_NL(); WRITE_UINT(*layout, dir_view_type);
WRITE_NL(); WRITE_UINT(*layout, file_view_type);
WRITE_NL(); WRITE_BOOL(*layout, show_marks);
WRITE_NL(); WRITE_BOOL(*layout, show_thumbnails);
WRITE_NL(); WRITE_BOOL(*layout, show_directory_date);
WRITE_NL(); WRITE_CHAR(*layout, home_path);
WRITE_SEPARATOR();

WRITE_INT(*layout, main_window.x);
WRITE_INT(*layout, main_window.y);
WRITE_INT(*layout, main_window.w);
WRITE_INT(*layout, main_window.h);
WRITE_BOOL(*layout, main_window.maximized);
WRITE_INT(*layout, main_window.hdivider_pos);
WRITE_INT(*layout, main_window.vdivider_pos);
WRITE_NL(); WRITE_INT(*layout, main_window.x);
WRITE_NL(); WRITE_INT(*layout, main_window.y);
WRITE_NL(); WRITE_INT(*layout, main_window.w);
WRITE_NL(); WRITE_INT(*layout, main_window.h);
WRITE_NL(); WRITE_BOOL(*layout, main_window.maximized);
WRITE_NL(); WRITE_INT(*layout, main_window.hdivider_pos);
WRITE_NL(); WRITE_INT(*layout, main_window.vdivider_pos);
WRITE_SEPARATOR();

WRITE_INT(*layout, float_window.x);
WRITE_INT(*layout, float_window.y);
WRITE_INT(*layout, float_window.w);
WRITE_INT(*layout, float_window.h);
WRITE_INT(*layout, float_window.vdivider_pos);
WRITE_NL(); WRITE_INT(*layout, float_window.x);
WRITE_NL(); WRITE_INT(*layout, float_window.y);
WRITE_NL(); WRITE_INT(*layout, float_window.w);
WRITE_NL(); WRITE_INT(*layout, float_window.h);
WRITE_NL(); WRITE_INT(*layout, float_window.vdivider_pos);
WRITE_SEPARATOR();

WRITE_INT(*layout, properties_window.w);
WRITE_INT(*layout, properties_window.h);
WRITE_NL(); WRITE_INT(*layout, properties_window.w);
WRITE_NL(); WRITE_INT(*layout, properties_window.h);
WRITE_SEPARATOR();

WRITE_BOOL(*layout, tools_float);
WRITE_BOOL(*layout, tools_hidden);
WRITE_NL(); WRITE_BOOL(*layout, tools_float);
WRITE_NL(); WRITE_BOOL(*layout, tools_hidden);
WRITE_SEPARATOR();

WRITE_BOOL(*layout, toolbar_hidden);
WRITE_BOOL(*layout, info_pixel_hidden);
WRITE_NL(); WRITE_BOOL(*layout, toolbar_hidden);
WRITE_NL(); WRITE_BOOL(*layout, info_pixel_hidden);

WRITE_UINT(*layout, image_overlay.state);
WRITE_INT(*layout, image_overlay.histogram_channel);
WRITE_INT(*layout, image_overlay.histogram_mode);
WRITE_NL(); WRITE_UINT(*layout, image_overlay.state);
WRITE_NL(); WRITE_INT(*layout, image_overlay.histogram_channel);
WRITE_NL(); WRITE_INT(*layout, image_overlay.histogram_mode);
}


void layout_write_config(LayoutWindow *lw, GString *outstr, gint indent)
{
layout_sync_options_with_current_state(lw);
WRITE_STRING("<layout\n");
WRITE_NL(); WRITE_STRING("<layout");
layout_write_attributes(&lw->options, outstr, indent + 1);
WRITE_STRING(">\n");
WRITE_STRING(">");

bar_sort_write_config(lw->bar_sort, outstr, indent + 1);
bar_write_config(lw->bar, outstr, indent + 1);

layout_toolbar_write_config(lw, outstr, indent + 1);

WRITE_STRING("</layout>\n");
WRITE_NL(); WRITE_STRING("</layout>");
}

void layout_load_attributes(LayoutOptions *layout, const gchar **attribute_names, const gchar **attribute_values)
Expand Down
8 changes: 4 additions & 4 deletions src/layout_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1819,18 +1819,18 @@ void layout_toolbar_add_default(LayoutWindow *lw)
void layout_toolbar_write_config(LayoutWindow *lw, GString *outstr, gint indent)
{
GList *work = lw->toolbar_actions;
WRITE_STRING("<toolbar>\n");
WRITE_NL(); WRITE_STRING("<toolbar>");
indent++;
while (work)
{
gchar *action = work->data;
work = work->next;
WRITE_STRING("<toolitem\n");
WRITE_NL(); WRITE_STRING("<toolitem ");
write_char_option(outstr, indent + 1, "action", action);
WRITE_STRING("/>\n");
WRITE_STRING("/>");
}
indent--;
WRITE_STRING("</toolbar>\n");
WRITE_NL(); WRITE_STRING("</toolbar>");
}

void layout_toolbar_add_from_config(LayoutWindow *lw, const gchar **attribute_names, const gchar **attribute_values)
Expand Down
20 changes: 11 additions & 9 deletions src/metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -1239,37 +1239,39 @@ static void keyword_tree_node_write_config(GtkTreeModel *keyword_tree, GtkTreeIt
GtkTreeIter children;
gchar *name;

WRITE_STRING("<keyword\n");
indent++;
WRITE_NL(); WRITE_STRING("<keyword ");
name = keyword_get_name(keyword_tree, &iter);
write_char_option(outstr, indent, "name", name);
g_free(name);
write_bool_option(outstr, indent, "kw", keyword_get_is_keyword(keyword_tree, &iter));
indent--;
WRITE_STRING(">\n");
indent++;
if (gtk_tree_model_iter_children(keyword_tree, &children, &iter))
{
WRITE_STRING(">");
indent++;
keyword_tree_node_write_config(keyword_tree, &children, outstr, indent);
indent--;
WRITE_NL(); WRITE_STRING("</keyword>");
}
else
{
WRITE_STRING("/>");
}
indent--;
WRITE_STRING("</keyword>\n");
if (!gtk_tree_model_iter_next(keyword_tree, &iter)) return;
}
}

void keyword_tree_write_config(GString *outstr, gint indent)
{
GtkTreeIter iter;
WRITE_STRING("<keyword_tree>\n");
WRITE_NL(); WRITE_STRING("<keyword_tree>");
indent++;

if (keyword_tree && gtk_tree_model_get_iter_first(GTK_TREE_MODEL(keyword_tree), &iter))
{
keyword_tree_node_write_config(GTK_TREE_MODEL(keyword_tree), &iter, outstr, indent);
}
indent--;
WRITE_STRING("</keyword_tree>\n");
WRITE_NL(); WRITE_STRING("</keyword_tree>");
}

GtkTreeIter *keyword_add_from_config(GtkTreeStore *keyword_tree, GtkTreeIter *parent, const gchar **attribute_names, const gchar **attribute_values)
Expand Down
Loading

0 comments on commit 75ad70e

Please sign in to comment.