--- ./src-copy/develop/imageop.c 2019-04-23 12:35:26.133780700 +0100 +++ ./src/develop/imageop.c 2019-04-25 19:56:42.886286400 +0100 @@ -68,6 +68,7 @@ typedef enum dt_module_header_icons_t { DT_MODULE_SWITCH = 0, + DT_MODULE_ICON, // mak insert DT_MODULE_LABEL, DT_MODULE_INSTANCE, DT_MODULE_RESET, @@ -1908,8 +1909,27 @@ return FALSE; } +// mak insert start +static GdkPixbuf *load_image(const char *filename, int size) +{ + GError *error = NULL; + if(!g_file_test(filename, G_FILE_TEST_IS_REGULAR)) return NULL; + + GdkPixbuf *pixbuf = dt_gdk_pixbuf_new_from_file_at_size(filename, size, size, &error); + if(!pixbuf) + { + fprintf(stderr, "error loading file `%s': %s\n", filename, error->message); + g_error_free(error); + } + return pixbuf; +} + +static const uint8_t fallback_pixel[4] = { 0, 0, 0, 0 }; +// mak insert end + GtkWidget *dt_iop_gui_get_expander(dt_iop_module_t *module) { + int bs = DT_PIXEL_APPLY_DPI(12); // mak insert char tooltip[512]; GtkWidget *header = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); @@ -1936,7 +1956,50 @@ * initialize the header widgets */ GtkWidget *hw[DT_MODULE_LAST] = { NULL }; - + + // mak insert start + /* add module icon */ + GdkPixbuf *pixbuf; + cairo_surface_t *surface; + char filename[PATH_MAX] = { 0 }; + char datadir[PATH_MAX] = { 0 }; + dt_loc_get_datadir(datadir, sizeof(datadir)); + + // make the icons a little more visible + #define ICON_SIZE (bs * 1.7) + + snprintf(filename, sizeof(filename), "%s/pixmaps/plugins/darkroom/%s.svg", datadir, module->op); + pixbuf = load_image(filename, ICON_SIZE); + if(pixbuf) goto got_image; + + snprintf(filename, sizeof(filename), "%s/pixmaps/plugins/darkroom/%s.png", datadir, module->op); + pixbuf = load_image(filename, ICON_SIZE); + if(pixbuf) goto got_image; + + snprintf(filename, sizeof(filename), "%s/pixmaps/plugins/darkroom/template.svg", datadir); + pixbuf = load_image(filename, ICON_SIZE); + if(pixbuf) goto got_image; + + snprintf(filename, sizeof(filename), "%s/pixmaps/plugins/darkroom/template.png", datadir); + pixbuf = load_image(filename, ICON_SIZE); + if(pixbuf) goto got_image; + + #undef ICON_SIZE + + // wow, we could neither load the SVG nor the PNG files. something is fucked up. + pixbuf = gdk_pixbuf_new_from_data(fallback_pixel, GDK_COLORSPACE_RGB, TRUE, 8, 1, 1, 4, NULL, NULL); + +got_image: + surface = dt_gdk_cairo_surface_create_from_pixbuf(pixbuf, 1, NULL); + hw[DT_MODULE_ICON] = gtk_image_new_from_surface(surface); + gtk_widget_set_margin_start(GTK_WIDGET(hw[DT_MODULE_ICON]), DT_PIXEL_APPLY_DPI(5)); + gtk_widget_set_size_request(GTK_WIDGET(hw[DT_MODULE_ICON]), bs, bs); + gtk_widget_set_name(GTK_WIDGET(hw[DT_MODULE_ICON]), "iop-panel-icon"); + cairo_surface_destroy(surface); + g_object_unref(pixbuf); + + // mak insert end + /* add module label */ hw[DT_MODULE_LABEL] = gtk_label_new(""); _iop_panel_label(hw[DT_MODULE_LABEL], module); @@ -1960,7 +2023,6 @@ g_signal_connect(G_OBJECT(hw[DT_MODULE_RESET]), "clicked", G_CALLBACK(dt_iop_gui_reset_callback), module); gtk_widget_set_name(GTK_WIDGET(hw[DT_MODULE_RESET]), "module-reset-button"); - /* add preset button if module has implementation */ hw[DT_MODULE_PRESETS] = dtgtk_button_new(dtgtk_cairo_paint_presets, CPF_STYLE_FLAT | CPF_DO_NOT_USE_BORDER, NULL); module->presets_button = GTK_WIDGET(hw[DT_MODULE_PRESETS]);