* 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;
{
/* 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, '_');
{
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 ();
/* 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;
{
/* 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, '_');
}
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[])
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 ();
}