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
b22bc91e
Commit
b22bc91e
authored
Jul 12, 2019
by
Victor Ananjevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use GSettings instead of config file
parent
9f0ec896
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
132 additions
and
188 deletions
+132
-188
.gitignore
.gitignore
+2
-0
configure.ac
configure.ac
+3
-0
Makefile.am
data/Makefile.am
+7
-2
yad.gschema.xml.in
data/yad.gschema.xml.in
+45
-0
POTFILES.in
po/POTFILES.in
+1
-0
entry.c
src/entry.c
+1
-1
icons.c
src/icons.c
+1
-1
main.c
src/main.c
+16
-8
option.c
src/option.c
+10
-10
print.c
src/print.c
+33
-14
text.c
src/text.c
+1
-1
util.c
src/util.c
+8
-127
yad.h
src/yad.h
+4
-24
No files found.
.gitignore
View file @
b22bc91e
...
@@ -27,3 +27,5 @@ src/pfd
...
@@ -27,3 +27,5 @@ src/pfd
stamp-h1
stamp-h1
*.tar.xz
*.tar.xz
build.log
build.log
*.gschema.xml
*.gschema.valid
configure.ac
View file @
b22bc91e
...
@@ -108,6 +108,9 @@ AC_ARG_ENABLE([icon-browser],
...
@@ -108,6 +108,9 @@ AC_ARG_ENABLE([icon-browser],
[build_ib=$enableval], [build_ib=no])
[build_ib=$enableval], [build_ib=no])
AM_CONDITIONAL([BUILD_IB], [test x$build_ib = xyes])
AM_CONDITIONAL([BUILD_IB], [test x$build_ib = xyes])
# GSettings
GLIB_GSETTINGS
# *******************************
# *******************************
# Internationalization
# Internationalization
# *******************************
# *******************************
...
...
data/Makefile.am
View file @
b22bc91e
...
@@ -7,6 +7,11 @@ desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
...
@@ -7,6 +7,11 @@ desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
@INTLTOOL_DESKTOP_RULE@
@INTLTOOL_DESKTOP_RULE@
endif
endif
gsettings_in_file
=
yad.gschema.xml.in
gsettings_SCHEMAS
=
$
(
gsettings_in_file:.xml.in
=
.xml
)
@INTLTOOL_XML_NOMERGE_RULE@
@GSETTINGS_RULES@
dist_man_MANS
=
yad.1
dist_man_MANS
=
yad.1
if
BUILD_PFD
if
BUILD_PFD
dist_man_MANS
+=
pfd.1
dist_man_MANS
+=
pfd.1
...
@@ -15,6 +20,6 @@ endif
...
@@ -15,6 +20,6 @@ endif
m4dir
=
$(datadir)
/aclocal
m4dir
=
$(datadir)
/aclocal
m4_DATA
=
yad.m4
m4_DATA
=
yad.m4
EXTRA_DIST
=
$(desktop_in_files)
zenity.sh notify-send
EXTRA_DIST
=
$(desktop_in_files)
$(gsettings_in_files)
zenity.sh notify-send
DISTCLEAN_FILES
=
$(desktop_DATA)
$(m4_DATA)
yad.spec
DISTCLEAN_FILES
=
$(desktop_DATA)
$(
gsettings_SCHEMAS)
$(
m4_DATA)
yad.spec
data/yad.gschema.xml.in
0 → 100644
View file @
b22bc91e
<schemalist>
<schema id="yad.settings" path="/yad/settings/" gettext-domain="yad">
<key name="width" type="i">
<default>-1</default>
<_summary>Default width of dialog window</_summary>
</key>
<key name="height" type="i">
<default>-1</default>
<_summary>Default height of dialog window</_summary>
</key>
<key name="border" type="i">
<default>5</default>
<_summary>Borders around dialog</_summary>
</key>
<key name="combo_always_editable" type="b">
<default>false</default>
<_summary>Combo-box in entry dialog is always editable</_summary>
</key>
<key name="terminal" type="s">
<default>'xterm -e "%s"'</default>
<_summary>Default terminal command (use %s for arguments placeholder)</_summary>
</key>
<key name="open_command" type="s">
<default>'xdg-open "%s"'</default>
<_summary>Default open command (use %s for arguments placeholder)</_summary>
</key>
<key name="date_format" type="s">
<default>'%x'</default>
<_summary>Default date format (see strftime(3) for details)</_summary>
</key>
<key name="uri_color" type="s">
<default>'blue'</default>
<_summary>Default color for URI in text-info dialog</_summary>
</key>
<key name="ignore_unknown_options" type="b">
<default>true</default>
<_summary>Ignore unknown command-line options</_summary>
</key>
<key name="max_tab" type="i">
<default>100</default>
<_summary>Maximum number of tabs in notebook dialog</_summary>
</key>
</schema>
</schemalist>
po/POTFILES.in
View file @
b22bc91e
...
@@ -22,3 +22,4 @@ src/browser.c
...
@@ -22,3 +22,4 @@ src/browser.c
src/notebook.c
src/notebook.c
src/pfd.c
src/pfd.c
data/yad-icon-browser.desktop.in
data/yad-icon-browser.desktop.in
data/yad.gschema.xml.in
src/entry.c
View file @
b22bc91e
...
@@ -188,7 +188,7 @@ entry_create_widget (GtkWidget * dlg)
...
@@ -188,7 +188,7 @@ entry_create_widget (GtkWidget * dlg)
{
{
gint
active
,
i
;
gint
active
,
i
;
if
(
options
.
common_data
.
editable
||
settings
.
combo_always_editable
)
if
(
options
.
common_data
.
editable
||
g_settings_get_boolean
(
settings
,
"combo_always_editable"
)
)
{
{
c
=
gtk_combo_box_text_new_with_entry
();
c
=
gtk_combo_box_text_new_with_entry
();
gtk_widget_set_name
(
c
,
"yad-entry-edit-combo"
);
gtk_widget_set_name
(
c
,
"yad-entry-edit-combo"
);
...
...
src/icons.c
View file @
b22bc91e
...
@@ -346,7 +346,7 @@ parse_desktop_file (gchar * filename)
...
@@ -346,7 +346,7 @@ parse_desktop_file (gchar * filename)
gchar
*
url
=
g_key_file_get_string
(
kf
,
"Desktop Entry"
,
"URL"
,
NULL
);
gchar
*
url
=
g_key_file_get_string
(
kf
,
"Desktop Entry"
,
"URL"
,
NULL
);
if
(
url
)
if
(
url
)
{
{
ent
->
command
=
g_strdup_printf
(
settings
.
open_cmd
,
url
);
ent
->
command
=
g_strdup_printf
(
g_settings_get_string
(
settings
,
"open_command"
)
,
url
);
g_free
(
url
);
g_free
(
url
);
}
}
}
}
...
...
src/main.c
View file @
b22bc91e
...
@@ -34,6 +34,12 @@
...
@@ -34,6 +34,12 @@
#include "yad.h"
#include "yad.h"
YadOptions
options
;
YadOptions
options
;
GSettings
*
settings
;
GtkIconTheme
*
yad_icon_theme
;
GdkPixbuf
*
big_fallback_image
=
NULL
;
GdkPixbuf
*
small_fallback_image
=
NULL
;
static
GtkWidget
*
dialog
=
NULL
;
static
GtkWidget
*
dialog
=
NULL
;
static
gint
ret
=
YAD_RESPONSE_ESC
;
static
gint
ret
=
YAD_RESPONSE_ESC
;
...
@@ -113,7 +119,7 @@ timeout_cb (gpointer data)
...
@@ -113,7 +119,7 @@ timeout_cb (gpointer data)
{
{
gdouble
percent
=
((
gdouble
)
options
.
data
.
timeout
-
count
)
/
(
gdouble
)
options
.
data
.
timeout
;
gdouble
percent
=
((
gdouble
)
options
.
data
.
timeout
-
count
)
/
(
gdouble
)
options
.
data
.
timeout
;
gtk_progress_bar_set_fraction
(
GTK_PROGRESS_BAR
(
w
),
percent
);
gtk_progress_bar_set_fraction
(
GTK_PROGRESS_BAR
(
w
),
percent
);
if
(
settings
.
show_remain
)
if
(
g_settings_get_boolean
(
settings
,
"show_remain"
)
)
{
{
gchar
*
lbl
=
g_strdup_printf
(
_
(
"%d sec"
),
options
.
data
.
timeout
-
count
);
gchar
*
lbl
=
g_strdup_printf
(
_
(
"%d sec"
),
options
.
data
.
timeout
-
count
);
gtk_progress_bar_set_text
(
GTK_PROGRESS_BAR
(
w
),
lbl
);
gtk_progress_bar_set_text
(
GTK_PROGRESS_BAR
(
w
),
lbl
);
...
@@ -386,7 +392,7 @@ create_dialog (void)
...
@@ -386,7 +392,7 @@ create_dialog (void)
gtk_box_pack_end
(
GTK_BOX
(
cbox
),
topb
,
FALSE
,
FALSE
,
2
);
gtk_box_pack_end
(
GTK_BOX
(
cbox
),
topb
,
FALSE
,
FALSE
,
2
);
}
}
if
(
settings
.
show_remain
)
if
(
g_settings_get_boolean
(
settings
,
"show_remain"
)
)
{
{
gchar
*
lbl
=
g_strdup_printf
(
_
(
"%d sec"
),
options
.
data
.
timeout
);
gchar
*
lbl
=
g_strdup_printf
(
_
(
"%d sec"
),
options
.
data
.
timeout
);
gtk_progress_bar_set_show_text
(
GTK_PROGRESS_BAR
(
topb
),
TRUE
);
gtk_progress_bar_set_show_text
(
GTK_PROGRESS_BAR
(
topb
),
TRUE
);
...
@@ -656,7 +662,11 @@ main (gint argc, gchar ** argv)
...
@@ -656,7 +662,11 @@ main (gint argc, gchar ** argv)
gtk_init
(
&
argc
,
&
argv
);
gtk_init
(
&
argc
,
&
argv
);
g_set_application_name
(
"YAD"
);
g_set_application_name
(
"YAD"
);
read_settings
();
settings
=
g_settings_new
(
"yad.settings"
);
yad_icon_theme
=
gtk_icon_theme_get_default
();
yad_options_init
();
yad_options_init
();
ctx
=
yad_create_context
();
ctx
=
yad_create_context
();
...
@@ -708,13 +718,11 @@ main (gint argc, gchar ** argv)
...
@@ -708,13 +718,11 @@ main (gint argc, gchar ** argv)
/* set default icons and icon theme */
/* set default icons and icon theme */
if
(
options
.
data
.
icon_theme
)
if
(
options
.
data
.
icon_theme
)
gtk_icon_theme_set_custom_theme
(
settings
.
icon_theme
,
options
.
data
.
icon_theme
);
gtk_icon_theme_set_custom_theme
(
yad_
icon_theme
,
options
.
data
.
icon_theme
);
gtk_icon_size_lookup
(
GTK_ICON_SIZE_DIALOG
,
&
w
,
&
h
);
gtk_icon_size_lookup
(
GTK_ICON_SIZE_DIALOG
,
&
w
,
&
h
);
settings
.
big_fallback_image
=
big_fallback_image
=
gtk_icon_theme_load_icon
(
yad_icon_theme
,
"yad"
,
MIN
(
w
,
h
),
GTK_ICON_LOOKUP_GENERIC_FALLBACK
,
NULL
);
gtk_icon_theme_load_icon
(
settings
.
icon_theme
,
"yad"
,
MIN
(
w
,
h
),
GTK_ICON_LOOKUP_GENERIC_FALLBACK
,
NULL
);
gtk_icon_size_lookup
(
GTK_ICON_SIZE_MENU
,
&
w
,
&
h
);
gtk_icon_size_lookup
(
GTK_ICON_SIZE_MENU
,
&
w
,
&
h
);
settings
.
small_fallback_image
=
small_fallback_image
=
gtk_icon_theme_load_icon
(
yad_icon_theme
,
"yad"
,
MIN
(
w
,
h
),
GTK_ICON_LOOKUP_GENERIC_FALLBACK
,
NULL
);
gtk_icon_theme_load_icon
(
settings
.
icon_theme
,
"yad"
,
MIN
(
w
,
h
),
GTK_ICON_LOOKUP_GENERIC_FALLBACK
,
NULL
);
/* correct separators */
/* correct separators */
str
=
g_strcompress
(
options
.
common_data
.
separator
);
str
=
g_strcompress
(
options
.
common_data
.
separator
);
...
...
src/option.c
View file @
b22bc91e
...
@@ -1150,7 +1150,7 @@ static gboolean
...
@@ -1150,7 +1150,7 @@ static gboolean
add_image_path
(
const
gchar
*
option_name
,
const
gchar
*
value
,
gpointer
data
,
GError
**
err
)
add_image_path
(
const
gchar
*
option_name
,
const
gchar
*
value
,
gpointer
data
,
GError
**
err
)
{
{
if
(
value
)
if
(
value
)
gtk_icon_theme_append_search_path
(
settings
.
icon_theme
,
value
);
gtk_icon_theme_append_search_path
(
yad_
icon_theme
,
value
);
return
TRUE
;
return
TRUE
;
}
}
...
@@ -1443,8 +1443,8 @@ yad_options_init (void)
...
@@ -1443,8 +1443,8 @@ yad_options_init (void)
/* Initialize general data */
/* Initialize general data */
options
.
data
.
dialog_title
=
NULL
;
options
.
data
.
dialog_title
=
NULL
;
options
.
data
.
window_icon
=
"yad"
;
options
.
data
.
window_icon
=
"yad"
;
options
.
data
.
width
=
settings
.
width
;
options
.
data
.
width
=
g_settings_get_int
(
settings
,
"width"
)
;
options
.
data
.
height
=
settings
.
height
;
options
.
data
.
height
=
g_settings_get_int
(
settings
,
"height"
)
;
options
.
data
.
use_posx
=
FALSE
;
options
.
data
.
use_posx
=
FALSE
;
options
.
data
.
posx
=
0
;
options
.
data
.
posx
=
0
;
options
.
data
.
use_posy
=
FALSE
;
options
.
data
.
use_posy
=
FALSE
;
...
@@ -1455,12 +1455,12 @@ yad_options_init (void)
...
@@ -1455,12 +1455,12 @@ yad_options_init (void)
options
.
data
.
dialog_image
=
NULL
;
options
.
data
.
dialog_image
=
NULL
;
options
.
data
.
icon_theme
=
NULL
;
options
.
data
.
icon_theme
=
NULL
;
options
.
data
.
expander
=
NULL
;
options
.
data
.
expander
=
NULL
;
options
.
data
.
timeout
=
settings
.
timeout
;
options
.
data
.
timeout
=
0
;
options
.
data
.
to_indicator
=
settings
.
to_indicator
;
options
.
data
.
to_indicator
=
NULL
;
options
.
data
.
buttons
=
NULL
;
options
.
data
.
buttons
=
NULL
;
options
.
data
.
no_buttons
=
FALSE
;
options
.
data
.
no_buttons
=
FALSE
;
options
.
data
.
buttons_layout
=
GTK_BUTTONBOX_END
;
options
.
data
.
buttons_layout
=
GTK_BUTTONBOX_END
;
options
.
data
.
borders
=
2
;
options
.
data
.
borders
=
g_settings_get_int
(
settings
,
"border"
);
;
options
.
data
.
no_markup
=
FALSE
;
options
.
data
.
no_markup
=
FALSE
;
options
.
data
.
no_escape
=
FALSE
;
options
.
data
.
no_escape
=
FALSE
;
options
.
data
.
escape_ok
=
FALSE
;
options
.
data
.
escape_ok
=
FALSE
;
...
@@ -1491,7 +1491,7 @@ yad_options_init (void)
...
@@ -1491,7 +1491,7 @@ yad_options_init (void)
options
.
common_data
.
editable
=
FALSE
;
options
.
common_data
.
editable
=
FALSE
;
options
.
common_data
.
tail
=
FALSE
;
options
.
common_data
.
tail
=
FALSE
;
options
.
common_data
.
command
=
NULL
;
options
.
common_data
.
command
=
NULL
;
options
.
common_data
.
date_format
=
settings
.
date_format
;
options
.
common_data
.
date_format
=
g_settings_get_string
(
settings
,
"date_format"
)
;
options
.
common_data
.
float_precision
=
3
;
options
.
common_data
.
float_precision
=
3
;
options
.
common_data
.
vertical
=
FALSE
;
options
.
common_data
.
vertical
=
FALSE
;
options
.
common_data
.
align
=
0
.
0
;
options
.
common_data
.
align
=
0
.
0
;
...
@@ -1582,7 +1582,7 @@ yad_options_init (void)
...
@@ -1582,7 +1582,7 @@ yad_options_init (void)
options
.
icons_data
.
compact
=
FALSE
;
options
.
icons_data
.
compact
=
FALSE
;
options
.
icons_data
.
generic
=
FALSE
;
options
.
icons_data
.
generic
=
FALSE
;
options
.
icons_data
.
width
=
-
1
;
options
.
icons_data
.
width
=
-
1
;
options
.
icons_data
.
term
=
settings
.
term
;
options
.
icons_data
.
term
=
g_settings_get_string
(
settings
,
"term"
)
;
options
.
icons_data
.
sort_by_name
=
FALSE
;
options
.
icons_data
.
sort_by_name
=
FALSE
;
options
.
icons_data
.
descend
=
FALSE
;
options
.
icons_data
.
descend
=
FALSE
;
options
.
icons_data
.
single_click
=
FALSE
;
options
.
icons_data
.
single_click
=
FALSE
;
...
@@ -1680,7 +1680,7 @@ yad_options_init (void)
...
@@ -1680,7 +1680,7 @@ yad_options_init (void)
options
.
text_data
.
justify
=
GTK_JUSTIFY_LEFT
;
options
.
text_data
.
justify
=
GTK_JUSTIFY_LEFT
;
options
.
text_data
.
margins
=
0
;
options
.
text_data
.
margins
=
0
;
options
.
text_data
.
hide_cursor
=
TRUE
;
options
.
text_data
.
hide_cursor
=
TRUE
;
options
.
text_data
.
uri_color
=
"blue"
;
options
.
text_data
.
uri_color
=
g_settings_get_string
(
settings
,
"uri_color"
)
;
options
.
text_data
.
formatted
=
FALSE
;
options
.
text_data
.
formatted
=
FALSE
;
#ifdef HAVE_SOURCEVIEW
#ifdef HAVE_SOURCEVIEW
...
@@ -1856,7 +1856,7 @@ yad_create_context (void)
...
@@ -1856,7 +1856,7 @@ yad_create_context (void)
g_option_context_add_group
(
tmp_ctx
,
a_group
);
g_option_context_add_group
(
tmp_ctx
,
a_group
);
g_option_context_set_help_enabled
(
tmp_ctx
,
TRUE
);
g_option_context_set_help_enabled
(
tmp_ctx
,
TRUE
);
g_option_context_set_ignore_unknown_options
(
tmp_ctx
,
settings
.
ignore_unknown
);
g_option_context_set_ignore_unknown_options
(
tmp_ctx
,
g_settings_get_boolean
(
settings
,
"ignore_unknown_options"
)
);
return
tmp_ctx
;
return
tmp_ctx
;
}
}
src/print.c
View file @
b22bc91e
...
@@ -213,9 +213,11 @@ yad_print_run (void)
...
@@ -213,9 +213,11 @@ yad_print_run (void)
{
{
GtkWidget
*
dlg
;
GtkWidget
*
dlg
;
GtkWidget
*
box
,
*
img
,
*
lbl
;
GtkWidget
*
box
,
*
img
,
*
lbl
;
gchar
*
uri
,
*
job_name
=
NULL
;
gchar
*
uri
,
*
fn
,
*
job_name
=
NULL
;
GtkPrintCapabilities
pcap
;
GtkPrintCapabilities
pcap
;
GtkPrintOperationAction
act
=
GTK_PRINT_OPERATION_ACTION_PRINT
;
GtkPrintOperationAction
act
=
GTK_PRINT_OPERATION_ACTION_PRINT
;
GtkPrintSettings
*
print_settings
=
NULL
;
GtkPageSetup
*
page_setup
=
NULL
;
gint
resp
,
ret
=
0
;
gint
resp
,
ret
=
0
;
GError
*
err
=
NULL
;
GError
*
err
=
NULL
;
...
@@ -234,6 +236,15 @@ yad_print_run (void)
...
@@ -234,6 +236,15 @@ yad_print_run (void)
return
1
;
return
1
;
}
}
/* load previously saved print settings */
fn
=
g_build_filename
(
g_get_user_config_dir
(),
"yad"
,
"print.conf"
,
NULL
);
if
(
g_file_test
(
fn
,
G_FILE_TEST_EXISTS
))
{
print_settings
=
gtk_print_settings_new_from_file
(
fn
,
NULL
);
page_setup
=
gtk_page_setup_new_from_file
(
fn
,
NULL
);
}
g_free
(
fn
);
/* create print dialog */
/* create print dialog */
dlg
=
gtk_print_unix_dialog_new
(
options
.
data
.
dialog_title
,
NULL
);
dlg
=
gtk_print_unix_dialog_new
(
options
.
data
.
dialog_title
,
NULL
);
gtk_window_set_type_hint
(
GTK_WINDOW
(
dlg
),
GDK_WINDOW_TYPE_HINT_NORMAL
);
gtk_window_set_type_hint
(
GTK_WINDOW
(
dlg
),
GDK_WINDOW_TYPE_HINT_NORMAL
);
...
@@ -245,17 +256,15 @@ yad_print_run (void)
...
@@ -245,17 +256,15 @@ yad_print_run (void)
pcap
|=
GTK_PRINT_CAPABILITY_PREVIEW
;
pcap
|=
GTK_PRINT_CAPABILITY_PREVIEW
;
gtk_print_unix_dialog_set_manual_capabilities
(
GTK_PRINT_UNIX_DIALOG
(
dlg
),
pcap
);
gtk_print_unix_dialog_set_manual_capabilities
(
GTK_PRINT_UNIX_DIALOG
(
dlg
),
pcap
);
if
(
!
settings
.
print_settings
)
settings
.
print_settings
=
gtk_print_unix_dialog_get_settings
(
GTK_PRINT_UNIX_DIALOG
(
dlg
));
uri
=
g_build_filename
(
g_get_current_dir
(),
"yad.pdf"
,
NULL
);
uri
=
g_build_filename
(
g_get_current_dir
(),
"yad.pdf"
,
NULL
);
gtk_print_settings_set
(
settings
.
print_settings
,
"output-uri"
,
g_filename_to_uri
(
uri
,
NULL
,
NULL
));
gtk_print_settings_set
(
print_settings
,
"output-uri"
,
g_filename_to_uri
(
uri
,
NULL
,
NULL
));
g_free
(
uri
);
g_free
(
uri
);
gtk_print_unix_dialog_set_settings
(
GTK_PRINT_UNIX_DIALOG
(
dlg
),
settings
.
print_settings
);
if
(
print_settings
)
gtk_print_unix_dialog_set_settings
(
GTK_PRINT_UNIX_DIALOG
(
dlg
),
print_settings
);
if
(
settings
.
page_setup
)
if
(
page_setup
)
gtk_print_unix_dialog_set_page_setup
(
GTK_PRINT_UNIX_DIALOG
(
dlg
),
settings
.
page_setup
);
gtk_print_unix_dialog_set_page_setup
(
GTK_PRINT_UNIX_DIALOG
(
dlg
),
page_setup
);
/* set window behavior */
/* set window behavior */
gtk_widget_set_name
(
dlg
,
"yad-dialog-window"
);
gtk_widget_set_name
(
dlg
,
"yad-dialog-window"
);
...
@@ -325,16 +334,16 @@ yad_print_run (void)
...
@@ -325,16 +334,16 @@ yad_print_run (void)
case
GTK_RESPONSE_APPLY
:
/* ask for preview */
case
GTK_RESPONSE_APPLY
:
/* ask for preview */
act
=
GTK_PRINT_OPERATION_ACTION_PREVIEW
;
act
=
GTK_PRINT_OPERATION_ACTION_PREVIEW
;
case
GTK_RESPONSE_OK
:
/* run print */
case
GTK_RESPONSE_OK
:
/* run print */
settings
.
print_settings
=
gtk_print_unix_dialog_get_settings
(
GTK_PRINT_UNIX_DIALOG
(
dlg
));
print_settings
=
gtk_print_unix_dialog_get_settings
(
GTK_PRINT_UNIX_DIALOG
(
dlg
));
settings
.
page_setup
=
gtk_print_unix_dialog_get_page_setup
(
GTK_PRINT_UNIX_DIALOG
(
dlg
));
page_setup
=
gtk_print_unix_dialog_get_page_setup
(
GTK_PRINT_UNIX_DIALOG
(
dlg
));
job_name
=
g_strdup_printf
(
"yad-%s-%d"
,
g_path_get_basename
(
options
.
common_data
.
uri
),
getpid
());
job_name
=
g_strdup_printf
(
"yad-%s-%d"
,
g_path_get_basename
(
options
.
common_data
.
uri
),
getpid
());
if
(
options
.
print_data
.
type
!=
YAD_PRINT_RAW
)
if
(
options
.
print_data
.
type
!=
YAD_PRINT_RAW
)
{
{
/* print text or image */
/* print text or image */
GtkPrintOperation
*
op
=
gtk_print_operation_new
();
GtkPrintOperation
*
op
=
gtk_print_operation_new
();
gtk_print_operation_set_unit
(
op
,
GTK_UNIT_POINTS
);
gtk_print_operation_set_unit
(
op
,
GTK_UNIT_POINTS
);
gtk_print_operation_set_print_settings
(
op
,
settings
.
print_settings
);
gtk_print_operation_set_print_settings
(
op
,
print_settings
);
gtk_print_operation_set_default_page_setup
(
op
,
settings
.
page_setup
);
gtk_print_operation_set_default_page_setup
(
op
,
page_setup
);
gtk_print_operation_set_job_name
(
op
,
job_name
);
gtk_print_operation_set_job_name
(
op
,
job_name
);
switch
(
options
.
print_data
.
type
)
switch
(
options
.
print_data
.
type
)
...
@@ -388,7 +397,7 @@ yad_print_run (void)
...
@@ -388,7 +397,7 @@ yad_print_run (void)
if
(
ret
==
1
)
if
(
ret
==
1
)
break
;
break
;
job
=
gtk_print_job_new
(
job_name
,
prnt
,
settings
.
print_settings
,
settings
.
page_setup
);
job
=
gtk_print_job_new
(
job_name
,
prnt
,
print_settings
,
page_setup
);
if
(
gtk_print_job_set_source_file
(
job
,
options
.
common_data
.
uri
,
&
err
))
if
(
gtk_print_job_set_source_file
(
job
,
options
.
common_data
.
uri
,
&
err
))
{
{
gtk_print_job_send
(
job
,
(
GtkPrintJobCompleteFunc
)
raw_print_done
,
&
ret
,
NULL
);
gtk_print_job_send
(
job
,
(
GtkPrintJobCompleteFunc
)
raw_print_done
,
&
ret
,
NULL
);
...
@@ -409,6 +418,16 @@ yad_print_run (void)
...
@@ -409,6 +418,16 @@ yad_print_run (void)
while
(
resp
==
GTK_RESPONSE_APPLY
);
while
(
resp
==
GTK_RESPONSE_APPLY
);
gtk_widget_destroy
(
dlg
);
gtk_widget_destroy
(
dlg
);
write_settings
();
/* save print settings */
fn
=
g_build_filename
(
g_get_user_config_dir
(),
"yad"
,
NULL
);
g_mkdir_with_parents
(
fn
,
0700
);
g_free
(
fn
);
fn
=
g_build_filename
(
g_get_user_config_dir
(),
"yad"
,
"print.conf"
,
NULL
);
gtk_print_settings_to_file
(
print_settings
,
fn
,
NULL
);
gtk_page_setup_to_file
(
page_setup
,
fn
,
NULL
);
g_free
(
fn
);
return
ret
;
return
ret
;
}
}
src/text.c
View file @
b22bc91e
...
@@ -173,7 +173,7 @@ tag_event_cb (GtkTextTag * tag, GObject * obj, GdkEvent * ev, GtkTextIter * iter
...
@@ -173,7 +173,7 @@ tag_event_cb (GtkTextTag * tag, GObject * obj, GdkEvent * ev, GtkTextIter * iter
gtk_text_iter_forward_to_tag_toggle
(
&
end
,
tag
);
gtk_text_iter_forward_to_tag_toggle
(
&
end
,
tag
);
url
=
gtk_text_iter_get_text
(
&
start
,
&
end
);
url
=
gtk_text_iter_get_text
(
&
start
,
&
end
);
cmdline
=
g_strdup_printf
(
settings
.
open_cmd
,
url
);
cmdline
=
g_strdup_printf
(
g_settings_get_string
(
settings
,
"open_command"
)
,
url
);
g_free
(
url
);
g_free
(
url
);
g_spawn_command_line_async
(
cmdline
,
NULL
);
g_spawn_command_line_async
(
cmdline
,
NULL
);
...
...
src/util.c
View file @
b22bc91e
...
@@ -30,8 +30,6 @@
...
@@ -30,8 +30,6 @@
#include "yad.h"
#include "yad.h"
YadSettings
settings
;
const
YadStock
yad_stock_items
[]
=
{
const
YadStock
yad_stock_items
[]
=
{
{
"yad-about"
,
N_
(
"About"
),
"help-about"
},
{
"yad-about"
,
N_
(
"About"
),
"help-about"
},
{
"yad-add"
,
N_
(
"Add"
),
"list-add"
},
{
"yad-add"
,
N_
(
"Add"
),
"list-add"
},
...
@@ -54,124 +52,6 @@ const YadStock yad_stock_items[] = {
...
@@ -54,124 +52,6 @@ const YadStock yad_stock_items[] = {
{
"yad-yes"
,
N_
(
"Yes"
),
"gtk-yes"
}
{
"yad-yes"
,
N_
(
"Yes"
),
"gtk-yes"
}
};
};
void
read_settings
(
void
)
{
GKeyFile
*
kf
;
gchar
*
filename
;
/* set defaults */
settings
.
width
=
settings
.
height
=
-
1
;
settings
.
timeout
=
0
;
settings
.
to_indicator
=
"none"
;
settings
.
show_remain
=
FALSE
;
settings
.
combo_always_editable
=
FALSE
;
settings
.
term
=
"xterm -e '%s'"
;
settings
.
open_cmd
=
"xdg-open '%s'"
;
settings
.
date_format
=
"%x"
;
settings
.
ignore_unknown
=
TRUE
;
settings
.
max_tab
=
100
;
settings
.
print_settings
=
NULL
;
settings
.
page_setup
=
NULL
;
settings
.
icon_theme
=
gtk_icon_theme_get_default
();
filename
=
g_build_filename
(
g_get_user_config_dir
(),
YAD_SETTINGS_FILE
,
NULL
);
if
(
g_file_test
(
filename
,
G_FILE_TEST_EXISTS
))
{
kf
=
g_key_file_new
();
if
(
g_key_file_load_from_file
(
kf
,
filename
,
G_KEY_FILE_NONE
,
NULL
))
{
if
(
g_key_file_has_key
(
kf
,
"General"
,
"width"
,
NULL
))
settings
.
width
=
g_key_file_get_integer
(
kf
,
"General"
,
"width"
,
NULL
);
if
(
g_key_file_has_key
(
kf
,
"General"
,
"height"
,
NULL
))
settings
.
height
=
g_key_file_get_integer
(
kf
,
"General"
,
"height"
,
NULL
);
if
(
g_key_file_has_key
(
kf
,
"General"
,
"timeout"
,
NULL
))
settings
.
timeout
=
g_key_file_get_integer
(
kf
,
"General"
,
"timeout"
,
NULL
);
if
(
g_key_file_has_key
(
kf
,
"General"
,
"timeout_indicator"
,
NULL
))
settings
.
to_indicator
=
g_key_file_get_string
(
kf
,
"General"
,
"timeout_indicator"
,
NULL
);
if
(
g_key_file_has_key
(
kf
,
"General"
,
"show_remain"
,
NULL
))
settings
.
show_remain
=
g_key_file_get_boolean
(
kf
,
"General"
,
"show_remain"
,
NULL
);
if
(
g_key_file_has_key
(
kf
,
"General"
,
"combo_always_editable"
,
NULL
))
settings
.
combo_always_editable
=
g_key_file_get_boolean
(
kf
,
"General"
,
"combo_always_editable"
,
NULL
);
if
(
g_key_file_has_key
(
kf
,
"General"
,
"terminal"
,
NULL
))
settings
.
term
=
g_key_file_get_string
(
kf
,
"General"
,
"terminal"
,
NULL
);
if
(
g_key_file_has_key
(
kf
,
"General"
,
"open_command"
,
NULL
))
settings
.
open_cmd
=
g_key_file_get_string
(
kf
,
"General"
,
"open_command"
,
NULL
);
if
(
g_key_file_has_key
(
kf
,
"General"
,
"date_format"
,
NULL
))
settings
.
date_format
=
g_key_file_get_string
(
kf
,
"General"
,
"date_format"
,
NULL
);
if
(
g_key_file_has_key
(
kf
,
"General"
,
"ignore_unknown_options"
,
NULL
))
settings
.
ignore_unknown
=
g_key_file_get_boolean
(
kf
,
"General"
,
"ignore_unknown_options"
,
NULL
);
if
(
g_key_file_has_key
(
kf
,
"General"
,
"max_tab"
,
NULL
))
settings
.
max_tab
=
g_key_file_get_integer
(
kf
,
"General"
,
"max_tab"
,
NULL
);
settings
.
print_settings
=
gtk_print_settings_new_from_key_file
(
kf
,
NULL
,
NULL
);
settings
.
page_setup
=
gtk_page_setup_new_from_key_file
(
kf
,
NULL
,
NULL
);
}
g_key_file_free
(
kf
);
}
else
write_settings
();
g_free
(
filename
);
}
void
write_settings
(
void
)
{
GKeyFile
*
kf
;
gchar
*
context
;
kf
=
g_key_file_new
();
g_key_file_set_integer
(
kf
,
"General"
,
"width"
,
settings
.
width
);
g_key_file_set_comment
(
kf
,
"General"
,
"width"
,
" Default dialog width"
,
NULL
);
g_key_file_set_integer
(
kf
,
"General"
,
"height"
,
settings
.
height
);
g_key_file_set_comment
(
kf
,
"General"
,
"height"
,
" Default dialog height"
,
NULL
);
g_key_file_set_integer
(
kf
,
"General"
,
"timeout"
,
settings
.
timeout
);
g_key_file_set_comment
(
kf
,
"General"
,
"timeout"
,
" Default timeout (0 for no timeout)"
,
NULL
);
g_key_file_set_string
(
kf
,
"General"
,
"timeout_indicator"
,
settings
.
to_indicator
);
g_key_file_set_comment
(
kf
,
"General"
,
"timeout_indicator"
,
" Position of timeout indicator (top, bottom, left, right, none)"
,
NULL
);
g_key_file_set_boolean
(
kf
,
"General"
,
"show_remain"
,
settings
.
show_remain
);
g_key_file_set_comment
(
kf
,
"General"
,
"show_remain"
,
" Show remain seconds in timeout indicator"
,
NULL
);
g_key_file_set_boolean
(
kf
,
"General"
,
"combo_always_editable"
,
settings
.
combo_always_editable
);
g_key_file_set_comment
(
kf
,
"General"
,
"combo_always_editable"
,
" Combo-box in entry dialog is always editable"
,
NULL
);
g_key_file_set_string
(
kf
,
"General"
,
"terminal"
,
settings
.
term
);
g_key_file_set_comment
(
kf
,
"General"
,
"terminal"
,
" Default terminal command (use %s for arguments placeholder)"
,
NULL
);
g_key_file_set_string
(
kf
,
"General"
,
"open_command"
,
settings
.
open_cmd
);
g_key_file_set_comment
(
kf
,
"General"
,
"open_command"
,
" Default open command (use %s for arguments placeholder)"
,
NULL
);
g_key_file_set_string
(
kf
,
"General"
,
"date_format"
,
settings
.
date_format
);
g_key_file_set_comment
(
kf
,
"General"
,
"date_format"
,
" Default date format (see strftime(3) for details)"
,
NULL
);
g_key_file_set_boolean
(
kf
,
"General"
,
"ignore_unknown_options"
,
settings
.
ignore_unknown
);
g_key_file_set_comment
(
kf
,
"General"
,
"ignore_unknown_options"
,
" Ignore unknown command-line options"
,
NULL
);
g_key_file_set_integer
(
kf
,
"General"
,
"max_tab"
,
settings
.
max_tab
);
g_key_file_set_comment
(
kf
,
"General"
,
"max_tab"
,
" Maximum number of tabs in notebook"
,
NULL
);
if
(
settings
.
print_settings
)
gtk_print_settings_to_key_file
(
settings
.
print_settings
,
kf
,
NULL
);
if
(
settings
.
page_setup
)
gtk_page_setup_to_key_file
(
settings
.
page_setup
,
kf
,
NULL
);
context
=
g_key_file_to_data
(
kf
,
NULL
,
NULL
);
g_key_file_free
(
kf
);
if
(
g_mkdir_with_parents
(
g_get_user_config_dir
(),
0755
)
!=
-
1
)
{
gchar
*
filename
=
g_build_filename
(
g_get_user_config_dir
(),
YAD_SETTINGS_FILE
,
NULL
);
g_file_set_contents
(
filename
,
context
,
-
1
,
NULL
);
g_free
(
filename
);
}
else
g_printerr
(
"yad: cannot write settings file: %s
\n
"
,
strerror
(
errno
));
g_free
(
context
);
}
gboolean
gboolean
stock_lookup
(
gchar
*
key
,
YadStock
*
it
)
stock_lookup
(
gchar
*
key
,
YadStock
*
it
)
{
{
...
@@ -218,14 +98,14 @@ get_pixbuf (gchar * name, YadIconSize size, gboolean force)
...
@@ -218,14 +98,14 @@ get_pixbuf (gchar * name, YadIconSize size, gboolean force)
}
}
}
}
else
else
pb
=
gtk_icon_theme_load_icon
(
settings
.
icon_theme
,
name
,
MIN
(
w
,
h
),
GTK_ICON_LOOKUP_GENERIC_FALLBACK
,
NULL
);
pb
=
gtk_icon_theme_load_icon
(
yad_
icon_theme
,
name
,
MIN
(
w
,
h
),
GTK_ICON_LOOKUP_GENERIC_FALLBACK
,
NULL
);
if
(
!
pb
)
if
(
!
pb
)
{
{
if
(
size
==
YAD_BIG_ICON
)
if
(
size
==
YAD_BIG_ICON
)
pb
=
g_object_ref
(
settings
.
big_fallback_image
);
pb
=
g_object_ref
(
big_fallback_image
);
else
else
pb
=
g_object_ref
(
s
ettings
.
s
mall_fallback_image
);
pb
=
g_object_ref
(
small_fallback_image
);
}
}
/* force scaling image to specific size */
/* force scaling image to specific size */
...
@@ -357,12 +237,13 @@ YadNTabs *
...
@@ -357,12 +237,13 @@ YadNTabs *
get_tabs
(
key_t
key
,
gboolean
create
)
get_tabs
(
key_t
key
,
gboolean
create
)
{
{
YadNTabs
*
t
=
NULL
;
YadNTabs
*
t
=
NULL
;
int
shmid
,
i
;
int
shmid
,
i
,
max_tab
;
/* get shared memory */
/* get shared memory */
max_tab
=
g_settings_get_int
(
settings
,
"max_tab"
)
+
1
;
if
(
create
)
if
(
create
)
{
{
if
((
shmid
=
shmget
(
key
,
(
settings
.
max_tab
+
1
)
*
sizeof
(
YadNTabs
),
IPC_CREAT
|
IPC_EXCL
|
0644
))
==
-
1
)
if
((
shmid
=
shmget
(
key
,
max_tab
*
sizeof
(
YadNTabs
),
IPC_CREAT
|
IPC_EXCL
|
0644
))
==
-
1
)
{
{
g_printerr
(
"yad: cannot create shared memory for key %d: %s
\n
"
,
key
,
strerror
(
errno
));
g_printerr
(
"yad: cannot create shared memory for key %d: %s
\n
"
,
key
,
strerror
(
errno
));
return
NULL
;
return
NULL
;
...
@@ -370,7 +251,7 @@ get_tabs (key_t key, gboolean create)
...
@@ -370,7 +251,7 @@ get_tabs (key_t key, gboolean create)
}
}
else
else
{
{
if
((
shmid
=
shmget
(
key
,
(
settings
.
max_tab
+
1
)
*
sizeof
(
YadNTabs
),
0
))
==
-
1
)
if
((
shmid
=
shmget
(
key
,
max_tab
*
sizeof
(
YadNTabs
),
0
))
==
-
1
)
{
{
if
(
errno
!=
ENOENT
)
if
(
errno
!=
ENOENT
)
g_printerr
(
"yad: cannot get shared memory for key %d: %s
\n
"
,
key
,
strerror
(
errno
));
g_printerr
(
"yad: cannot get shared memory for key %d: %s
\n
"
,
key
,
strerror
(
errno
));
...
@@ -388,7 +269,7 @@ get_tabs (key_t key, gboolean create)
...
@@ -388,7 +269,7 @@ get_tabs (key_t key, gboolean create)
/* initialize memory */
/* initialize memory */
if
(
create
)
if
(
create
)
{
{
for
(
i
=
0
;
i
<
settings
.
max_tab
+
1
;
i
++
)
for
(
i
=
0
;
i
<
max_tab
;
i
++
)
{
{
t
[
i
].
pid
=
-
1
;
t
[
i
].
pid
=
-
1
;
t
[
i
].
xid
=
0
;
t
[
i
].
xid
=
0
;
...
...
src/yad.h
View file @
b22bc91e
...
@@ -43,8 +43,6 @@
...
@@ -43,8 +43,6 @@
G_BEGIN_DECLS
G_BEGIN_DECLS
#define YAD_SETTINGS_FILE "yad.conf"
#define YAD_RESPONSE_OK 0
#define YAD_RESPONSE_OK 0
#define YAD_RESPONSE_CANCEL 1
#define YAD_RESPONSE_CANCEL 1
#define YAD_RESPONSE_TIMEOUT 70
#define YAD_RESPONSE_TIMEOUT 70
...
@@ -520,29 +518,11 @@ typedef struct {
...
@@ -520,29 +518,11 @@ typedef struct {
}
YadOptions
;
}
YadOptions
;
extern
YadOptions
options
;
extern
YadOptions
options
;
extern
GSettings
*
settings
;
extern
GtkIconTheme
*
yad_icon_theme
;
/* SETTINGS */
extern
GdkPixbuf
*
big_fallback_image
;
typedef
struct
{
extern
GdkPixbuf
*
small_fallback_image
;
guint
width
;
guint
height
;
guint
timeout
;
gchar
*
to_indicator
;
gboolean
show_remain
;
gboolean
combo_always_editable
;
gboolean
ignore_unknown
;
GtkIconTheme
*
icon_theme
;
GdkPixbuf
*
big_fallback_image
;
GdkPixbuf
*
small_fallback_image
;
gchar
*
term
;
gchar
*
open_cmd
;
gchar
*
date_format
;
guint
max_tab
;
GtkPrintSettings
*
print_settings
;
GtkPageSetup
*
page_setup
;
}
YadSettings
;
extern
YadSettings
settings
;
/* TABS */
/* TABS */
typedef
struct
{
typedef
struct
{
...
...
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