| 110 | } |
| 111 | |
| 112 | void PiuFieldBind(void* it, PiuApplication* application, PiuView* view) |
| 113 | { |
| 114 | PiuField* self = (PiuField*)it; |
| 115 | xsMachine* the = (*self)->the; |
| 116 | PiuContentBind(it, application, view); |
| 117 | PiuFieldComputeStyle(self); |
| 118 | PiuSkin* skin = (*self)->skin; |
| 119 | PiuStyle* style = (*self)->computedStyle; |
| 120 | |
| 121 | char buffer[1024]; |
| 122 | snprintf(buffer, sizeof(buffer), |
| 123 | "#field {\n" |
| 124 | " background-color: transparent;\n" |
| 125 | " background-image: none;\n" |
| 126 | " border: 0 none transparent;\n" |
| 127 | " box-shadow: none;\n" |
| 128 | " color: #%2.2x%2.2x%2.2x;\n" |
| 129 | " outline: transparent none 0;\n" |
| 130 | " margin: 0;\n" |
| 131 | " padding: 0px 4px 0px 4px;\n" |
| 132 | "}\n" |
| 133 | "#field selection {\n" |
| 134 | " background-color: #%2.2x%2.2x%2.2x;\n" |
| 135 | " color: #%2.2x%2.2x%2.2x;\n" |
| 136 | "}\n", |
| 137 | (*style)->color[0].r, (*style)->color[0].g, (*style)->color[0].b, |
| 138 | (*skin)->data.color.fill[1].r, (*skin)->data.color.fill[1].g, (*skin)->data.color.fill[1].b, |
| 139 | (*style)->color[1].r, (*style)->color[1].g, (*style)->color[1].b); |
| 140 | |
| 141 | (*self)->gtkCssProvider = gtk_css_provider_new(); |
| 142 | gtk_css_provider_load_from_data((*self)->gtkCssProvider, buffer, -1, NULL); |
| 143 | |
| 144 | |
| 145 | GtkFixed* gtkFixed = (*view)->gtkFixed; |
| 146 | GtkWidget* gtkField = gtk_entry_new(); |
| 147 | g_signal_connect(G_OBJECT(gtkField), "activate", G_CALLBACK(gtk_entry_activate), self); |
| 148 | g_signal_connect(G_OBJECT(gtkField), "focus-in-event", G_CALLBACK(gtk_entry_focused), self); |
| 149 | // gtk_entry_set_attributes(GTK_ENTRY(gtkField), (*font)->pangoAttributes); |
| 150 | gtk_widget_set_name(GTK_WIDGET(gtkField), "field"); |
| 151 | GtkStyleContext* style_context = gtk_widget_get_style_context(gtkField); |
| 152 | gtk_style_context_add_class(style_context, GTK_STYLE_CLASS_VIEW ); |
| 153 | gtk_style_context_add_provider(style_context, GTK_STYLE_PROVIDER((*self)->gtkCssProvider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); |
| 154 | if ((*self)->hint) { |
| 155 | xsStringValue string = PiuToString((*self)->hint); |
| 156 | gtk_entry_set_placeholder_text(GTK_ENTRY(gtkField), string); |
| 157 | } |
| 158 | if ((*self)->string) { |
| 159 | xsStringValue string = PiuToString((*self)->string); |
| 160 | gtk_entry_set_text(GTK_ENTRY(gtkField), string); |
| 161 | } |
| 162 | g_signal_connect(G_OBJECT(gtkField), "changed", G_CALLBACK(gtk_entry_changed), self); |
| 163 | GtkPiuClip* gtkClip = gtk_piu_clip_new((PiuContent*)self, GTK_WIDGET(gtkField)); |
| 164 | gtk_container_add(GTK_CONTAINER(gtkClip), GTK_WIDGET(gtkField)); |
| 165 | gtk_container_add(GTK_CONTAINER(gtkFixed), GTK_WIDGET(gtkClip)); |
| 166 | gtk_widget_show(GTK_WIDGET(gtkClip)); |
| 167 | (*self)->gtkClip = GTK_WIDGET(gtkClip); |
| 168 | (*self)->gtkField = gtkField; |
| 169 | } |
nothing calls this directly
no test coverage detected