void gui_init(struct dt_iop_module_t *self) { const int force_lcms2 = dt_conf_get_bool("plugins/lighttable/export/force_lcms2"); self->gui_data = calloc(1, sizeof(dt_iop_colorout_gui_data_t)); dt_iop_colorout_gui_data_t *g = (dt_iop_colorout_gui_data_t *)self->gui_data; g->profiles = NULL; dt_iop_color_profile_t *prof = (dt_iop_color_profile_t *)g_malloc0(sizeof(dt_iop_color_profile_t)); g_strlcpy(prof->filename, "sRGB", sizeof(prof->filename)); g_strlcpy(prof->name, "sRGB", sizeof(prof->name)); int pos; int display_pos; prof->pos = 0; prof->display_pos = 0; g->profiles = g_list_append(g->profiles, prof); prof = (dt_iop_color_profile_t *)g_malloc0(sizeof(dt_iop_color_profile_t)); g_strlcpy(prof->filename, "adobergb", sizeof(prof->filename)); g_strlcpy(prof->name, "adobergb", sizeof(prof->name)); prof->pos = 1; prof->display_pos = 1; g->profiles = g_list_append(g->profiles, prof); prof = (dt_iop_color_profile_t *)g_malloc0(sizeof(dt_iop_color_profile_t)); g_strlcpy(prof->filename, "X profile", sizeof(prof->filename)); g_strlcpy(prof->name, "X profile", sizeof(prof->name)); prof->pos = -1; prof->display_pos = 2; g->profiles = g_list_append(g->profiles, prof); prof = (dt_iop_color_profile_t *)g_malloc0(sizeof(dt_iop_color_profile_t)); g_strlcpy(prof->filename, "linear_rgb", sizeof(prof->filename)); g_strlcpy(prof->name, "linear_rgb", sizeof(prof->name)); pos = prof->pos = 2; display_pos = prof->display_pos = 3; g->profiles = g_list_append(g->profiles, prof); prof = (dt_iop_color_profile_t *)g_malloc0(sizeof(dt_iop_color_profile_t)); g_strlcpy(prof->filename, "linear_rec2020_rgb", sizeof(prof->filename)); g_strlcpy(prof->name, "linear_rec2020_rgb", sizeof(prof->name)); pos = prof->pos = 3; display_pos = prof->display_pos = 4; g->profiles = g_list_append(g->profiles, prof); // read {conf,data}dir/color/out/*.icc char datadir[PATH_MAX] = { 0 }; char confdir[PATH_MAX] = { 0 }; char dirname[PATH_MAX] = { 0 }; char filename[PATH_MAX] = { 0 }; dt_loc_get_user_config_dir(confdir, sizeof(confdir)); dt_loc_get_datadir(datadir, sizeof(datadir)); snprintf(dirname, sizeof(dirname), "%s/color/out", confdir); if(!g_file_test(dirname, G_FILE_TEST_IS_DIR)) snprintf(dirname, sizeof(dirname), "%s/color/out", datadir); cmsHPROFILE tmpprof; const gchar *d_name; GDir *dir = g_dir_open(dirname, 0, NULL); if(dir) { while((d_name = g_dir_read_name(dir))) { snprintf(filename, sizeof(filename), "%s/%s", dirname, d_name); tmpprof = cmsOpenProfileFromFile(filename, "r"); if(tmpprof) { char *lang = getenv("LANG"); if(!lang) lang = "en_US"; dt_iop_color_profile_t *prof = (dt_iop_color_profile_t *)g_malloc0(sizeof(dt_iop_color_profile_t)); dt_colorspaces_get_profile_name(tmpprof, lang, lang + 3, prof->name, sizeof(prof->name)); g_strlcpy(prof->filename, d_name, sizeof(prof->filename)); prof->pos = ++pos; prof->display_pos = ++display_pos; cmsCloseProfile(tmpprof); g->profiles = g_list_append(g->profiles, prof); } } g_dir_close(dir); } self->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, DT_BAUHAUS_SPACE); // TODO: g->cbox1 = dt_bauhaus_combobox_new(self); gtk_box_pack_start(GTK_BOX(self->widget), g->cbox1, TRUE, TRUE, 0); dt_bauhaus_widget_set_label(g->cbox1, NULL, _("output intent")); dt_bauhaus_combobox_add(g->cbox1, _("perceptual")); dt_bauhaus_combobox_add(g->cbox1, _("relative colorimetric")); dt_bauhaus_combobox_add(g->cbox1, C_("rendering intent", "saturation")); dt_bauhaus_combobox_add(g->cbox1, _("absolute colorimetric")); g->cbox4 = dt_bauhaus_combobox_new(self); dt_bauhaus_widget_set_label(g->cbox4, NULL, _("display intent")); gtk_box_pack_start(GTK_BOX(self->widget), g->cbox4, TRUE, TRUE, 0); dt_bauhaus_combobox_add(g->cbox4, _("perceptual")); dt_bauhaus_combobox_add(g->cbox4, _("relative colorimetric")); dt_bauhaus_combobox_add(g->cbox4, C_("rendering intent", "saturation")); dt_bauhaus_combobox_add(g->cbox4, _("absolute colorimetric")); if(!force_lcms2) { gtk_widget_set_no_show_all(g->cbox1, TRUE); gtk_widget_set_visible(g->cbox1, FALSE); gtk_widget_set_no_show_all(g->cbox4, TRUE); gtk_widget_set_visible(g->cbox4, FALSE); } g->cbox2 = dt_bauhaus_combobox_new(self); g->cbox3 = dt_bauhaus_combobox_new(self); g->cbox5 = dt_bauhaus_combobox_new(self); dt_bauhaus_widget_set_label(g->cbox2, NULL, _("output profile")); dt_bauhaus_widget_set_label(g->cbox5, NULL, _("softproof profile")); dt_bauhaus_widget_set_label(g->cbox3, NULL, _("display profile")); gtk_box_pack_start(GTK_BOX(self->widget), g->cbox2, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(self->widget), g->cbox5, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(self->widget), g->cbox3, TRUE, TRUE, 0); GList *l = g->profiles; while(l) { dt_iop_color_profile_t *prof = (dt_iop_color_profile_t *)l->data; if(!strcmp(prof->name, "X profile")) { // the system display profile is only suitable for display purposes dt_bauhaus_combobox_add(g->cbox3, _("system display profile")); } else if(!strcmp(prof->name, "linear_rec709_rgb") || !strcmp(prof->name, "linear_rgb")) { dt_bauhaus_combobox_add(g->cbox2, _("linear Rec709 RGB")); dt_bauhaus_combobox_add(g->cbox3, _("linear Rec709 RGB")); dt_bauhaus_combobox_add(g->cbox5, _("linear Rec709 RGB")); } else if(!strcmp(prof->name, "linear_rec2020_rgb")) { dt_bauhaus_combobox_add(g->cbox2, _("linear Rec2020 RGB")); dt_bauhaus_combobox_add(g->cbox3, _("linear Rec2020 RGB")); dt_bauhaus_combobox_add(g->cbox5, _("linear Rec2020 RGB")); } else if(!strcmp(prof->name, "sRGB")) { dt_bauhaus_combobox_add(g->cbox2, _("sRGB (web-safe)")); dt_bauhaus_combobox_add(g->cbox3, _("sRGB (web-safe)")); dt_bauhaus_combobox_add(g->cbox5, _("sRGB (web-safe)")); } else if(!strcmp(prof->name, "adobergb")) { dt_bauhaus_combobox_add(g->cbox2, _("Adobe RGB (compatible)")); dt_bauhaus_combobox_add(g->cbox3, _("Adobe RGB (compatible)")); dt_bauhaus_combobox_add(g->cbox5, _("Adobe RGB (compatible)")); } else { dt_bauhaus_combobox_add(g->cbox2, prof->name); dt_bauhaus_combobox_add(g->cbox3, prof->name); dt_bauhaus_combobox_add(g->cbox5, prof->name); } l = g_list_next(l); } char tooltip[1024]; g_object_set(G_OBJECT(g->cbox1), "tooltip-text", _("rendering intent"), (char *)NULL); snprintf(tooltip, sizeof(tooltip), _("ICC profiles in %s/color/out or %s/color/out"), confdir, datadir); g_object_set(G_OBJECT(g->cbox2), "tooltip-text", tooltip, (char *)NULL); snprintf(tooltip, sizeof(tooltip), _("display ICC profiles in %s/color/out or %s/color/out"), confdir, datadir); g_object_set(G_OBJECT(g->cbox3), "tooltip-text", tooltip, (char *)NULL); snprintf(tooltip, sizeof(tooltip), _("softproof ICC profiles in %s/color/out or %s/color/out"), confdir, datadir); g_object_set(G_OBJECT(g->cbox5), "tooltip-text", tooltip, (char *)NULL); g_signal_connect(G_OBJECT(g->cbox1), "value-changed", G_CALLBACK(intent_changed), (gpointer)self); g_signal_connect(G_OBJECT(g->cbox4), "value-changed", G_CALLBACK(display_intent_changed), (gpointer)self); g_signal_connect(G_OBJECT(g->cbox2), "value-changed", G_CALLBACK(output_profile_changed), (gpointer)self); g_signal_connect(G_OBJECT(g->cbox3), "value-changed", G_CALLBACK(display_profile_changed), (gpointer)self); g_signal_connect(G_OBJECT(g->cbox5), "value-changed", G_CALLBACK(softproof_profile_changed), (gpointer)self); // reload the profiles when the display profile changed! dt_control_signal_connect(darktable.signals, DT_SIGNAL_CONTROL_PROFILE_CHANGED, G_CALLBACK(_signal_profile_changed), self->dev); }
void gui_init(dt_lib_module_t *self) { dt_lib_tagging_t *d = (dt_lib_tagging_t *)malloc(sizeof(dt_lib_tagging_t)); self->data = (void *)d; d->imgsel = -1; self->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); // gtk_widget_set_size_request(self->widget, DT_PIXEL_APPLY_DPI(100), -1); GtkBox *box, *hbox; GtkWidget *button; GtkWidget *w; GtkListStore *liststore; // left side, current box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 5)); gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(box), TRUE, TRUE, 0); w = gtk_scrolled_window_new(NULL, NULL); gtk_widget_set_size_request(w, -1, DT_PIXEL_APPLY_DPI(100)); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(w), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start(box, w, TRUE, TRUE, 0); d->current = GTK_TREE_VIEW(gtk_tree_view_new()); gtk_tree_view_set_headers_visible(d->current, FALSE); liststore = gtk_list_store_new(DT_LIB_TAGGING_NUM_COLS, G_TYPE_STRING, G_TYPE_UINT); GtkTreeViewColumn *col = gtk_tree_view_column_new(); gtk_tree_view_append_column(d->current, col); GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_add_attribute(col, renderer, "text", DT_LIB_TAGGING_COL_TAG); gtk_tree_selection_set_mode(gtk_tree_view_get_selection(d->current), GTK_SELECTION_SINGLE); gtk_tree_view_set_model(d->current, GTK_TREE_MODEL(liststore)); g_object_unref(liststore); gtk_widget_set_tooltip_text(GTK_WIDGET(d->current), _("attached tags,\ndoubleclick to detach")); g_signal_connect(G_OBJECT(d->current), "row-activated", G_CALLBACK(detach_activated), (gpointer)self); gtk_container_add(GTK_CONTAINER(w), GTK_WIDGET(d->current)); // attach/detach buttons hbox = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5)); button = gtk_button_new_with_label(_("attach")); d->attach_button = button; gtk_widget_set_tooltip_text(button, _("attach tag to all selected images")); gtk_box_pack_start(hbox, button, FALSE, TRUE, 0); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(attach_button_clicked), (gpointer)self); button = gtk_button_new_with_label(_("detach")); d->detach_button = button; gtk_widget_set_tooltip_text(button, _("detach tag from all selected images")); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(detach_button_clicked), (gpointer)self); gtk_box_pack_start(hbox, button, FALSE, TRUE, 0); gtk_box_pack_start(box, GTK_WIDGET(hbox), FALSE, TRUE, 0); // right side, related box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 5)); gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(box), TRUE, TRUE, 5); // text entry and new button w = gtk_entry_new(); gtk_widget_set_tooltip_text(w, _("enter tag name")); gtk_box_pack_start(box, w, TRUE, TRUE, 0); gtk_widget_add_events(GTK_WIDGET(w), GDK_KEY_RELEASE_MASK); // g_signal_connect(G_OBJECT(w), "key-release-event", g_signal_connect(G_OBJECT(w), "changed", G_CALLBACK(tag_name_changed), (gpointer)self); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(entry_activated), (gpointer)self); d->entry = GTK_ENTRY(w); dt_gui_key_accel_block_on_focus_connect(GTK_WIDGET(d->entry)); // related tree view w = gtk_scrolled_window_new(NULL, NULL); gtk_widget_set_size_request(w, -1, DT_PIXEL_APPLY_DPI(100)); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(w), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start(box, w, TRUE, TRUE, 0); d->related = GTK_TREE_VIEW(gtk_tree_view_new()); gtk_tree_view_set_headers_visible(d->related, FALSE); liststore = gtk_list_store_new(DT_LIB_TAGGING_NUM_COLS, G_TYPE_STRING, G_TYPE_UINT); col = gtk_tree_view_column_new(); gtk_tree_view_append_column(d->related, col); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_add_attribute(col, renderer, "text", DT_LIB_TAGGING_COL_TAG); gtk_tree_selection_set_mode(gtk_tree_view_get_selection(d->related), GTK_SELECTION_SINGLE); gtk_tree_view_set_model(d->related, GTK_TREE_MODEL(liststore)); g_object_unref(liststore); gtk_widget_set_tooltip_text(GTK_WIDGET(d->related), _("related tags,\ndoubleclick to attach")); g_signal_connect(G_OBJECT(d->related), "row-activated", G_CALLBACK(attach_activated), (gpointer)self); gtk_container_add(GTK_CONTAINER(w), GTK_WIDGET(d->related)); // attach and delete buttons hbox = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5)); button = gtk_button_new_with_label(_("new")); d->new_button = button; gtk_widget_set_tooltip_text(button, _("create a new tag with the\nname you entered")); gtk_box_pack_start(hbox, button, FALSE, TRUE, 0); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(new_button_clicked), (gpointer)self); button = gtk_button_new_with_label(_("delete")); d->delete_button = button; gtk_widget_set_tooltip_text(button, _("delete selected tag")); gtk_box_pack_start(hbox, button, FALSE, TRUE, 0); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(delete_button_clicked), (gpointer)self); button = gtk_button_new_with_label(C_("verb", "import")); d->import_button = button; gtk_widget_set_tooltip_text(button, _("import tags from a Lightroom keyword file")); gtk_box_pack_start(hbox, button, FALSE, TRUE, 0); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(import_button_clicked), (gpointer)self); button = gtk_button_new_with_label(C_("verb", "export")); d->export_button = button; gtk_widget_set_tooltip_text(button, _("export all tags to a Lightroom keyword file")); gtk_box_pack_start(hbox, button, FALSE, TRUE, 0); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(export_button_clicked), (gpointer)self); gtk_box_pack_start(box, GTK_WIDGET(hbox), FALSE, TRUE, 0); // add entry completion GtkEntryCompletion *completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(completion, gtk_tree_view_get_model(GTK_TREE_VIEW(d->related))); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_set_completion(d->entry, completion); /* connect to mouse over id */ dt_control_signal_connect(darktable.signals, DT_SIGNAL_MOUSE_OVER_IMAGE_CHANGE, G_CALLBACK(_lib_tagging_redraw_callback), self); dt_control_signal_connect(darktable.signals, DT_SIGNAL_TAG_CHANGED, G_CALLBACK(_lib_tagging_tags_changed_callback), self); update(self, 0); set_keyword(self, d); }
void gui_init(dt_lib_module_t *self) { /* initialize ui widgets */ dt_lib_filmstrip_t *d = (dt_lib_filmstrip_t *)g_malloc(sizeof(dt_lib_filmstrip_t)); self->data = (void *)d; memset(d,0,sizeof(dt_lib_filmstrip_t)); d->last_selected_id = -1; d->history_copy_imgid = -1; d->activated_image = -1; d->mouse_over_id = -1; /* create drawingarea */ self->widget = gtk_vbox_new(FALSE,0); /* createing filmstrip box*/ d->filmstrip = gtk_event_box_new(); gtk_widget_add_events(d->filmstrip, GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_SCROLL_MASK | GDK_LEAVE_NOTIFY_MASK); /* connect callbacks */ g_signal_connect (G_OBJECT (d->filmstrip), "expose-event", G_CALLBACK (_lib_filmstrip_expose_callback), self); g_signal_connect (G_OBJECT (d->filmstrip), "button-press-event", G_CALLBACK (_lib_filmstrip_button_press_callback), self); g_signal_connect (G_OBJECT (d->filmstrip), "scroll-event", G_CALLBACK (_lib_filmstrip_scroll_callback), self); g_signal_connect (G_OBJECT (d->filmstrip), "motion-notify-event", G_CALLBACK(_lib_filmstrip_motion_notify_callback), self); g_signal_connect (G_OBJECT (d->filmstrip), "leave-notify-event", G_CALLBACK(_lib_filmstrip_mouse_leave_callback), self); /* set size of filmstrip */ int32_t height = dt_conf_get_int("plugins/lighttable/filmstrip/height"); gtk_widget_set_size_request(d->filmstrip, -1, CLAMP(height,64,400)); /* create the resize handle */ GtkWidget *size_handle = gtk_event_box_new(); gtk_widget_set_size_request(size_handle,-1,10); gtk_widget_add_events(size_handle, GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK ); g_signal_connect (G_OBJECT (size_handle), "button-press-event", G_CALLBACK (_lib_filmstrip_size_handle_button_callback), self); g_signal_connect (G_OBJECT (size_handle), "button-release-event", G_CALLBACK (_lib_filmstrip_size_handle_button_callback), self); g_signal_connect (G_OBJECT (size_handle), "motion-notify-event", G_CALLBACK (_lib_filmstrip_size_handle_motion_notify_callback), self); g_signal_connect (G_OBJECT (size_handle), "leave-notify-event", G_CALLBACK(_lib_filmstrip_size_handle_cursor_callback), self); g_signal_connect (G_OBJECT (size_handle), "enter-notify-event", G_CALLBACK(_lib_filmstrip_size_handle_cursor_callback), self); gtk_box_pack_start(GTK_BOX(self->widget), size_handle, FALSE, FALSE,0); gtk_box_pack_start(GTK_BOX(self->widget), d->filmstrip, FALSE, FALSE,0); /* initialize view manager proxy */ darktable.view_manager->proxy.filmstrip.module = self; darktable.view_manager->proxy.filmstrip.scroll_to_image = _lib_filmstrip_scroll_to_image; darktable.view_manager->proxy.filmstrip.activated_image = _lib_filmstrip_get_activated_imgid; /* connect signal handler */ dt_control_signal_connect(darktable.signals, DT_SIGNAL_COLLECTION_CHANGED, G_CALLBACK(_lib_filmstrip_collection_changed_callback), (gpointer)self); dt_control_signal_connect(darktable.signals, DT_SIGNAL_DEVELOP_MIPMAP_UPDATED, G_CALLBACK(_lib_filmstrip_collection_changed_callback), (gpointer)self); }
void gui_init (dt_lib_module_t *self) { dt_lib_collect_t *d = (dt_lib_collect_t *)malloc(sizeof(dt_lib_collect_t)); self->data = (void *)d; self->widget = gtk_vbox_new(FALSE, 5); gtk_widget_set_size_request(self->widget, 100, -1); d->active_rule = 0; d->params = (dt_lib_collect_params_t*)malloc(sizeof(dt_lib_collect_params_t)); dt_control_signal_connect(darktable.signals, DT_SIGNAL_COLLECTION_CHANGED, G_CALLBACK(collection_updated), self); GtkBox *box; GtkWidget *w; GtkWidget *sw = gtk_scrolled_window_new(NULL, NULL); GtkTreeView *view = GTK_TREE_VIEW(gtk_tree_view_new()); d->view = view; GtkListStore *liststore; for(int i=0; i<MAX_RULES; i++) { d->rule[i].num = i; box = GTK_BOX(gtk_hbox_new(FALSE, 5)); d->rule[i].hbox = GTK_WIDGET(box); gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(box), TRUE, TRUE, 0); w = gtk_combo_box_new_text(); d->rule[i].combo = GTK_COMBO_BOX(w); for(int k=0; k<dt_lib_collect_string_cnt; k++) gtk_combo_box_append_text(GTK_COMBO_BOX(w), _(dt_lib_collect_string[k])); g_signal_connect(G_OBJECT(w), "changed", G_CALLBACK(combo_changed), d->rule + i); gtk_box_pack_start(box, w, FALSE, FALSE, 0); w = gtk_entry_new(); dt_gui_key_accel_block_on_focus(w); d->rule[i].text = w; gtk_widget_add_events(w, GDK_FOCUS_CHANGE_MASK); g_signal_connect(G_OBJECT(w), "focus-in-event", G_CALLBACK(entry_focus_in_callback), d->rule + i); /* xgettext:no-c-format */ g_object_set(G_OBJECT(w), "tooltip-text", _("type your query, use `%' as wildcard"), (char *)NULL); gtk_widget_add_events(w, GDK_KEY_PRESS_MASK); g_signal_connect(G_OBJECT(w), "changed", G_CALLBACK(changed_callback), d->rule + i); g_signal_connect(G_OBJECT(w), "activate", G_CALLBACK(entry_activated), d->rule + i); gtk_box_pack_start(box, w, TRUE, TRUE, 0); w = dtgtk_button_new(dtgtk_cairo_paint_presets, CPF_STYLE_FLAT|CPF_DO_NOT_USE_BORDER); d->rule[i].button = w; gtk_widget_set_events(w, GDK_BUTTON_PRESS_MASK); g_signal_connect(G_OBJECT(w), "button-press-event", G_CALLBACK(popup_button_callback), d->rule + i); gtk_box_pack_start(box, w, FALSE, FALSE, 0); gtk_widget_set_size_request(w, 13, 13); } d->scrolledwindow = GTK_SCROLLED_WINDOW(sw); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add(GTK_CONTAINER(sw), GTK_WIDGET(view)); gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(sw), TRUE, TRUE, 0); gtk_tree_view_set_headers_visible(view, FALSE); liststore = gtk_list_store_new(DT_LIB_COLLECT_NUM_COLS, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING); GtkTreeViewColumn *col = gtk_tree_view_column_new(); gtk_tree_view_append_column(view, col); gtk_widget_set_size_request(GTK_WIDGET(view), -1, 300); GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_add_attribute(col, renderer, "text", DT_LIB_COLLECT_COL_TEXT); gtk_tree_selection_set_mode(gtk_tree_view_get_selection(view), GTK_SELECTION_SINGLE); gtk_tree_view_set_model(view, GTK_TREE_MODEL(liststore)); g_signal_connect(G_OBJECT (view), "row-activated", G_CALLBACK (row_activated), d); /* setup proxy */ darktable.view_manager->proxy.module_collect.module = self; darktable.view_manager->proxy.module_collect.update = _lib_collect_gui_update; _lib_collect_gui_update(self); }
void gui_init(dt_lib_module_t *self) { GtkBox *hbox; GtkWidget *button; GtkWidget *label; GtkEntryCompletion *completion; int line = 0; dt_lib_metadata_t *d = (dt_lib_metadata_t *)calloc(1, sizeof(dt_lib_metadata_t)); self->data = (void *)d; d->imgsel = -1; self->widget = gtk_grid_new(); gtk_grid_set_row_spacing(GTK_GRID(self->widget), DT_PIXEL_APPLY_DPI(5)); gtk_grid_set_column_spacing(GTK_GRID(self->widget), DT_PIXEL_APPLY_DPI(10)); g_signal_connect(self->widget, "draw", G_CALLBACK(draw), self); struct { char *name; GtkComboBox **box; } entries[] = { // clang-format off {N_("title"), &d->title}, {N_("description"), &d->description}, {N_("creator"), &d->creator}, {N_("publisher"), &d->publisher}, {N_("rights"), &d->rights} // clang-format on }; for(line = 0; line < sizeof(entries) / sizeof(entries[0]); line++) { label = gtk_label_new(_(entries[line].name)); g_object_set(G_OBJECT(label), "xalign", 0.0, (gchar *)0); GtkWidget *combobox = gtk_combo_box_text_new_with_entry(); *(entries[line].box) = GTK_COMBO_BOX(combobox); gtk_widget_set_hexpand(combobox, TRUE); GtkWidget *entry = gtk_bin_get_child(GTK_BIN(combobox)); dt_gui_key_accel_block_on_focus_connect(entry); completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(completion, gtk_combo_box_get_model(GTK_COMBO_BOX(combobox))); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_set_completion(GTK_ENTRY(entry), completion); g_object_unref(completion); g_signal_connect(entry, "key-press-event", G_CALLBACK(key_pressed), self); gtk_entry_set_width_chars(GTK_ENTRY(entry), 0); gtk_grid_attach(GTK_GRID(self->widget), label, 0, line, 1, 1); gtk_grid_attach_next_to(GTK_GRID(self->widget), combobox, label, GTK_POS_RIGHT, 1, 1); } // reset/apply buttons hbox = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5)); button = gtk_button_new_with_label(_("clear")); d->clear_button = button; gtk_widget_set_hexpand(GTK_WIDGET(button), TRUE); gtk_widget_set_tooltip_text(button, _("remove metadata from selected images")); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(clear_button_clicked), (gpointer)self); gtk_box_pack_start(hbox, button, FALSE, TRUE, 0); button = gtk_button_new_with_label(_("apply")); d->apply_button = button; gtk_widget_set_hexpand(GTK_WIDGET(button), TRUE); gtk_widget_set_tooltip_text(button, _("write metadata for selected images")); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(apply_button_clicked), (gpointer)self); gtk_box_pack_start(hbox, button, FALSE, TRUE, 0); gtk_widget_set_margin_top(GTK_WIDGET(hbox), DT_PIXEL_APPLY_DPI(5)); gtk_grid_attach(GTK_GRID(self->widget), GTK_WIDGET(hbox), 0, line, 2, 1); /* lets signup for mouse over image change signals */ dt_control_signal_connect(darktable.signals, DT_SIGNAL_MOUSE_OVER_IMAGE_CHANGE, G_CALLBACK(_mouse_over_image_callback), self); }
void init_main_table(GtkWidget *container) { GtkWidget *widget; // Creating the table widget = gtk_table_new(3, 5, FALSE); gtk_box_pack_start(GTK_BOX(container), widget, TRUE, TRUE, 0); gtk_widget_show(widget); container = widget; // Adding the left border widget = gtk_drawing_area_new(); darktable.gui->widgets.left_border = widget; gtk_widget_set_size_request(widget, 10, -1); gtk_widget_set_app_paintable(widget, TRUE); gtk_widget_set_events(widget, GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_STRUCTURE_MASK | GDK_SCROLL_MASK); gtk_table_attach(GTK_TABLE(container), widget, 0, 1, 0, 2, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show(widget); // Adding the right border widget = gtk_drawing_area_new(); darktable.gui->widgets.right_border = widget; gtk_widget_set_size_request(widget, 10, -1); gtk_widget_set_app_paintable(widget, TRUE); gtk_widget_set_events(widget, GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_STRUCTURE_MASK | GDK_SCROLL_MASK); gtk_table_attach(GTK_TABLE(container), widget, 4, 5, 0, 2, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show(widget); /* initialize the top container */ _ui_init_panel_top(darktable.gui->ui, container); /* * initialize the center top/center/bottom */ widget = gtk_vbox_new(FALSE, 0); gtk_table_attach(GTK_TABLE(container), widget, 2, 3, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); /* intiialize the center top panel */ _ui_init_panel_center_top(darktable.gui->ui, widget); /* setup center drawing area */ GtkWidget *cda = gtk_drawing_area_new(); gtk_widget_set_size_request(cda, -1, 500); gtk_widget_set_app_paintable(cda, TRUE); gtk_widget_set_events(cda, GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); gtk_widget_set_can_focus(cda, TRUE); gtk_widget_set_visible(cda, TRUE); gtk_box_pack_start(GTK_BOX(widget), cda, TRUE, TRUE, 0); darktable.gui->ui->center = cda; /* center should redraw when signal redraw center is raised*/ dt_control_signal_connect(darktable.signals, DT_SIGNAL_CONTROL_REDRAW_CENTER, G_CALLBACK(_ui_widget_redraw_callback), darktable.gui->ui->center); /* initialize the center bottom panel */ _ui_init_panel_center_bottom(darktable.gui->ui, widget); /* initialize the bottom panel */ _ui_init_panel_bottom(darktable.gui->ui, container); /* initialize left panel */ _ui_init_panel_left(darktable.gui->ui, container); /* initialize right panel */ _ui_init_panel_right(darktable.gui->ui, container); }
void gui_init(dt_lib_module_t *self) { /* initialize ui widgets */ dt_lib_keywords_t *d = (dt_lib_keywords_t *)g_malloc(sizeof(dt_lib_keywords_t)); memset(d,0,sizeof(dt_lib_keywords_t)); self->data = (void *)d; self->widget = gtk_vbox_new(FALSE, 5); /* Create a new scrolled window, with scrollbars only if needed */ GtkWidget *scrolled_window; scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); /* add the treeview to show hierarchy tags*/ GtkCellRenderer *renderer; d->view = GTK_TREE_VIEW (gtk_tree_view_new()); gtk_widget_set_size_request(GTK_WIDGET(d->view), -1, 300); gtk_container_add(GTK_CONTAINER(scrolled_window), GTK_WIDGET(d->view)); renderer = gtk_cell_renderer_text_new (); gtk_tree_view_insert_column_with_attributes(d->view, -1, "", renderer, "text", 0, NULL); gtk_tree_view_set_headers_visible(d->view, FALSE); /* setup dnd source and destination within treeview */ static const GtkTargetEntry dnd_target = { "keywords-reorganize", GTK_TARGET_SAME_WIDGET, 0 }; gtk_tree_view_enable_model_drag_source(d->view, GDK_BUTTON1_MASK, &dnd_target, 1, GDK_ACTION_MOVE); gtk_tree_view_enable_model_drag_dest(d->view, &dnd_target, 1, GDK_ACTION_MOVE); /* setup drag and drop signals */ g_signal_connect(G_OBJECT(d->view),"drag-data-received", G_CALLBACK(_lib_keywords_drag_data_received_callback), self); g_signal_connect(G_OBJECT(d->view),"drag-data-get", G_CALLBACK(_lib_keywords_drag_data_get_callback), self); /* add callback when keyword is activated */ g_signal_connect(G_OBJECT(d->view), "row-activated", G_CALLBACK(_lib_keywords_add_collection_rule), self); gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(scrolled_window), TRUE, TRUE, 0); gtk_widget_show_all(GTK_WIDGET(d->view)); dt_control_signal_connect(darktable.signals, DT_SIGNAL_TAG_CHANGED, G_CALLBACK(_lib_tag_gui_update), self); /* raise signal of tags change to refresh keywords tree */ dt_control_signal_raise(darktable.signals, DT_SIGNAL_TAG_CHANGED); }
void gui_init(dt_lib_module_t *self) { GtkBox *hbox; GtkWidget *button; GtkWidget *label; GtkEntryCompletion *completion; dt_lib_metadata_t *d = (dt_lib_metadata_t *)calloc(1, sizeof(dt_lib_metadata_t)); self->data = (void *)d; d->imgsel = -1; self->widget = gtk_table_new(6, 2, FALSE); gtk_table_set_row_spacings(GTK_TABLE(self->widget), 5); g_signal_connect(self->widget, "expose-event", G_CALLBACK(expose), self); label = gtk_label_new(_("title")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(self->widget), label, 0, 1, 0, 1, GTK_EXPAND|GTK_FILL, 0, 0, 0); d->title = GTK_COMBO_BOX(gtk_combo_box_text_new_with_entry()); dt_gui_key_accel_block_on_focus_connect(GTK_WIDGET(gtk_bin_get_child(GTK_BIN(d->title)))); completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(completion, gtk_combo_box_get_model(GTK_COMBO_BOX(d->title))); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_set_completion(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(d->title))), completion); g_signal_connect (GTK_WIDGET(gtk_bin_get_child(GTK_BIN(d->title))), "key-press-event", G_CALLBACK (key_pressed), self); gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(d->title), 1, 2, 0, 1, GTK_EXPAND|GTK_FILL, 0, 0, 0); label = gtk_label_new(_("description")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(self->widget), label, 0, 1, 1, 2, GTK_EXPAND|GTK_FILL, 0, 0, 0); d->description = GTK_COMBO_BOX(gtk_combo_box_text_new_with_entry()); dt_gui_key_accel_block_on_focus_connect(GTK_WIDGET(gtk_bin_get_child(GTK_BIN(d->description)))); completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(completion, gtk_combo_box_get_model(GTK_COMBO_BOX(d->description))); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_set_completion(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(d->description))), completion); g_signal_connect (GTK_WIDGET(gtk_bin_get_child(GTK_BIN(d->description))), "key-press-event", G_CALLBACK (key_pressed), self); gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(d->description), 1, 2, 1, 2, GTK_EXPAND|GTK_FILL, 0, 0, 0); label = gtk_label_new(_("creator")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(self->widget), label, 0, 1, 2, 3, GTK_EXPAND|GTK_FILL, 0, 0, 0); d->creator = GTK_COMBO_BOX(gtk_combo_box_text_new_with_entry()); dt_gui_key_accel_block_on_focus_connect(GTK_WIDGET(gtk_bin_get_child(GTK_BIN(d->creator)))); completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(completion, gtk_combo_box_get_model(GTK_COMBO_BOX(d->creator))); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_set_completion(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(d->creator))), completion); g_signal_connect (GTK_WIDGET(gtk_bin_get_child(GTK_BIN(d->creator))), "key-press-event", G_CALLBACK (key_pressed), self); gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(d->creator), 1, 2, 2, 3, GTK_EXPAND|GTK_FILL, 0, 0, 0); label = gtk_label_new(_("publisher")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(self->widget), label, 0, 1, 3, 4, GTK_EXPAND|GTK_FILL, 0, 0, 0); d->publisher = GTK_COMBO_BOX(gtk_combo_box_text_new_with_entry()); dt_gui_key_accel_block_on_focus_connect(GTK_WIDGET(gtk_bin_get_child(GTK_BIN(d->publisher)))); completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(completion, gtk_combo_box_get_model(GTK_COMBO_BOX(d->publisher))); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_set_completion(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(d->publisher))), completion); g_signal_connect (GTK_WIDGET(gtk_bin_get_child(GTK_BIN(d->publisher))), "key-press-event", G_CALLBACK (key_pressed), self); gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(d->publisher), 1, 2, 3, 4, GTK_EXPAND|GTK_FILL, 0, 0, 0); label = gtk_label_new(_("rights")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(self->widget), label, 0, 1, 4, 5, GTK_EXPAND|GTK_FILL, 0, 0, 0); d->rights = GTK_COMBO_BOX(gtk_combo_box_text_new_with_entry()); dt_gui_key_accel_block_on_focus_connect(GTK_WIDGET(gtk_bin_get_child(GTK_BIN(d->rights)))); completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(completion, gtk_combo_box_get_model(GTK_COMBO_BOX(d->rights))); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_set_completion(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(d->rights))), completion); g_signal_connect (GTK_WIDGET(gtk_bin_get_child(GTK_BIN(d->rights))), "key-press-event", G_CALLBACK (key_pressed), self); gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(d->rights), 1, 2, 4, 5, GTK_EXPAND|GTK_FILL, 0, 0, 0); g_object_unref(completion); // reset/apply buttons hbox = GTK_BOX(gtk_hbox_new(TRUE, 5)); button = gtk_button_new_with_label(_("clear")); d->clear_button = button; g_object_set(G_OBJECT(button), "tooltip-text", _("remove metadata from selected images"), (char *)NULL); gtk_box_pack_start(hbox, button, FALSE, TRUE, 0); g_signal_connect(G_OBJECT (button), "clicked", G_CALLBACK (clear_button_clicked), (gpointer)self); button = gtk_button_new_with_label(_("apply")); d->apply_button = button; g_object_set(G_OBJECT(button), "tooltip-text", _("write metadata for selected images"), (char *)NULL); g_signal_connect(G_OBJECT (button), "clicked", G_CALLBACK (apply_button_clicked), (gpointer)self); gtk_box_pack_start(hbox, button, FALSE, TRUE, 0); gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(hbox), 0, 2, 5, 6, GTK_EXPAND|GTK_FILL, 0, 0, 0); /* lets signup for mouse over image change signals */ dt_control_signal_connect(darktable.signals,DT_SIGNAL_MOUSE_OVER_IMAGE_CHANGE, G_CALLBACK(_mouse_over_image_callback), self); }
void init_widgets() { GtkWidget* container; GtkWidget* widget; // Creating the main window widget = gtk_window_new(GTK_WINDOW_TOPLEVEL); darktable.gui->ui->main_window = widget; gtk_window_set_default_size(GTK_WINDOW(widget), 900, 500); gtk_window_set_icon_name(GTK_WINDOW(widget), "darktable"); gtk_window_set_title(GTK_WINDOW(widget), "Darktable"); g_signal_connect (G_OBJECT (widget), "delete_event", G_CALLBACK (dt_control_quit), NULL); g_signal_connect (G_OBJECT (widget), "key-press-event", G_CALLBACK (key_pressed_override), NULL); g_signal_connect (G_OBJECT (widget), "key-release-event", G_CALLBACK (key_released), NULL); container = widget; // Adding the outermost vbox widget = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(container), widget); gtk_widget_show(widget); /* connect to signal redraw all */ dt_control_signal_connect(darktable.signals, DT_SIGNAL_CONTROL_REDRAW_ALL, G_CALLBACK(_ui_widget_redraw_callback), darktable.gui->ui->main_window); container = widget; // Initializing the top border widget = gtk_drawing_area_new(); darktable.gui->widgets.top_border = widget; gtk_box_pack_start(GTK_BOX(container), widget, FALSE, TRUE, 0); gtk_widget_set_size_request(widget, -1, 10); gtk_widget_set_app_paintable(widget, TRUE); gtk_widget_set_events(widget, GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_STRUCTURE_MASK | GDK_SCROLL_MASK); gtk_widget_show(widget); // Initializing the main table init_main_table(container); // Initializing the bottom border widget = gtk_drawing_area_new(); darktable.gui->widgets.bottom_border = widget; gtk_box_pack_start(GTK_BOX(container), widget, FALSE, TRUE, 0); gtk_widget_set_size_request(widget, -1, 10); gtk_widget_set_app_paintable(widget, TRUE); gtk_widget_set_events(widget, GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_STRUCTURE_MASK | GDK_SCROLL_MASK); gtk_widget_show(widget); // Showing everything gtk_widget_show_all(dt_ui_main_window(darktable.gui->ui)); /* hide panels depending on last ui state */ for(int k=0;k<DT_UI_PANEL_SIZE;k++) { /* prevent show all */ gtk_widget_set_no_show_all(GTK_WIDGET(darktable.gui->ui->containers[k]), TRUE); /* check last visible state of panel */ char key[512]; g_snprintf(key, 512, "ui_last/%s/visible", _ui_panel_config_names[k]); /* if no key, lets default to TRUE*/ if(!dt_conf_key_exists(key)) dt_conf_set_bool(key,TRUE); if (!dt_conf_get_bool(key)) gtk_widget_set_visible(darktable.gui->ui->panels[k],FALSE); } }
void gui_init(dt_lib_module_t *self) { dt_lib_image_t *d = (dt_lib_image_t *)malloc(sizeof(dt_lib_image_t)); self->data = (void *)d; self->widget = gtk_grid_new(); GtkGrid *grid = GTK_GRID(self->widget); gtk_grid_set_row_spacing(grid, DT_PIXEL_APPLY_DPI(5)); gtk_grid_set_column_spacing(grid, DT_PIXEL_APPLY_DPI(5)); gtk_grid_set_column_homogeneous(grid, TRUE); int line = 0; GtkWidget *button; button = gtk_button_new_with_label(_("remove")); ellipsize_button(button); d->remove_button = button; gtk_widget_set_tooltip_text(button, _("remove from the collection")); gtk_grid_attach(grid, button, 0, line, 2, 1); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(0)); button = gtk_button_new_with_label(_image_get_delete_button_label()); ellipsize_button(button); d->delete_button = button; gtk_widget_set_tooltip_text(button, _image_get_delete_button_tooltip()); gtk_grid_attach(grid, button, 2, line++, 2, 1); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(1)); button = gtk_button_new_with_label(_("move")); ellipsize_button(button); d->move_button = button; gtk_widget_set_tooltip_text(button, _("move to other folder")); gtk_grid_attach(grid, button, 0, line, 2, 1); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(8)); button = gtk_button_new_with_label(_("copy")); ellipsize_button(button); d->copy_button = button; gtk_widget_set_tooltip_text(button, _("copy to other folder")); gtk_grid_attach(grid, button, 2, line++, 2, 1); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(9)); button = gtk_button_new_with_label(_("create HDR")); ellipsize_button(button); d->create_hdr_button = button; gtk_grid_attach(grid, button, 0, line, 2, 1); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(7)); gtk_widget_set_tooltip_text(button, _("create a high dynamic range image from selected shots")); button = gtk_button_new_with_label(_("duplicate")); ellipsize_button(button); d->duplicate_button = button; gtk_widget_set_tooltip_text(button, _("add a duplicate to the collection, including its history stack")); gtk_grid_attach(grid, button, 2, line++, 2, 1); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(3)); button = dtgtk_button_new(dtgtk_cairo_paint_refresh, CPF_DO_NOT_USE_BORDER); d->rotate_ccw_button = button; gtk_widget_set_tooltip_text(button, _("rotate selected images 90 degrees CCW")); gtk_grid_attach(grid, button, 0, line, 1, 1); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(4)); button = dtgtk_button_new(dtgtk_cairo_paint_refresh, 1 | CPF_DO_NOT_USE_BORDER); d->rotate_cw_button = button; gtk_widget_set_tooltip_text(button, _("rotate selected images 90 degrees CW")); gtk_grid_attach(grid, button, 1, line, 1, 1); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(5)); button = gtk_button_new_with_label(_("reset rotation")); ellipsize_button(button); d->reset_button = button; gtk_widget_set_tooltip_text(button, _("reset rotation to EXIF data")); gtk_grid_attach(grid, button, 2, line++, 2, 1); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(6)); button = gtk_button_new_with_label(_("copy locally")); ellipsize_button(button); d->cache_button = button; gtk_widget_set_tooltip_text(button, _("copy the image locally")); gtk_grid_attach(grid, button, 0, line, 2, 1); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(12)); button = gtk_button_new_with_label(_("resync local copy")); ellipsize_button(button); d->uncache_button = button; gtk_widget_set_tooltip_text(button, _("synchronize the image's XMP and remove the local copy")); gtk_grid_attach(grid, button, 2, line++, 2, 1); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(13)); button = gtk_button_new_with_label(_("group")); ellipsize_button(button); d->group_button = button; gtk_widget_set_tooltip_text(button, _("add selected images to expanded group or create a new one")); gtk_grid_attach(grid, button, 0, line, 2, 1); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(10)); button = gtk_button_new_with_label(_("ungroup")); ellipsize_button(button); d->ungroup_button = button; gtk_widget_set_tooltip_text(button, _("remove selected images from the group")); gtk_grid_attach(grid, button, 2, line, 2, 1); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), GINT_TO_POINTER(11)); /* connect preference changed signal */ dt_control_signal_connect( darktable.signals, DT_SIGNAL_PREFERENCES_CHANGE, G_CALLBACK(_image_preference_changed), (gpointer)self); }
void gui_init(dt_lib_module_t *self) { dt_lib_styles_t *d = (dt_lib_styles_t *)malloc(sizeof(dt_lib_styles_t)); self->data = (void *)d; d->edit_button = NULL; self->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); GtkWidget *w; GtkWidget *scrolled; /* list */ d->list = GTK_TREE_VIEW(gtk_tree_view_new()); gtk_tree_view_set_headers_visible(d->list, FALSE); GtkListStore *liststore = gtk_list_store_new(DT_STYLES_NUM_COLS, G_TYPE_STRING, G_TYPE_STRING); GtkTreeViewColumn *col = gtk_tree_view_column_new(); gtk_tree_view_append_column(GTK_TREE_VIEW(d->list), col); GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_add_attribute(col, renderer, "text", DT_STYLES_COL_NAME); gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(d->list)), GTK_SELECTION_SINGLE); gtk_tree_view_set_model(GTK_TREE_VIEW(d->list), GTK_TREE_MODEL(liststore)); g_object_unref(liststore); g_object_set(G_OBJECT(d->list), "tooltip-text", _("available styles,\ndoubleclick to apply"), (char *)NULL); g_signal_connect(d->list, "row-activated", G_CALLBACK(_styles_row_activated_callback), d); /* filter entry */ w = gtk_entry_new(); d->entry = GTK_ENTRY(w); g_object_set(G_OBJECT(w), "tooltip-text", _("enter style name"), (char *)NULL); g_signal_connect(d->entry, "changed", G_CALLBACK(entry_callback), d); g_signal_connect(d->entry, "activate", G_CALLBACK(entry_activated), d); dt_gui_key_accel_block_on_focus_connect(GTK_WIDGET(d->entry)); scrolled = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(scrolled), DT_PIXEL_APPLY_DPI(150)); gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(d->entry), TRUE, FALSE, 0); gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(scrolled), TRUE, FALSE, 0); gtk_container_add(GTK_CONTAINER(scrolled), GTK_WIDGET(d->list)); d->duplicate = gtk_check_button_new_with_label(_("create duplicate")); gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(d->duplicate), TRUE, FALSE, 0); g_signal_connect(d->duplicate, "toggled", G_CALLBACK(duplicate_callback), d); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(d->duplicate), dt_conf_get_bool("ui_last/styles_create_duplicate")); g_object_set(d->duplicate, "tooltip-text", _("creates a duplicate of the image before applying style"), (char *)NULL); GtkWidget *hbox1 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5); GtkWidget *hbox2 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5); gtk_box_pack_start(GTK_BOX(self->widget), hbox1, TRUE, FALSE, 0); gtk_box_pack_start(GTK_BOX(self->widget), hbox2, TRUE, FALSE, 0); // create GtkWidget *cbutton = gtk_button_new_with_label(_("create")); g_signal_connect(G_OBJECT(cbutton), "clicked", G_CALLBACK(create_clicked), d); g_object_set(G_OBJECT(cbutton), "tooltip-text", _("create styles from history stack of selected images"), (char *)NULL); gtk_box_pack_start(GTK_BOX(hbox1), cbutton, TRUE, TRUE, 0); // edit GtkWidget *widget = gtk_button_new_with_label(_("edit")); d->edit_button = widget; g_signal_connect(widget, "clicked", G_CALLBACK(edit_clicked), d); g_object_set(widget, "tooltip-text", _("edit the selected style in list above"), (char *)NULL); gtk_box_pack_start(GTK_BOX(hbox1), widget, TRUE, TRUE, 0); // delete widget = gtk_button_new_with_label(_("delete")); d->delete_button = widget; g_signal_connect(widget, "clicked", G_CALLBACK(delete_clicked), d); g_object_set(widget, "tooltip-text", _("deletes the selected style in list above"), (char *)NULL); gtk_box_pack_start(GTK_BOX(hbox1), widget, TRUE, TRUE, 0); // import button GtkWidget *importButton = gtk_button_new_with_label(C_("styles", "import")); d->import_button = importButton; g_object_set(importButton, "tooltip-text", _("import style from a style file"), (char *)NULL); g_signal_connect(importButton, "clicked", G_CALLBACK(import_clicked), d); gtk_box_pack_start(GTK_BOX(hbox2), importButton, TRUE, TRUE, 0); // export button GtkWidget *exportButton = gtk_button_new_with_label(_("export")); d->export_button = exportButton; g_object_set(exportButton, "tooltip-text", _("export the selected style into a style file"), (char *)NULL); g_signal_connect(exportButton, "clicked", G_CALLBACK(export_clicked), d); gtk_box_pack_start(GTK_BOX(hbox2), exportButton, TRUE, TRUE, 0); // add entry completion GtkEntryCompletion *completion = gtk_entry_completion_new(); gtk_entry_completion_set_model(completion, gtk_tree_view_get_model(GTK_TREE_VIEW(d->list))); gtk_entry_completion_set_text_column(completion, 0); gtk_entry_completion_set_inline_completion(completion, TRUE); gtk_entry_set_completion(d->entry, completion); /* update filtered list */ _gui_styles_update_view(d); dt_control_signal_connect(darktable.signals, DT_SIGNAL_STYLE_CHANGED, G_CALLBACK(_styles_changed_callback), d); }
void gui_init(dt_lib_module_t *self) { /* initialize ui widgets */ dt_lib_modulegroups_t *d = (dt_lib_modulegroups_t *)g_malloc0(sizeof(dt_lib_modulegroups_t)); self->data = (void *)d; self->widget = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); dtgtk_cairo_paint_flags_t pf = CPF_STYLE_FLAT; /* favorites */ d->buttons[DT_MODULEGROUP_FAVORITES] = dtgtk_togglebutton_new(dtgtk_cairo_paint_modulegroup_favorites, pf); g_signal_connect(d->buttons[DT_MODULEGROUP_FAVORITES], "toggled", G_CALLBACK(_lib_modulegroups_toggle), self); g_object_set(d->buttons[DT_MODULEGROUP_FAVORITES], "tooltip-text", _("show only your favourite modules (selected in `more modules' below)"), (char *)NULL); /* active */ d->buttons[DT_MODULEGROUP_ACTIVE_PIPE] = dtgtk_togglebutton_new(dtgtk_cairo_paint_modulegroup_active, pf); g_signal_connect(d->buttons[DT_MODULEGROUP_ACTIVE_PIPE], "toggled", G_CALLBACK(_lib_modulegroups_toggle), self); g_object_set(d->buttons[DT_MODULEGROUP_ACTIVE_PIPE], "tooltip-text", _("show only active modules"), (char *)NULL); /* basic */ d->buttons[DT_MODULEGROUP_BASIC] = dtgtk_togglebutton_new(dtgtk_cairo_paint_modulegroup_basic, pf); g_signal_connect(d->buttons[DT_MODULEGROUP_BASIC], "toggled", G_CALLBACK(_lib_modulegroups_toggle), self); g_object_set(d->buttons[DT_MODULEGROUP_BASIC], "tooltip-text", _("basic group"), (char *)NULL); /* correct */ d->buttons[DT_MODULEGROUP_CORRECT] = dtgtk_togglebutton_new(dtgtk_cairo_paint_modulegroup_correct, pf); g_signal_connect(d->buttons[DT_MODULEGROUP_CORRECT], "toggled", G_CALLBACK(_lib_modulegroups_toggle), self); g_object_set(d->buttons[DT_MODULEGROUP_CORRECT], "tooltip-text", _("correction group"), (char *)NULL); /* color */ d->buttons[DT_MODULEGROUP_COLOR] = dtgtk_togglebutton_new(dtgtk_cairo_paint_modulegroup_color, pf); g_signal_connect(d->buttons[DT_MODULEGROUP_COLOR], "toggled", G_CALLBACK(_lib_modulegroups_toggle), self); g_object_set(d->buttons[DT_MODULEGROUP_COLOR], "tooltip-text", _("color group"), (char *)NULL); /* tone */ d->buttons[DT_MODULEGROUP_TONE] = dtgtk_togglebutton_new(dtgtk_cairo_paint_modulegroup_tone, pf); g_signal_connect(d->buttons[DT_MODULEGROUP_TONE], "toggled", G_CALLBACK(_lib_modulegroups_toggle), self); g_object_set(d->buttons[DT_MODULEGROUP_TONE], "tooltip-text", _("tone group"), (char *)NULL); /* effect */ d->buttons[DT_MODULEGROUP_EFFECT] = dtgtk_togglebutton_new(dtgtk_cairo_paint_modulegroup_effect, pf); g_signal_connect(d->buttons[DT_MODULEGROUP_EFFECT], "toggled", G_CALLBACK(_lib_modulegroups_toggle), self); g_object_set(d->buttons[DT_MODULEGROUP_EFFECT], "tooltip-text", _("effects group"), (char *)NULL); /* minimize table height before adding the buttons */ gtk_widget_set_size_request(self->widget, -1, -1); /* * layout button row */ int iconsize = DT_PIXEL_APPLY_DPI(28); GtkWidget *br = self->widget; for(int k = 0; k < DT_MODULEGROUP_SIZE; k++) { gtk_widget_set_size_request(d->buttons[k], iconsize, iconsize); gtk_box_pack_start(GTK_BOX(br), d->buttons[k], TRUE, TRUE, 0); } gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(d->buttons[d->current]), TRUE); gtk_widget_show_all(self->widget); /* * set the proxy functions */ darktable.develop->proxy.modulegroups.module = self; darktable.develop->proxy.modulegroups.set = _lib_modulegroups_set; darktable.develop->proxy.modulegroups.get = _lib_modulegroups_get; darktable.develop->proxy.modulegroups.test = _lib_modulegroups_test; darktable.develop->proxy.modulegroups.switch_group = _lib_modulegroups_switch_group; /* let's connect to view changed signal to set default group */ dt_control_signal_connect(darktable.signals, DT_SIGNAL_VIEWMANAGER_VIEW_CHANGED, G_CALLBACK(_lib_modulegroups_viewchanged_callback), self); }
void gui_init(struct dt_iop_module_t *self) { self->gui_data = malloc(sizeof(dt_iop_zonesystem_gui_data_t)); dt_iop_zonesystem_gui_data_t *g = (dt_iop_zonesystem_gui_data_t *)self->gui_data; g->in_preview_buffer = g->out_preview_buffer = NULL; g->is_dragging = FALSE; g->hilite_zone = FALSE; g->preview_width=g->preview_height = 0; g->mouse_over_output_zones = FALSE; dt_pthread_mutex_init(&g->lock, NULL); self->widget = gtk_vbox_new (FALSE,DT_GUI_IOP_MODULE_CONTROL_SPACING); /* create the zone preview widget */ const int panel_width = dt_conf_get_int("panel_width") * 0.8; g->preview = gtk_drawing_area_new(); g_signal_connect (G_OBJECT (g->preview), "expose-event", G_CALLBACK (dt_iop_zonesystem_preview_expose), self); gtk_widget_add_events (GTK_WIDGET (g->preview), GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_LEAVE_NOTIFY_MASK); gtk_widget_set_size_request(g->preview, panel_width, panel_width); /* create the zonesystem bar widget */ g->zones = gtk_drawing_area_new(); g_object_set (GTK_OBJECT(g->zones), "tooltip-text", _("lightness zones\nuse mouse scrollwheel to change the number of zones\nleft-click on a border to create a marker\nright-click on a marker to delete it"), (char *)NULL); g_signal_connect (G_OBJECT (g->zones), "expose-event", G_CALLBACK (dt_iop_zonesystem_bar_expose), self); g_signal_connect (G_OBJECT (g->zones), "motion-notify-event", G_CALLBACK (dt_iop_zonesystem_bar_motion_notify), self); g_signal_connect (G_OBJECT (g->zones), "leave-notify-event", G_CALLBACK (dt_iop_zonesystem_bar_leave_notify), self); g_signal_connect (G_OBJECT (g->zones), "button-press-event", G_CALLBACK (dt_iop_zonesystem_bar_button_press), self); g_signal_connect (G_OBJECT (g->zones), "button-release-event", G_CALLBACK (dt_iop_zonesystem_bar_button_release), self); g_signal_connect (G_OBJECT (g->zones), "scroll-event", G_CALLBACK (dt_iop_zonesystem_bar_scrolled), self); gtk_widget_add_events (GTK_WIDGET (g->zones), GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_LEAVE_NOTIFY_MASK); gtk_widget_set_size_request(g->zones, -1, DT_PIXEL_APPLY_DPI(40)); gtk_box_pack_start (GTK_BOX (self->widget),g->preview,TRUE,TRUE,0); gtk_box_pack_start (GTK_BOX (self->widget),g->zones,TRUE,TRUE,0); /* add signal handler for preview pipe finish to redraw the preview */ dt_control_signal_connect(darktable.signals, DT_SIGNAL_DEVELOP_PREVIEW_PIPE_FINISHED, G_CALLBACK(_iop_zonesystem_redraw_preview_callback), self); /* load the dt logo as a brackground */ g->image = NULL; g->image_buffer = NULL; g->image_width = 0; g->image_height = 0; char filename[PATH_MAX]; char datadir[PATH_MAX]; const char *logo = is_it_xmas()?"%s/pixmaps/idbutton-2.svg":"%s/pixmaps/idbutton.svg"; dt_loc_get_datadir(datadir, sizeof(datadir)); snprintf(filename, sizeof(filename), logo, datadir); RsvgHandle *svg = rsvg_handle_new_from_file(filename, NULL); if(svg) { cairo_surface_t *surface; cairo_t *cr; RsvgDimensionData dimension; rsvg_handle_get_dimensions(svg, &dimension); float svg_size = MAX(dimension.width, dimension.height); float final_size = panel_width * 0.75; float factor = final_size / svg_size; float final_width = dimension.width * factor, final_height = dimension.height * factor; int stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, final_width); g->image_buffer = (guint8 *)calloc(stride * final_height, sizeof(guint8)); surface = cairo_image_surface_create_for_data(g->image_buffer, CAIRO_FORMAT_ARGB32, final_width, final_height, stride); if(cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS) { free(g->image_buffer); g->image_buffer = NULL; } else { cr = cairo_create(surface); cairo_scale(cr, factor, factor); rsvg_handle_render_cairo(svg, cr); cairo_surface_flush(surface); g->image = surface; g->image_width = final_width; g->image_height = final_height; } g_object_unref(svg); } }
void gui_init (dt_lib_module_t *self) { dt_lib_export_t *d = (dt_lib_export_t *)malloc(sizeof(dt_lib_export_t)); self->data = (void *)d; self->widget = gtk_table_new(8, 2, FALSE); gtk_table_set_row_spacings(GTK_TABLE(self->widget), 5); GtkWidget *label; label = dtgtk_label_new(_("target storage"), DARKTABLE_LABEL_TAB | DARKTABLE_LABEL_ALIGN_RIGHT); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(self->widget), label, 0, 2, 0, 1, GTK_FILL|GTK_EXPAND, 0, 0, 0); d->storage = GTK_COMBO_BOX(gtk_combo_box_text_new()); GList *it = darktable.imageio->plugins_storage; while(it) { dt_imageio_module_storage_t *module = (dt_imageio_module_storage_t *)it->data; gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(d->storage), module->name(module)); it = g_list_next(it); } dt_control_signal_connect(darktable.signals,DT_SIGNAL_IMAGEIO_STORAGE_CHANGE,G_CALLBACK(on_storage_list_changed),self); gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(d->storage), 0, 2, 1, 2, GTK_EXPAND|GTK_FILL, 0, 0, 0); g_signal_connect (G_OBJECT (d->storage), "changed", G_CALLBACK (storage_changed), (gpointer)d); d->storage_box = GTK_CONTAINER(gtk_alignment_new(1.0, 1.0, 1.0, 1.0)); gtk_alignment_set_padding(GTK_ALIGNMENT(d->storage_box), 0, 0, 0, 0); gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(d->storage_box), 0, 2, 2, 3, GTK_EXPAND|GTK_FILL, 0, 0, 0); label = dtgtk_label_new(_("file format"), DARKTABLE_LABEL_TAB | DARKTABLE_LABEL_ALIGN_RIGHT); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_set_row_spacing(GTK_TABLE(self->widget), 2, 20); gtk_table_attach(GTK_TABLE(self->widget), label, 0, 2, 3, 4, GTK_EXPAND|GTK_FILL, 0, 0, 0); d->format = GTK_COMBO_BOX(gtk_combo_box_text_new()); gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(d->format), 0, 2, 4, 5, GTK_EXPAND|GTK_FILL, 0, 0, 0); g_signal_connect (G_OBJECT (d->format), "changed", G_CALLBACK (format_changed), (gpointer)d); d->format_box = GTK_CONTAINER(gtk_alignment_new(1.0, 1.0, 1.0, 1.0)); gtk_alignment_set_padding(GTK_ALIGNMENT(d->format_box), 0, 0, 0, 0); gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(d->format_box), 0, 2, 5, 6, GTK_EXPAND|GTK_FILL, 0, 0, 0); label = dtgtk_label_new(_("global options"), DARKTABLE_LABEL_TAB | DARKTABLE_LABEL_ALIGN_RIGHT); gtk_table_set_row_spacing(GTK_TABLE(self->widget), 5, 20); gtk_table_attach(GTK_TABLE(self->widget), label, 0, 2, 6, 7, GTK_EXPAND|GTK_FILL, 0, 0, 0); d->width = GTK_SPIN_BUTTON(gtk_spin_button_new_with_range(0, 10000, 1)); g_object_set(G_OBJECT(d->width), "tooltip-text", _("maximum output width\nset to 0 for no scaling"), (char *)NULL); d->height = GTK_SPIN_BUTTON(gtk_spin_button_new_with_range(0, 10000, 1)); g_object_set(G_OBJECT(d->height), "tooltip-text", _("maximum output height\nset to 0 for no scaling"), (char *)NULL); dt_gui_key_accel_block_on_focus_connect (GTK_WIDGET (d->width)); dt_gui_key_accel_block_on_focus_connect (GTK_WIDGET (d->height)); /* gtk_widget_add_events(GTK_WIDGET(d->width), GDK_FOCUS_CHANGE_MASK); g_signal_connect (G_OBJECT (d->width), "focus-in-event", G_CALLBACK(focus_in), NULL); g_signal_connect (G_OBJECT (d->width), "focus-out-event", G_CALLBACK(focus_out), NULL); gtk_widget_add_events(GTK_WIDGET(d->height), GDK_FOCUS_CHANGE_MASK); g_signal_connect (G_OBJECT (d->height), "focus-in-event", G_CALLBACK(focus_in), NULL); g_signal_connect (G_OBJECT (d->height), "focus-out-event", G_CALLBACK(focus_out), NULL); */ label = gtk_label_new(_("max size")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(self->widget), label, 0, 1, 7, 8, GTK_EXPAND|GTK_FILL, 0, 0, 0); GtkBox *hbox = GTK_BOX(gtk_hbox_new(FALSE, 5)); gtk_box_pack_start(hbox, GTK_WIDGET(d->width), TRUE, TRUE, 0); gtk_box_pack_start(hbox, gtk_label_new(_("x")), FALSE, FALSE, 0); gtk_box_pack_start(hbox, GTK_WIDGET(d->height), TRUE, TRUE, 0); gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(hbox), 1, 2, 7, 8, GTK_EXPAND|GTK_FILL, 0, 0, 0); label = gtk_label_new(_("intent")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(self->widget), label, 0, 1, 8, 9, GTK_EXPAND|GTK_FILL, 0, 0, 0); d->intent = GTK_COMBO_BOX(gtk_combo_box_text_new()); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(d->intent), _("image settings")); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(d->intent), _("perceptual")); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(d->intent), _("relative colorimetric")); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(d->intent), C_("rendering intent", "saturation")); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(d->intent), _("absolute colorimetric")); gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(d->intent), 1, 2, 8, 9, GTK_EXPAND|GTK_FILL, 0, 0, 0); // Add profile combo d->profiles = NULL; dt_lib_export_profile_t *prof = (dt_lib_export_profile_t *)g_malloc0(sizeof(dt_lib_export_profile_t)); g_strlcpy(prof->filename, "sRGB", sizeof(prof->filename)); dt_utf8_strlcpy(prof->name, _("sRGB (web-safe)"), sizeof(prof->name)); int pos; prof->pos = 1; d->profiles = g_list_append(d->profiles, prof); prof = (dt_lib_export_profile_t *)g_malloc0(sizeof(dt_lib_export_profile_t)); g_strlcpy(prof->filename, "adobergb", sizeof(prof->filename)); dt_utf8_strlcpy(prof->name, _("Adobe RGB (compatible)"), sizeof(prof->name)); prof->pos = 2; d->profiles = g_list_append(d->profiles, prof); prof = (dt_lib_export_profile_t *)g_malloc0(sizeof(dt_lib_export_profile_t)); g_strlcpy(prof->filename, "X profile", sizeof(prof->filename)); dt_utf8_strlcpy(prof->name, "X profile", sizeof(prof->name)); prof->pos = 3; d->profiles = g_list_append(d->profiles, prof); prof = (dt_lib_export_profile_t *)g_malloc0(sizeof(dt_lib_export_profile_t)); g_strlcpy(prof->filename, "linear_rgb", sizeof(prof->filename)); dt_utf8_strlcpy(prof->name, _("linear Rec709 RGB"), sizeof(prof->name)); pos = prof->pos = 4; d->profiles = g_list_append(d->profiles, prof); // read datadir/color/out/*.icc char datadir[DT_MAX_PATH_LEN]; char confdir[DT_MAX_PATH_LEN]; char dirname[DT_MAX_PATH_LEN]; char filename[DT_MAX_PATH_LEN]; dt_loc_get_user_config_dir(confdir, DT_MAX_PATH_LEN); dt_loc_get_datadir(datadir, DT_MAX_PATH_LEN); cmsHPROFILE tmpprof; const gchar *d_name; snprintf(dirname, DT_MAX_PATH_LEN, "%s/color/out", confdir); if(!g_file_test(dirname, G_FILE_TEST_IS_DIR)) snprintf(dirname, DT_MAX_PATH_LEN, "%s/color/out", datadir); GDir *dir = g_dir_open(dirname, 0, NULL); if(dir) { while((d_name = g_dir_read_name(dir))) { snprintf(filename, DT_MAX_PATH_LEN, "%s/%s", dirname, d_name); tmpprof = cmsOpenProfileFromFile(filename, "r"); if(tmpprof) { char *lang = getenv("LANG"); if (!lang) lang = "en_US"; dt_lib_export_profile_t *prof = (dt_lib_export_profile_t *)g_malloc0(sizeof(dt_lib_export_profile_t)); dt_colorspaces_get_profile_name(tmpprof, lang, lang+3, prof->name, sizeof(prof->name)); g_strlcpy(prof->filename, d_name, sizeof(prof->filename)); prof->pos = ++pos; cmsCloseProfile(tmpprof); d->profiles = g_list_append(d->profiles, prof); } } g_dir_close(dir); } GList *l = d->profiles; label = gtk_label_new(_("profile")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(self->widget), label, 0, 1, 9, 10, GTK_EXPAND|GTK_FILL, 0, 0, 0); d->profile = GTK_COMBO_BOX(gtk_combo_box_text_new()); dt_ellipsize_combo(d->profile); gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(d->profile), 1, 2, 9, 10, GTK_SHRINK|GTK_EXPAND|GTK_FILL, 0, 0, 0); // gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(d->profile), 1, 2, 9, 10, GTK_EXPAND|GTK_FILL, 0, 0, 0); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(d->profile), _("image settings")); while(l) { dt_lib_export_profile_t *prof = (dt_lib_export_profile_t *)l->data; if(!strcmp(prof->name, "X profile")) gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(d->profile), _("system display profile")); else gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(d->profile), prof->name); l = g_list_next(l); } gtk_combo_box_set_active(d->profile, 0); char tooltip[1024]; snprintf(tooltip, sizeof(tooltip), _("output ICC profiles in %s/color/out or %s/color/out"), confdir, datadir); g_object_set(G_OBJECT(d->profile), "tooltip-text", tooltip, (char *)NULL); // Add style combo label = gtk_label_new(_("style")); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_table_attach(GTK_TABLE(self->widget), label, 0, 1, 10, 11, GTK_EXPAND|GTK_FILL, 0, 0, 0); d->style = GTK_COMBO_BOX(gtk_combo_box_text_new()); dt_ellipsize_combo(d->style); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(d->style), _("none")); GList *styles = dt_styles_get_list(""); while (styles) { dt_style_t *style=(dt_style_t *)styles->data; gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(d->style), style->name); styles=g_list_next(styles); } gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(d->style), 1, 2, 10, 11, GTK_EXPAND|GTK_FILL, 0, 0, 0); g_object_set(G_OBJECT(d->style), "tooltip-text", _("temporary style to append while exporting"), (char *)NULL); // Set callback signals g_signal_connect (G_OBJECT (d->intent), "changed", G_CALLBACK (intent_changed), (gpointer)d); g_signal_connect (G_OBJECT (d->profile), "changed", G_CALLBACK (profile_changed), (gpointer)d); g_signal_connect (G_OBJECT (d->style), "changed", G_CALLBACK (style_changed), (gpointer)d); // Export button GtkButton *button = GTK_BUTTON(gtk_button_new_with_label(_("export"))); d->export_button = button; g_object_set(G_OBJECT(button), "tooltip-text", _("export with current settings (ctrl-e)"), (char *)NULL); gtk_table_attach(GTK_TABLE(self->widget), GTK_WIDGET(button), 1, 2, 11, 12, GTK_EXPAND|GTK_FILL, 0, 0, 0); g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (export_button_clicked), (gpointer)self); g_signal_connect (G_OBJECT (d->width), "value-changed", G_CALLBACK (width_changed), NULL); g_signal_connect (G_OBJECT (d->height), "value-changed", G_CALLBACK (height_changed), NULL); self->gui_reset(self); }
void enter(dt_view_t *self) { /* connect to ui pipe finished signal for redraw */ dt_control_signal_connect(darktable.signals, DT_SIGNAL_DEVELOP_UI_PIPE_FINISHED,G_CALLBACK(_darkroom_ui_pipe_finish_signal_callback), (gpointer)self); dt_print(DT_DEBUG_CONTROL, "[run_job+] 11 %f in darkroom mode\n", dt_get_wtime()); dt_develop_t *dev = (dt_develop_t *)self->data; dev->gui_leaving = 0; dev->gui_module = NULL; select_this_image(dev->image_storage.id); DT_CTL_SET_GLOBAL(dev_zoom, DT_ZOOM_FIT); DT_CTL_SET_GLOBAL(dev_zoom_x, 0); DT_CTL_SET_GLOBAL(dev_zoom_y, 0); DT_CTL_SET_GLOBAL(dev_closeup, 0); // take a copy of the image struct for convenience. dt_dev_load_image(darktable.develop, dev->image_storage.id); /* * Add view specific tool buttons */ /* create favorite plugin preset popup tool */ GtkWidget *favorite_presets = dtgtk_button_new(dtgtk_cairo_paint_presets, CPF_STYLE_FLAT|CPF_DO_NOT_USE_BORDER); g_object_set(G_OBJECT(favorite_presets), "tooltip-text", _("quick access to presets of your favorites"), (char *)NULL); g_signal_connect (G_OBJECT (favorite_presets), "clicked", G_CALLBACK (_darkroom_ui_favorite_presets_popupmenu), NULL); dt_view_manager_view_toolbox_add(darktable.view_manager, favorite_presets); /* add IOP modules to plugin list */ /* create quick styles popup menu tool */ GtkWidget *styles = dtgtk_button_new (dtgtk_cairo_paint_styles,CPF_STYLE_FLAT|CPF_DO_NOT_USE_BORDER); g_signal_connect (G_OBJECT (styles), "clicked", G_CALLBACK (_darkroom_ui_apply_style_popupmenu), NULL); g_object_set (G_OBJECT (styles), "tooltip-text", _("quick access for applying any of your styles"), (char *)NULL); dt_view_manager_view_toolbox_add(darktable.view_manager, styles); /* * add IOP modules to plugin list */ // avoid triggering of events before plugin is ready: darktable.gui->reset = 1; char option[1024]; GList *modules = g_list_last(dev->iop); while(modules) { dt_iop_module_t *module = (dt_iop_module_t *)(modules->data); /* initialize gui if iop have one defined */ if (!dt_iop_is_hidden(module)) { module->gui_init(module); dt_iop_reload_defaults(module); /* add module to right panel */ GtkWidget *expander = dt_iop_gui_get_expander(module); dt_ui_container_add_widget(darktable.gui->ui, DT_UI_CONTAINER_PANEL_RIGHT_CENTER, expander); snprintf(option, 1024, "plugins/darkroom/%s/expanded", module->op); dt_iop_gui_set_expanded(module, dt_conf_get_bool(option)); } /* setup key accelerators */ module->accel_closures = NULL; if(module->connect_key_accels) module->connect_key_accels(module); dt_iop_connect_common_accels(module); modules = g_list_previous(modules); } darktable.gui->reset = 0; /* signal that darktable.develop is initialized and ready to be used */ dt_control_signal_raise(darktable.signals,DT_SIGNAL_DEVELOP_INITIALIZE); // synch gui and flag gegl pipe as dirty // this is done here and not in dt_read_history, as it would else be triggered before module->gui_init. dt_dev_pop_history_items(dev, dev->history_end); /* ensure that filmstrip shows current image */ dt_view_filmstrip_scroll_to_image(darktable.view_manager, dev->image_storage.id, FALSE); // switch on groups as they where last time: dt_dev_modulegroups_set(dev, dt_conf_get_int("plugins/darkroom/groups")); // make signals work again: darktable.gui->reset = 0; // get last active plugin: gchar *active_plugin = dt_conf_get_string("plugins/darkroom/active"); if(active_plugin) { GList *modules = dev->iop; while(modules) { dt_iop_module_t *module = (dt_iop_module_t *)(modules->data); if(!strcmp(module->op, active_plugin)) dt_iop_request_focus(module); modules = g_list_next(modules); } g_free(active_plugin); } // image should be there now. float zoom_x, zoom_y; dt_dev_check_zoom_bounds(dev, &zoom_x, &zoom_y, DT_ZOOM_FIT, 0, NULL, NULL); DT_CTL_SET_GLOBAL(dev_zoom_x, zoom_x); DT_CTL_SET_GLOBAL(dev_zoom_y, zoom_y); /* connect signal for filmstrip image activate */ dt_control_signal_connect(darktable.signals, DT_SIGNAL_VIEWMANAGER_FILMSTRIP_ACTIVATE, G_CALLBACK(_view_darkroom_filmstrip_activate_callback), self); // prefetch next few from first selected image on. dt_view_filmstrip_prefetch(); }
void gui_init(dt_lib_module_t *self) { /* initialize ui widgets */ dt_lib_filmstrip_t *d = (dt_lib_filmstrip_t *)g_malloc(sizeof(dt_lib_filmstrip_t)); self->data = (void *)d; memset(d,0,sizeof(dt_lib_filmstrip_t)); d->last_selected_id = -1; d->history_copy_imgid = -1; d->activated_image = -1; d->mouse_over_id = -1; dt_gui_hist_dialog_init(&d->dg); /* creating drawing area */ self->widget = gtk_vbox_new(FALSE,0); /* creating filmstrip box*/ d->filmstrip = gtk_event_box_new(); /* allow drag&drop of images from the filmstrip. this has to come before the other callbacks are registered! */ gtk_drag_source_set(d->filmstrip, GDK_BUTTON1_MASK, target_list_all, n_targets_all, GDK_ACTION_COPY); #ifdef HAVE_MAP gtk_drag_dest_set(d->filmstrip, GTK_DEST_DEFAULT_ALL, target_list_internal, n_targets_internal, GDK_ACTION_COPY); #endif g_signal_connect_after(d->filmstrip, "drag-begin", G_CALLBACK(_lib_filmstrip_dnd_begin_callback), self); g_signal_connect(d->filmstrip, "drag-data-get", G_CALLBACK(_lib_filmstrip_dnd_get_callback), self); gtk_widget_add_events(d->filmstrip, GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_SCROLL_MASK | GDK_LEAVE_NOTIFY_MASK); /* connect callbacks */ g_signal_connect (G_OBJECT (d->filmstrip), "expose-event", G_CALLBACK (_lib_filmstrip_expose_callback), self); g_signal_connect (G_OBJECT (d->filmstrip), "button-press-event", G_CALLBACK (_lib_filmstrip_button_press_callback), self); g_signal_connect (G_OBJECT (d->filmstrip), "button-release-event", G_CALLBACK (_lib_filmstrip_button_release_callback), self); g_signal_connect (G_OBJECT (d->filmstrip), "scroll-event", G_CALLBACK (_lib_filmstrip_scroll_callback), self); g_signal_connect (G_OBJECT (d->filmstrip), "motion-notify-event", G_CALLBACK(_lib_filmstrip_motion_notify_callback), self); g_signal_connect (G_OBJECT (d->filmstrip), "leave-notify-event", G_CALLBACK(_lib_filmstrip_mouse_leave_callback), self); /* set size of filmstrip */ int32_t height = dt_conf_get_int("plugins/lighttable/filmstrip/height"); gtk_widget_set_size_request(d->filmstrip, -1, CLAMP(height,64,400)); /* create the resize handle */ GtkWidget *size_handle = gtk_event_box_new(); gtk_widget_set_size_request(size_handle,-1,10); gtk_widget_add_events(size_handle, GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK ); g_signal_connect (G_OBJECT (size_handle), "button-press-event", G_CALLBACK (_lib_filmstrip_size_handle_button_callback), self); g_signal_connect (G_OBJECT (size_handle), "button-release-event", G_CALLBACK (_lib_filmstrip_size_handle_button_callback), self); g_signal_connect (G_OBJECT (size_handle), "motion-notify-event", G_CALLBACK (_lib_filmstrip_size_handle_motion_notify_callback), self); g_signal_connect (G_OBJECT (size_handle), "leave-notify-event", G_CALLBACK(_lib_filmstrip_size_handle_cursor_callback), self); g_signal_connect (G_OBJECT (size_handle), "enter-notify-event", G_CALLBACK(_lib_filmstrip_size_handle_cursor_callback), self); gtk_box_pack_start(GTK_BOX(self->widget), size_handle, FALSE, FALSE,0); gtk_box_pack_start(GTK_BOX(self->widget), d->filmstrip, FALSE, FALSE,0); /* initialize view manager proxy */ darktable.view_manager->proxy.filmstrip.module = self; darktable.view_manager->proxy.filmstrip.scroll_to_image = _lib_filmstrip_scroll_to_image; darktable.view_manager->proxy.filmstrip.activated_image = _lib_filmstrip_get_activated_imgid; darktable.view_manager->proxy.filmstrip.widget = _lib_filmstrip_get_widget; /* connect signal handler */ dt_control_signal_connect(darktable.signals, DT_SIGNAL_COLLECTION_CHANGED, G_CALLBACK(_lib_filmstrip_collection_changed_callback), (gpointer)self); dt_control_signal_connect(darktable.signals, DT_SIGNAL_DEVELOP_MIPMAP_UPDATED, G_CALLBACK(_lib_filmstrip_collection_changed_callback), (gpointer)self); }