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
9d70c5e6
Commit
9d70c5e6
authored
Apr 27, 2020
by
Victor Ananjevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve thumbnails handling. Add --large-preview option
parent
75af2258
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
49 additions
and
10 deletions
+49
-10
yad.1
data/yad.1
+4
-2
yad.gschema.xml.in
data/yad.gschema.xml.in
+4
-0
ru.po
po/ru.po
+0
-0
uk.po
po/uk.po
+0
-0
option.c
src/option.c
+7
-0
util.c
src/util.c
+33
-8
yad.h
src/yad.h
+1
-0
No files found.
data/yad.1
View file @
9d70c5e6
...
...
@@ -966,9 +966,11 @@ is a name of mime type (for example text/plain). This option may be used multipl
Add filter for images supported by gdk-pixbuf library. \fINAME\fP in as optional name for this filter.
.TP
.B \-\-add-preview
Add preview widget. Preview images loads from
large or normal
thumbnails according to XDG Thumbnails
Add preview widget. Preview images loads from
normal (default) or large
thumbnails according to XDG Thumbnails
specification v0.8.0 (http://standards.freedesktop.org/thumbnail-spec/latest/) or creates by yad for image files and saves
as large thumbnails.
as normal or large thumbnails.
.TP \--large-preview
Use large previews by default. This option can be permanently turned on througn yad settings.
This options applies to all of yad's file chooser dialogs.
...
...
data/yad.gschema.xml.in
View file @
9d70c5e6
...
...
@@ -40,6 +40,10 @@
<default>100</default>
<_summary>Maximum number of tabs in notebook dialog</_summary>
</key>
<key name="large-preview" type="b">
<default>false</default>
<_summary>Use large previews in file selection dialogs</_summary>
</key>
<key name="ignore-unknown-options" type="b">
<default>true</default>
<_summary>Ignore unknown command-line options</_summary>
...
...
po/ru.po
View file @
9d70c5e6
This diff is collapsed.
Click to expand it.
po/uk.po
View file @
9d70c5e6
This diff is collapsed.
Click to expand it.
src/option.c
View file @
9d70c5e6
...
...
@@ -209,6 +209,8 @@ static GOptionEntry common_options[] = {
N_
(
"Allow multiple selection"
),
NULL
},
{
"add-preview"
,
0
,
0
,
G_OPTION_ARG_NONE
,
&
options
.
common_data
.
preview
,
N_
(
"Enable preview"
),
NULL
},
{
"large-preview"
,
0
,
0
,
G_OPTION_ARG_NONE
,
&
options
.
common_data
.
large_preview
,
N_
(
"Use large preview"
),
NULL
},
{
"show-hidden"
,
0
,
0
,
G_OPTION_ARG_NONE
,
&
options
.
common_data
.
show_hidden
,
N_
(
"Show hidden files in file selection dialogs"
),
NULL
},
{
"filename"
,
0
,
0
,
G_OPTION_ARG_FILENAME
,
&
options
.
common_data
.
uri
,
...
...
@@ -1542,6 +1544,11 @@ yad_options_init (void)
options
.
common_data
.
align
=
0
.
0
;
options
.
common_data
.
listen
=
FALSE
;
options
.
common_data
.
preview
=
FALSE
;
#ifndef STANDALONE
options
.
common_data
.
large_preview
=
g_settings_get_boolean
(
settings
,
"large-preview"
);
#else
options
.
common_data
.
large_preview
=
FALSE
;
#endif
options
.
common_data
.
show_hidden
=
FALSE
;
options
.
common_data
.
quoted_output
=
FALSE
;
options
.
common_data
.
num_output
=
FALSE
;
...
...
src/util.c
View file @
9d70c5e6
...
...
@@ -21,6 +21,9 @@
#define _GNU_SOURCE 1
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
...
...
@@ -165,38 +168,60 @@ update_preview (GtkFileChooser * chooser, GtkWidget *p)
{
gchar
*
file
;
GChecksum
*
chs
;
GdkPixbuf
*
pb
;
GdkPixbuf
*
pb
=
NULL
;
chs
=
g_checksum_new
(
G_CHECKSUM_MD5
);
g_checksum_update
(
chs
,
(
const
guchar
*
)
uri
,
-
1
);
/* first try to get preview from large thumbnail */
file
=
g_strdup_printf
(
"%s/%s.png"
,
large_path
,
g_checksum_get_string
(
chs
));
if
(
g_file_test
(
file
,
G_FILE_TEST_EXISTS
))
if
(
options
.
common_data
.
large_preview
&&
g_file_test
(
file
,
G_FILE_TEST_EXISTS
))
pb
=
gdk_pixbuf_new_from_file
(
file
,
NULL
);
else
{
/* try to get preview from normal thumbnail */
g_free
(
file
);
file
=
g_strdup_printf
(
"%s/%s.png"
,
normal_path
,
g_checksum_get_string
(
chs
));
if
(
g_file_test
(
file
,
G_FILE_TEST_EXISTS
))
if
(
!
options
.
common_data
.
large_preview
&&
g_file_test
(
file
,
G_FILE_TEST_EXISTS
))
pb
=
gdk_pixbuf_new_from_file
(
file
,
NULL
);
else
{
/* try to create it */
g_free
(
file
);
file
=
g_filename_from_uri
(
uri
,
NULL
,
NULL
);
pb
=
gdk_pixbuf_new_from_file_at_size
(
file
,
256
,
256
,
NULL
);
g_free
(
file
);
if
(
options
.
common_data
.
large_preview
)
pb
=
gdk_pixbuf_new_from_file_at_scale
(
file
,
256
,
256
,
TRUE
,
NULL
);
else
pb
=
gdk_pixbuf_new_from_file_at_scale
(
file
,
128
,
128
,
TRUE
,
NULL
);
if
(
pb
)
{
struct
stat
st
;
gchar
*
smtime
;
stat
(
file
,
&
st
);
smtime
=
g_strdup_printf
(
"%d"
,
st
.
st_mtime
);
g_free
(
file
);
/* save thumbnail */
g_mkdir_with_parents
(
large_path
,
0755
);
file
=
g_strdup_printf
(
"%s/%s.png"
,
large_path
,
g_checksum_get_string
(
chs
));
gdk_pixbuf_save
(
pb
,
file
,
"png"
,
NULL
,
NULL
);
if
(
options
.
common_data
.
large_preview
)
{
g_mkdir_with_parents
(
large_path
,
0755
);
file
=
g_strdup_printf
(
"%s/%s.png"
,
large_path
,
g_checksum_get_string
(
chs
));
}
else
{
g_mkdir_with_parents
(
normal_path
,
0755
);
file
=
g_strdup_printf
(
"%s/%s.png"
,
normal_path
,
g_checksum_get_string
(
chs
));
}
gdk_pixbuf_save
(
pb
,
file
,
"png"
,
NULL
,
"tEXt::Thumb::URI"
,
uri
,
"tEXt::Thumb::MTime"
,
smtime
,
NULL
);
g_free
(
smtime
);
}
}
}
g_checksum_free
(
chs
);
g_free
(
file
);
if
(
pb
)
{
...
...
src/yad.h
View file @
9d70c5e6
...
...
@@ -470,6 +470,7 @@ typedef struct {
gdouble
align
;
gboolean
listen
;
gboolean
preview
;
gboolean
large_preview
;
gboolean
show_hidden
;
gboolean
quoted_output
;
gboolean
num_output
;
...
...
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