本文整理汇总了C++中G_TYPE_FROM_INSTANCE函数的典型用法代码示例。如果您正苦于以下问题:C++ G_TYPE_FROM_INSTANCE函数的具体用法?C++ G_TYPE_FROM_INSTANCE怎么用?C++ G_TYPE_FROM_INSTANCE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了G_TYPE_FROM_INSTANCE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gum_sanity_checker_count_leaks_by_type_name
static GHashTable *
gum_sanity_checker_count_leaks_by_type_name (GumSanityChecker * self,
GList * instances)
{
GHashTable * count_by_type;
const GumInstanceVTable * vtable;
GList * cur;
count_by_type = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL);
vtable =
gum_instance_tracker_get_current_vtable (self->priv->instance_tracker);
for (cur = instances; cur != NULL; cur = cur->next)
{
const gchar * type_name;
guint count;
type_name = vtable->type_id_to_name (G_TYPE_FROM_INSTANCE (cur->data));
count = GPOINTER_TO_UINT (g_hash_table_lookup (count_by_type,
type_name));
count++;
g_hash_table_insert (count_by_type, (gpointer) type_name,
GUINT_TO_POINTER (count));
}
return count_by_type;
}
示例2: shell_dir_info_equal
/**
* shell_dir_info_equal:
* @dirinfo1: the first #ShellDirInfo.
* @dirinfo2: the second #ShellDirInfo.
*
* Checks if two #ShellDirInfo<!-- -->s are equal.
*
* Returns: %TRUE if @dirinfo1 is equal to @dirinfo2. %FALSE otherwise.
**/
gboolean
shell_dir_info_equal (ShellDirInfo *dirinfo1,
ShellDirInfo *dirinfo2)
{
ShellDirInfoIface *iface;
g_return_val_if_fail (SHELL_IS_DIR_INFO (dirinfo1), FALSE);
g_return_val_if_fail (SHELL_IS_DIR_INFO (dirinfo2), FALSE);
if (G_TYPE_FROM_INSTANCE (dirinfo1) != G_TYPE_FROM_INSTANCE (dirinfo2))
return FALSE;
iface = SHELL_DIR_INFO_GET_IFACE (dirinfo1);
return (* iface->equal) (dirinfo1, dirinfo2);
}
示例3: file_open_convert_items
/* Converts items from one image to another */
static void
file_open_convert_items (GimpImage *dest_image,
const gchar *basename,
GList *items)
{
GList *list;
for (list = items; list; list = g_list_next (list))
{
GimpItem *src = list->data;
GimpItem *item;
item = gimp_item_convert (src, dest_image, G_TYPE_FROM_INSTANCE (src));
if (g_list_length (items) == 1)
{
gimp_object_set_name (GIMP_OBJECT (item), basename);
}
else
{
gimp_object_set_name (GIMP_OBJECT (item),
gimp_object_get_name (src));
}
list->data = item;
}
}
示例4: system_collections_value_take_dictionary_entry
#line 341 "DictionaryEntry.c"
}
}
void system_collections_value_take_dictionary_entry (GValue* value, gpointer v_object) {
SystemCollectionsDictionaryEntry* old;
#line 24 "/home/developer/projects/Backup/LibDotNet/src/System/Collections/DictionaryEntry.vala"
g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, SYSTEM_COLLECTIONS_TYPE_DICTIONARY_ENTRY));
#line 24 "/home/developer/projects/Backup/LibDotNet/src/System/Collections/DictionaryEntry.vala"
old = value->data[0].v_pointer;
#line 24 "/home/developer/projects/Backup/LibDotNet/src/System/Collections/DictionaryEntry.vala"
if (v_object) {
#line 24 "/home/developer/projects/Backup/LibDotNet/src/System/Collections/DictionaryEntry.vala"
g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, SYSTEM_COLLECTIONS_TYPE_DICTIONARY_ENTRY));
#line 24 "/home/developer/projects/Backup/LibDotNet/src/System/Collections/DictionaryEntry.vala"
g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
#line 24 "/home/developer/projects/Backup/LibDotNet/src/System/Collections/DictionaryEntry.vala"
value->data[0].v_pointer = v_object;
#line 360 "DictionaryEntry.c"
} else {
#line 24 "/home/developer/projects/Backup/LibDotNet/src/System/Collections/DictionaryEntry.vala"
value->data[0].v_pointer = NULL;
#line 364 "DictionaryEntry.c"
}
#line 24 "/home/developer/projects/Backup/LibDotNet/src/System/Collections/DictionaryEntry.vala"
if (old) {
示例5: import_dialog_drop_callback
static void
import_dialog_drop_callback (GtkWidget *widget,
gint x,
gint y,
GimpViewable *viewable,
gpointer data)
{
ImportDialog *dialog = data;
gimp_context_set_by_type (dialog->context,
G_TYPE_FROM_INSTANCE (viewable),
GIMP_OBJECT (viewable));
if (GIMP_IS_GRADIENT (viewable) &&
dialog->import_type != GRADIENT_IMPORT)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->gradient_radio),
TRUE);
}
else if (GIMP_IS_IMAGE (viewable) &&
dialog->import_type != IMAGE_IMPORT)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->image_radio),
TRUE);
}
}
示例6: on_listbox_row_changed
static void on_listbox_row_changed(GtkTreeModel* model,
GtkTreePath* path,
GtkTreeIter* iter,
PrivateListBoxData* data)
{
GtkListBoxRow* row = gtk_list_box_get_row_at_index(data->widget, gtk_tree_path_get_indices(path)[0]);
if(row)
{
GtkWidget* content = gtk_bin_get_child(GTK_BIN(row));
for(GSList* item = data->model_bindings; item != NULL; item = item->next)
{
const ModelPropertyBinding* bind = item->data;
GValue value = G_VALUE_INIT;
gtk_tree_model_get_value(GTK_TREE_MODEL(model), iter, bind->column, &value);
if(bind->widget)
{
GObject* child = gtk_widget_get_template_child(content, G_TYPE_FROM_INSTANCE(content), bind->widget);
if(child)
g_object_set_property(child, bind->prop, &value);
}
else
g_object_set_property(G_OBJECT(content), bind->prop, &value);
g_value_unset(&value);
}
}
}
示例7: polkit_backend_session_monitor_get_session_for_subject
/**
* polkit_backend_session_monitor_get_session_for_subject:
* @monitor: A #PolkitBackendSessionMonitor.
* @subject: A #PolkitSubject.
* @error: Return location for error.
*
* Gets the session corresponding to @subject or %NULL if no session exists.
*
* Returns: %NULL if @error is set otherwise a #PolkitUnixSession that should be freed with g_object_unref().
*/
PolkitSubject *
polkit_backend_session_monitor_get_session_for_subject (PolkitBackendSessionMonitor *monitor,
PolkitSubject *subject,
GError **error)
{
PolkitUnixProcess *tmp_process = NULL;
PolkitUnixProcess *process = NULL;
PolkitSubject *session = NULL;
char *session_id = NULL;
pid_t pid;
#if HAVE_SD_UID_GET_DISPLAY
uid_t uid;
#endif
if (POLKIT_IS_UNIX_PROCESS (subject))
process = POLKIT_UNIX_PROCESS (subject); /* We already have a process */
else if (POLKIT_IS_SYSTEM_BUS_NAME (subject))
{
/* Convert bus name to process */
tmp_process = (PolkitUnixProcess*)polkit_system_bus_name_get_process_sync (POLKIT_SYSTEM_BUS_NAME (subject), NULL, error);
if (!tmp_process)
goto out;
process = tmp_process;
}
else
{
g_set_error (error,
POLKIT_ERROR,
POLKIT_ERROR_NOT_SUPPORTED,
"Cannot get session for subject of type %s",
g_type_name (G_TYPE_FROM_INSTANCE (subject)));
}
/* Now do process -> pid -> same session */
g_assert (process != NULL);
pid = polkit_unix_process_get_pid (process);
if (sd_pid_get_session (pid, &session_id) >= 0)
{
session = polkit_unix_session_new (session_id);
goto out;
}
#if HAVE_SD_UID_GET_DISPLAY
/* Now do process -> uid -> graphical session (systemd version 213)*/
if (sd_pid_get_owner_uid (pid, &uid) < 0)
goto out;
if (sd_uid_get_display (uid, &session_id) >= 0)
{
session = polkit_unix_session_new (session_id);
goto out;
}
#endif
out:
free (session_id);
if (tmp_process) g_object_unref (tmp_process);
return session;
}
示例8: _do_test
static void
_do_test(AtkObject *obj)
{
const char *type_name = g_type_name(G_TYPE_FROM_INSTANCE(obj));
AtkStateSet *state_set = atk_object_ref_state_set(obj);
g_assert_cmpstr(type_name, ==, "EailLabel");
/**
* AtkText tests
*/
g_assert(ATK_IS_TEXT(obj));
g_assert(atk_state_set_contains_state(state_set, ATK_STATE_MULTI_LINE));
g_object_unref(state_set);
/* atk_text_get_text */
gchar *text = atk_text_get_text(ATK_TEXT(obj), 6, 11);
g_assert_cmpstr(text, ==, "ipsum");
g_free(text);
/* atk_text_get_character_at_offset */
g_assert(atk_text_get_character_at_offset(ATK_TEXT(obj), 12) == 'd');
/* atk_text_get_character_count */
g_assert(atk_text_get_character_count(ATK_TEXT(obj)) == 440);
}
示例9: edited_callback
static void
edited_callback (GtkCellRendererText *renderer,
const gchar *path_string,
const gchar *new_text,
GtkTreeView *tree_view)
{
GtkTreeModel *model = NULL;
GtkTreeModelSort *sort_model = NULL;
GtkTreePath *path;
GtkTreeIter iter;
guint value = atoi (new_text);
g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));
model = gtk_tree_view_get_model (tree_view);
if (GTK_IS_TREE_MODEL_SORT (model))
{
sort_model = GTK_TREE_MODEL_SORT (model);
model = gtk_tree_model_sort_get_model (sort_model);
}
if (model == NULL)
return;
if (sort_model)
{
g_warning ("FIXME implement conversion from TreeModelSort iter to child model iter");
return;
}
path = gtk_tree_path_new_from_string (path_string);
if (!gtk_tree_model_get_iter (model,
&iter, path))
{
g_warning ("%s: bad path?", G_STRLOC);
return;
}
gtk_tree_path_free (path);
if (GTK_IS_LIST_STORE (model))
{
gtk_list_store_set (GTK_LIST_STORE (model),
&iter,
4,
value,
-1);
}
else if (GTK_IS_TREE_STORE (model))
{
gtk_tree_store_set (GTK_TREE_STORE (model),
&iter,
4,
value,
-1);
}
else
g_warning ("don't know how to actually toggle value for model type %s",
g_type_name (G_TYPE_FROM_INSTANCE (model)));
}
示例10: gimp_view_new_full
GtkWidget *
gimp_view_new_full (GimpContext *context,
GimpViewable *viewable,
gint width,
gint height,
gint border_width,
gboolean is_popup,
gboolean clickable,
gboolean show_popup)
{
GtkWidget *view;
g_return_val_if_fail (context == NULL || GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
view = gimp_view_new_full_by_types (context,
GIMP_TYPE_VIEW,
G_TYPE_FROM_INSTANCE (viewable),
width, height, border_width,
is_popup, clickable, show_popup);
if (view)
gimp_view_set_viewable (GIMP_VIEW (view), viewable);
gimp_view_renderer_remove_idle (GIMP_VIEW (view)->renderer);
return view;
}
示例11: gom_resource_build_save_cmd
void
gom_resource_build_save_cmd (GomResource *resource,
GomAdapter *adapter)
{
GomCommandBuilder *builder;
gboolean has_pkey, is_insert;
GSList *types = NULL;
GSList *iter;
GType resource_type;
GList *cmds = NULL;
resource_type = G_TYPE_FROM_INSTANCE(resource);
g_assert(g_type_is_a(resource_type, GOM_TYPE_RESOURCE));
builder = g_object_new(GOM_TYPE_COMMAND_BUILDER,
"adapter", adapter,
NULL);
has_pkey = has_primary_key(resource);
if (has_pkey) {
/* Could be an insert for a non-automatic primary key,
* or an update */
is_insert = !resource->priv->is_from_table;
} else {
is_insert = TRUE;
}
g_object_set_data (G_OBJECT (resource), "is-insert", GINT_TO_POINTER (is_insert));
do {
types = g_slist_prepend(types, GINT_TO_POINTER(resource_type));
} while ((resource_type = g_type_parent(resource_type)) != GOM_TYPE_RESOURCE);
for (iter = types; iter; iter = iter->next) {
GomCommand *command;
resource_type = GPOINTER_TO_INT(iter->data);
g_object_set(builder,
"resource-type", resource_type,
NULL);
if (is_insert) {
command = gom_command_builder_build_insert(builder, resource);
} else {
command = gom_command_builder_build_update(builder, resource);
}
if (is_insert && gom_resource_has_dynamic_pkey(resource_type))
is_insert = FALSE;
cmds = g_list_prepend (cmds, command);
}
cmds = g_list_reverse (cmds);
g_object_set_data_full (G_OBJECT(resource), "save-commands", cmds, free_save_cmds);
g_slist_free(types);
g_object_unref (builder);
}
示例12: gom_resource_do_delete
static gboolean
gom_resource_do_delete (GomResource *resource,
GomAdapter *adapter,
GError **error)
{
GomCommandBuilder *builder;
GType resource_type;
g_return_val_if_fail(GOM_IS_RESOURCE(resource), FALSE);
g_return_val_if_fail(GOM_IS_ADAPTER(adapter), FALSE);
resource_type = G_TYPE_FROM_INSTANCE(resource);
builder = g_object_new(GOM_TYPE_COMMAND_BUILDER,
"adapter", adapter,
NULL);
do {
GomResourceClass *klass;
GParamSpec *pspec;
GomCommand *command;
GomFilter *filter;
GArray *values;
GValue value = { 0 };
gchar *sql;
klass = g_type_class_peek(resource_type);
g_assert(GOM_IS_RESOURCE_CLASS(klass));
pspec = g_object_class_find_property(G_OBJECT_CLASS(klass),
klass->primary_key);
g_assert(pspec);
g_value_init(&value, pspec->value_type);
g_object_get_property(G_OBJECT(resource), klass->primary_key, &value);
sql = g_strdup_printf("'%s'.'%s' = ?", klass->table, klass->primary_key);
values = g_array_sized_new(FALSE, FALSE, sizeof(GValue), 1);
g_array_append_val(values, value);
filter = gom_filter_new_sql(sql, values);
g_free(sql);
memset(&value, 0, sizeof value);
g_array_unref(values);
g_object_set(builder,
"filter", filter,
"resource-type", resource_type,
NULL);
g_object_unref(filter);
command = gom_command_builder_build_delete(builder);
if (!gom_command_execute(command, NULL, error)) {
g_object_unref(command);
g_object_unref(builder);
return FALSE;
}
g_object_unref(command);
} while ((resource_type = g_type_parent(resource_type)) != GOM_TYPE_RESOURCE);
g_object_unref(builder);
return TRUE;
}
示例13: ppg_instrument_set_session
static void
ppg_instrument_set_session (PpgInstrument *instrument,
PpgSession *session)
{
PpgInstrumentClass *klass;
PpgInstrumentPrivate *priv;
GError *error = NULL;
g_return_if_fail(PPG_IS_INSTRUMENT(instrument));
g_return_if_fail(PPG_IS_SESSION(session));
priv = instrument->priv;
klass = PPG_INSTRUMENT_GET_CLASS(instrument);
priv->session = session;
g_object_add_weak_pointer(G_OBJECT(priv->session), (gpointer *)&priv->session);
if (klass->load) {
if (!klass->load(instrument, session, &error)) {
priv->failed = TRUE;
g_critical("Failed to load instrument %s: %s",
g_type_name(G_TYPE_FROM_INSTANCE(instrument)),
error->message);
/*
* XXX: Should we store the error?
*/
g_error_free(error);
return;
}
}
}
示例14: fo_object_sprintf
/**
* fo_object_sprintf:
* @object: The #FoObject object.
*
* Calls sprintf method of class of @object, if @object is an
* #FoObject or descendant type of #FoObject.
*
* Return value: Result of sprintf method of class of @object.
**/
gchar*
fo_object_sprintf (gpointer object)
{
if (object == NULL)
{
return g_strdup ("(null)");
}
else if (!G_IS_OBJECT (object))
{
return g_strdup_printf ("Not a GObject: %p",
object);
}
else if (!FO_IS_OBJECT (object))
{
return g_strdup_printf ("GObject but not an FoObject:: %s (%p : %d%s)",
g_type_name (G_TYPE_FROM_INSTANCE (object)),
object,
((GObject *) object)->ref_count,
g_object_is_floating (object) ? " (floating)" : "");
}
else
{
return FO_OBJECT_GET_CLASS (object)->print_sprintf (object);
}
}
示例15: fo_property_space_start_minimum_validate
/**
* fo_property_space_start_minimum_validate:
* @datatype: #FoDatatype to be validated against allowed datatypes and
* values for current property.
* @context: #FoContext object from which to possibly inherit values.
* @error: Information about any error that has occurred.
*
* Validates @datatype against allowed values. Returns @datatype, a
* replacement datatype value, or NULL if validation failed.
*
* Return value: Valid datatype value or NULL.
**/
FoDatatype*
fo_property_space_start_minimum_validate (FoDatatype *datatype,
FoContext *context,
GError **error)
{
g_return_val_if_fail (datatype != NULL, NULL);
g_return_val_if_fail (FO_IS_DATATYPE (datatype), NULL);
g_return_val_if_fail (context != NULL, NULL);
g_return_val_if_fail (FO_IS_CONTEXT (context), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
if (FO_IS_LENGTH (datatype))
{
return datatype;
}
else
{
gchar *datatype_sprintf = fo_object_sprintf (datatype);
g_set_error (error,
FO_FO_ERROR,
FO_FO_ERROR_DATATYPE,
_(fo_fo_error_messages[FO_FO_ERROR_DATATYPE]),
class_name,
datatype_sprintf,
g_type_name (G_TYPE_FROM_INSTANCE (datatype)));
g_object_unref (datatype);
g_free (datatype_sprintf);
return NULL;
}
}