Commit 3a07897d authored by Elias Alejandro's avatar Elias Alejandro

New upstream version 0.2.5+git20161221

parent 9e6323d9
......@@ -185,10 +185,14 @@ env.Alias(target="install", source=[
env.InstallDataAutoDir(dir=env['DESTDIR'] + '/share/locale/', relative_dir='share/locale/', source=[env.Glob('share/locale/*/LC_MESSAGES/gpick.mo')]),
])
env.Alias(target="nsis", source=[
env.Alias(target = "nsis", source = [
env.WriteNsisVersion("version.py")
])
env.Alias(target = "version", source = [
env.Template(target = "#version.txt", source = "version.template"),
])
tarFiles = env.GetSourceFiles( "("+RegexEscape(os.sep)+r"\.)|("+RegexEscape(os.sep)+r"\.svn$)|(^"+RegexEscape(os.sep)+r"build$)", r"(^\.)|(\.pyc$)|(\.orig$)|(~$)|(\.log$)|(\.diff)|(\.mo$)|(\.patch)|(^gpick-.*\.tar\.gz$)|(^user-config\.py$)")
for item in parser_files:
......@@ -196,7 +200,7 @@ for item in parser_files:
if 'TAR' in env:
env.Alias(target = "tar", source = [
env.Template(target = "#version.txt", source = "version.template"),
'version',
env.Append(TARFLAGS = ['-z']),
env.Prepend(TARFLAGS = ['--transform', '"s,(^(build/)?),gpick_'+str(env['GPICK_BUILD_VERSION'])+'/,x"']),
env.Tar('gpick_'+str(env['GPICK_BUILD_VERSION'])+'.tar.gz', tarFiles)
......
......@@ -26,8 +26,8 @@
<url type="bugtracker">https://github.com/thezbyg/gpick</url>
<update_contact>albertas.vysniauskas@gpick.org</update_contact>
<developer_name>Albertas Vyšniauskas</developer_name>
<url type="donation">http://www.gpick.org</url>
<url type="help">https://www.gpick.org/help</url>
<url type="donation">http://www.gpick.org/help/donation.html</url>
<url type="help">http://www.gpick.org/help.html</url>
<translation type="gettext">gpick</translation>
<keywords>
<keyword>color</keyword>
......@@ -37,5 +37,5 @@
<keyword>palette</keyword>
<keyword>scheme</keyword>
</keywords>
<url type="translate">http://www.gpick.org/translation</url>
<url type="translate">http://www.gpick.org/help/translation.html</url>
</component>
......@@ -269,7 +269,7 @@ static gboolean preview_list_button_press_cb(GtkWidget *widget, GdkEventButton *
gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new());
if (selection_avail){
ColorList *color_list = color_list_new(nullptr);
ColorList *color_list = color_list_new();
palette_list_forfirst_selected(args->preview_list, color_list_selected, color_list);
if (color_list_get_count(color_list) != 0){
StandardMenu::appendMenu(menu, *color_list->colors.begin(), args->preview_list, args->gs);
......
......@@ -60,7 +60,7 @@ void Clipboard::set(GtkWidget *palette_widget, GlobalState *gs, Converter *conve
if (converter == nullptr)
converter = converters_get_first(gs->getConverters(), ConverterArrayType::copy);
stringstream text(ios::out);
ColorList *color_list = color_list_new(nullptr);
ColorList *color_list = color_list_new();
palette_list_foreach_selected(palette_widget, (PaletteListCallback)addToColorList, color_list);
string text_line;
ConverterSerializePosition position(color_list->colors.size());
......
This diff is collapsed.
/*
* Copyright (c) 2009-2016, Albertas Vyšniauskas
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* * Neither the name of the software author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef GPICK_CLOSEST_COLORS_H_
#define GPICK_CLOSEST_COLORS_H_
struct ColorSourceManager;
int closest_colors_source_register(ColorSourceManager *csm);
#endif /* GPICK_CLOSEST_COLORS_H_ */
......@@ -22,14 +22,10 @@
#include <algorithm>
using namespace std;
ColorList* color_list_new(struct dynvHandlerMap* handler_map)
ColorList* color_list_new()
{
ColorList* color_list = new ColorList;
if (handler_map){
color_list->params = dynv_system_create(handler_map);
}else{
color_list->params = nullptr;
}
color_list->params = nullptr;
color_list->on_insert = nullptr;
color_list->on_change = nullptr;
color_list->on_delete = nullptr;
......@@ -39,9 +35,31 @@ ColorList* color_list_new(struct dynvHandlerMap* handler_map)
color_list->userdata = nullptr;
return color_list;
}
ColorList* color_list_new(ColorList *color_list)
{
ColorList *result = color_list_new();
if (color_list){
dynvHandlerMap *handler_map = dynv_system_get_handler_map(color_list->params);
result->params = dynv_system_create(handler_map);
dynv_handler_map_release(handler_map);
}else{
result->params = nullptr;
}
return result;
}
ColorList* color_list_new(struct dynvHandlerMap* handler_map)
{
ColorList *result = color_list_new();
if (handler_map){
result->params = dynv_system_create(handler_map);
}else{
result->params = nullptr;
}
return result;
}
ColorList* color_list_new_with_one_color(ColorList *template_color_list, const Color *color)
{
ColorList *color_list = color_list_new(nullptr);
ColorList *color_list = color_list_new();
ColorObject *color_object = new ColorObject("", *color);
color_list_add_color_object(color_list, color_object, 1);
return color_list;
......@@ -71,13 +89,22 @@ ColorObject* color_list_add_color(ColorList *color_list, const Color *color)
return 0;
}
}
int color_list_add_color_object(ColorList *color_list, ColorObject *color_object, int add_to_palette)
int color_list_add_color_object(ColorList *color_list, ColorObject *color_object, bool add_to_palette)
{
color_list->colors.push_back(color_object->reference());
if (add_to_palette && color_list->on_insert)
color_list->on_insert(color_list, color_object);
return 0;
}
int color_list_add(ColorList *color_list, ColorList *items, bool add_to_palette)
{
for (auto color_object: items->colors){
color_list->colors.push_back(color_object->reference());
if (add_to_palette && color_list->on_insert && color_object->isVisible())
color_list->on_insert(color_list, color_object);
}
return 0;
}
int color_list_remove_color_object(ColorList *color_list, ColorObject *color_object)
{
list<ColorObject*>::iterator i = std::find(color_list->colors.begin(), color_list->colors.end(), color_object);
......
......@@ -40,12 +40,15 @@ class ColorList
void* userdata;
};
ColorList* color_list_new();
ColorList* color_list_new(struct dynvHandlerMap *handler_map);
ColorList* color_list_new(ColorList *color_list);
ColorList* color_list_new_with_one_color(ColorList *template_color_list, const Color *color);
void color_list_destroy(ColorList *color_list);
ColorObject* color_list_new_color_object(ColorList *color_list, const Color *color);
ColorObject* color_list_add_color(ColorList *color_list, const Color *color);
int color_list_add_color_object(ColorList *color_list, ColorObject *color_object, int add_to_palette);
int color_list_add_color_object(ColorList *color_list, ColorObject *color_object, bool add_to_palette);
int color_list_add(ColorList *color_list, ColorList *items, bool add_to_palette);
int color_list_remove_color_object(ColorList *color_list, ColorObject *color_object);
int color_list_remove_selected(ColorList *color_list);
int color_list_remove_all(ColorList *color_list);
......
......@@ -26,7 +26,8 @@ ColorObject::ColorObject():
m_position(0),
m_position_set(false),
m_selected(false),
m_visited(false)
m_visited(false),
m_visible(true)
{
}
ColorObject::ColorObject(const char *name, const Color &color):
......@@ -36,7 +37,8 @@ ColorObject::ColorObject(const char *name, const Color &color):
m_position(0),
m_position_set(false),
m_selected(false),
m_visited(false)
m_visited(false),
m_visible(true)
{
}
ColorObject::ColorObject(const std::string &name, const Color &color):
......@@ -46,7 +48,8 @@ ColorObject::ColorObject(const std::string &name, const Color &color):
m_position(0),
m_position_set(false),
m_selected(false),
m_visited(false)
m_visited(false),
m_visible(true)
{
}
ColorObject *ColorObject::reference()
......@@ -103,6 +106,10 @@ bool ColorObject::isPositionSet() const
{
return m_position_set;
}
bool ColorObject::isVisible() const
{
return m_visible;
}
void ColorObject::setPosition(size_t position)
{
m_position = position;
......@@ -120,6 +127,10 @@ void ColorObject::setVisited(bool visited)
{
m_visited = visited;
}
void ColorObject::setVisible(bool visible)
{
m_visible = visible;
}
size_t ColorObject::getReferenceCount() const
{
return m_refcnt;
......
......@@ -45,6 +45,8 @@ class ColorObject
void setSelected(bool selected);
void setVisited(bool visited);
size_t getReferenceCount() const;
void setVisible(bool visible);
bool isVisible() const;
private:
size_t m_refcnt;
std::string m_name;
......@@ -53,6 +55,7 @@ class ColorObject
bool m_position_set;
bool m_selected;
bool m_visited;
bool m_visible;
};
#endif /* GPICK_COLOR_OBJECT_H_ */
......@@ -655,58 +655,45 @@ static void on_oversample_falloff_changed(GtkWidget *widget, gpointer data) {
}
}
static GtkWidget* create_falloff_type_list (void){
GtkListStore *store;
GtkCellRenderer *renderer;
GtkWidget *widget;
store = gtk_list_store_new (3, GDK_TYPE_PIXBUF,G_TYPE_STRING,G_TYPE_INT);
widget = gtk_combo_box_new_with_model (GTK_TREE_MODEL(store));
gtk_combo_box_set_add_tearoffs (GTK_COMBO_BOX (widget), 0);
renderer = gtk_cell_renderer_pixbuf_new();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (widget),renderer,0);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (widget), renderer,"pixbuf",0,nullptr);
static GtkWidget* create_falloff_type_list()
{
GtkListStore *store = gtk_list_store_new(3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT);
GtkWidget *widget = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
gtk_combo_box_set_add_tearoffs(GTK_COMBO_BOX(widget), 0);
GtkCellRenderer *renderer = gtk_cell_renderer_pixbuf_new();
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget),renderer, 0);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget), renderer, "pixbuf", 0, nullptr);
renderer = gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (widget),renderer,0);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (widget), renderer,"text",1,nullptr);
g_object_unref (GTK_TREE_MODEL(store));
GtkTreeIter iter1;
const char* falloff_types[][2] = {
{"gpick-falloff-none", _("None")},
{"gpick-falloff-linear", _("Linear")},
{"gpick-falloff-quadratic", _("Quadratic")},
{"gpick-falloff-cubic", _("Cubic")},
{"gpick-falloff-exponential", _("Exponential")},
};
SamplerFalloff falloff_type_ids[]={
SamplerFalloff::none,
SamplerFalloff::linear,
SamplerFalloff::quadratic,
SamplerFalloff::cubic,
SamplerFalloff::exponential,
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget), renderer, 0);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget), renderer, "text", 1, nullptr);
g_object_unref(GTK_TREE_MODEL(store));
struct{
const char *icon;
const char *label;
SamplerFalloff falloff;
}falloff_types[] = {
{"gpick-falloff-none", _("None"), SamplerFalloff::none},
{"gpick-falloff-linear", _("Linear"), SamplerFalloff::linear},
{"gpick-falloff-quadratic", _("Quadratic"), SamplerFalloff::quadratic},
{"gpick-falloff-cubic", _("Cubic"), SamplerFalloff::cubic},
{"gpick-falloff-exponential", _("Exponential"), SamplerFalloff::exponential},
};
GtkIconTheme *icon_theme;
icon_theme = gtk_icon_theme_get_default ();
GtkIconTheme *icon_theme = gtk_icon_theme_get_default();
gint icon_size;
gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, 0, &icon_size);
for (guint32 i=0;i<sizeof(falloff_type_ids)/sizeof(gint32);++i){
for (size_t i = 0; i < sizeof(falloff_types) / sizeof(falloff_types[0]); ++i){
GError *error = nullptr;
GdkPixbuf* pixbuf = gtk_icon_theme_load_icon(icon_theme, falloff_types[i][0], icon_size, GtkIconLookupFlags(0), &error);
if (error) g_error_free (error);
GdkPixbuf* pixbuf = gtk_icon_theme_load_icon(icon_theme, falloff_types[i].icon, icon_size, GtkIconLookupFlags(0), &error);
if (error) g_error_free(error);
GtkTreeIter iter1;
gtk_list_store_append(store, &iter1);
gtk_list_store_set(store, &iter1,
0, pixbuf,
1, falloff_types[i][1],
2, falloff_type_ids[i],
1, falloff_types[i].label,
2, falloff_types[i].falloff,
-1);
if (pixbuf) g_object_unref (pixbuf);
}
return widget;
}
static int source_destroy(ColorPickerArgs *args)
......
......@@ -61,7 +61,7 @@ class CopyMenuItemState
string text_line;
if (copy_menu_item_state->m_palette_widget){
stringstream text(ios::out);
ColorList *color_list = color_list_new(nullptr);
ColorList *color_list = color_list_new();
palette_list_foreach_selected(copy_menu_item_state->m_palette_widget, (PaletteListCallback)addToColorList, color_list);
ConverterSerializePosition position(color_list->colors.size());
if (position.count > 0){
......
......@@ -117,7 +117,9 @@ int palette_file_load(const char* filename, ColorList* color_list)
color_objects.sort(color_object_position_sort);
for (list<ColorObject*>::iterator i=color_objects.begin(); i != color_objects.end(); ++i){
color_list_add_color_object(color_list, *i, ((*i)->getPosition() != ~(size_t)0));
bool visible = (*i)->getPosition() != ~(size_t)0;
(*i)->setVisible(visible);
color_list_add_color_object(color_list, *i, visible);
(*i)->release();
}
......
......@@ -202,6 +202,7 @@ bool ImportExport::importGPL()
c.rgb.green = g / 255.0;
c.rgb.blue = b / 255.0;
color_object = color_list_new_color_object(m_color_list, &c);
stripLeadingTrailingChars(line, strip_chars);
color_object->setName(line);
color_list_add_color_object(m_color_list, color_object, true);
color_object->release();
......
......@@ -17,7 +17,6 @@
*/
#include "RegisterSources.h"
#include "GenerateScheme.h"
#include "ColorPicker.h"
#include "LayoutPreview.h"
......@@ -25,8 +24,10 @@
#include "BrightnessDarkness.h"
#include "ColorMixer.h"
#include "BlendColors.h"
#include "ClosestColors.h"
int register_sources(ColorSourceManager *csm){
int register_sources(ColorSourceManager *csm)
{
generate_scheme_source_register(csm);
color_picker_source_register(csm);
layout_preview_source_register(csm);
......@@ -34,5 +35,6 @@ int register_sources(ColorSourceManager *csm){
brightness_darkness_source_register(csm);
color_mixer_source_register(csm);
blend_colors_source_register(csm);
closest_colors_source_register(csm);
return 0;
}
......@@ -16,11 +16,8 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef REGISTERSOURCES_H_
#define REGISTERSOURCES_H_
#ifndef GPICK_REGISTER_SOURCES_H_
#define GPICK_REGISTER_SOURCES_H_
#include "ColorSourceManager.h"
int register_sources(ColorSourceManager *csm);
#endif /* REGISTERSOURCES_H_ */
#endif /* GPICK_REGISTER_SOURCES_H_ */
This diff is collapsed.
......@@ -18,30 +18,16 @@
#ifndef GPICK_COLOR_NAMES_COLOR_NAMES_H_
#define GPICK_COLOR_NAMES_COLOR_NAMES_H_
#include "../Color.h"
#include "../DynvHelpers.h"
#include <string>
#include <list>
typedef struct ColorNameEntry{
std::string name;
}ColorNameEntry;
typedef struct ColorEntry{
Color color;
ColorNameEntry* name;
}ColorEntry;
typedef struct ColorNames{
std::list<ColorNameEntry*> names;
std::list<ColorEntry*> colors[8][8][8];
void (*color_space_convert)(const Color* a, Color* b);
float (*color_space_distance)(const Color* a, const Color* b);
}ColorNames;
ColorNames* color_names_new();
void color_names_clear(ColorNames *cnames);
void color_names_load(ColorNames *cnames, dynvSystem *params);
int color_names_load_from_file(ColorNames* cnames, const char* filename);
void color_names_destroy(ColorNames* cnames);
std::string color_names_get(ColorNames* cnames, const Color* color, bool imprecision_postfix);
#include <vector>
struct ColorNames;
ColorNames *color_names_new();
void color_names_clear(ColorNames *color_names);
void color_names_load(ColorNames *color_names, dynvSystem *params);
int color_names_load_from_file(ColorNames *color_names, const char *filename);
void color_names_destroy(ColorNames *color_names);
std::string color_names_get(ColorNames *color_names, const Color *color, bool imprecision_postfix);
void color_names_find_nearest(ColorNames *color_names, const Color &color, size_t count, std::vector<std::pair<const char*, Color>> &colors);
#endif /* GPICK_COLOR_NAMES_COLOR_NAMES_H_ */
......@@ -601,6 +601,8 @@ void** dynv_get_array(struct dynvSystem* dynv_system, const char* handler_name,
int error_redir;
if (error == nullptr) error = &error_redir;
if (count)
*count = 0;
*error = 0;
struct dynvSystem* dlevel = dynv_system_ref(dynv_system);
......
......@@ -195,6 +195,7 @@ static gboolean draw(GtkWidget *widget, cairo_t *cr)
gtk_widget_get_allocation(widget, &rectangle);
int width = rectangle.width - widget->style->xthickness * 2 - 1, height = rectangle.height - widget->style->ythickness * 2 - 1;
#endif
bool sensitive = gtk_widget_get_sensitive(widget);
if (ns->rounded_rectangle){
cairo_rounded_rectangle(cr, 0, 0, width, height, ns->roundness);
if (ns->transformation_chain){
......@@ -202,8 +203,10 @@ static gboolean draw(GtkWidget *widget, cairo_t *cr)
}else{
color_copy(&ns->color, &color);
}
cairo_set_source_rgb(cr, boost::math::round(color.rgb.red * 255.0) / 255.0, boost::math::round(color.rgb.green * 255.0) / 255.0, boost::math::round(color.rgb.blue * 255.0) / 255.0);
cairo_fill_preserve(cr);
if (sensitive){
cairo_set_source_rgb(cr, boost::math::round(color.rgb.red * 255.0) / 255.0, boost::math::round(color.rgb.green * 255.0) / 255.0, boost::math::round(color.rgb.blue * 255.0) / 255.0);
cairo_fill_preserve(cr);
}
if (gtk_widget_has_focus(widget)){
#if GTK_MAJOR_VERSION >= 3
//TODO: GTK3 get border color
......@@ -222,10 +225,12 @@ static gboolean draw(GtkWidget *widget, cairo_t *cr)
}else{
color_copy(&ns->color, &color);
}
cairo_set_source_rgb(cr, color.rgb.red, color.rgb.green, color.rgb.blue);
cairo_paint(cr);
if (sensitive){
cairo_set_source_rgb(cr, color.rgb.red, color.rgb.green, color.rgb.blue);
cairo_paint(cr);
}
}
if (ns->text){
if (sensitive && ns->text){
PangoLayout *layout;
PangoFontDescription *font_description;
font_description = pango_font_description_new();
......
......@@ -88,3 +88,42 @@ BOOST_AUTO_TEST_CASE(string_array_overwrite)
delete [] values;
BOOST_CHECK(dynv_system_release(dynv) == 0);
}
BOOST_AUTO_TEST_CASE(dynv_array)
{
auto dynv = buildDynv();
dynvSystem *data[] = {dynv_system_create(dynv), dynv_system_create(dynv), dynv_system_create(dynv)};
dynv_set_array(dynv, "dynv", "a", (const void**)data, 3);
int error;
uint32_t count;
dynvSystem** values = (dynvSystem**)dynv_get_array(dynv, "dynv", "a", &count, &error);
BOOST_CHECK(error == 0);
BOOST_CHECK(values != nullptr);
BOOST_CHECK(count == 3);
for (int i = 0; i < 3; i++){
BOOST_CHECK(values[i] == data[i]);
BOOST_CHECK(dynv_system_release(values[i]) == -1);
}
for (int i = 0; i < 3; i++){
BOOST_CHECK(dynv_system_release(data[i]) == -1);
}
delete [] values;
BOOST_CHECK(dynv_system_release(dynv) == 0);
}
BOOST_AUTO_TEST_CASE(dynv_array_null)
{
auto dynv = buildDynv();
dynvSystem *data[] = {dynv_system_create(dynv), dynv_system_create(dynv), dynv_system_create(dynv)};
dynv_set_array(dynv, "dynv", "a", (const void**)data, 3);
dynv_set_array(dynv, "dynv", "a", nullptr, 0);
int error;
uint32_t count;
dynvSystem** values = (dynvSystem**)dynv_get_array(dynv, "dynv", "a", &count, &error);
BOOST_CHECK(error != 0);
BOOST_CHECK(values == nullptr);
BOOST_CHECK(count == 0);
for (int i = 0; i < 3; i++){
BOOST_CHECK(dynv_system_release(data[i]) == 0);
}
delete [] values;
BOOST_CHECK(dynv_system_release(dynv) == 0);
}
\ No newline at end of file
This diff is collapsed.
......@@ -22,6 +22,7 @@
#include "DynvHelpers.h"
#include "ImportExport.h"
#include "StringUtils.h"
#include "ColorList.h"
#include "Converter.h"
#include "GlobalState.h"
#include "Internationalisation.h"
......@@ -388,10 +389,12 @@ bool ImportExportDialog::showImport()
auto converters = m_gs->getConverters();
for (size_t i = 0; i != n_formats; ++i){
if (formats[i].type == type){
ImportExport import_export(m_color_list, filename, m_gs);
ColorList *color_list = color_list_new(m_color_list);
ImportExport import_export(color_list, filename, m_gs);
import_export.setConverters(converters);
if (import_export.importType(formats[i].type)){
finished = true;
color_list_add(m_color_list, color_list, true);
}else{
message = gtk_message_dialog_new(GTK_WINDOW(dialog), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("File could not be imported"));
gtk_window_set_title(GTK_WINDOW(message), _("Import"));
......@@ -400,6 +403,7 @@ bool ImportExportDialog::showImport()
}
const char *identification = (const char*)g_object_get_data(G_OBJECT(gtk_file_chooser_get_filter(GTK_FILE_CHOOSER(dialog))), "identification");
dynv_set_string(m_gs->getSettings(), "gpick.import.filter", identification);
color_list_destroy(color_list);
break;
}
}
......@@ -431,7 +435,8 @@ bool ImportExportDialog::showImportTextFile()
import_export_dialog_options.saveState();
GtkWidget* message;
gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
ImportExport import_export(m_color_list, filename, m_gs);
ColorList *color_list = color_list_new(m_color_list);
ImportExport import_export(color_list, filename, m_gs);
auto converters = m_gs->getConverters();
import_export.setConverters(converters);
text_file_parser::Configuration configuration;
......@@ -446,6 +451,7 @@ bool ImportExportDialog::showImportTextFile()
configuration.float_values = import_export_dialog_options.isFloatValuesEnabled();
if (import_export.importTextFile(configuration)){
finished = true;
color_list_add(m_color_list, color_list, true);
}else{
message = gtk_message_dialog_new(GTK_WINDOW(dialog), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("File could not be imported"));
gtk_window_set_title(GTK_WINDOW(message), _("Import text file"));
......@@ -453,6 +459,7 @@ bool ImportExportDialog::showImportTextFile()
gtk_widget_destroy(message);
}
g_free(filename);
color_list_destroy(color_list);
}else break;
}
gtk_widget_destroy(dialog);
......
......@@ -299,53 +299,38 @@ void dialog_transformations_show(GtkWindow* parent, GlobalState* gs)
gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1);
GtkWidget *widget;
GtkWidget* vbox = gtk_vbox_new(false, 5);
GtkWidget *vbox2 = gtk_vbox_new(false, 5);
args->enabled = widget = gtk_check_button_new_with_mnemonic (_("_Enable display filters"));
GtkWidget *widget = args->enabled = gtk_check_button_new_with_mnemonic(_("_Enable display filters"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), dynv_get_bool_wd(args->transformations_params, "enabled", false));
gtk_box_pack_start(GTK_BOX(vbox), args->enabled, false, false, 0);
args->vpaned = gtk_vpaned_new();
args->vpaned = gtk_vpaned_new();
gtk_box_pack_start(GTK_BOX(vbox), args->vpaned, true, true, 0);
GtkWidget *list, *scrolled;
GtkTreeIter iter1;
GtkTreeModel *model;
GtkWidget *hbox = gtk_hbox_new(false, 5);
args->available_transformations = list = transformations_list_new(true);
GtkWidget *list = args->available_transformations = transformations_list_new(true);
g_signal_connect(G_OBJECT(list), "row-activated", G_CALLBACK(available_transformation_row_activated), args);
scrolled = gtk_scrolled_window_new(0, 0);
GtkWidget *scrolled = gtk_scrolled_window_new(0, 0);
gtk_container_add(GTK_CONTAINER(scrolled), list);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_box_pack_start(GTK_BOX(hbox), scrolled, true, true, 0);
model = gtk_tree_view_get_model(GTK_TREE_VIEW(list));
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(list));
vector<transformation::Factory::TypeInfo> types = transformation::Factory::getAllTypes();
for (size_t i = 0; i != types.size(); i++){
gtk_list_store_append(GTK_LIST_STORE(model), &iter1);
available_tranformations_update_row(model, &iter1, &types[i], args);
GtkTreeIter iter;
gtk_list_store_append(GTK_LIST_STORE(model), &iter);
available_tranformations_update_row(model, &iter, &types[i], args);
}
GtkWidget *vbox3 = gtk_vbox_new(5, true);
GtkWidget *button = gtk_button_new_from_stock(GTK_STOCK_ADD);
gtk_box_pack_start(GTK_BOX(vbox3), button, false, false, 0);
g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(add_transformation_cb), args);
button = gtk_button_new_from_stock(GTK_STOCK_REMOVE);
gtk_box_pack_start(GTK_BOX(vbox3), button, false, false, 0);
g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(remove_transformation_cb), args);
gtk_box_pack_start(GTK_BOX(hbox), vbox3, false, false, 0);
args->transformation_list = list = transformations_list_new(false);
g_signal_connect(G_OBJECT(list), "row-activated", G_CALLBACK(transformation_chain_row_activated), args);
g_signal_connect(G_OBJECT(list), "cursor-changed", G_CALLBACK(transformation_chain_cursor_changed), args);
......@@ -362,37 +347,27 @@ void dialog_transformations_show(GtkWindow* parent, GlobalState* gs)
args->config_vbox = gtk_vbox_new(false, 5);
gtk_box_pack_start(GTK_BOX(config_wrap_vbox), args->config_vbox, true, true, 0);
gtk_paned_pack2(GTK_PANED(args->vpaned), config_wrap_vbox, false, false);
auto chain = args->gs->getTransformationChain();
model = gtk_tree_view_get_model(GTK_TREE_VIEW(list));
for (auto transformation: chain->getAll()){
gtk_list_store_append(GTK_LIST_STORE(model), &iter1);
tranformations_update_row(model, &iter1, transformation.get(), args);
GtkTreeIter iter;
gtk_list_store_append(GTK_LIST_STORE(model), &iter);
tranformations_update_row(model, &iter, transformation.get(), args);
}
gtk_paned_set_position(GTK_PANED(args->vpaned), dynv_get_int32_wd(args->params, "paned_position", -1));
gtk_widget_show_all(vbox);
gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), vbox, true, true, 5);
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) {
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK){
apply_configuration(args);
GtkListStore *store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(list)));
GtkTreeIter iter;
GtkListStore *store;
gboolean valid;
store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(list)));
valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter);
bool valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter);
bool enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(args->enabled));
dynv_set_bool(args->transformations_params, "enabled", enabled);
chain->setEnabled(enabled);
unsigned int count = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), nullptr);
if (count > 0){
struct dynvSystem** config_array = new struct dynvSystem*[count];
......@@ -433,18 +408,14 @@ void dialog_transformations_show(GtkWindow* parent, GlobalState* gs)
}
dynv_system_release(config_array[i]);
}
delete [] config_array;
}
gint width, height;
gtk_window_get_size(GTK_WINDOW(dialog), &width, &height);