Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yad
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vladislav
yad
Commits
9f11bb0a
Commit
9f11bb0a
authored
Aug 05, 2019
by
Victor Ananjevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge progress and multi-progress dialogs
parent
6d3ed4fd
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
13 additions
and
325 deletions
+13
-325
Makefile.am
src/Makefile.am
+0
-1
main.c
src/main.c
+2
-7
multi-progress.c
src/multi-progress.c
+0
-275
option.c
src/option.c
+9
-34
progress.c
src/progress.c
+0
-0
yad.h
src/yad.h
+2
-8
No files found.
src/Makefile.am
View file @
9f11bb0a
...
...
@@ -14,7 +14,6 @@ yad_SOURCES = \
form.c
\
icons.c
\
list.c
\
multi-progress.c
\
notebook.c
\
option.c
\
paned.c
\
...
...
src/main.c
View file @
9f11bb0a
...
...
@@ -237,9 +237,6 @@ create_layout (GtkWidget *dlg)
case
YAD_MODE_LIST
:
mw
=
list_create_widget
(
dlg
);
break
;
case
YAD_MODE_MULTI_PROGRESS
:
mw
=
multi_progress_create_widget
(
dlg
);
break
;
case
YAD_MODE_NOTEBOOK
:
if
(
options
.
plug
==
-
1
)
mw
=
notebook_create_widget
(
dlg
);
...
...
@@ -456,8 +453,7 @@ create_dialog (void)
}
else
{
if
(
options
.
mode
==
YAD_MODE_PROGRESS
||
options
.
mode
==
YAD_MODE_MULTI_PROGRESS
||
options
.
mode
==
YAD_MODE_DND
||
options
.
mode
==
YAD_MODE_PICTURE
)
if
(
options
.
mode
==
YAD_MODE_PROGRESS
||
options
.
mode
==
YAD_MODE_DND
||
options
.
mode
==
YAD_MODE_PICTURE
)
{
/* add close button */
btn
=
gtk_button_new
();
...
...
@@ -871,8 +867,7 @@ main (gint argc, gchar ** argv)
/* autokill option for progress dialog */
if
(
!
options
.
kill_parent
)
{
if
((
options
.
mode
==
YAD_MODE_PROGRESS
||
options
.
mode
==
YAD_MODE_MULTI_PROGRESS
)
&&
options
.
progress_data
.
autokill
&&
ret
!=
YAD_RESPONSE_OK
)
if
(
options
.
mode
==
YAD_MODE_PROGRESS
&&
options
.
progress_data
.
autokill
&&
ret
!=
YAD_RESPONSE_OK
)
kill
(
getppid
(),
SIGHUP
);
}
#endif
...
...
src/multi-progress.c
deleted
100644 → 0
View file @
6d3ed4fd
/*
* This file is part of YAD.
*
* YAD 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.
*
* YAD 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 YAD. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright (C) 2008-2019, Victor Ananjevsky <ananasik@gmail.com>
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
#include "yad.h"
static
GSList
*
progress_bars
=
NULL
;
static
guint
nbars
=
0
;
static
gboolean
pulsate_progress_bar
(
GtkProgressBar
*
bar
)
{
gtk_progress_bar_pulse
(
bar
);
return
TRUE
;
}
static
gboolean
handle_stdin
(
GIOChannel
*
channel
,
GIOCondition
condition
,
gpointer
data
)
{
float
percentage
=
0
.
0
;
if
((
condition
==
G_IO_IN
)
||
(
condition
==
G_IO_IN
+
G_IO_HUP
))
{
GString
*
string
;
gchar
**
value
;
GError
*
err
=
NULL
;
string
=
g_string_new
(
NULL
);
while
(
channel
->
is_readable
!=
TRUE
);
do
{
gint
status
,
num
;
GtkProgressBar
*
pb
;
YadProgressBar
*
b
;
do
{
status
=
g_io_channel_read_line_string
(
channel
,
string
,
NULL
,
&
err
);
while
(
gtk_events_pending
())
gtk_main_iteration
();
}
while
(
status
==
G_IO_STATUS_AGAIN
);
if
(
status
!=
G_IO_STATUS_NORMAL
)
{
if
(
err
)
{
g_printerr
(
"yad_multi_progress_handle_stdin(): %s
\n
"
,
err
->
message
);
g_error_free
(
err
);
err
=
NULL
;
}
/* stop handling */
g_io_channel_shutdown
(
channel
,
TRUE
,
NULL
);
return
FALSE
;
}
value
=
g_strsplit
(
string
->
str
,
":"
,
2
);
num
=
atoi
(
value
[
0
])
-
1
;
if
(
num
<
0
||
num
>
nbars
-
1
)
continue
;
pb
=
GTK_PROGRESS_BAR
(
g_slist_nth_data
(
progress_bars
,
num
));
b
=
(
YadProgressBar
*
)
g_slist_nth_data
(
options
.
multi_progress_data
.
bars
,
num
);
if
(
value
[
1
]
&&
value
[
1
][
0
]
==
'#'
)
{
gchar
*
match
;
/* We have a comment, so let's try to change the label */
match
=
g_strcompress
(
value
[
1
]
+
1
);
strip_new_line
(
match
);
gtk_progress_bar_set_text
(
pb
,
match
);
g_free
(
match
);
}
else
{
if
(
value
[
1
]
&&
b
->
type
==
YAD_PROGRESS_PULSE
)
gtk_progress_bar_pulse
(
pb
);
else
if
(
value
[
1
]
&&
b
->
type
==
YAD_PROGRESS_PERM
)
{
guint
id
;
if
(
strncmp
(
value
[
1
],
"start"
,
5
)
==
0
)
{
id
=
GPOINTER_TO_INT
(
g_object_get_data
(
G_OBJECT
(
pb
),
"id"
));
if
(
id
==
0
)
{
id
=
g_timeout_add
(
100
,
(
GSourceFunc
)
pulsate_progress_bar
,
pb
);
g_object_set_data
(
G_OBJECT
(
pb
),
"id"
,
GINT_TO_POINTER
(
id
));
}
}
else
if
(
strncmp
(
value
[
1
],
"stop"
,
4
)
==
0
)
{
id
=
GPOINTER_TO_INT
(
g_object_get_data
(
G_OBJECT
(
pb
),
"id"
));
if
(
id
>
0
)
{
g_source_remove
(
id
);
g_object_set_data
(
G_OBJECT
(
pb
),
"id"
,
GINT_TO_POINTER
(
0
));
}
}
}
else
{
if
(
!
value
[
1
]
||
!
g_ascii_isdigit
(
*
value
[
1
]))
continue
;
/* Now try to convert the thing to a number */
percentage
=
atoi
(
value
[
1
]);
if
(
percentage
>=
100
)
gtk_progress_bar_set_fraction
(
pb
,
1
.
0
);
else
gtk_progress_bar_set_fraction
(
pb
,
percentage
/
100
.
0
);
/* Check if all of progress bars reaches 100% */
if
(
options
.
progress_data
.
autoclose
&&
options
.
plug
==
-
1
)
{
guint
i
;
gboolean
close
=
TRUE
;
gboolean
need_close
=
FALSE
;
if
(
options
.
multi_progress_data
.
watch_bar
>
0
&&
options
.
multi_progress_data
.
watch_bar
<=
nbars
)
{
GtkProgressBar
*
cpb
=
GTK_PROGRESS_BAR
(
g_slist_nth_data
(
progress_bars
,
options
.
multi_progress_data
.
watch_bar
-
1
));
need_close
=
TRUE
;
if
(
gtk_progress_bar_get_fraction
(
cpb
)
!=
1
.
0
)
close
=
FALSE
;
}
else
{
for
(
i
=
0
;
i
<
nbars
;
i
++
)
{
GtkProgressBar
*
cpb
=
GTK_PROGRESS_BAR
(
g_slist_nth_data
(
progress_bars
,
i
));
YadProgressBar
*
cb
=
(
YadProgressBar
*
)
g_slist_nth_data
(
options
.
multi_progress_data
.
bars
,
i
);
if
(
cb
->
type
!=
YAD_PROGRESS_PULSE
)
{
need_close
=
TRUE
;
if
(
gtk_progress_bar_get_fraction
(
cpb
)
!=
1
.
0
)
{
close
=
FALSE
;
break
;
}
}
}
}
if
(
need_close
&&
close
)
yad_exit
(
options
.
data
.
def_resp
);
}
}
}
}
while
(
g_io_channel_get_buffer_condition
(
channel
)
==
G_IO_IN
);
g_string_free
(
string
,
TRUE
);
}
if
((
condition
!=
G_IO_IN
)
&&
(
condition
!=
G_IO_IN
+
G_IO_HUP
))
{
g_io_channel_shutdown
(
channel
,
TRUE
,
NULL
);
return
FALSE
;
}
return
TRUE
;
}
GtkWidget
*
multi_progress_create_widget
(
GtkWidget
*
dlg
)
{
GtkWidget
*
table
;
GIOChannel
*
channel
;
GSList
*
b
;
gint
i
=
0
;
nbars
=
g_slist_length
(
options
.
multi_progress_data
.
bars
);
if
(
nbars
<
1
)
return
NULL
;
table
=
gtk_grid_new
();
gtk_grid_set_row_spacing
(
GTK_GRID
(
table
),
2
);
gtk_grid_set_column_spacing
(
GTK_GRID
(
table
),
2
);
for
(
b
=
options
.
multi_progress_data
.
bars
;
b
;
b
=
b
->
next
)
{
GtkWidget
*
l
,
*
w
;
YadProgressBar
*
p
=
(
YadProgressBar
*
)
b
->
data
;
/* add label */
l
=
gtk_label_new
(
NULL
);
if
(
options
.
data
.
no_markup
)
gtk_label_set_text
(
GTK_LABEL
(
l
),
p
->
name
);
else
gtk_label_set_markup
(
GTK_LABEL
(
l
),
p
->
name
);
gtk_label_set_xalign
(
GTK_LABEL
(
l
),
options
.
common_data
.
align
);
if
(
options
.
common_data
.
vertical
)
gtk_grid_attach
(
GTK_GRID
(
table
),
l
,
i
,
1
,
1
,
1
);
else
gtk_grid_attach
(
GTK_GRID
(
table
),
l
,
0
,
i
,
1
,
1
);
/* add progress bar */
w
=
gtk_progress_bar_new
();
gtk_widget_set_name
(
w
,
"yad-progress-widget"
);
gtk_progress_bar_set_show_text
(
GTK_PROGRESS_BAR
(
w
),
TRUE
);
if
(
p
->
type
!=
YAD_PROGRESS_PULSE
)
{
if
(
options
.
extra_data
&&
options
.
extra_data
[
i
])
{
if
(
g_ascii_isdigit
(
*
options
.
extra_data
[
i
]))
gtk_progress_bar_set_fraction
(
GTK_PROGRESS_BAR
(
w
),
atoi
(
options
.
extra_data
[
i
])
/
100
.
0
);
}
}
else
{
if
(
options
.
extra_data
&&
options
.
extra_data
[
i
])
{
if
(
g_ascii_isdigit
(
*
options
.
extra_data
[
i
]))
gtk_progress_bar_set_pulse_step
(
GTK_PROGRESS_BAR
(
w
),
atoi
(
options
.
extra_data
[
i
])
/
100
.
0
);
}
}
gtk_progress_bar_set_inverted
(
GTK_PROGRESS_BAR
(
w
),
p
->
type
==
YAD_PROGRESS_RTL
);
if
(
options
.
common_data
.
vertical
)
gtk_orientable_set_orientation
(
GTK_ORIENTABLE
(
w
),
GTK_ORIENTATION_VERTICAL
);
if
(
options
.
common_data
.
vertical
)
{
gtk_grid_attach
(
GTK_GRID
(
table
),
w
,
i
,
0
,
1
,
1
);
gtk_widget_set_vexpand
(
w
,
TRUE
);
}
else
{
gtk_grid_attach
(
GTK_GRID
(
table
),
w
,
1
,
i
,
1
,
1
);
gtk_widget_set_hexpand
(
w
,
TRUE
);
}
progress_bars
=
g_slist_append
(
progress_bars
,
w
);
i
++
;
}
channel
=
g_io_channel_unix_new
(
0
);
g_io_channel_set_encoding
(
channel
,
NULL
,
NULL
);
g_io_channel_set_flags
(
channel
,
G_IO_FLAG_NONBLOCK
,
NULL
);
g_io_add_watch
(
channel
,
G_IO_IN
|
G_IO_HUP
,
handle_stdin
,
dlg
);
return
table
;
}
src/option.c
View file @
9f11bb0a
...
...
@@ -79,7 +79,6 @@ static gboolean html_mode = FALSE;
#endif
static
gboolean
icons_mode
=
FALSE
;
static
gboolean
list_mode
=
FALSE
;
static
gboolean
multi_progress_mode
=
FALSE
;
static
gboolean
notebook_mode
=
FALSE
;
#ifdef HAVE_TRAY
static
gboolean
notification_mode
=
FALSE
;
...
...
@@ -468,25 +467,6 @@ static GOptionEntry list_options[] = {
{
NULL
}
};
static
GOptionEntry
multi_progress_options
[]
=
{
{
"multi-progress"
,
0
,
G_OPTION_FLAG_IN_MAIN
,
G_OPTION_ARG_NONE
,
&
multi_progress_mode
,
N_
(
"Display multi progress bars dialog"
),
NULL
},
{
"bar"
,
0
,
0
,
G_OPTION_ARG_CALLBACK
,
add_bar
,
N_
(
"Add the progress bar (norm, rtl, pulse or perm)"
),
N_
(
"LABEL[:TYPE]"
)
},
{
"watch-bar"
,
0
,
0
,
G_OPTION_ARG_INT
,
&
options
.
multi_progress_data
.
watch_bar
,
N_
(
"Watch for specific bar for auto close"
),
N_
(
"NUMBER"
)
},
{
"align"
,
0
,
G_OPTION_FLAG_NOALIAS
,
G_OPTION_ARG_CALLBACK
,
set_align
,
N_
(
"Set alignment of bar labels (left, center or right)"
),
N_
(
"TYPE"
)
},
{
"auto-close"
,
0
,
G_OPTION_FLAG_NOALIAS
,
G_OPTION_ARG_NONE
,
&
options
.
progress_data
.
autoclose
,
/* xgettext: no-c-format */
N_
(
"Dismiss the dialog when 100% of all bars has been reached"
),
NULL
},
#ifndef G_OS_WIN32
{
"auto-kill"
,
0
,
G_OPTION_FLAG_NOALIAS
,
G_OPTION_ARG_NONE
,
&
options
.
progress_data
.
autokill
,
N_
(
"Kill parent process if cancel button is pressed"
),
NULL
},
#endif
{
NULL
}
};
static
GOptionEntry
notebook_options
[]
=
{
{
"notebook"
,
0
,
G_OPTION_FLAG_IN_MAIN
,
G_OPTION_ARG_NONE
,
&
notebook_mode
,
N_
(
"Display notebook dialog"
),
NULL
},
...
...
@@ -552,6 +532,12 @@ static GOptionEntry print_options[] = {
static
GOptionEntry
progress_options
[]
=
{
{
"progress"
,
0
,
G_OPTION_FLAG_IN_MAIN
,
G_OPTION_ARG_NONE
,
&
progress_mode
,
N_
(
"Display progress indication dialog"
),
NULL
},
{
"bar"
,
0
,
0
,
G_OPTION_ARG_CALLBACK
,
add_bar
,
N_
(
"Add the progress bar (norm, rtl, pulse or perm)"
),
N_
(
"LABEL[:TYPE]"
)
},
{
"watch-bar"
,
0
,
0
,
G_OPTION_ARG_INT
,
&
options
.
progress_data
.
watch_bar
,
N_
(
"Watch for specific bar for auto close"
),
N_
(
"NUMBER"
)
},
{
"align"
,
0
,
G_OPTION_FLAG_NOALIAS
,
G_OPTION_ARG_CALLBACK
,
set_align
,
N_
(
"Set alignment of bar labels (left, center or right)"
),
N_
(
"TYPE"
)
},
{
"progress-text"
,
0
,
0
,
G_OPTION_ARG_STRING
,
&
options
.
progress_data
.
progress_text
,
N_
(
"Set progress text"
),
N_
(
"TEXT"
)
},
{
"percentage"
,
0
,
0
,
G_OPTION_ARG_INT
,
&
options
.
progress_data
.
percentage
,
...
...
@@ -848,7 +834,7 @@ add_bar (const gchar * option_name, const gchar * value, gpointer data, GError *
}
else
bar
->
type
=
YAD_PROGRESS_NORMAL
;
options
.
multi_progress_data
.
bars
=
g_slist_append
(
options
.
multi_
progress_data
.
bars
,
bar
);
options
.
progress_data
.
bars
=
g_slist_append
(
options
.
progress_data
.
bars
,
bar
);
g_strfreev
(
bstr
);
return
TRUE
;
...
...
@@ -1399,8 +1385,6 @@ yad_set_mode (void)
options
.
mode
=
YAD_MODE_ICONS
;
else
if
(
list_mode
)
options
.
mode
=
YAD_MODE_LIST
;
else
if
(
multi_progress_mode
)
options
.
mode
=
YAD_MODE_MULTI_PROGRESS
;
else
if
(
notebook_mode
)
options
.
mode
=
YAD_MODE_NOTEBOOK
;
#ifdef HAVE_TRAY
...
...
@@ -1639,10 +1623,6 @@ yad_options_init (void)
options
.
list_data
.
add_on_top
=
FALSE
;
options
.
list_data
.
simple_tips
=
FALSE
;
/* Initialize multiprogress data */
options
.
multi_progress_data
.
bars
=
NULL
;
options
.
multi_progress_data
.
watch_bar
=
0
;
/* Initialize notebook data */
options
.
notebook_data
.
tabs
=
NULL
;
options
.
notebook_data
.
borders
=
5
;
...
...
@@ -1670,6 +1650,8 @@ yad_options_init (void)
options
.
print_data
.
headers
=
FALSE
;
/* Initialize progress data */
options
.
progress_data
.
bars
=
NULL
;
options
.
progress_data
.
watch_bar
=
0
;
options
.
progress_data
.
progress_text
=
NULL
;
options
.
progress_data
.
percentage
=
0
;
options
.
progress_data
.
pulsate
=
FALSE
;
...
...
@@ -1800,13 +1782,6 @@ yad_create_context (void)
g_option_group_set_translation_domain
(
a_group
,
GETTEXT_PACKAGE
);
g_option_context_add_group
(
tmp_ctx
,
a_group
);
/* Adds multi progress option entries */
a_group
=
g_option_group_new
(
"multi-progress"
,
_
(
"Multi progress bars options"
),
_
(
"Show multi progress bars options"
),
NULL
,
NULL
);
g_option_group_add_entries
(
a_group
,
multi_progress_options
);
g_option_group_set_translation_domain
(
a_group
,
GETTEXT_PACKAGE
);
g_option_context_add_group
(
tmp_ctx
,
a_group
);
/* Adds notebook option entries */
a_group
=
g_option_group_new
(
"notebook"
,
_
(
"Notebook options"
),
_
(
"Show notebook dialog options"
),
NULL
,
NULL
);
g_option_group_add_entries
(
a_group
,
notebook_options
);
...
...
src/progress.c
View file @
9f11bb0a
This diff is collapsed.
Click to expand it.
src/yad.h
View file @
9f11bb0a
...
...
@@ -70,7 +70,6 @@ typedef enum {
#endif
YAD_MODE_ICONS
,
YAD_MODE_LIST
,
YAD_MODE_MULTI_PROGRESS
,
YAD_MODE_NOTEBOOK
,
#ifdef HAVE_TRAY
YAD_MODE_NOTIFICATION
,
...
...
@@ -368,11 +367,6 @@ typedef struct {
}
YadListData
;
typedef
struct
{
GSList
*
bars
;
gint
watch_bar
;
}
YadMultiProgressData
;
typedef
struct
{
GSList
*
tabs
;
guint
borders
;
GtkPositionType
pos
;
...
...
@@ -404,6 +398,8 @@ typedef struct {
}
YadPrintData
;
typedef
struct
{
GSList
*
bars
;
gint
watch_bar
;
gchar
*
progress_text
;
gboolean
pulsate
;
gboolean
autoclose
;
...
...
@@ -500,7 +496,6 @@ typedef struct {
#endif
YadIconsData
icons_data
;
YadListData
list_data
;
YadMultiProgressData
multi_progress_data
;
YadNotebookData
notebook_data
;
#ifdef HAVE_TRAY
YadNotificationData
notification_data
;
...
...
@@ -582,7 +577,6 @@ GtkWidget *html_create_widget (GtkWidget *dlg);
#endif
GtkWidget
*
icons_create_widget
(
GtkWidget
*
dlg
);
GtkWidget
*
list_create_widget
(
GtkWidget
*
dlg
);
GtkWidget
*
multi_progress_create_widget
(
GtkWidget
*
dlg
);
GtkWidget
*
notebook_create_widget
(
GtkWidget
*
dlg
);
GtkWidget
*
paned_create_widget
(
GtkWidget
*
dlg
);
GtkWidget
*
picture_create_widget
(
GtkWidget
*
dlg
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment