Skip to content

Commit

Permalink
Move more options to ConfOptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurent Monin committed Apr 11, 2008
1 parent 638d6c3 commit 9049047
Show file tree
Hide file tree
Showing 12 changed files with 160 additions and 166 deletions.
4 changes: 2 additions & 2 deletions src/collect-table.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ static void collection_table_update_extras(CollectTable *ct, gint loading, gdoub
static void collection_table_toggle_filenames(CollectTable *ct)
{
ct->show_text = !ct->show_text;
show_icon_names = ct->show_text;
options->show_icon_names = ct->show_text;

collection_table_populate_at_new_size(ct, ct->listview->allocation.width, ct->listview->allocation.height, TRUE);
}
Expand Down Expand Up @@ -2362,7 +2362,7 @@ CollectTable *collection_table_new(CollectionData *cd)
ct->focus_column = 0;
ct->focus_info = NULL;

ct->show_text = show_icon_names;
ct->show_text = options->show_icon_names;

ct->sync_idle_id = -1;
ct->drop_idle_id = -1;
Expand Down
51 changes: 23 additions & 28 deletions src/globals.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@

#include "main.h"

GList *filename_filter = NULL;
#ifdef DEBUG
gint debug = FALSE;
#endif


ConfOptions *init_options(ConfOptions *options)
{
Expand Down Expand Up @@ -108,37 +111,29 @@ ConfOptions *init_options(ConfOptions *options)

options->file_sort_case_sensitive = FALSE;

return options;
}

/* -- options -- */
#ifdef DEBUG
gint debug = FALSE;
#endif

/* layout */
options->layout_order = NULL;
options->layout_style = 0;

/* layout */
gchar *layout_order = NULL;
gint layout_style = 0;
options->layout_view_icons = FALSE;
options->layout_view_tree = FALSE;

gint layout_view_icons = FALSE;
gint layout_view_tree = FALSE;
options->show_icon_names = TRUE;

gint show_icon_names = TRUE;
options->tree_descend_subdirs = FALSE;

gint tree_descend_subdirs = FALSE;
options->lazy_image_sync = FALSE;
options->update_on_time_change = TRUE;
options->exif_rotate_enable = TRUE;

gint lazy_image_sync = FALSE;
gint update_on_time_change = TRUE;
gint exif_rotate_enable = TRUE;

/* color profiles */
gint color_profile_enabled = FALSE;
gint color_profile_input_type = 0;
gchar *color_profile_input_file[COLOR_PROFILE_INPUTS];
gchar *color_profile_input_name[COLOR_PROFILE_INPUTS];
gint color_profile_screen_type = 0;
gchar *color_profile_screen_file = NULL;
gint color_profile_use_image = TRUE;
/* color profiles */
options->color_profile_enabled = FALSE;
options->color_profile_input_type = 0;
options->color_profile_screen_type = 0;
options->color_profile_screen_file = NULL;
options->color_profile_use_image = TRUE;

options->filename_filter = NULL;

return options;
}
14 changes: 7 additions & 7 deletions src/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,10 @@ static gint image_post_process_color(ImageWindow *imd, gint start_row, ExifData
gint n;

n = imd->color_profile_input - 1;
if (!color_profile_input_file[n]) return FALSE;
if (!options->color_profile_input_file[n]) return FALSE;

input_type = COLOR_PROFILE_FILE;
input_file = color_profile_input_file[n];
input_file = options->color_profile_input_file[n];
}
else if (imd->color_profile_input == 0)
{
Expand All @@ -351,10 +351,10 @@ static gint image_post_process_color(ImageWindow *imd, gint start_row, ExifData
}

if (imd->color_profile_screen == 1 &&
color_profile_screen_file)
options->color_profile_screen_file)
{
screen_type = COLOR_PROFILE_FILE;
screen_file = color_profile_screen_file;
screen_file = options->color_profile_screen_file;
}
else if (imd->color_profile_screen == 0)
{
Expand Down Expand Up @@ -427,13 +427,13 @@ static void image_post_process(ImageWindow *imd, gint clamp)

if (!image_get_pixbuf(imd)) return;

if (exif_rotate_enable ||
if (options->exif_rotate_enable ||
(imd->color_profile_enable && imd->color_profile_use_image) )
{
exif = exif_read_fd(imd->image_fd, (imd->color_profile_enable && imd->color_profile_use_image));
}

if (exif_rotate_enable && exif)
if (options->exif_rotate_enable && exif)
{
gint orientation;

Expand Down Expand Up @@ -1522,7 +1522,7 @@ static gint image_auto_refresh_cb(gpointer data)

if (!imd || !image_get_pixbuf(imd) ||
imd->il || !imd->image_fd ||
!update_on_time_change) return TRUE;
!options->update_on_time_change) return TRUE;

newtime = filetime(imd->image_fd->path);
if (newtime > 0 && newtime != imd->mtime)
Expand Down
22 changes: 11 additions & 11 deletions src/layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ static void layout_color_button_press_cb(GtkWidget *widget, gpointer data)
buf = g_strdup_printf("%s %s", front, "sRGB");
g_free(front);
item = menu_item_add_radio(menu, NULL,
buf, (color_profile_input_type == 0),
buf, (options->color_profile_input_type == 0),
G_CALLBACK(layout_color_menu_input_cb), lw);
g_free(buf);
g_object_set_data(G_OBJECT(item), COLOR_MENU_KEY, GINT_TO_POINTER(0));
Expand All @@ -421,8 +421,8 @@ static void layout_color_button_press_cb(GtkWidget *widget, gpointer data)
{
const gchar *name;

name = color_profile_input_name[i];
if (!name) name = filename_from_path(color_profile_input_file[i]);
name = options->color_profile_input_name[i];
if (!name) name = filename_from_path(options->color_profile_input_file[i]);

front = g_strdup_printf(_("Input _%d:"), i + 1);
end = layout_color_name_parse(name);
Expand All @@ -435,7 +435,7 @@ static void layout_color_button_press_cb(GtkWidget *widget, gpointer data)
G_CALLBACK(layout_color_menu_input_cb), lw);
g_free(buf);
g_object_set_data(G_OBJECT(item), COLOR_MENU_KEY, GINT_TO_POINTER(i + 1));
gtk_widget_set_sensitive(item, active && color_profile_input_file[i]);
gtk_widget_set_sensitive(item, active && options->color_profile_input_file[i]);
}

menu_item_add_divider(menu);
Expand All @@ -452,7 +452,7 @@ static void layout_color_button_press_cb(GtkWidget *widget, gpointer data)
_("_Screen profile"), (screen == 1),
G_CALLBACK(layout_color_menu_screen_cb), lw);
g_object_set_data(G_OBJECT(item), COLOR_MENU_KEY, GINT_TO_POINTER(1));
gtk_widget_set_sensitive(item, active && color_profile_screen_file);
gtk_widget_set_sensitive(item, active && options->color_profile_screen_file);

gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, GDK_CURRENT_TIME);
#endif /* HAVE_LCMS */
Expand Down Expand Up @@ -995,7 +995,7 @@ gint layout_set_path(LayoutWindow *lw, const gchar *path)
layout_image_set_fd(lw, file_data_new_simple(path));
}
}
else if (!lazy_image_sync)
else if (!options->lazy_image_sync)
{
layout_image_set_index(lw, 0);
}
Expand Down Expand Up @@ -1039,7 +1039,7 @@ static gint layout_check_for_update_cb(gpointer data)
{
LayoutWindow *lw = data;

if (!update_on_time_change) return TRUE;
if (!options->update_on_time_change) return TRUE;

if (lw->path)
{
Expand Down Expand Up @@ -1704,7 +1704,7 @@ void layout_styles_update(void)
LayoutWindow *lw = work->data;
work = work->next;

layout_style_set(lw, layout_style, layout_order);
layout_style_set(lw, options->layout_style, options->layout_order);
}
}

Expand Down Expand Up @@ -1900,10 +1900,10 @@ LayoutWindow *layout_new_with_geometry(const gchar *path, gint popped, gint hidd

/* default layout */

layout_config_parse(layout_style, layout_order,
layout_config_parse(options->layout_style, options->layout_order,
&lw->dir_location, &lw->file_location, &lw->image_location);
lw->tree_view = layout_view_tree;
lw->icon_view = layout_view_icons;
lw->tree_view = options->layout_view_tree;
lw->icon_view = options->layout_view_icons;

/* divider positions */

Expand Down
7 changes: 4 additions & 3 deletions src/layout_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -1704,9 +1704,10 @@ GtkWidget *layout_image_new(LayoutWindow *lw, gint i)

layout_image_dnd_init(lw, i);
image_color_profile_set(lw->split_images[i],
color_profile_input_type, color_profile_screen_type,
color_profile_use_image);
image_color_profile_set_use(lw->split_images[i], color_profile_enabled);
options->color_profile_input_type,
options->color_profile_screen_type,
options->color_profile_use_image);
image_color_profile_set_use(lw->split_images[i], options->color_profile_enabled);
}

return lw->split_images[i]->widget;
Expand Down
15 changes: 8 additions & 7 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1174,8 +1174,8 @@ static void setup_default_options(void)

for (i = 0; i < COLOR_PROFILE_INPUTS; i++)
{
color_profile_input_file[i] = NULL;
color_profile_input_name[i] = NULL;
options->color_profile_input_file[i] = NULL;
options->color_profile_input_name[i] = NULL;
}

options->fullscreen_info = g_strdup("%collection%(%number%/%total%) <b>%name%</b>\n"
Expand Down Expand Up @@ -1209,7 +1209,7 @@ static void exit_program_final(void)

layout_geometry_get_dividers(NULL, &options->window_hdivider_pos, &options->window_vdivider_pos);

layout_views_get(NULL, &layout_view_tree, &layout_view_icons);
layout_views_get(NULL, &options->layout_view_tree, &options->layout_view_icons);

options->thumbnails_enabled = layout_thumb_get(NULL);
layout_sort_get(NULL, &options->file_sort_method, &options->file_sort_ascending);
Expand All @@ -1219,10 +1219,11 @@ static void exit_program_final(void)
layout_tools_float_get(NULL, &options->tools_float, &options->tools_hidden);
options->toolbar_hidden = layout_toolbar_hidden(NULL);

color_profile_enabled = layout_image_color_profile_get_use(NULL);
options->color_profile_enabled = layout_image_color_profile_get_use(NULL);
layout_image_color_profile_get(NULL,
&color_profile_input_type, &color_profile_screen_type,
&color_profile_use_image);
&options->color_profile_input_type,
&options->color_profile_screen_type,
&options->color_profile_use_image);

save_options();
keys_save();
Expand Down Expand Up @@ -1323,7 +1324,7 @@ int main (int argc, char *argv[])
printf("%s %s, This is an alpha release.\n", GQ_APPNAME, VERSION);
#endif
options = init_options(NULL);
layout_order = g_strdup("123");
options->layout_order = g_strdup("123"); /* TODO: move to init_options() */
setup_default_options();
load_options();

Expand Down
30 changes: 0 additions & 30 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,43 +112,13 @@ ConfOptions *init_options(ConfOptions *options); /* TODO: move to globals.h */

ConfOptions *options;

/*
* Since globals are used everywhere,
* it is easier to define them here.
*/

extern GList *filename_filter;

/* -- options -- */


#ifdef DEBUG
extern gint debug;
#endif


/* layout */
extern gchar *layout_order;
extern gint layout_style;

extern gint layout_view_icons;
extern gint layout_view_tree;

extern gint show_icon_names;

extern gint tree_descend_subdirs;

extern gint lazy_image_sync;
extern gint update_on_time_change;
extern gint exif_rotate_enable;

extern gint color_profile_enabled;
extern gint color_profile_input_type;
extern gchar *color_profile_input_file[];
extern gchar *color_profile_input_name[];
extern gint color_profile_screen_type;
extern gchar *color_profile_screen_file;
extern gint color_profile_use_image;

/*
*----------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 9049047

Please sign in to comment.