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
92b4a24e
Commit
92b4a24e
authored
May 03, 2021
by
Victor Ananjevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rewrite confirmation dialog. add confirmation for save in text-info dialog
parent
7561d3e2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
58 additions
and
17 deletions
+58
-17
yad.1
data/yad.1
+4
-0
ru.po
po/ru.po
+0
-0
uk.po
po/uk.po
+0
-0
file.c
src/file.c
+1
-14
option.c
src/option.c
+16
-1
text.c
src/text.c
+12
-0
util.c
src/util.c
+19
-0
yad.h
src/yad.h
+6
-2
No files found.
data/yad.1
View file @
92b4a24e
...
...
@@ -980,6 +980,10 @@ Enable file operations. This option adds open and save menu items to popup menu,
.B \-\-disable-search
Disable search bar.
.TP
.B \-\-confirm\-save=\fI[TEXT]\fP
Confirm file saving if file content was changed. This option works only when \fI\-\-in-place\fP is specified.
Optional argument is a text for confirmation dialog.
.TP
Next options works only if yad builds with GtkSourceView.
.TP
.B \-\-lang=\fILANGUAGE\fP
...
...
po/ru.po
View file @
92b4a24e
This diff is collapsed.
Click to expand it.
po/uk.po
View file @
92b4a24e
This diff is collapsed.
Click to expand it.
src/file.c
View file @
92b4a24e
...
...
@@ -36,20 +36,7 @@ file_confirm_overwrite (GtkWidget * dlg)
gchar
*
filename
=
gtk_file_chooser_get_filename
(
GTK_FILE_CHOOSER
(
filechooser
));
if
(
g_file_test
(
filename
,
G_FILE_TEST_EXISTS
))
{
GtkWidget
*
d
;
gint
r
;
gchar
*
buf
;
buf
=
g_strcompress
(
options
.
file_data
.
confirm_text
);
d
=
gtk_message_dialog_new
(
GTK_WINDOW
(
dlg
),
GTK_DIALOG_DESTROY_WITH_PARENT
,
GTK_MESSAGE_QUESTION
,
GTK_BUTTONS_YES_NO
,
"%s"
,
buf
);
g_free
(
buf
);
r
=
gtk_dialog_run
(
GTK_DIALOG
(
d
));
gtk_widget_destroy
(
d
);
if
(
r
!=
GTK_RESPONSE_YES
)
return
FALSE
;
}
return
yad_confirm_dlg
(
GTK_WINDOW
(
dlg
),
options
.
file_data
.
confirm_text
);
}
return
TRUE
;
...
...
src/option.c
View file @
92b4a24e
...
...
@@ -28,6 +28,7 @@ static gboolean add_bar (const gchar *, const gchar *, gpointer, GError **);
static
gboolean
add_scale_mark
(
const
gchar
*
,
const
gchar
*
,
gpointer
,
GError
**
);
static
gboolean
add_palette
(
const
gchar
*
,
const
gchar
*
,
gpointer
,
GError
**
);
static
gboolean
add_confirm_overwrite
(
const
gchar
*
,
const
gchar
*
,
gpointer
,
GError
**
);
static
gboolean
add_confirm_save
(
const
gchar
*
,
const
gchar
*
,
gpointer
,
GError
**
);
static
gboolean
add_file_filter
(
const
gchar
*
,
const
gchar
*
,
gpointer
,
GError
**
);
static
gboolean
set_color_mode
(
const
gchar
*
,
const
gchar
*
,
gpointer
,
GError
**
);
static
gboolean
set_buttons_layout
(
const
gchar
*
,
const
gchar
*
,
gpointer
,
GError
**
);
...
...
@@ -658,6 +659,8 @@ static GOptionEntry text_options[] = {
N_
(
"Save file instead of print on exit"
),
NULL
},
{
"file-op"
,
0
,
0
,
G_OPTION_ARG_NONE
,
&
options
.
text_data
.
file_op
,
N_
(
"Enable file operations"
),
NULL
},
{
"confirm-save"
,
0
,
G_OPTION_FLAG_OPTIONAL_ARG
,
G_OPTION_ARG_CALLBACK
,
add_confirm_save
,
N_
(
"Confirm save the file if text was changed"
),
N_
(
"[TEXT]"
)
},
{
NULL
}
};
...
...
@@ -962,6 +965,16 @@ add_confirm_overwrite (const gchar * option_name, const gchar * value, gpointer
}
static
gboolean
add_confirm_save
(
const
gchar
*
option_name
,
const
gchar
*
value
,
gpointer
data
,
GError
**
err
)
{
options
.
text_data
.
confirm_save
=
TRUE
;
if
(
value
)
options
.
text_data
.
confirm_text
=
g_strdup
(
value
);
return
TRUE
;
}
static
gboolean
add_file_filter
(
const
gchar
*
option_name
,
const
gchar
*
value
,
gpointer
data
,
GError
**
err
)
{
GtkFileFilter
*
filter
=
gtk_file_filter_new
();
...
...
@@ -1704,7 +1717,7 @@ yad_options_init (void)
options
.
file_data
.
directory
=
FALSE
;
options
.
file_data
.
save
=
FALSE
;
options
.
file_data
.
confirm_overwrite
=
FALSE
;
options
.
file_data
.
confirm_text
=
N
_
(
"File exist. Overwrite?"
);
options
.
file_data
.
confirm_text
=
_
(
"File exist. Overwrite?"
);
options
.
file_data
.
file_filt
=
NULL
;
options
.
file_data
.
mime_filt
=
NULL
;
options
.
file_data
.
image_filt
=
NULL
;
...
...
@@ -1845,6 +1858,8 @@ yad_options_init (void)
options
.
text_data
.
hide_cursor
=
TRUE
;
options
.
text_data
.
fore
=
NULL
;
options
.
text_data
.
back
=
NULL
;
options
.
text_data
.
confirm_save
=
FALSE
;
options
.
text_data
.
confirm_text
=
_
(
"File was changed. Save it?"
);
#ifndef STANDALONE
options
.
text_data
.
uri_color
=
g_settings_get_string
(
settings
,
"uri-color"
);
#else
...
...
src/text.c
View file @
92b4a24e
...
...
@@ -836,7 +836,19 @@ text_print_result (void)
return
;
if
(
options
.
text_data
.
in_place
&&
options
.
common_data
.
uri
)
{
if
(
text_changed
)
{
if
(
options
.
text_data
.
confirm_save
)
{
if
(
yad_confirm_dlg
(
GTK_WINDOW
(
gtk_widget_get_toplevel
(
text_view
)),
options
.
text_data
.
confirm_text
))
save_file_cb
(
NULL
,
NULL
);
}
else
save_file_cb
(
NULL
,
NULL
);
}
}
else
{
GtkTextIter
start
,
end
;
...
...
src/util.c
View file @
92b4a24e
...
...
@@ -894,3 +894,22 @@ create_search_bar ()
return
sb
;
}
/* Confirmation dialog */
gboolean
yad_confirm_dlg
(
GtkWindow
*
parent
,
gchar
*
txt
)
{
GtkWidget
*
d
;
gchar
*
buf
;
buf
=
g_strcompress
(
options
.
text_data
.
confirm_text
);
d
=
gtk_message_dialog_new
(
parent
,
GTK_DIALOG_DESTROY_WITH_PARENT
,
GTK_MESSAGE_QUESTION
,
GTK_BUTTONS_YES_NO
,
"%s"
,
buf
);
gtk_window_set_position
(
GTK_WINDOW
(
d
),
GTK_WIN_POS_CENTER_ON_PARENT
);
g_free
(
buf
);
ret
=
gtk_dialog_run
(
GTK_DIALOG
(
d
));
gtk_widget_destroy
(
d
);
return
(
ret
==
GTK_RESPONSE_YES
);
}
src/yad.h
View file @
92b4a24e
...
...
@@ -476,6 +476,8 @@ typedef struct {
gchar
*
back
;
gboolean
in_place
;
gboolean
file_op
;
gboolean
confirm_save
;
gchar
*
confirm_text
;
}
YadTextData
;
#ifdef HAVE_SOURCEVIEW
...
...
@@ -722,11 +724,13 @@ gchar *print_bool_val (gboolean val);
gint
run_command_sync
(
gchar
*
cmd
,
gchar
**
out
);
void
run_command_async
(
gchar
*
cmd
);
gchar
*
pango_to_css
(
gchar
*
font
);
gchar
*
pango_to_css
(
gchar
*
font
);
void
open_uri
(
const
gchar
*
uri
);
YadSearchBar
*
create_search_bar
();
YadSearchBar
*
create_search_bar
();
gboolean
yad_confirm_dlg
(
GtkWindow
*
parent
,
gchar
*
txt
);
static
inline
void
strip_new_line
(
gchar
*
str
)
...
...
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