/
gui.c
162 lines (114 loc) · 4.72 KB
/
gui.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
Koi - a GIMP image authentication plugin
Copyright (C) 2010 ben howard
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "clone.h"
#include "grain.h"
#include "texture.h"
#include "jpeg_compress.h"
#include "speckle.h"
#include "mosaic.h"
#include "gui.h"
#define NUM_PLUGINS 6
KOI_PLUGIN* plugin[NUM_PLUGINS];
static gboolean koi_dialog (GimpDrawable *drawable)
{
GtkWidget *dialog;
GtkWidget *main_vbox;
GtkWidget *main_hbox;
GtkWidget *preview;
GtkWidget *frame;
GtkWidget *alignment;
GtkWidget *vbox;
GtkWidget *label;
GtkWidget *thread_count_spinbutton;
GtkObject *thread_count_spinbutton_value;
GtkWidget *notebook;
int ii;
// gui_options.threads = 4;
// gui_options.texture_threshold = 140;
// gui_options.clone_block_size = 16;
// gui_options.histogram_block_size = 8;
// gui_options.radius = 20;
// gui_options.jpeg_threshold = 64;
// gui_options.compress = .85;
gboolean run;
printf("######################################\n");
printf("############## GUI init ##############\n");
gimp_ui_init ("Koi", FALSE);
dialog = gimp_dialog_new ("Koi", "Koi", NULL, 0, gimp_standard_help_func, "Koi", GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
//create plugins and link them into the list
create_clone_plugin();
plugin[0] = &clone_plugin;
create_grain_plugin();
plugin[1] = &grain_plugin;
create_texture_plugin();
plugin[2] = &texture_plugin;
create_speckle_plugin();
plugin[3] = &speckle_plugin;
create_mosaic_plugin();
plugin[4] = &mosaic_plugin;
create_jpeg_plugin();
plugin[5] = &jpeg_plugin;
main_vbox = gtk_vbox_new (FALSE, 6);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), main_vbox);
gtk_widget_show (main_vbox);
preview = gimp_drawable_preview_new (drawable, (gboolean *)TRUE);
gtk_box_pack_start (GTK_BOX (main_vbox), preview, TRUE, TRUE, 0);
gtk_widget_show (preview);
frame = gtk_frame_new (NULL);
gtk_widget_show (frame);
gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (frame), 6);
alignment = gtk_alignment_new (0.5, 0.5, 1, 1);
gtk_widget_show (alignment);
gtk_container_add (GTK_CONTAINER (frame), alignment);
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 6, 6, 6);
main_hbox = gtk_hbox_new (FALSE, 0);
gtk_widget_show (main_hbox);
gtk_container_add (GTK_CONTAINER (alignment), main_hbox);
//######################################3
//this is where im make my notebook tabs
notebook = gtk_notebook_new();
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP);
gtk_widget_show (notebook);
printf("creating tabs\n");
for(ii = 0; ii< NUM_PLUGINS; ii++)
{
// should make a checkbox with its name will do that later
//add the page to the notbook
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), plugin[ii]->create_gui(), plugin[ii]->label);
}
printf("all tabs created\n");
gtk_box_pack_start (GTK_BOX (main_hbox), notebook, FALSE, FALSE, 6);
vbox = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox);
label = gtk_label_new ("Thread count");
gtk_widget_show (label);
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
thread_count_spinbutton = gimp_spin_button_new (&thread_count_spinbutton_value, NUM_THREADS, 0, 16, 1, 1, 0, 1, 0);
gtk_widget_show (thread_count_spinbutton);
gtk_box_pack_start (GTK_BOX (vbox), thread_count_spinbutton, FALSE, FALSE, 0);
// thread_count_spinbutton = gimp_spin_button_new (&thread_count_spinbutton_value, gui_options.threads, 1, 8, 1, 1, 1, 1, 0);
// gtk_box_pack_start (GTK_BOX (vbox), thread_count_spinbutton, FALSE, FALSE, 0);
// gtk_widget_show (thread_count_spinbutton);
gtk_box_pack_start (GTK_BOX (main_hbox), vbox, FALSE, FALSE, 0);
g_signal_connect_swapped (preview, "invalidated",G_CALLBACK (koi), drawable);
koi (drawable, GIMP_PREVIEW (preview));
// g_signal_connect (clone_check_button, "clicked", G_CALLBACK (cb_clone_check_button), &gui_options);
g_signal_connect (thread_count_spinbutton_value, "value_changed", G_CALLBACK (gimp_int_adjustment_update), &NUM_THREADS);
gtk_widget_show (dialog);
run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
gtk_widget_destroy (dialog);
return run;
}