Skip to content

Commit 42dc662

Browse files
authored
Merge pull request #36 from jun08111/master
[Client]progressbar update
2 parents 75977d4 + 3ce3608 commit 42dc662

File tree

4 files changed

+124
-70
lines changed

4 files changed

+124
-70
lines changed

src/glade/bxr_plover

336 Bytes
Binary file not shown.

src/glade/main.c

Lines changed: 54 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,36 @@
2323
#include "decode.c"
2424

2525
#define MAX_ERROR_MSG 0x1000
26-
#define MAX_CNTF 50 // 최대 검출 파일 개수 //
26+
#define MAX_CNTF 50 // 최대 검출 파일 개수 //
2727

2828
typedef struct Data_storage
2929
{
30-
char fname[20]; // 파일 이름 //
31-
uint jcnt; // 주민번호 개수 //
32-
uint dcnt; // 운전면허 개수 //
33-
uint fgcnt; // 외국인등록번호 개수 //
34-
uint pcnt; // 여권번호 개수 //
35-
uint fsize; // 파일 크기 //
36-
char stat; // 파일 상태 //
37-
char fpath[300]; // 파일 경로 //
30+
char fname[20]; // 파일 이름 //
31+
uint jcnt; // 주민번호 개수 //
32+
uint dcnt; // 운전면허 개수 //
33+
uint fgcnt; // 외국인등록번호 개수 //
34+
uint pcnt; // 여권번호 개수 //
35+
uint fsize; // 파일 크기 //
36+
char stat; // 파일 상태 //
37+
char fpath[300]; // 파일 경로 //
3838

3939

4040
}data_storage;
4141

42-
data_storage ds[MAX_CNTF]; // 파일기준의 data구조체 //
42+
data_storage ds[MAX_CNTF]; // 파일기준의 data구조체 //
4343

44-
static gchar *path; // 파일경로 //
45-
static int cntf = 0; // 파일개수 cnt //
46-
static char chkfname[20];
47-
static int chk_tf; // chk_true or false //
48-
//uint data_flag = 1; // 어떤종류의 민감정보인지 확인하기위한 flag //
44+
static gchar *path; // 검사 파일경로 //
45+
static gchar *vsf_path; // 검사결과 리스트 선택 파일경로 //
46+
static int cntf = 0; // 파일개수 cnt //
47+
static char chk_fname[20]; // 정규식돌고있는 파일이름 //
48+
static int chk_tf; // chk_true or false //
49+
//uint data_flag = 1; // 민감정보 종류 확인 flag //
4950

5051

5152
GtkWidget *detect_window,
52-
*setting_window;
53+
*setting_window,
54+
*d_progressbar_status,
55+
*d_progressbar;
5356

5457
GtkEntry *d_detect_entry;
5558

@@ -71,6 +74,15 @@ void d_option_btn_clicked (GtkButton *d_option_btn, gpointer *data);
7174
void d_folder_btn_clicked (GtkButton *d_folder_btn, gpointer *data);
7275
void d_close_btn_clicked (GtkButton *d_close_btn, gpointer *data);
7376
void d_detect_entry_activate (GtkEntry *d_detect_entry, gpointer *data);
77+
78+
gboolean view_selection_func (GtkTreeSelection *selection,
79+
GtkTreeModel *model,
80+
GtkTreePath *path,
81+
gboolean path_currently_selected,
82+
gpointer userdata);
83+
84+
static GtkTreeModel *create_and_fill_model (void);
85+
static GtkWidget *create_view_and_model (void);
7486
/* end of detect_window */
7587

7688
// setting_window //
@@ -170,15 +182,15 @@ char match_regex_jnfg (regex_t *r, const char *to_match, char *filepath, struct
170182
// 주민번호 유효성 통과 //
171183
if (jtmp == chk)
172184
{
173-
int res = strcmp(chkfname, file->d_name); // 같은파일 = 0 //
185+
int res = strcmp(chk_fname, file->d_name); // 같은파일 = 0 //
174186

175187
if (res != 0)
176188
{
177189
cntf++;
178190
}
179191

180192
// 읽고있는중인 파일 이름 저장 //
181-
strcpy(chkfname, file->d_name);
193+
strcpy(chk_fname, file->d_name);
182194

183195
// 검출된 주민등록번호의 수 //
184196
ds[cntf].jcnt++;
@@ -195,15 +207,15 @@ char match_regex_jnfg (regex_t *r, const char *to_match, char *filepath, struct
195207
// 외국인등록번호 유효성 통과 //
196208
if (fgtmp == chk)
197209
{
198-
int res = strcmp(chkfname, file->d_name); // 같은파일 = 0 //
210+
int res = strcmp(chk_fname, file->d_name); // 같은파일 = 0 //
199211

200212
if (res != 0)
201213
{
202214
cntf++;
203215
}
204216

205217
// 읽고있는중인 파일 이름 저장 //
206-
strcpy(chkfname, file->d_name);
218+
strcpy(chk_fname, file->d_name);
207219

208220
// 검출된 외국인등록번호의 수 //
209221
ds[cntf].fgcnt++;
@@ -259,15 +271,15 @@ char match_regex_d (regex_t *r, const char *to_match, char *filepath, struct dir
259271
//운전면허 정규식 검사 통과//
260272
if (i == 0)
261273
{
262-
int res = strcmp(chkfname, file->d_name); //같은파일 = 0 //
274+
int res = strcmp(chk_fname, file->d_name); //같은파일 = 0 //
263275

264276
if (res != 0)
265277
{
266278
cntf++;
267279
}
268280

269281
// 읽고있는중인 파일 이름 저장 //
270-
strcpy(chkfname, file->d_name);
282+
strcpy(chk_fname, file->d_name);
271283

272284
// 검출된 운전면허의 수 //
273285
ds[cntf].dcnt++;
@@ -323,15 +335,15 @@ char match_regex_p (regex_t *r, const char *to_match, char *filepath, struct dir
323335
// 운전면허 정규식 검사 통과 //
324336
if (i == 0)
325337
{
326-
int res = strcmp(chkfname, file->d_name); // 같은파일 = 0 //
338+
int res = strcmp(chk_fname, file->d_name); // 같은파일 = 0 //
327339

328340
if (res != 0)
329341
{
330342
cntf++;
331343
}
332344

333345
// 읽고있는중인 파일 이름 저장 //
334-
strcpy(chkfname, file->d_name);
346+
strcpy(chk_fname, file->d_name);
335347

336348
// 검출된 운전면허의 수 //
337349
ds[cntf].pcnt++;
@@ -456,7 +468,7 @@ int scan_dir (gchar *path)
456468
memset(buffer, 0, sizeof(buffer));
457469
fclose(fp);
458470
printf("Close FILE\n");
459-
chkfname[0] = 0; // 초기화 //
471+
chk_fname[0] = 0; // 초기화 //
460472
}
461473
}
462474
closedir(dp);
@@ -703,7 +715,7 @@ int detect_func(gchar *path)
703715
// 계정이 있는지 확인: TRUE(1)=있다 FALSE(0)=없다 //
704716
int chk_user()
705717
{
706-
chk_tf = FALSE;
718+
chk_tf = TRUE;
707719

708720
return chk_tf;
709721
}
@@ -798,21 +810,19 @@ view_selection_func (GtkTreeSelection *selection,
798810

799811
if (gtk_tree_model_get_iter(model, &iter, path))
800812
{
801-
gchar *name;
802-
803-
gtk_tree_model_get(model, &iter, d_treeview_filelocation, &name, -1);
813+
gtk_tree_model_get(model, &iter, d_treeview_filelocation, &vsf_path, -1);
804814

805815
if (!path_currently_selected)
806816
{
807-
g_print ("%s is going to be selected.\n", name);
817+
g_print ("%s 선택.\n", vsf_path);
808818
}
809819

810820
else
811821
{
812-
g_print ("%s is going to be unselected.\n", name);
822+
g_print ("%s 선택 해제.\n", vsf_path);
813823
}
814824

815-
g_free(name);
825+
g_free(vsf_path);
816826
}
817827

818828
return TRUE; /* allow selection state to change */
@@ -959,12 +969,21 @@ create_view_and_model (void)
959969
void d_detect_btn_clicked (GtkButton *d_detect_btn, gpointer *data)
960970
{
961971
GtkWidget *view;
972+
char message[1024];
973+
gdouble percent = 0.0;
962974

963975
detect_func(path);
964976

977+
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(d_progressbar), 0 );
978+
965979
view = create_view_and_model();
966-
gtk_container_add(GTK_CONTAINER(d_scrolledwindow), view);
967-
gtk_widget_show_all((GtkWidget *)d_scrolledwindow);
980+
gtk_container_add (GTK_CONTAINER(d_scrolledwindow), view);
981+
gtk_widget_show_all ((GtkWidget *)d_scrolledwindow);
982+
983+
memset( message, 0x00, strlen(message));
984+
sprintf( message, "%.0f%% Complete", percent);
985+
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(d_progressbar), percent / 100.0);
986+
gtk_progress_bar_set_text (GTK_PROGRESS_BAR(d_progressbar), message);
968987

969988
return;
970989
}
@@ -1043,6 +1062,7 @@ int main (int argc, char *argv[])
10431062
setting_window = GTK_WIDGET(gtk_builder_get_object(builder, "setting_window"));
10441063
d_scrolledwindow = GTK_SCROLLED_WINDOW(gtk_builder_get_object(builder, "d_scrolledwindow"));
10451064
gtk_window_set_position(GTK_WINDOW(detect_window), GTK_WIN_POS_CENTER);
1065+
d_progressbar = GTK_WIDGET(gtk_builder_get_object(builder, "d_progressbar"));
10461066

10471067
// 닫기x 버튼을 hide로 바꾸기, -버튼 활성화 하고 싶으면 glade에서 modal 해제 //
10481068
g_signal_connect(detect_window, "delete_event", G_CALLBACK (gtk_widget_hide_on_delete), NULL);

src/glade/main.glade

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<property name="can_focus">False</property>
4242
<child>
4343
<object class="GtkEntry" id="d_detect_entry">
44-
<property name="width_request">272</property>
44+
<property name="width_request">267</property>
4545
<property name="height_request">40</property>
4646
<property name="visible">True</property>
4747
<property name="can_focus">True</property>
@@ -50,7 +50,7 @@
5050
<signal name="activate" handler="d_detect_entry_activate" swapped="no"/>
5151
</object>
5252
<packing>
53-
<property name="x">120</property>
53+
<property name="x">125</property>
5454
<property name="y">154</property>
5555
</packing>
5656
</child>
@@ -168,6 +168,7 @@
168168
<property name="height_request">270</property>
169169
<property name="visible">True</property>
170170
<property name="can_focus">True</property>
171+
<property name="margin_bottom">36</property>
171172
<property name="shadow_type">in</property>
172173
<child>
173174
<placeholder/>
@@ -178,6 +179,19 @@
178179
<property name="y">10</property>
179180
</packing>
180181
</child>
182+
<child>
183+
<object class="GtkProgressBar" id="d_progressbar">
184+
<property name="width_request">620</property>
185+
<property name="height_request">30</property>
186+
<property name="visible">True</property>
187+
<property name="can_focus">False</property>
188+
<property name="show_text">True</property>
189+
</object>
190+
<packing>
191+
<property name="x">20</property>
192+
<property name="y">280</property>
193+
</packing>
194+
</child>
181195
</object>
182196
<packing>
183197
<property name="expand">False</property>
@@ -206,6 +220,7 @@
206220
</object>
207221
<packing>
208222
<property name="x">148</property>
223+
<property name="y">9</property>
209224
</packing>
210225
</child>
211226
<child>
@@ -223,6 +238,7 @@
223238
</object>
224239
<packing>
225240
<property name="x">272</property>
241+
<property name="y">9</property>
226242
</packing>
227243
</child>
228244
<child>
@@ -240,6 +256,7 @@
240256
</object>
241257
<packing>
242258
<property name="x">396</property>
259+
<property name="y">9</property>
243260
</packing>
244261
</child>
245262
<child>
@@ -252,7 +269,7 @@
252269
</object>
253270
<packing>
254271
<property name="x">150</property>
255-
<property name="y">2</property>
272+
<property name="y">10</property>
256273
</packing>
257274
</child>
258275
<child>
@@ -265,7 +282,7 @@
265282
</object>
266283
<packing>
267284
<property name="x">274</property>
268-
<property name="y">2</property>
285+
<property name="y">10</property>
269286
</packing>
270287
</child>
271288
<child>
@@ -278,7 +295,7 @@
278295
</object>
279296
<packing>
280297
<property name="x">398</property>
281-
<property name="y">2</property>
298+
<property name="y">10</property>
282299
</packing>
283300
</child>
284301
</object>

0 commit comments

Comments
 (0)