forked from AuroraMiddleware/gtk
settings: Remove RC property parsers
They've not been used for a long time and the APIs where they could reasonably be used have been gone for as long.
This commit is contained in:
parent
bbdaa4a0ff
commit
d92cfa2179
@ -2603,11 +2603,6 @@ GtkSettings
|
|||||||
GtkSettingsValue
|
GtkSettingsValue
|
||||||
gtk_settings_get_default
|
gtk_settings_get_default
|
||||||
gtk_settings_get_for_display
|
gtk_settings_get_for_display
|
||||||
gtk_rc_property_parse_color
|
|
||||||
gtk_rc_property_parse_enum
|
|
||||||
gtk_rc_property_parse_flags
|
|
||||||
gtk_rc_property_parse_requisition
|
|
||||||
gtk_rc_property_parse_border
|
|
||||||
gtk_settings_reset_property
|
gtk_settings_reset_property
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
GtkSettingsClass
|
GtkSettingsClass
|
||||||
|
@ -1473,346 +1473,6 @@ gtk_settings_set_property_value_internal (GtkSettings *settings,
|
|||||||
apply_queued_setting (settings, pspec, qvalue);
|
apply_queued_setting (settings, pspec, qvalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const GScannerConfig gtk_rc_scanner_config =
|
|
||||||
{
|
|
||||||
(char *) (
|
|
||||||
" \t\r\n"
|
|
||||||
) /* cset_skip_characters */,
|
|
||||||
(char *) (
|
|
||||||
"_"
|
|
||||||
G_CSET_a_2_z
|
|
||||||
G_CSET_A_2_Z
|
|
||||||
) /* cset_identifier_first */,
|
|
||||||
(char *) (
|
|
||||||
G_CSET_DIGITS
|
|
||||||
"-_"
|
|
||||||
G_CSET_a_2_z
|
|
||||||
G_CSET_A_2_Z
|
|
||||||
) /* cset_identifier_nth */,
|
|
||||||
(char *) ( "#\n" ) /* cpair_comment_single */,
|
|
||||||
|
|
||||||
TRUE /* case_sensitive */,
|
|
||||||
|
|
||||||
TRUE /* skip_comment_multi */,
|
|
||||||
TRUE /* skip_comment_single */,
|
|
||||||
TRUE /* scan_comment_multi */,
|
|
||||||
TRUE /* scan_identifier */,
|
|
||||||
FALSE /* scan_identifier_1char */,
|
|
||||||
FALSE /* scan_identifier_NULL */,
|
|
||||||
TRUE /* scan_symbols */,
|
|
||||||
TRUE /* scan_binary */,
|
|
||||||
TRUE /* scan_octal */,
|
|
||||||
TRUE /* scan_float */,
|
|
||||||
TRUE /* scan_hex */,
|
|
||||||
TRUE /* scan_hex_dollar */,
|
|
||||||
TRUE /* scan_string_sq */,
|
|
||||||
TRUE /* scan_string_dq */,
|
|
||||||
TRUE /* numbers_2_int */,
|
|
||||||
FALSE /* int_2_float */,
|
|
||||||
FALSE /* identifier_2_string */,
|
|
||||||
TRUE /* char_2_token */,
|
|
||||||
TRUE /* symbol_2_token */,
|
|
||||||
FALSE /* scope_0_fallback */,
|
|
||||||
};
|
|
||||||
|
|
||||||
static GScanner*
|
|
||||||
gtk_rc_scanner_new (void)
|
|
||||||
{
|
|
||||||
return g_scanner_new (>k_rc_scanner_config);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gtk_rc_property_parse_enum:
|
|
||||||
* @pspec: a #GParamSpec
|
|
||||||
* @gstring: the #GString to be parsed
|
|
||||||
* @property_value: a #GValue which must hold enum values.
|
|
||||||
*
|
|
||||||
* A #GtkRcPropertyParser for use with gtk_settings_install_property_parser()
|
|
||||||
* or gtk_widget_class_install_style_property_parser() which parses a single
|
|
||||||
* enumeration value.
|
|
||||||
*
|
|
||||||
* The enumeration value can be specified by its name, its nickname or
|
|
||||||
* its numeric value. For consistency with flags parsing, the value
|
|
||||||
* may be surrounded by parentheses.
|
|
||||||
*
|
|
||||||
* Returns: %TRUE if @gstring could be parsed and @property_value
|
|
||||||
* has been set to the resulting #GEnumValue.
|
|
||||||
**/
|
|
||||||
gboolean
|
|
||||||
gtk_rc_property_parse_enum (const GParamSpec *pspec,
|
|
||||||
const GString *gstring,
|
|
||||||
GValue *property_value)
|
|
||||||
{
|
|
||||||
gboolean need_closing_brace = FALSE, success = FALSE;
|
|
||||||
GScanner *scanner;
|
|
||||||
GEnumValue *enum_value = NULL;
|
|
||||||
|
|
||||||
g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE);
|
|
||||||
g_return_val_if_fail (G_VALUE_HOLDS_ENUM (property_value), FALSE);
|
|
||||||
|
|
||||||
scanner = gtk_rc_scanner_new ();
|
|
||||||
g_scanner_input_text (scanner, gstring->str, gstring->len);
|
|
||||||
|
|
||||||
/* we just want to parse _one_ value, but for consistency with flags parsing
|
|
||||||
* we support optional parenthesis
|
|
||||||
*/
|
|
||||||
g_scanner_get_next_token (scanner);
|
|
||||||
if (scanner->token == '(')
|
|
||||||
{
|
|
||||||
need_closing_brace = TRUE;
|
|
||||||
g_scanner_get_next_token (scanner);
|
|
||||||
}
|
|
||||||
if (scanner->token == G_TOKEN_IDENTIFIER)
|
|
||||||
{
|
|
||||||
GEnumClass *class = G_PARAM_SPEC_ENUM (pspec)->enum_class;
|
|
||||||
|
|
||||||
enum_value = g_enum_get_value_by_name (class, scanner->value.v_identifier);
|
|
||||||
if (!enum_value)
|
|
||||||
enum_value = g_enum_get_value_by_nick (class, scanner->value.v_identifier);
|
|
||||||
if (enum_value)
|
|
||||||
{
|
|
||||||
g_value_set_enum (property_value, enum_value->value);
|
|
||||||
success = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (scanner->token == G_TOKEN_INT)
|
|
||||||
{
|
|
||||||
g_value_set_enum (property_value, scanner->value.v_int);
|
|
||||||
success = TRUE;
|
|
||||||
}
|
|
||||||
if (need_closing_brace && g_scanner_get_next_token (scanner) != ')')
|
|
||||||
success = FALSE;
|
|
||||||
if (g_scanner_get_next_token (scanner) != G_TOKEN_EOF)
|
|
||||||
success = FALSE;
|
|
||||||
|
|
||||||
g_scanner_destroy (scanner);
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
static guint
|
|
||||||
parse_flags_value (GScanner *scanner,
|
|
||||||
GFlagsClass *class,
|
|
||||||
guint *number)
|
|
||||||
{
|
|
||||||
g_scanner_get_next_token (scanner);
|
|
||||||
if (scanner->token == G_TOKEN_IDENTIFIER)
|
|
||||||
{
|
|
||||||
GFlagsValue *flags_value;
|
|
||||||
|
|
||||||
flags_value = g_flags_get_value_by_name (class, scanner->value.v_identifier);
|
|
||||||
if (!flags_value)
|
|
||||||
flags_value = g_flags_get_value_by_nick (class, scanner->value.v_identifier);
|
|
||||||
if (flags_value)
|
|
||||||
{
|
|
||||||
*number |= flags_value->value;
|
|
||||||
return G_TOKEN_NONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (scanner->token == G_TOKEN_INT)
|
|
||||||
{
|
|
||||||
*number |= scanner->value.v_int;
|
|
||||||
return G_TOKEN_NONE;
|
|
||||||
}
|
|
||||||
return G_TOKEN_IDENTIFIER;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gtk_rc_property_parse_flags:
|
|
||||||
* @pspec: a #GParamSpec
|
|
||||||
* @gstring: the #GString to be parsed
|
|
||||||
* @property_value: a #GValue which must hold flags values.
|
|
||||||
*
|
|
||||||
* A #GtkRcPropertyParser for use with gtk_settings_install_property_parser()
|
|
||||||
* or gtk_widget_class_install_style_property_parser() which parses flags.
|
|
||||||
*
|
|
||||||
* Flags can be specified by their name, their nickname or
|
|
||||||
* numerically. Multiple flags can be specified in the form
|
|
||||||
* `"( flag1 | flag2 | ... )"`.
|
|
||||||
*
|
|
||||||
* Returns: %TRUE if @gstring could be parsed and @property_value
|
|
||||||
* has been set to the resulting flags value.
|
|
||||||
**/
|
|
||||||
gboolean
|
|
||||||
gtk_rc_property_parse_flags (const GParamSpec *pspec,
|
|
||||||
const GString *gstring,
|
|
||||||
GValue *property_value)
|
|
||||||
{
|
|
||||||
GFlagsClass *class;
|
|
||||||
gboolean success = FALSE;
|
|
||||||
GScanner *scanner;
|
|
||||||
|
|
||||||
g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE);
|
|
||||||
g_return_val_if_fail (G_VALUE_HOLDS_FLAGS (property_value), FALSE);
|
|
||||||
|
|
||||||
class = G_PARAM_SPEC_FLAGS (pspec)->flags_class;
|
|
||||||
scanner = gtk_rc_scanner_new ();
|
|
||||||
g_scanner_input_text (scanner, gstring->str, gstring->len);
|
|
||||||
|
|
||||||
/* parse either a single flags value or a "\( ... [ \| ... ] \)" compound */
|
|
||||||
if (g_scanner_peek_next_token (scanner) == G_TOKEN_IDENTIFIER ||
|
|
||||||
scanner->next_token == G_TOKEN_INT)
|
|
||||||
{
|
|
||||||
guint token, flags_value = 0;
|
|
||||||
|
|
||||||
token = parse_flags_value (scanner, class, &flags_value);
|
|
||||||
|
|
||||||
if (token == G_TOKEN_NONE && g_scanner_peek_next_token (scanner) == G_TOKEN_EOF)
|
|
||||||
{
|
|
||||||
success = TRUE;
|
|
||||||
g_value_set_flags (property_value, flags_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (g_scanner_get_next_token (scanner) == '(')
|
|
||||||
{
|
|
||||||
guint token, flags_value = 0;
|
|
||||||
|
|
||||||
/* parse first value */
|
|
||||||
token = parse_flags_value (scanner, class, &flags_value);
|
|
||||||
|
|
||||||
/* parse nth values, preceeded by '|' */
|
|
||||||
while (token == G_TOKEN_NONE && g_scanner_get_next_token (scanner) == '|')
|
|
||||||
token = parse_flags_value (scanner, class, &flags_value);
|
|
||||||
|
|
||||||
/* done, last token must have closed expression */
|
|
||||||
if (token == G_TOKEN_NONE && scanner->token == ')' &&
|
|
||||||
g_scanner_peek_next_token (scanner) == G_TOKEN_EOF)
|
|
||||||
{
|
|
||||||
g_value_set_flags (property_value, flags_value);
|
|
||||||
success = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
g_scanner_destroy (scanner);
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
get_braced_int (GScanner *scanner,
|
|
||||||
gboolean first,
|
|
||||||
gboolean last,
|
|
||||||
gint *value)
|
|
||||||
{
|
|
||||||
if (first)
|
|
||||||
{
|
|
||||||
g_scanner_get_next_token (scanner);
|
|
||||||
if (scanner->token != '{')
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_scanner_get_next_token (scanner);
|
|
||||||
if (scanner->token != G_TOKEN_INT)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
*value = scanner->value.v_int;
|
|
||||||
|
|
||||||
if (last)
|
|
||||||
{
|
|
||||||
g_scanner_get_next_token (scanner);
|
|
||||||
if (scanner->token != '}')
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
g_scanner_get_next_token (scanner);
|
|
||||||
if (scanner->token != ',')
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gtk_rc_property_parse_requisition:
|
|
||||||
* @pspec: a #GParamSpec
|
|
||||||
* @gstring: the #GString to be parsed
|
|
||||||
* @property_value: a #GValue which must hold boxed values.
|
|
||||||
*
|
|
||||||
* A #GtkRcPropertyParser for use with gtk_settings_install_property_parser()
|
|
||||||
* or gtk_widget_class_install_style_property_parser() which parses a
|
|
||||||
* requisition in the form
|
|
||||||
* `"{ width, height }"` for integers %width and %height.
|
|
||||||
*
|
|
||||||
* Returns: %TRUE if @gstring could be parsed and @property_value
|
|
||||||
* has been set to the resulting #GtkRequisition.
|
|
||||||
**/
|
|
||||||
gboolean
|
|
||||||
gtk_rc_property_parse_requisition (const GParamSpec *pspec,
|
|
||||||
const GString *gstring,
|
|
||||||
GValue *property_value)
|
|
||||||
{
|
|
||||||
GtkRequisition requisition;
|
|
||||||
GScanner *scanner;
|
|
||||||
gboolean success = FALSE;
|
|
||||||
|
|
||||||
g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE);
|
|
||||||
g_return_val_if_fail (G_VALUE_HOLDS_BOXED (property_value), FALSE);
|
|
||||||
|
|
||||||
scanner = gtk_rc_scanner_new ();
|
|
||||||
g_scanner_input_text (scanner, gstring->str, gstring->len);
|
|
||||||
|
|
||||||
if (get_braced_int (scanner, TRUE, FALSE, &requisition.width) &&
|
|
||||||
get_braced_int (scanner, FALSE, TRUE, &requisition.height))
|
|
||||||
{
|
|
||||||
g_value_set_boxed (property_value, &requisition);
|
|
||||||
success = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_scanner_destroy (scanner);
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gtk_rc_property_parse_border:
|
|
||||||
* @pspec: a #GParamSpec
|
|
||||||
* @gstring: the #GString to be parsed
|
|
||||||
* @property_value: a #GValue which must hold boxed values.
|
|
||||||
*
|
|
||||||
* A #GtkRcPropertyParser for use with gtk_settings_install_property_parser()
|
|
||||||
* or gtk_widget_class_install_style_property_parser() which parses
|
|
||||||
* borders in the form
|
|
||||||
* `"{ left, right, top, bottom }"` for integers
|
|
||||||
* left, right, top and bottom.
|
|
||||||
*
|
|
||||||
* Returns: %TRUE if @gstring could be parsed and @property_value
|
|
||||||
* has been set to the resulting #GtkBorder.
|
|
||||||
**/
|
|
||||||
gboolean
|
|
||||||
gtk_rc_property_parse_border (const GParamSpec *pspec,
|
|
||||||
const GString *gstring,
|
|
||||||
GValue *property_value)
|
|
||||||
{
|
|
||||||
GtkBorder border;
|
|
||||||
GScanner *scanner;
|
|
||||||
gboolean success = FALSE;
|
|
||||||
int left, right, top, bottom;
|
|
||||||
|
|
||||||
g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE);
|
|
||||||
g_return_val_if_fail (G_VALUE_HOLDS_BOXED (property_value), FALSE);
|
|
||||||
|
|
||||||
scanner = gtk_rc_scanner_new ();
|
|
||||||
g_scanner_input_text (scanner, gstring->str, gstring->len);
|
|
||||||
|
|
||||||
if (get_braced_int (scanner, TRUE, FALSE, &left) &&
|
|
||||||
get_braced_int (scanner, FALSE, FALSE, &right) &&
|
|
||||||
get_braced_int (scanner, FALSE, FALSE, &top) &&
|
|
||||||
get_braced_int (scanner, FALSE, TRUE, &bottom))
|
|
||||||
{
|
|
||||||
border.left = left;
|
|
||||||
border.right = right;
|
|
||||||
border.top = top;
|
|
||||||
border.bottom = bottom;
|
|
||||||
g_value_set_boxed (property_value, &border);
|
|
||||||
success = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_scanner_destroy (scanner);
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
settings_update_double_click (GtkSettings *settings)
|
settings_update_double_click (GtkSettings *settings)
|
||||||
{
|
{
|
||||||
|
@ -73,28 +73,6 @@ GtkSettings* gtk_settings_get_default (void);
|
|||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
GtkSettings* gtk_settings_get_for_display (GdkDisplay *display);
|
GtkSettings* gtk_settings_get_for_display (GdkDisplay *display);
|
||||||
|
|
||||||
/* --- precoded parsing functions --- */
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
|
||||||
gboolean gtk_rc_property_parse_color (const GParamSpec *pspec,
|
|
||||||
const GString *gstring,
|
|
||||||
GValue *property_value);
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
|
||||||
gboolean gtk_rc_property_parse_enum (const GParamSpec *pspec,
|
|
||||||
const GString *gstring,
|
|
||||||
GValue *property_value);
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
|
||||||
gboolean gtk_rc_property_parse_flags (const GParamSpec *pspec,
|
|
||||||
const GString *gstring,
|
|
||||||
GValue *property_value);
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
|
||||||
gboolean gtk_rc_property_parse_requisition (const GParamSpec *pspec,
|
|
||||||
const GString *gstring,
|
|
||||||
GValue *property_value);
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
|
||||||
gboolean gtk_rc_property_parse_border (const GParamSpec *pspec,
|
|
||||||
const GString *gstring,
|
|
||||||
GValue *property_value);
|
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
void gtk_settings_reset_property (GtkSettings *settings,
|
void gtk_settings_reset_property (GtkSettings *settings,
|
||||||
const gchar *name);
|
const gchar *name);
|
||||||
|
Loading…
Reference in New Issue
Block a user