mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-15 21:20:09 +00:00
Merge branch 'matthiasc/for-master' into 'master'
some builder-tool improvements See merge request GNOME/gtk!1248
This commit is contained in:
commit
78227bf5b0
@ -187,12 +187,14 @@ gtk_builder_cscope_get_module (GtkBuilderCScope *self)
|
||||
* GtkWindow -> gtk_window_get_type
|
||||
* GtkHBox -> gtk_hbox_get_type
|
||||
* GtkUIManager -> gtk_ui_manager_get_type
|
||||
* GWeatherLocation -> gweather_location_get_type
|
||||
* GWeatherLocation -> gweather_location_get_type (split_first_cap == FALSE)
|
||||
* GThemedIcon -> g_themed_icon_get_type (slit_first_cap == TRUE)
|
||||
*
|
||||
* Keep in sync with testsuite/gtk/typename.c !
|
||||
*/
|
||||
static gchar *
|
||||
type_name_mangle (const gchar *name)
|
||||
type_name_mangle (const gchar *name,
|
||||
gboolean split_first_cap)
|
||||
{
|
||||
GString *symbol_name = g_string_new ("");
|
||||
gint i;
|
||||
@ -201,8 +203,9 @@ type_name_mangle (const gchar *name)
|
||||
{
|
||||
/* skip if uppercase, first or previous is uppercase */
|
||||
if ((name[i] == g_ascii_toupper (name[i]) &&
|
||||
i > 0 && name[i-1] != g_ascii_toupper (name[i-1])) ||
|
||||
(i > 2 && name[i] == g_ascii_toupper (name[i]) &&
|
||||
((i > 0 && name[i-1] != g_ascii_toupper (name[i-1])) ||
|
||||
(i == 1 && name[0] == g_ascii_toupper (name[0]) && split_first_cap))) ||
|
||||
(i > 2 && name[i] == g_ascii_toupper (name[i]) &&
|
||||
name[i-1] == g_ascii_toupper (name[i-1]) &&
|
||||
name[i-2] == g_ascii_toupper (name[i-2])))
|
||||
g_string_append_c (symbol_name, '_');
|
||||
@ -219,14 +222,21 @@ gtk_builder_cscope_resolve_type_lazily (GtkBuilderCScope *self,
|
||||
{
|
||||
GModule *module;
|
||||
GType (*func) (void);
|
||||
gchar *symbol;
|
||||
char *symbol;
|
||||
GType gtype = G_TYPE_INVALID;
|
||||
|
||||
module = gtk_builder_cscope_get_module (self);
|
||||
if (!module)
|
||||
return G_TYPE_INVALID;
|
||||
|
||||
symbol = type_name_mangle (name);
|
||||
symbol = type_name_mangle (name, TRUE);
|
||||
|
||||
if (g_module_symbol (module, symbol, (gpointer)&func))
|
||||
gtype = func ();
|
||||
|
||||
g_free (symbol);
|
||||
|
||||
symbol = type_name_mangle (name, FALSE);
|
||||
|
||||
if (g_module_symbol (module, symbol, (gpointer)&func))
|
||||
gtype = func ();
|
||||
|
@ -35,6 +35,9 @@ struct Element {
|
||||
char **attribute_values;
|
||||
char *data;
|
||||
GList *children;
|
||||
|
||||
int line_number;
|
||||
int char_number;
|
||||
};
|
||||
|
||||
static void
|
||||
@ -77,6 +80,8 @@ start_element (GMarkupParseContext *context,
|
||||
elt->attribute_names = g_strdupv ((char **)attribute_names);
|
||||
elt->attribute_values = g_strdupv ((char **)attribute_values);
|
||||
|
||||
g_markup_parse_context_get_position (context, &elt->line_number, &elt->char_number);
|
||||
|
||||
if (data->current)
|
||||
data->current->children = g_list_append (data->current->children, elt);
|
||||
data->current = elt;
|
||||
@ -444,9 +449,12 @@ value_is_default (Element *element,
|
||||
if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (pspec), G_TYPE_OBJECT))
|
||||
return FALSE;
|
||||
|
||||
if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (pspec), G_TYPE_BOXED))
|
||||
return FALSE;
|
||||
|
||||
if (!gtk_builder_value_from_string (data->builder, pspec, value_string, &value, &error))
|
||||
{
|
||||
g_printerr (_("%s: Couldn’t parse value for %s: %s\n"), data->input_filename, pspec->name, error->message);
|
||||
g_printerr (_("%s:%d: Couldn’t parse value for property '%s': %s\n"), data->input_filename, element->line_number, pspec->name, error->message);
|
||||
g_error_free (error);
|
||||
ret = FALSE;
|
||||
}
|
||||
@ -639,8 +647,8 @@ property_can_be_omitted (Element *element,
|
||||
"Layout "
|
||||
};
|
||||
|
||||
g_printerr (_("%s: %sproperty %s::%s not found\n"),
|
||||
data->input_filename, kind_str[kind], class_name, property_name);
|
||||
g_printerr (_("%s:%d: %sproperty %s::%s not found\n"),
|
||||
data->input_filename, element->line_number, kind_str[kind], class_name, property_name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,8 @@
|
||||
|
||||
/* Keep in sync with gtkbuilder.c ! */
|
||||
static gchar *
|
||||
type_name_mangle (const gchar *name)
|
||||
type_name_mangle (const gchar *name,
|
||||
gboolean split_first_cap)
|
||||
{
|
||||
GString *symbol_name = g_string_new ("");
|
||||
gint i;
|
||||
@ -29,8 +30,9 @@ type_name_mangle (const gchar *name)
|
||||
{
|
||||
/* skip if uppercase, first or previous is uppercase */
|
||||
if ((name[i] == g_ascii_toupper (name[i]) &&
|
||||
i > 0 && name[i-1] != g_ascii_toupper (name[i-1])) ||
|
||||
(i > 2 && name[i] == g_ascii_toupper (name[i]) &&
|
||||
((i > 0 && name[i-1] != g_ascii_toupper (name[i-1])) ||
|
||||
(i == 1 && name[0] == g_ascii_toupper (name[0]) && split_first_cap))) ||
|
||||
(i > 2 && name[i] == g_ascii_toupper (name[i]) &&
|
||||
name[i-1] == g_ascii_toupper (name[i-1]) &&
|
||||
name[i-2] == g_ascii_toupper (name[i-2])))
|
||||
g_string_append_c (symbol_name, '_');
|
||||
@ -42,22 +44,27 @@ type_name_mangle (const gchar *name)
|
||||
}
|
||||
|
||||
static void
|
||||
check (const gchar *TN, const gchar *gtf)
|
||||
check (const gchar *TN, const gchar *gtf, const char *gtf_splitcap)
|
||||
{
|
||||
gchar *symbol;
|
||||
|
||||
symbol = type_name_mangle (TN);
|
||||
symbol = type_name_mangle (TN, FALSE);
|
||||
g_assert_cmpstr (symbol, ==, gtf);
|
||||
g_free (symbol);
|
||||
|
||||
symbol = type_name_mangle (TN, TRUE);
|
||||
g_assert_cmpstr (symbol, ==, gtf_splitcap ? gtf_splitcap : gtf);
|
||||
g_free (symbol);
|
||||
}
|
||||
|
||||
static void test_GtkWindow (void) { check ("GtkWindow", "gtk_window_get_type"); }
|
||||
static void test_GtkHBox (void) { check ("GtkHBox", "gtk_hbox_get_type"); }
|
||||
static void test_GtkUIManager (void) { check ("GtkUIManager", "gtk_ui_manager_get_type"); }
|
||||
static void test_GtkCList (void) { check ("GtkCList", "gtk_clist_get_type"); }
|
||||
static void test_GtkIMContext (void) { check ("GtkIMContext", "gtk_im_context_get_type"); }
|
||||
static void test_Me2Shell (void) { check ("Me2Shell", "me_2shell_get_type"); }
|
||||
static void test_GWeather (void) { check ("GWeatherLocation", "gweather_location_get_type"); }
|
||||
static void test_GtkWindow (void) { check ("GtkWindow", "gtk_window_get_type", NULL); }
|
||||
static void test_GtkHBox (void) { check ("GtkHBox", "gtk_hbox_get_type", NULL); }
|
||||
static void test_GtkUIManager (void) { check ("GtkUIManager", "gtk_ui_manager_get_type", NULL); }
|
||||
static void test_GtkCList (void) { check ("GtkCList", "gtk_clist_get_type", NULL); }
|
||||
static void test_GtkIMContext (void) { check ("GtkIMContext", "gtk_im_context_get_type", NULL); }
|
||||
static void test_Me2Shell (void) { check ("Me2Shell", "me_2shell_get_type", NULL); }
|
||||
static void test_GWeather (void) { check ("GWeatherLocation", "gweather_location_get_type", "g_weather_location_get_type"); }
|
||||
static void test_GThemedIcon (void) { check ("GThemedIcon", "gthemed_icon_get_type", "g_themed_icon_get_type"); }
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
@ -71,6 +78,7 @@ main (int argc, char *argv[])
|
||||
g_test_add_func ("/builder/get-type/GtkIMContext", test_GtkIMContext);
|
||||
g_test_add_func ("/builder/get-type/Me2Shell", test_Me2Shell);
|
||||
g_test_add_func ("/builder/get-type/GWeather", test_GWeather);
|
||||
g_test_add_func ("/builder/get-type/GThemedIcon", test_GThemedIcon);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user