Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
libxfce4ui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xfce
libxfce4ui
Commits
466ff674
Commit
466ff674
authored
4 weeks ago
by
Theo Linkspfeifer
Committed by
Alexander Schwinn
3 weeks ago
Browse files
Options
Downloads
Patches
Plain Diff
filename-input: Use tooltip instead of label for errors
parent
e6b62091
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!141
filename-input tweaks
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libxfce4ui/xfce-filename-input.c
+10
-21
10 additions, 21 deletions
libxfce4ui/xfce-filename-input.c
with
10 additions
and
21 deletions
libxfce4ui/xfce-filename-input.c
+
10
−
21
View file @
466ff674
...
...
@@ -108,7 +108,6 @@ struct _XfceFilenameInput
GtkBox
parent
;
GtkEntry
*
entry
;
GtkLabel
*
label
;
GRegex
*
whitespace_regex
;
GRegex
*
dir_sep_regex
;
...
...
@@ -225,25 +224,17 @@ xfce_filename_input_init (XfceFilenameInput *filename_input)
filename_input
->
whitespace_regex
=
g_regex_new
(
"^
\\
s|
\\
s$"
,
0
,
0
,
&
err
);
filename_input
->
dir_sep_regex
=
g_regex_new
(
G_DIR_SEPARATOR_S
,
0
,
0
,
&
err
);
gtk_orientable_set_orientation
(
GTK_ORIENTABLE
(
filename_input
),
GTK_ORIENTATION_VERTICAL
);
/* set up the GtkEntry for the input */
filename_input
->
entry
=
GTK_ENTRY
(
gtk_entry_new
());
gtk_widget_set_hexpand
(
GTK_WIDGET
(
filename_input
->
entry
),
TRUE
);
gtk_widget_set_valign
(
GTK_WIDGET
(
filename_input
->
entry
),
GTK_ALIGN_CENTER
);
gtk_box_pack_start
(
GTK_BOX
(
filename_input
),
GTK_WIDGET
(
filename_input
->
entry
),
FALSE
,
FALS
E
,
0
);
gtk_box_pack_start
(
GTK_BOX
(
filename_input
),
GTK_WIDGET
(
filename_input
->
entry
),
TRUE
,
TRU
E
,
0
);
/* retrieve the error and warning messages */
filename_input
->
too_long_mssg
=
_
(
"Filename is too long"
);
filename_input
->
sep_illegal_mssg
=
_
(
"Directory separator illegal in file name"
);
filename_input
->
whitespace_mssg
=
_
(
"Filenames should not start or end with a space"
);
/* set up the GtkLabel to display any error or warning messages */
filename_input
->
label
=
GTK_LABEL
(
gtk_label_new
(
""
));
gtk_label_set_xalign
(
filename_input
->
label
,
0
.
0
f
);
gtk_box_pack_start
(
GTK_BOX
(
filename_input
),
GTK_WIDGET
(
filename_input
->
label
),
FALSE
,
FALSE
,
0
);
gtk_label_set_line_wrap
(
filename_input
->
label
,
TRUE
);
/* allow reverting the filename with ctrl + z */
g_signal_connect
(
filename_input
->
entry
,
"key-press-event"
,
G_CALLBACK
(
xfce_filename_input_entry_undo
),
filename_input
);
...
...
@@ -400,11 +391,10 @@ xfce_filename_input_entry_changed (GtkEditable *editable,
{
XfceFilenameInput
*
filename_input
;
GtkEntry
*
entry
;
GtkLabel
*
label
;
gint
text_length
;
const
gchar
*
text
;
const
gchar
*
label
_text
=
""
;
const
gchar
*
tooltip
_text
=
NULL
;
const
gchar
*
icon_name
=
NULL
;
gboolean
new_text_valid
=
TRUE
;
gboolean
match_ws
,
match_ds
;
...
...
@@ -414,7 +404,6 @@ xfce_filename_input_entry_changed (GtkEditable *editable,
g_return_if_fail
(
XFCE_IS_FILENAME_INPUT
(
data
));
filename_input
=
XFCE_FILENAME_INPUT
(
data
);
label
=
filename_input
->
label
;
/* cancel any pending timer to display a warning about the text starting or ending with whitespace */
if
(
filename_input
->
whitespace_warning_timer_id
!=
0
)
...
...
@@ -436,13 +425,13 @@ xfce_filename_input_entry_changed (GtkEditable *editable,
{
/* the string is empty */
icon_name
=
NULL
;
label
_text
=
""
;
tooltip
_text
=
NULL
;
new_text_valid
=
FALSE
;
}
else
if
(
match_ds
)
{
/* the string contains a directory separator */
label
_text
=
filename_input
->
sep_illegal_mssg
;
tooltip
_text
=
filename_input
->
sep_illegal_mssg
;
icon_name
=
"dialog-error"
;
new_text_valid
=
FALSE
;
}
...
...
@@ -450,7 +439,7 @@ xfce_filename_input_entry_changed (GtkEditable *editable,
text_length
>
filename_input
->
max_text_length
)
{
/* the string is too long */
label
_text
=
filename_input
->
too_long_mssg
;
tooltip
_text
=
filename_input
->
too_long_mssg
;
icon_name
=
"dialog-error"
;
new_text_valid
=
FALSE
;
}
...
...
@@ -464,15 +453,15 @@ xfce_filename_input_entry_changed (GtkEditable *editable,
filename_input
,
xfce_filename_input_whitespace_warning_timer_destroy
);
icon_name
=
NULL
;
label
_text
=
""
;
tooltip
_text
=
NULL
;
new_text_valid
=
TRUE
;
}
/* update the icon
in the GtkEntry and the message in
the Gtk
Label
*/
/* update the icon
and tooltip of
the Gtk
Entry
*/
gtk_entry_set_icon_from_icon_name
(
entry
,
GTK_ENTRY_ICON_SECONDARY
,
icon_name
);
gtk_
label_set_text
(
label
,
label
_text
);
gtk_
widget_set_tooltip_text
(
GTK_WIDGET
(
filename_input
),
tooltip
_text
);
/* send a signal to indicate whether the filename is valid */
gtk_entry_set_activates_default
(
entry
,
new_text_valid
);
...
...
@@ -521,11 +510,11 @@ xfce_filename_input_whitespace_warning_timer (gpointer data)
g_return_val_if_fail
(
XFCE_IS_FILENAME_INPUT
(
data
),
FALSE
);
filename_input
=
XFCE_FILENAME_INPUT
(
data
);
/* update the icon
in the GtkEntry and the message in
the Gtk
Label
*/
/* update the icon
and tooltip of
the Gtk
Entry
*/
gtk_entry_set_icon_from_icon_name
(
filename_input
->
entry
,
GTK_ENTRY_ICON_SECONDARY
,
"dialog-warning"
);
gtk_
label_set_text
(
filename_input
->
label
,
filename_input
->
whitespace_mssg
);
gtk_
widget_set_tooltip_text
(
GTK_WIDGET
(
filename_input
)
,
filename_input
->
whitespace_mssg
);
return
FALSE
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment