static GtkWidget *_lib_location_place_widget_new(dt_lib_location_t *lib, _lib_location_result_t *place) { GtkWidget *eb, *hb, *vb, *w; eb = gtk_event_box_new(); hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, DT_PIXEL_APPLY_DPI(2)); vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, DT_PIXEL_APPLY_DPI(2)); /* add name */ w = gtk_label_new(place->name); gtk_label_set_line_wrap(GTK_LABEL(w), TRUE); gtk_widget_set_halign(w, GTK_ALIGN_START); g_object_set(G_OBJECT(w), "xalign", 0.0, (gchar *)0); gtk_box_pack_start(GTK_BOX(vb), w, FALSE, FALSE, 0); /* add location coord */ gchar *lat = dt_util_latitude_str(place->lat); gchar *lon = dt_util_longitude_str(place->lon); gchar *location = g_strconcat(lat, ", ", lon, NULL); w = gtk_label_new(location); g_free(lat); g_free(lon); g_free(location); gtk_label_set_line_wrap(GTK_LABEL(w), TRUE); gtk_widget_set_halign(w, GTK_ALIGN_START); gtk_box_pack_start(GTK_BOX(vb), w, FALSE, FALSE, 0); /* type icon */ GtkWidget *icon = dtgtk_icon_new(dtgtk_cairo_paint_triangle, CPF_DIRECTION_LEFT, NULL); gtk_widget_set_size_request(icon, DT_PIXEL_APPLY_DPI(10), -1); /* setup layout */ gtk_box_pack_start(GTK_BOX(hb), icon, FALSE, FALSE, DT_PIXEL_APPLY_DPI(2)); gtk_box_pack_start(GTK_BOX(hb), vb, FALSE, FALSE, DT_PIXEL_APPLY_DPI(2)); gtk_container_add(GTK_CONTAINER(eb), hb); gtk_widget_show_all(eb); /* connect button press signal for result item */ _callback_param_t *param = (_callback_param_t *)malloc(sizeof(_callback_param_t)); lib->callback_params = g_list_append(lib->callback_params, param); param->lib = lib; param->result = place; g_signal_connect(G_OBJECT(eb), "button-press-event", G_CALLBACK(_lib_location_result_item_activated), (gpointer)param); return eb; }
static GtkWidget *_lib_location_place_widget_new(_lib_location_result_t *place) { GtkWidget *eb, *hb, *vb, *w; char location[512]; eb = gtk_event_box_new(); hb = gtk_hbox_new(FALSE,2); vb = gtk_vbox_new(FALSE,2); /* add name */ w = gtk_label_new(place->name); gtk_label_set_line_wrap(GTK_LABEL(w), TRUE); gtk_misc_set_alignment(GTK_MISC(w), 0.0, 0.5); gtk_box_pack_start(GTK_BOX(vb), w, FALSE, FALSE, 0); /* add location coord */ g_snprintf(location, sizeof(location), "lat: %.4f lon: %.4f", place->lat, place->lon); w = gtk_label_new(location); gtk_label_set_line_wrap(GTK_LABEL(w), TRUE); gtk_misc_set_alignment(GTK_MISC(w), 0.0, 0.5); gtk_box_pack_start(GTK_BOX(vb), w, FALSE, FALSE, 0); /* type icon */ GtkWidget *icon = dtgtk_icon_new(dtgtk_cairo_paint_store, 0); /* setup layout */ gtk_box_pack_start(GTK_BOX(hb), icon, FALSE, FALSE, 2); gtk_box_pack_start(GTK_BOX(hb), vb, FALSE, FALSE, 2); gtk_container_add(GTK_CONTAINER(eb), hb); gtk_widget_show_all(eb); /* connect button press signal for result item */ g_signal_connect(G_OBJECT (eb), "button-press-event", G_CALLBACK (_lib_location_result_item_activated), (gpointer)place); return eb; }
GtkWidget * dt_lib_gui_get_expander (dt_lib_module_t *module) { /* check if module is expandable */ if(!module->expandable()) { module->expander = NULL; return NULL; } int bs = 12; GtkWidget *expander = gtk_vbox_new(FALSE, 3); GtkWidget *header_evb = gtk_event_box_new(); GtkWidget *header = gtk_hbox_new(FALSE, 0); GtkWidget *pluginui_frame = gtk_frame_new(NULL); GtkWidget *pluginui = gtk_event_box_new(); /* setup the header box */ gtk_container_add(GTK_CONTAINER(header_evb), header); g_signal_connect(G_OBJECT(header_evb), "button-press-event", G_CALLBACK(_lib_plugin_header_button_press), module); /* setup plugin content frame */ gtk_frame_set_shadow_type(GTK_FRAME(pluginui_frame),GTK_SHADOW_IN); gtk_container_add(GTK_CONTAINER(pluginui_frame),pluginui); /* layout the main expander widget */ gtk_box_pack_start(GTK_BOX(expander), header_evb, TRUE, FALSE, 0); gtk_box_pack_start(GTK_BOX(expander), pluginui_frame, TRUE, FALSE,0); /* * initialize the header widgets */ int idx=0; GtkWidget *hw[5]= {NULL,NULL,NULL,NULL,NULL}; /* add the expand indicator icon */ hw[idx] = dtgtk_icon_new(dtgtk_cairo_paint_solid_arrow, CPF_DIRECTION_LEFT); gtk_widget_set_size_request(GTK_WIDGET(hw[idx++]),bs,bs); /* add module label */ char label[128]; g_snprintf(label,128,"<span size=\"larger\">%s</span>",module->name()); hw[idx] = gtk_label_new(""); gtk_widget_set_name(hw[idx], "panel_label"); gtk_label_set_markup(GTK_LABEL(hw[idx++]),label); /* add reset button if module has implementation */ if (module->gui_reset) { hw[idx] = dtgtk_button_new(dtgtk_cairo_paint_reset, CPF_STYLE_FLAT|CPF_DO_NOT_USE_BORDER); module->reset_button = GTK_WIDGET(hw[idx]); g_object_set(G_OBJECT(hw[idx]), "tooltip-text", _("reset parameters"), (char *)NULL); g_signal_connect (G_OBJECT (hw[idx]), "clicked", G_CALLBACK (dt_lib_gui_reset_callback), module); } else hw[idx] = gtk_fixed_new(); gtk_widget_set_size_request(GTK_WIDGET(hw[idx++]),bs,bs); /* add preset button if module has implementation */ if (module->get_params) { hw[idx] = dtgtk_button_new(dtgtk_cairo_paint_presets,CPF_STYLE_FLAT|CPF_DO_NOT_USE_BORDER); module->presets_button = GTK_WIDGET(hw[idx]); g_object_set(G_OBJECT(hw[idx]), "tooltip-text", _("presets"), (char *)NULL); g_signal_connect (G_OBJECT (hw[idx]), "clicked", G_CALLBACK (popup_callback), module); } else hw[idx] = gtk_fixed_new(); gtk_widget_set_size_request(GTK_WIDGET(hw[idx++]),bs,bs); /* add a spacer to align buttons with iop buttons (enabled button) */ hw[idx] = gtk_fixed_new(); gtk_widget_set_size_request(GTK_WIDGET(hw[idx++]),bs,bs); /* lets order header elements depending on left/right side panel placement */ int c = module->container(); if ( (c == DT_UI_CONTAINER_PANEL_LEFT_TOP) || (c == DT_UI_CONTAINER_PANEL_LEFT_CENTER) || (c == DT_UI_CONTAINER_PANEL_LEFT_BOTTOM) ) { for(int i=0; i<=4; i++) if (hw[i]) gtk_box_pack_start(GTK_BOX(header), hw[i],i==1?TRUE:FALSE,i==1?TRUE:FALSE,2); gtk_misc_set_alignment(GTK_MISC(hw[1]),0.0,0.5); dtgtk_icon_set_paint(hw[0], dtgtk_cairo_paint_solid_arrow, CPF_DIRECTION_RIGHT); } else { for(int i=4; i>=0; i--) if (hw[i]) gtk_box_pack_start(GTK_BOX(header), hw[i],i==1?TRUE:FALSE,i==1?TRUE:FALSE,2); gtk_misc_set_alignment(GTK_MISC(hw[1]),1.0,0.5); dtgtk_icon_set_paint(hw[0], dtgtk_cairo_paint_solid_arrow, CPF_DIRECTION_LEFT); } /* add module widget into an alignment */ GtkWidget *al = gtk_alignment_new(1.0, 1.0, 1.0, 1.0); gtk_alignment_set_padding(GTK_ALIGNMENT(al), 8, 8, 8, 8); gtk_container_add(GTK_CONTAINER(pluginui), al); gtk_container_add(GTK_CONTAINER(al), module->widget); gtk_widget_show_all(module->widget); module->expander = expander; return module->expander; }
GtkWidget *dt_lib_gui_get_expander(dt_lib_module_t *module) { /* check if module is expandable */ if(!module->expandable(module)) { module->expander = NULL; return NULL; } int bs = DT_PIXEL_APPLY_DPI(12); GtkWidget *header = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); GtkWidget *expander = dtgtk_expander_new(header, module->widget); GtkWidget *header_evb = dtgtk_expander_get_header_event_box(DTGTK_EXPANDER(expander)); GtkWidget *pluginui_frame = dtgtk_expander_get_frame(DTGTK_EXPANDER(expander)); /* setup the header box */ g_signal_connect(G_OBJECT(header_evb), "button-press-event", G_CALLBACK(_lib_plugin_header_button_press), module); /* setup plugin content frame */ gtk_frame_set_shadow_type(GTK_FRAME(pluginui_frame), GTK_SHADOW_IN); /* * initialize the header widgets */ int idx = 0; GtkWidget *hw[5] = { NULL, NULL, NULL, NULL, NULL }; /* add the expand indicator icon */ hw[idx] = dtgtk_icon_new(dtgtk_cairo_paint_solid_arrow, CPF_DIRECTION_LEFT); gtk_widget_set_size_request(GTK_WIDGET(hw[idx++]), bs, bs); /* add module label */ char label[128]; g_snprintf(label, sizeof(label), "<span size=\"larger\">%s</span>", module->name(module)); hw[idx] = gtk_label_new(""); gtk_widget_set_name(hw[idx], "panel_label"); gtk_label_set_markup(GTK_LABEL(hw[idx]), label); gtk_widget_set_tooltip_text(hw[idx], module->name(module)); gtk_label_set_ellipsize(GTK_LABEL(hw[idx++]), PANGO_ELLIPSIZE_MIDDLE); /* add reset button if module has implementation */ if(module->gui_reset) { hw[idx] = dtgtk_button_new(dtgtk_cairo_paint_reset, CPF_STYLE_FLAT | CPF_DO_NOT_USE_BORDER); module->reset_button = GTK_WIDGET(hw[idx]); gtk_widget_set_tooltip_text(hw[idx], _("reset parameters")); g_signal_connect(G_OBJECT(hw[idx]), "clicked", G_CALLBACK(dt_lib_gui_reset_callback), module); } else hw[idx] = gtk_fixed_new(); gtk_widget_set_size_request(GTK_WIDGET(hw[idx++]), bs, bs); /* add preset button if module has implementation */ if(module->get_params) { hw[idx] = dtgtk_button_new(dtgtk_cairo_paint_presets, CPF_STYLE_FLAT | CPF_DO_NOT_USE_BORDER); module->presets_button = GTK_WIDGET(hw[idx]); gtk_widget_set_tooltip_text(hw[idx], _("presets")); g_signal_connect(G_OBJECT(hw[idx]), "clicked", G_CALLBACK(popup_callback), module); } else hw[idx] = gtk_fixed_new(); gtk_widget_set_size_request(GTK_WIDGET(hw[idx++]), bs, bs); /* add a spacer to align buttons with iop buttons (enabled button) */ hw[idx] = gtk_fixed_new(); gtk_widget_set_size_request(GTK_WIDGET(hw[idx++]), bs, bs); /* lets order header elements depending on left/right side panel placement */ int c = module->container(module); if((c == DT_UI_CONTAINER_PANEL_LEFT_TOP) || (c == DT_UI_CONTAINER_PANEL_LEFT_CENTER) || (c == DT_UI_CONTAINER_PANEL_LEFT_BOTTOM)) { for(int i = 0; i <= 4; i++) if(hw[i]) gtk_box_pack_start(GTK_BOX(header), hw[i], i == 1 ? TRUE : FALSE, i == 1 ? TRUE : FALSE, 2); gtk_widget_set_halign(hw[1], GTK_ALIGN_START); dtgtk_icon_set_paint(hw[0], dtgtk_cairo_paint_solid_arrow, CPF_DIRECTION_RIGHT); } else { for(int i = 4; i >= 0; i--) if(hw[i]) gtk_box_pack_start(GTK_BOX(header), hw[i], i == 1 ? TRUE : FALSE, i == 1 ? TRUE : FALSE, 2); gtk_widget_set_halign(hw[1], GTK_ALIGN_END); dtgtk_icon_set_paint(hw[0], dtgtk_cairo_paint_solid_arrow, CPF_DIRECTION_LEFT); } /* add empty space around widget */ gtk_widget_set_margin_start(module->widget, DT_PIXEL_APPLY_DPI(8)); gtk_widget_set_margin_end(module->widget, DT_PIXEL_APPLY_DPI(8)); gtk_widget_set_margin_top(module->widget, DT_PIXEL_APPLY_DPI(8)); gtk_widget_set_margin_bottom(module->widget, DT_PIXEL_APPLY_DPI(8)); gtk_widget_show_all(module->widget); gtk_widget_set_name(pluginui_frame, "lib-plugin-ui"); module->expander = expander; gtk_widget_set_hexpand(module->widget, FALSE); gtk_widget_set_vexpand(module->widget, FALSE); return module->expander; }