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
068dedac
Commit
068dedac
authored
Jun 10, 2024
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added older progress bar
parent
03c99c16
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
273 additions
and
5 deletions
+273
-5
POTFILES.in
po/POTFILES.in
+1
-0
Makefile.am
src/Makefile.am
+5
-4
main.c
src/main.c
+6
-1
option.c
src/option.c
+40
-0
progress_old.c
src/progress_old.c
+215
-0
yad.h
src/yad.h
+6
-0
No files found.
po/POTFILES.in
View file @
068dedac
...
...
@@ -16,6 +16,7 @@ src/paned.c
src/picture.c
src/print.c
src/progress.c
src/progress_old.c
src/color.c
src/text.c
src/notebook.c
...
...
src/Makefile.am
View file @
068dedac
...
...
@@ -8,12 +8,12 @@ endif
CPICKER_SOURCES
=
cpicker.c cpicker.h
yad_SOURCES
=
\
yad_SOURCES
=
\
about.c
\
app.c
\
calendar.c
\
color.c
\
dnd.c
\
dnd.c
\
entry.c
\
file.c
\
font.c
\
...
...
@@ -23,15 +23,16 @@ yad_SOURCES = \
notebook.c
\
option.c
\
paned.c
\
picture.c
\
picture.c
\
print.c
\
progress.c
\
progress_old.c
\
scale.c
\
text.c
\
util.c
\
main.c
\
yad.h
\
calendar.xpm
\
calendar.xpm
\
$(CPICKER_SOURCES)
if
TRAY
...
...
src/main.c
View file @
068dedac
...
...
@@ -304,6 +304,9 @@ create_layout (GtkWidget *dlg)
case
YAD_MODE_PROGRESS
:
mw
=
progress_create_widget
(
dlg
);
break
;
case
YAD_MODE_PROGRESS_OLD
:
mw
=
progress_create_widget_old
(
dlg
);
break
;
case
YAD_MODE_SCALE
:
mw
=
scale_create_widget
(
dlg
);
break
;
...
...
@@ -578,7 +581,7 @@ create_dialog (void)
}
else
{
if
(
options
.
mode
==
YAD_MODE_PROGRESS
||
options
.
mode
==
YAD_MODE_DND
||
options
.
mode
==
YAD_MODE_PICTURE
)
if
(
options
.
mode
==
YAD_MODE_PROGRESS
||
options
.
mode
==
YAD_MODE_
PROGRESS_OLD
||
options
.
mode
==
YAD_MODE_
DND
||
options
.
mode
==
YAD_MODE_PICTURE
)
{
/* add close button */
btn
=
gtk_button_new
();
...
...
@@ -989,6 +992,8 @@ main (gint argc, gchar ** argv)
{
if
(
options
.
mode
==
YAD_MODE_PROGRESS
&&
options
.
progress_data
.
autokill
&&
ret
!=
YAD_RESPONSE_OK
)
kill
(
getppid
(),
SIGHUP
);
if
(
options
.
mode
==
YAD_MODE_PROGRESS_OLD
&&
options
.
progress_data
.
autokill
&&
ret
!=
YAD_RESPONSE_OK
)
kill
(
getppid
(),
SIGHUP
);
}
#endif
}
...
...
src/option.c
View file @
068dedac
...
...
@@ -85,6 +85,7 @@ static gboolean paned_mode = FALSE;
static
gboolean
picture_mode
=
FALSE
;
static
gboolean
print_mode
=
FALSE
;
static
gboolean
progress_mode
=
FALSE
;
static
gboolean
progress_mode_old
=
FALSE
;
static
gboolean
scale_mode
=
FALSE
;
static
gboolean
text_mode
=
FALSE
;
...
...
@@ -626,6 +627,37 @@ static GOptionEntry progress_options[] = {
{
NULL
}
};
static
GOptionEntry
progress_options_old
[]
=
{
{
"progress-old"
,
0
,
G_OPTION_FLAG_IN_MAIN
,
G_OPTION_ARG_NONE
,
&
progress_mode_old
,
N_
(
"Display progress indication dialog"
),
NULL
},
{
"progress-text"
,
0
,
0
,
G_OPTION_ARG_STRING
,
&
options
.
progress_data
.
progress_text
,
N_
(
"Set progress text"
),
N_
(
"TEXT"
)
},
{
"hide-text"
,
0
,
G_OPTION_FLAG_NOALIAS
,
G_OPTION_ARG_NONE
,
&
options
.
common_data
.
hide_text
,
N_
(
"Hide text on progress bar"
),
NULL
},
{
"percentage"
,
0
,
0
,
G_OPTION_ARG_INT
,
&
options
.
progress_data
.
percentage
,
N_
(
"Set initial percentage"
),
N_
(
"PERCENTAGE"
)
},
{
"pulsate"
,
0
,
0
,
G_OPTION_ARG_NONE
,
&
options
.
progress_data
.
pulsate
,
N_
(
"Pulsate progress bar"
),
NULL
},
{
"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% 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
{
"rtl"
,
0
,
0
,
G_OPTION_ARG_NONE
,
&
options
.
progress_data
.
rtl
,
N_
(
"Right-To-Left progress bar direction"
),
NULL
},
{
"enable-log"
,
0
,
G_OPTION_FLAG_OPTIONAL_ARG
,
G_OPTION_ARG_CALLBACK
,
set_progress_log
,
N_
(
"Show log window"
),
N_
(
"[TEXT]"
)
},
{
"log-expanded"
,
0
,
0
,
G_OPTION_ARG_NONE
,
&
options
.
progress_data
.
log_expanded
,
N_
(
"Expand log window"
),
NULL
},
{
"log-on-top"
,
0
,
0
,
G_OPTION_ARG_NONE
,
&
options
.
progress_data
.
log_on_top
,
N_
(
"Place log window above progress bar"
),
NULL
},
{
"log-height"
,
0
,
0
,
G_OPTION_ARG_INT
,
&
options
.
progress_data
.
log_height
,
N_
(
"Height of log window"
),
NULL
},
{
NULL
}
};
static
GOptionEntry
scale_options
[]
=
{
{
"scale"
,
0
,
G_OPTION_FLAG_IN_MAIN
,
G_OPTION_ARG_NONE
,
&
scale_mode
,
N_
(
"Display scale dialog"
),
NULL
},
...
...
@@ -1558,6 +1590,8 @@ yad_set_mode (void)
options
.
mode
=
YAD_MODE_PRINT
;
else
if
(
progress_mode
)
options
.
mode
=
YAD_MODE_PROGRESS
;
else
if
(
progress_mode_old
)
options
.
mode
=
YAD_MODE_PROGRESS_OLD
;
else
if
(
scale_mode
)
options
.
mode
=
YAD_MODE_SCALE
;
else
if
(
text_mode
)
...
...
@@ -2080,6 +2114,12 @@ yad_create_context (void)
g_option_group_set_translation_domain
(
a_group
,
GETTEXT_PACKAGE
);
g_option_context_add_group
(
tmp_ctx
,
a_group
);
/* Adds progress option entries */
a_group
=
g_option_group_new
(
"progress-old"
,
_
(
"Progress options"
),
_
(
"Show progress options"
),
NULL
,
NULL
);
g_option_group_add_entries
(
a_group
,
progress_options_old
);
g_option_group_set_translation_domain
(
a_group
,
GETTEXT_PACKAGE
);
g_option_context_add_group
(
tmp_ctx
,
a_group
);
/* Adds scale option entries */
a_group
=
g_option_group_new
(
"scale"
,
_
(
"Scale options"
),
_
(
"Show scale options"
),
NULL
,
NULL
);
g_option_group_add_entries
(
a_group
,
scale_options
);
...
...
src/progress_old.c
0 → 100644
View file @
068dedac
/*
* 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
GtkWidget
*
progress_bar
;
static
GtkWidget
*
progress_log
;
static
GtkTextBuffer
*
log_buffer
;
static
gboolean
pulsate_progress_bar
(
gpointer
user_data
)
{
gtk_progress_bar_pulse
(
GTK_PROGRESS_BAR
(
progress_bar
));
return
TRUE
;
}
static
gboolean
handle_stdin
(
GIOChannel
*
channel
,
GIOCondition
condition
,
gpointer
data
)
{
static
guint
pulsate_timeout
=
0
;
float
percentage
=
0
.
0
;
if
((
condition
==
G_IO_IN
)
||
(
condition
==
G_IO_IN
+
G_IO_HUP
))
{
GString
*
string
;
GError
*
err
=
NULL
;
string
=
g_string_new
(
NULL
);
if
(
options
.
progress_data
.
pulsate
)
{
if
(
pulsate_timeout
==
0
)
pulsate_timeout
=
g_timeout_add
(
100
,
pulsate_progress_bar
,
NULL
);
}
while
(
channel
->
is_readable
!=
TRUE
);
do
{
gint
status
;
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_progress_handle_stdin(): %s
\n
"
,
err
->
message
);
g_error_free
(
err
);
err
=
NULL
;
}
/* stop handling */
g_io_channel_shutdown
(
channel
,
TRUE
,
NULL
);
return
FALSE
;
}
if
(
string
->
str
[
0
]
==
'#'
)
{
gchar
*
match
;
/* We have a comment, so let's try to change the label or write it to the log */
match
=
g_strcompress
(
g_strstrip
(
string
->
str
+
1
));
if
(
options
.
progress_data
.
log
)
{
gchar
*
logline
;
GtkTextIter
end
;
logline
=
g_strdup_printf
(
"%s
\n
"
,
match
);
/* add new line */
gtk_text_buffer_get_end_iter
(
log_buffer
,
&
end
);
gtk_text_buffer_insert
(
log_buffer
,
&
end
,
logline
,
-
1
);
g_free
(
logline
);
/* scroll to end */
while
(
gtk_events_pending
())
gtk_main_iteration
();
gtk_text_buffer_get_end_iter
(
log_buffer
,
&
end
);
gtk_text_view_scroll_to_iter
(
GTK_TEXT_VIEW
(
progress_log
),
&
end
,
0
,
FALSE
,
0
,
0
);
}
else
{
if
(
!
options
.
common_data
.
hide_text
)
gtk_progress_bar_set_text
(
GTK_PROGRESS_BAR
(
progress_bar
),
match
);
}
g_free
(
match
);
}
else
{
if
(
g_ascii_isdigit
(
*
(
string
->
str
)))
{
/* Now try to convert the thing to a number */
percentage
=
atoi
(
string
->
str
);
if
(
percentage
>=
100
)
{
gtk_progress_bar_set_fraction
(
GTK_PROGRESS_BAR
(
progress_bar
),
1
.
0
);
if
(
options
.
progress_data
.
autoclose
&&
options
.
plug
==
-
1
)
yad_exit
(
options
.
data
.
def_resp
);
}
else
gtk_progress_bar_set_fraction
(
GTK_PROGRESS_BAR
(
progress_bar
),
percentage
/
100
.
0
);
}
}
}
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
))
{
gtk_progress_bar_set_fraction
(
GTK_PROGRESS_BAR
(
progress_bar
),
1
.
0
);
if
(
options
.
progress_data
.
pulsate
)
{
g_source_remove
(
pulsate_timeout
);
pulsate_timeout
=
0
;
}
if
(
options
.
progress_data
.
autoclose
&&
options
.
plug
==
-
1
)
yad_exit
(
options
.
data
.
def_resp
);
g_io_channel_shutdown
(
channel
,
TRUE
,
NULL
);
return
FALSE
;
}
return
TRUE
;
}
GtkWidget
*
progress_create_widget_old
(
GtkWidget
*
dlg
)
{
GtkWidget
*
w
;
GIOChannel
*
channel
;
// fix it when vertical specified
w
=
gtk_box_new
(
GTK_ORIENTATION_VERTICAL
,
0
);
progress_bar
=
gtk_progress_bar_new
();
gtk_widget_set_name
(
progress_bar
,
"yad-progress-widget"
);
if
(
options
.
progress_data
.
log_on_top
)
gtk_box_pack_end
(
GTK_BOX
(
w
),
progress_bar
,
FALSE
,
FALSE
,
0
);
else
gtk_box_pack_start
(
GTK_BOX
(
w
),
progress_bar
,
FALSE
,
FALSE
,
0
);
if
(
options
.
progress_data
.
percentage
>
100
)
options
.
progress_data
.
percentage
=
100
;
gtk_progress_bar_set_fraction
(
GTK_PROGRESS_BAR
(
progress_bar
),
options
.
progress_data
.
percentage
/
100
.
0
);
if
(
options
.
progress_data
.
progress_text
)
gtk_progress_bar_set_text
(
GTK_PROGRESS_BAR
(
progress_bar
),
options
.
progress_data
.
progress_text
);
gtk_progress_bar_set_inverted
(
GTK_PROGRESS_BAR
(
progress_bar
),
options
.
progress_data
.
rtl
);
if
(
options
.
progress_data
.
log
)
{
GtkWidget
*
ex
,
*
sw
;
ex
=
gtk_expander_new
(
options
.
progress_data
.
log
);
gtk_expander_set_spacing
(
GTK_EXPANDER
(
ex
),
2
);
gtk_expander_set_expanded
(
GTK_EXPANDER
(
ex
),
options
.
progress_data
.
log_expanded
);
gtk_box_pack_start
(
GTK_BOX
(
w
),
ex
,
TRUE
,
TRUE
,
2
);
sw
=
gtk_scrolled_window_new
(
NULL
,
NULL
);
gtk_scrolled_window_set_shadow_type
(
GTK_SCROLLED_WINDOW
(
sw
),
GTK_SHADOW_ETCHED_IN
);
gtk_scrolled_window_set_policy
(
GTK_SCROLLED_WINDOW
(
sw
),
options
.
hscroll_policy
,
options
.
vscroll_policy
);
gtk_scrolled_window_set_propagate_natural_height
(
GTK_SCROLLED_WINDOW
(
sw
),
TRUE
);
gtk_container_add
(
GTK_CONTAINER
(
ex
),
sw
);
progress_log
=
gtk_text_view_new
();
gtk_widget_set_name
(
progress_log
,
"yad-text-widget"
);
gtk_widget_set_size_request
(
progress_log
,
-
1
,
options
.
progress_data
.
log_height
);
gtk_container_add
(
GTK_CONTAINER
(
sw
),
progress_log
);
log_buffer
=
gtk_text_buffer_new
(
NULL
);
gtk_text_view_set_buffer
(
GTK_TEXT_VIEW
(
progress_log
),
log_buffer
);
gtk_text_view_set_left_margin
(
GTK_TEXT_VIEW
(
progress_log
),
5
);
gtk_text_view_set_right_margin
(
GTK_TEXT_VIEW
(
progress_log
),
5
);
gtk_text_view_set_editable
(
GTK_TEXT_VIEW
(
progress_log
),
FALSE
);
gtk_text_view_set_cursor_visible
(
GTK_TEXT_VIEW
(
progress_log
),
FALSE
);
}
else
gtk_progress_bar_set_show_text
(
GTK_PROGRESS_BAR
(
progress_bar
),
!
options
.
common_data
.
hide_text
);
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
w
;
}
src/yad.h
View file @
068dedac
...
...
@@ -90,6 +90,7 @@ typedef enum {
YAD_MODE_PICTURE
,
YAD_MODE_PRINT
,
YAD_MODE_PROGRESS
,
YAD_MODE_PROGRESS_OLD
,
YAD_MODE_SCALE
,
YAD_MODE_TEXTINFO
,
YAD_MODE_ABOUT
,
...
...
@@ -457,6 +458,7 @@ typedef struct {
#ifndef G_OS_WIN32
gboolean
autokill
;
#endif
guint
percentage
;
gboolean
rtl
;
gchar
*
log
;
gboolean
log_expanded
;
...
...
@@ -590,6 +592,9 @@ typedef struct {
gchar
*
css
;
gchar
*
gtkrc_file
;
GtkPolicyType
hscroll_policy
;
GtkPolicyType
vscroll_policy
;
gchar
*
rest_file
;
gchar
**
extra_data
;
...
...
@@ -676,6 +681,7 @@ GtkWidget *notebook_create_widget (GtkWidget *dlg);
GtkWidget
*
paned_create_widget
(
GtkWidget
*
dlg
);
GtkWidget
*
picture_create_widget
(
GtkWidget
*
dlg
);
GtkWidget
*
progress_create_widget
(
GtkWidget
*
dlg
);
GtkWidget
*
progress_create_widget_old
(
GtkWidget
*
dlg
);
GtkWidget
*
scale_create_widget
(
GtkWidget
*
dlg
);
GtkWidget
*
text_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