Unverified Commit 724db815 authored by peterbud's avatar peterbud Committed by Tobias Ellinghaus

Some cleanups, picked from PR 1327

These are generic code changes not directly related to the PR's purpose,
so let's pick them separately to make the changes to reason about less.
parent 8ff91a22
......@@ -9,4 +9,5 @@ tools/iop_deps.pdf
.DS_Store
cscope.out
.*.swp
.vscode/
......@@ -167,7 +167,7 @@ num_cpu()
SunOS)
ncpu=$(/usr/sbin/psrinfo |wc -l)
;;
Linux)
Linux|MINGW64*)
if [ -r /proc/cpuinfo ]; then
ncpu=$(grep -c "^processor" /proc/cpuinfo)
elif [ -x /sbin/sysctl ]; then
......
......@@ -397,7 +397,7 @@ int dt_init(int argc, char *argv[], const gboolean init_gui, const gboolean load
{
// check if DARKTABLE_SHAREDIR is already in there
gboolean found = FALSE;
gchar **tokens = g_strsplit(xdg_data_dirs, ":", 0);
gchar **tokens = g_strsplit(xdg_data_dirs, G_SEARCHPATH_SEPARATOR_S, 0);
// xdg_data_dirs is neither NULL nor empty => tokens != NULL
for(char **iter = tokens; *iter != NULL; iter++)
if(!strcmp(DARKTABLE_SHAREDIR, *iter))
......@@ -409,7 +409,7 @@ int dt_init(int argc, char *argv[], const gboolean init_gui, const gboolean load
if(found)
set_env = FALSE;
else
new_xdg_data_dirs = g_strjoin(":", DARKTABLE_SHAREDIR, xdg_data_dirs, NULL);
new_xdg_data_dirs = g_strjoin(G_SEARCHPATH_SEPARATOR_S, DARKTABLE_SHAREDIR, xdg_data_dirs, NULL);
}
else
{
......@@ -756,10 +756,10 @@ int dt_init(int argc, char *argv[], const gboolean init_gui, const gboolean load
const gchar *lang = dt_conf_get_string("ui_last/gui_language");
if(lang != NULL && lang[0] != '\0')
{
setenv("LANGUAGE", lang, 1);
g_setenv("LANGUAGE", lang, 1);
if(setlocale(LC_ALL, lang) != NULL) gtk_disable_setlocale();
setlocale(LC_MESSAGES, lang);
setenv("LANG", lang, 1);
g_setenv("LANG", lang, 1);
}
g_free((gchar *)lang);
......@@ -914,7 +914,7 @@ int dt_init(int argc, char *argv[], const gboolean init_gui, const gboolean load
darktable.lib = (dt_lib_t *)calloc(1, sizeof(dt_lib_t));
dt_lib_init(darktable.lib);
dt_control_load_config(darktable.control);
dt_gui_gtk_load_config();
}
dt_control_gui_mode_t mode = DT_LIBRARY;
......@@ -1020,7 +1020,6 @@ void dt_cleanup()
dt_ctl_switch_mode_to(DT_MODE_NONE);
dt_dbus_destroy(darktable.dbus);
dt_control_write_config(darktable.control);
dt_control_shutdown(darktable.control);
dt_lib_cleanup(darktable.lib);
......
......@@ -102,7 +102,7 @@ const char *dt_image_film_roll_name(const char *path)
if(numparts < 1) numparts = 1;
while(folder > path)
{
if(*folder == '/')
if(*folder == G_DIR_SEPARATOR)
if(++count >= numparts)
{
++folder;
......
......@@ -26,6 +26,9 @@
#include <unistd.h>
#endif
#include <math.h>
#include <glib/gi18n.h>
#include <sys/stat.h>
#ifdef HAVE_CONFIG_H
......
......@@ -43,53 +43,6 @@
#include <strings.h>
int dt_control_load_config(dt_control_t *c)
{
GtkWidget *widget = dt_ui_main_window(darktable.gui->ui);
dt_conf_set_int("ui_last/view", DT_MODE_NONE);
int width = dt_conf_get_int("ui_last/window_w");
int height = dt_conf_get_int("ui_last/window_h");
#ifndef __WIN32__
gint x = dt_conf_get_int("ui_last/window_x");
gint y = dt_conf_get_int("ui_last/window_y");
gtk_window_move(GTK_WINDOW(widget), x, y);
#endif
gtk_window_resize(GTK_WINDOW(widget), width, height);
int fullscreen = dt_conf_get_bool("ui_last/fullscreen");
if(fullscreen)
gtk_window_fullscreen(GTK_WINDOW(widget));
else
{
gtk_window_unfullscreen(GTK_WINDOW(widget));
int maximized = dt_conf_get_bool("ui_last/maximized");
if(maximized)
gtk_window_maximize(GTK_WINDOW(widget));
else
gtk_window_unmaximize(GTK_WINDOW(widget));
}
return 0;
}
int dt_control_write_config(dt_control_t *c)
{
// TODO: move to gtk.c
GtkWidget *widget = dt_ui_main_window(darktable.gui->ui);
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
gint x, y;
gtk_window_get_position(GTK_WINDOW(widget), &x, &y);
dt_conf_set_int("ui_last/window_x", x);
dt_conf_set_int("ui_last/window_y", y);
dt_conf_set_int("ui_last/window_w", allocation.width);
dt_conf_set_int("ui_last/window_h", allocation.height);
dt_conf_set_bool("ui_last/maximized",
(gdk_window_get_state(gtk_widget_get_window(widget)) & GDK_WINDOW_STATE_MAXIMIZED));
dt_conf_set_bool("ui_last/fullscreen",
(gdk_window_get_state(gtk_widget_get_window(widget)) & GDK_WINDOW_STATE_FULLSCREEN));
return 0;
}
void dt_control_init(dt_control_t *s)
{
memset(s->vimkey, 0, sizeof(s->vimkey));
......
......@@ -236,9 +236,6 @@ void dt_control_cleanup(dt_control_t *s);
// call this to quit dt
void dt_control_quit();
int dt_control_load_config(dt_control_t *c);
int dt_control_write_config(dt_control_t *c);
/** get threadsafe running state. */
int dt_control_running();
......
......@@ -477,9 +477,56 @@ static gboolean borders_scrolled(GtkWidget *widget, GdkEventScroll *event, gpoin
return TRUE;
}
int dt_gui_gtk_load_config()
{
GtkWidget *widget = dt_ui_main_window(darktable.gui->ui);
dt_conf_set_int("ui_last/view", DT_MODE_NONE);
int width = dt_conf_get_int("ui_last/window_w");
int height = dt_conf_get_int("ui_last/window_h");
gint x = MAX(0, dt_conf_get_int("ui_last/window_x"));
gint y = MAX(0, dt_conf_get_int("ui_last/window_y"));
gtk_window_move(GTK_WINDOW(widget), x, y);
gtk_window_resize(GTK_WINDOW(widget), width, height);
int fullscreen = dt_conf_get_bool("ui_last/fullscreen");
if(fullscreen)
gtk_window_fullscreen(GTK_WINDOW(widget));
else
{
gtk_window_unfullscreen(GTK_WINDOW(widget));
int maximized = dt_conf_get_bool("ui_last/maximized");
if(maximized)
gtk_window_maximize(GTK_WINDOW(widget));
else
gtk_window_unmaximize(GTK_WINDOW(widget));
}
return 0;
}
int dt_gui_gtk_write_config()
{
GtkWidget *widget = dt_ui_main_window(darktable.gui->ui);
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
gint x, y;
gtk_window_get_position(GTK_WINDOW(widget), &x, &y);
dt_conf_set_int("ui_last/window_x", x);
dt_conf_set_int("ui_last/window_y", y);
dt_conf_set_int("ui_last/window_w", allocation.width);
dt_conf_set_int("ui_last/window_h", allocation.height);
dt_conf_set_bool("ui_last/maximized",
(gdk_window_get_state(gtk_widget_get_window(widget)) & GDK_WINDOW_STATE_MAXIMIZED));
dt_conf_set_bool("ui_last/fullscreen",
(gdk_window_get_state(gtk_widget_get_window(widget)) & GDK_WINDOW_STATE_FULLSCREEN));
return 0;
}
void dt_gui_gtk_quit()
{
GtkWindow *win = GTK_WINDOW(dt_ui_main_window(darktable.gui->ui));
// Write out windows dimension before miminizing
dt_gui_gtk_write_config();
gtk_window_iconify(win);
GtkWidget *widget;
......
......@@ -135,6 +135,8 @@ void dt_gui_gtk_run(dt_gui_gtk_t *gui);
void dt_gui_gtk_cleanup(dt_gui_gtk_t *gui);
void dt_gui_gtk_quit();
void dt_gui_store_last_preset(const char *name);
int dt_gui_gtk_load_config();
int dt_gui_gtk_write_config();
/** block any keyaccelerators when widget have focus, block is released when widget lose focus. */
void dt_gui_key_accel_block_on_focus_connect(GtkWidget *w);
......
......@@ -243,11 +243,11 @@ void *legacy_params(dt_imageio_module_format_t *self, const void *const old_para
{
enum dt_imageio_exr_pixeltype_t
{
UINT = 0, // unsigned int (32 bit)
HALF = 1, // half (16 bit floating point)
FLOAT = 2, // float (32 bit floating point)
NUM_PIXELTYPES // number of different pixel types
}; // copy of Imf::PixelType
EXR_PT_UINT = 0, // unsigned int (32 bit)
EXR_PT_HALF = 1, // half (16 bit floating point)
EXR_PT_FLOAT = 2, // float (32 bit floating point)
NUM_PIXELTYPES // number of different pixel types
}; // copy of Imf::PixelType
struct dt_imageio_exr_v2_t
{
......
......@@ -1931,7 +1931,7 @@ static int reduce_region_radius( struct point * reg, int * reg_size,
image_char used, image_double angles,
double density_th )
{
double density,rad1,rad2,rad,xc,yc;
double density,radius1,radius2,rad,xc,yc;
int i;
/* check parameters */
......@@ -1955,9 +1955,9 @@ static int reduce_region_radius( struct point * reg, int * reg_size,
/* compute region's radius */
xc = (double) reg[0].x;
yc = (double) reg[0].y;
rad1 = dist( xc, yc, rec->x1, rec->y1 );
rad2 = dist( xc, yc, rec->x2, rec->y2 );
rad = rad1 > rad2 ? rad1 : rad2;
radius1 = dist( xc, yc, rec->x1, rec->y1 );
radius2 = dist( xc, yc, rec->x2, rec->y2 );
rad = radius1 > radius2 ? radius1 : radius2;
/* while the density criterion is not satisfied, remove farther pixels */
while( density < density_th )
......
......@@ -422,9 +422,9 @@ void process(struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, const
}
// convert from world space:
float rad10[2] = { circle->radius, circle->radius };
float radius10[2] = { circle->radius, circle->radius };
float radf[2];
masks_point_denormalize(piece, roi_in, rad10, 1, radf);
masks_point_denormalize(piece, roi_in, radius10, 1, radf);
const int rad = MIN(radf[0], radf[1]);
const int posx = points[0] - rad;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment