void GstEnginePipeline::SourceSetupCallback(GstURIDecodeBin* bin, GParamSpec* pspec, gpointer self) { GstEnginePipeline* instance = reinterpret_cast<GstEnginePipeline*>(self); GstElement* element; g_object_get(bin, "source", &element, nullptr); if (!element) { return; } if (g_object_class_find_property(G_OBJECT_GET_CLASS(element), "device") && !instance->source_device().isEmpty()) { // Gstreamer is not able to handle device in URL (refering to Gstreamer // documentation, this might be added in the future). Despite that, for now // we include device inside URL: we decompose it during Init and set device // here, when this callback is called. g_object_set(element, "device", instance->source_device().toLocal8Bit().constData(), nullptr); } if (g_object_class_find_property(G_OBJECT_GET_CLASS(element), "extra-headers") && instance->url().host().contains("amazonaws.com")) { GstStructure* headers = gst_structure_new("extra-headers", "Authorization", G_TYPE_STRING, instance->url().fragment().toAscii().data(), nullptr); g_object_set(element, "extra-headers", headers, nullptr); gst_structure_free(headers); } if (g_object_class_find_property(G_OBJECT_GET_CLASS(element), "user-agent")) { QString user_agent = QString("%1 %2").arg(QCoreApplication::applicationName(), QCoreApplication::applicationVersion()); g_object_set(element, "user-agent", user_agent.toUtf8().constData(), nullptr); #ifdef Q_OS_DARWIN g_object_set(element, "tls-database", instance->engine_->tls_database(), nullptr); g_object_set(element, "ssl-use-system-ca-file", false, nullptr); g_object_set(element, "ssl-strict", TRUE, nullptr); #endif } }
static void g_binding_constructed (GObject *gobject) { GBinding *binding = G_BINDING (gobject); /* assert that we were constructed correctly */ g_assert (binding->source != NULL); g_assert (binding->target != NULL); g_assert (binding->source_property != NULL); g_assert (binding->target_property != NULL); /* we assume a check was performed prior to construction - since * g_object_bind_property_full() does it; we cannot fail construction * anyway, so it would be hard for use to properly warn here */ binding->source_pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (binding->source), binding->source_property); binding->target_pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (binding->target), binding->target_property); g_assert (binding->source_pspec != NULL); g_assert (binding->target_pspec != NULL); /* set the default transformation functions here */ binding->transform_s2t = default_transform_to; binding->transform_t2s = default_transform_from; binding->transform_data = NULL; binding->notify = NULL; binding->source_notify = g_signal_connect (binding->source, "notify", G_CALLBACK (on_source_notify), binding); g_object_weak_ref (binding->source, weak_unbind, binding); add_binding_qdata (binding->source, binding); if (binding->flags & G_BINDING_BIDIRECTIONAL) binding->target_notify = g_signal_connect (binding->target, "notify", G_CALLBACK (on_target_notify), binding); g_object_weak_ref (binding->target, weak_unbind, binding); add_binding_qdata (binding->target, binding); }
static void property_override_default_guint_value (GObjectClass *oclass, const gchar *property_name, guint new_default) { GParamSpecUInt *pspec = G_PARAM_SPEC_UINT (g_object_class_find_property (oclass, property_name)); if (pspec != NULL) pspec->default_value = new_default; else g_warning ("pspec for %s not found\n", property_name); }
/** * seahorse_object_lookup_property: * @self: the object to look up the property * @field: the field to lookup * @value: the returned value * * Looks up the property @field in the object @self and returns it in @value * * Returns: TRUE if a property was found */ gboolean seahorse_object_lookup_property (SeahorseObject *self, const gchar *field, GValue *value) { GParamSpec *spec; g_return_val_if_fail (SEAHORSE_IS_OBJECT (self), FALSE); g_return_val_if_fail (field, FALSE); g_return_val_if_fail (value, FALSE); spec = g_object_class_find_property (G_OBJECT_GET_CLASS (self), field); if (!spec) { /* Some name mapping to new style names */ if (g_str_equal (field, "simple-name")) field = "nickname"; else if (g_str_equal (field, "key-id")) field = "identifier"; else if (g_str_equal (field, "display-name")) field = "label"; else if (g_str_equal (field, "key-desc")) field = "description"; else if (g_str_equal (field, "ktype")) field = "tag"; else if (g_str_equal (field, "etype")) field = "usage"; else if (g_str_equal (field, "display-id")) field = "identifier"; else if (g_str_equal (field, "stock-id")) field = "icon"; else if (g_str_equal (field, "raw-id")) field = "identifier"; else return FALSE; /* Try again */ spec = g_object_class_find_property (G_OBJECT_GET_CLASS (self), field); if (!spec) return FALSE; } g_value_init (value, spec->value_type); g_object_get_property (G_OBJECT (self), field, value); return TRUE; }
/** * gst_child_proxy_lookup: * @childproxy: child proxy object to lookup the property in * @name: name of the property to look up * @target: (out) (allow-none) (transfer full): pointer to a #GObject that * takes the real object to set property on * @pspec: (out) (allow-none) (transfer none): pointer to take the #GParamSpec * describing the property * * Looks up which object and #GParamSpec would be effected by the given @name. * * MT safe. * * Returns: TRUE if @target and @pspec could be found. FALSE otherwise. In that * case the values for @pspec and @target are not modified. Unref @target after * usage. For plain GObjects @target is the same as @object. */ gboolean gst_child_proxy_lookup (GstChildProxy * childproxy, const gchar * name, GObject ** target, GParamSpec ** pspec) { GObject *object; gboolean res = FALSE; gchar **names, **current; g_return_val_if_fail (GST_IS_CHILD_PROXY (childproxy), FALSE); g_return_val_if_fail (name != NULL, FALSE); object = g_object_ref (childproxy); current = names = g_strsplit (name, "::", -1); /* find the owner of the property */ while (current[1]) { GObject *next; if (!GST_IS_CHILD_PROXY (object)) { GST_INFO ("object %s is not a parent, so you cannot request a child by name %s", (GST_IS_OBJECT (object) ? GST_OBJECT_NAME (object) : ""), current[0]); break; } next = gst_child_proxy_get_child_by_name (GST_CHILD_PROXY (object), current[0]); if (!next) { GST_INFO ("no such object %s", current[0]); break; } g_object_unref (object); object = next; current++; } /* look for psec */ if (current[1] == NULL) { GParamSpec *spec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), current[0]); if (spec == NULL) { GST_INFO ("no param spec named %s", current[0]); } else { if (pspec) *pspec = spec; if (target) { g_object_ref (object); *target = object; } res = TRUE; } } g_object_unref (object); g_strfreev (names); return res; }
static void gimp_gegl_tool_map (GimpImageMapTool *image_map_tool) { GimpGeglTool *tool = GIMP_GEGL_TOOL (image_map_tool); GParamSpec **pspecs; guint n_pspecs; gint i; if (! tool->config) return; pspecs = gegl_list_properties (tool->operation, &n_pspecs); for (i = 0; i < n_pspecs; i++) { GParamSpec *gegl_pspec = pspecs[i]; GParamSpec *gimp_pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (tool->config), gegl_pspec->name); if (gimp_pspec) { GValue value = { 0, }; g_value_init (&value, gimp_pspec->value_type); g_object_get_property (G_OBJECT (tool->config), gimp_pspec->name, &value); if (GIMP_IS_PARAM_SPEC_RGB (gimp_pspec)) { GeglColor *gegl_color = gegl_color_new (NULL); GimpRGB gimp_color; gimp_value_get_rgb (&value, &gimp_color); g_value_unset (&value); gegl_color_set_rgba (gegl_color, gimp_color.r, gimp_color.g, gimp_color.b, gimp_color.a); g_value_init (&value, gegl_pspec->value_type); g_value_take_object (&value, gegl_color); } gegl_node_set_property (image_map_tool->operation, gegl_pspec->name, &value); g_value_unset (&value); } } g_free (pspecs); }
static void update_stream_info (GthMediaViewerPage *self) { GList *streaminfo; GstPad *videopad; streaminfo = NULL; videopad = NULL; g_object_get (self->priv->playbin, "stream-info", &streaminfo, NULL); streaminfo = g_list_copy (streaminfo); g_list_foreach (streaminfo, (GFunc) g_object_ref, NULL); for (/* void */ ; streaminfo; streaminfo = streaminfo->next) { GObject *info; int type; GParamSpec *pspec; GEnumValue *val; info = streaminfo->data; if (info == NULL) continue; type = -1; g_object_get (info, "type", &type, NULL); pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (info), "type"); val = g_enum_get_value (G_PARAM_SPEC_ENUM (pspec)->enum_class, type); if (strcmp (val->value_nick, "audio") == 0) { self->priv->has_audio = TRUE; } else if (strcmp (val->value_nick, "video") == 0) { self->priv->has_video = TRUE; if (videopad == NULL) g_object_get (info, "object", &videopad, NULL); } } if (videopad != NULL) { GstCaps *caps; if ((caps = gst_pad_get_negotiated_caps (videopad)) != NULL) { GstStructure *structure; structure = gst_caps_get_structure (caps, 0); gst_structure_get_fraction (structure, "framerate", &self->priv->video_fps_n, &self->priv->video_fps_d); gst_caps_unref (caps); } } g_list_foreach (streaminfo, (GFunc) g_object_unref, NULL); g_list_free (streaminfo); }
void LayoutTestController::overridePreference(JSStringRef key, JSStringRef value) { GOwnPtr<gchar> originalName(JSStringCopyUTF8CString(key)); GOwnPtr<gchar> valueAsString(JSStringCopyUTF8CString(value)); WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame); ASSERT(view); // This transformation could be handled by a hash table (and it once was), but // having it prominent, makes it easier for people from other ports to keep the // list up to date. const gchar* propertyName = 0; if (g_str_equal(originalName.get(), "WebKitJavaScriptEnabled")) propertyName = "enable-scripts"; else if (g_str_equal(originalName.get(), "WebKitDefaultFontSize")) propertyName = "default-font-size"; else if (g_str_equal(originalName.get(), "WebKitEnableCaretBrowsing")) propertyName = "enable-caret-browsing"; else if (g_str_equal(originalName.get(), "WebKitUsesPageCachePreferenceKey")) propertyName = "enable-page-cache"; else if (g_str_equal(originalName.get(), "WebKitPluginsEnabled")) propertyName = "enable-plugins"; else if (g_str_equal(originalName.get(), "WebKitHyperlinkAuditingEnabled")) propertyName = "enable-hyperlink-auditing"; else if (g_str_equal(originalName.get(), "WebKitWebGLEnabled")) propertyName = "enable-webgl"; else if (g_str_equal(originalName.get(), "WebKitTabToLinksPreferenceKey")) { DumpRenderTreeSupportGtk::setLinksIncludedInFocusChain(!g_ascii_strcasecmp(valueAsString.get(), "true") || !g_ascii_strcasecmp(valueAsString.get(), "1")); return; } else { fprintf(stderr, "LayoutTestController::overridePreference tried to override " "unknown preference '%s'.\n", originalName.get()); return; } WebKitWebSettings* settings = webkit_web_view_get_settings(view); GParamSpec* pspec = g_object_class_find_property(G_OBJECT_CLASS( WEBKIT_WEB_SETTINGS_GET_CLASS(settings)), propertyName); GValue currentPropertyValue = { 0, { { 0 } } }; g_value_init(¤tPropertyValue, pspec->value_type); if (G_VALUE_HOLDS_STRING(¤tPropertyValue)) g_object_set(settings, propertyName, valueAsString.get(), NULL); else if (G_VALUE_HOLDS_BOOLEAN(¤tPropertyValue)) g_object_set(G_OBJECT(settings), propertyName, !g_ascii_strcasecmp(valueAsString.get(), "true") || !g_ascii_strcasecmp(valueAsString.get(), "1"), NULL); else if (G_VALUE_HOLDS_INT(¤tPropertyValue)) g_object_set(G_OBJECT(settings), propertyName, atoi(valueAsString.get()), NULL); else if (G_VALUE_HOLDS_FLOAT(¤tPropertyValue)) { gfloat newValue = g_ascii_strtod(valueAsString.get(), 0); g_object_set(G_OBJECT(settings), propertyName, newValue, NULL); } else fprintf(stderr, "LayoutTestController::overridePreference failed to override " "preference '%s'.\n", originalName.get()); }
bool GstUtils::apply_property_value(GObject *g_object_master, GObject *g_object_slave, const char *property_name) { if (g_object_master == nullptr || g_object_slave == nullptr) return false; if (!G_IS_OBJECT(g_object_master) || !G_IS_OBJECT(g_object_slave)) return false; GParamSpec *pspec_master = g_object_class_find_property(G_OBJECT_CLASS (G_OBJECT_GET_CLASS(g_object_master)), property_name); if (pspec_master == nullptr) { g_debug("property %s not found for master ", property_name); return false; } GParamSpec *pspec_slave = g_object_class_find_property(G_OBJECT_CLASS (G_OBJECT_GET_CLASS(g_object_slave)), property_name); if (pspec_slave == nullptr) { g_debug("property %s, not found for slave", property_name); return false; } if (pspec_master->value_type != pspec_slave->value_type) { g_debug("master and slave properties has different type, canont apply"); return false; } GValue val = G_VALUE_INIT; g_value_init(&val, pspec_master->value_type); g_object_get_property(g_object_master, property_name, &val); g_object_set_property(g_object_slave, property_name, &val); g_value_unset(&val); return true; }
static void terminal_profile_init (TerminalProfile *profile) { TerminalProfilePrivate *priv; GObjectClass *object_class; GParamSpec **pspecs; guint n_pspecs, i; priv = profile->priv = G_TYPE_INSTANCE_GET_PRIVATE (profile, TERMINAL_TYPE_PROFILE, TerminalProfilePrivate); priv->gsettings_notification_pspec = NULL; priv->locked = g_new0 (gboolean, LAST_PROP); priv->properties = g_value_array_new (LAST_PROP); for (i = 0; i < LAST_PROP; ++i) g_value_array_append (priv->properties, NULL); pspecs = g_object_class_list_properties (G_OBJECT_CLASS (TERMINAL_PROFILE_GET_CLASS (profile)), &n_pspecs); for (i = 0; i < n_pspecs; ++i) { GParamSpec *pspec = pspecs[i]; GValue *value; if (pspec->owner_type != TERMINAL_TYPE_PROFILE) continue; g_assert (pspec->param_id < LAST_PROP); value = g_value_array_get_nth (priv->properties, pspec->param_id); g_value_init (value, pspec->value_type); g_param_value_set_default (pspec, value); } g_free (pspecs); /* A few properties don't have defaults via the param spec; set them explicitly */ object_class = G_OBJECT_CLASS (TERMINAL_PROFILE_GET_CLASS (profile)); terminal_profile_reset_property_internal (profile, g_object_class_find_property (object_class, TERMINAL_PROFILE_FOREGROUND_COLOR), FALSE); terminal_profile_reset_property_internal (profile, g_object_class_find_property (object_class, TERMINAL_PROFILE_BOLD_COLOR), FALSE); terminal_profile_reset_property_internal (profile, g_object_class_find_property (object_class, TERMINAL_PROFILE_BACKGROUND_COLOR), FALSE); terminal_profile_reset_property_internal (profile, g_object_class_find_property (object_class, TERMINAL_PROFILE_FONT), FALSE); terminal_profile_reset_property_internal (profile, g_object_class_find_property (object_class, TERMINAL_PROFILE_PALETTE), FALSE); }
static gchar * gst_ladspa_class_get_param_name (GstLADSPAClass * klass, gint portnum) { LADSPA_Descriptor *desc; gchar *ret, *paren; desc = klass->descriptor; ret = g_strdup (desc->PortNames[portnum]); paren = g_strrstr (ret, " ("); if (paren != NULL) *paren = '\0'; /* this is the same thing that param_spec_* will do */ g_strcanon (ret, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-'); /* satisfy glib2 (argname[0] must be [A-Za-z]) */ if (!((ret[0] >= 'a' && ret[0] <= 'z') || (ret[0] >= 'A' && ret[0] <= 'Z'))) { gchar *tempstr = ret; ret = g_strconcat ("param-", ret, NULL); g_free (tempstr); } /* check for duplicate property names */ if (g_object_class_find_property (G_OBJECT_CLASS (klass), ret)) { gint n = 1; gchar *nret = g_strdup_printf ("%s-%d", ret, n++); while (g_object_class_find_property (G_OBJECT_CLASS (klass), nret)) { g_free (nret); nret = g_strdup_printf ("%s-%d", ret, n++); } g_free (ret); ret = nret; } GST_DEBUG ("built property name '%s' from port name '%s'", ret, desc->PortNames[portnum]); return ret; }
static const gchar * lookup_method_action_and_details (gpointer instance, InvocationClient *client, uid_t uid, const GDBusMethodInfo *method, PolkitDetails **details) { GObjectClass *object_class; const gchar *message; /* Exception: The Job interface is not marked up like all our others */ if (UDISKS_IS_JOB (instance) && g_str_equal (method->name, "Cancel")) { *details = polkit_details_new (); polkit_details_insert (*details, "polkit.message", N_("Authentication is required to cancel a job")); /* This is a thread-safe call */ if (uid != udisks_job_get_started_by_uid (instance)) return "org.freedesktop.udisks2.cancel-job-other-user"; else return "org.freedesktop.udisks2.cancel-job"; } *details = NULL; object_class = G_OBJECT_GET_CLASS (instance); if (g_object_class_find_property (object_class, "polkit-details") != NULL) { ObjectGetDetails ogd = { instance, NULL }; g_main_context_invoke (NULL, object_get_polkit_details, &details); g_mutex_lock (&inv.mutex); while (ogd.details == NULL) g_cond_wait (&inv.wait_cond, &inv.mutex); g_mutex_unlock (&inv.mutex); *details = ogd.details; } if (!*details || polkit_details_lookup (*details, "polkit.message")) { message = g_dbus_annotation_info_lookup (method->annotations, "polkit.message"); if (message) { if (!*details) *details = polkit_details_new (); polkit_details_insert (*details, "polkit.message", message); } } return g_dbus_annotation_info_lookup (method->annotations, "polkit.action_id"); }
/** * Sets the string value of a GstElement's property * * @return false if the value could not be set. */ bool GstHelper::setProperty(GstElement *elem, const char *propertyName, const QByteArray &propertyValue) { Q_ASSERT(elem); Q_ASSERT(propertyName && strlen(propertyName)); if (g_object_class_find_property(G_OBJECT_GET_CLASS(elem), propertyName)) { g_object_set(G_OBJECT(elem), propertyName, propertyValue.constData(), NULL); return true; } return false; }
void _owr_session_emit_ice_state_changed(OwrSession *session, guint session_id, OwrComponentType component_type, OwrIceState state) { OwrIceState old_state, new_state; gchar *old_state_name, *new_state_name; GParamSpec *pspec; gboolean rtcp_mux = FALSE; pspec = g_object_class_find_property(G_OBJECT_GET_CLASS(session), "rtcp-mux"); if (pspec && G_PARAM_SPEC_TYPE(pspec) == G_TYPE_BOOLEAN) g_object_get(session, "rtcp-mux", &rtcp_mux, NULL); if (rtcp_mux) { old_state = session->priv->rtp_ice_state; } else { old_state = owr_session_aggregate_ice_state(session->priv->rtp_ice_state, session->priv->rtcp_ice_state); } if (component_type == OWR_COMPONENT_TYPE_RTP) session->priv->rtp_ice_state = state; else session->priv->rtcp_ice_state = state; if (rtcp_mux) { new_state = session->priv->rtp_ice_state; } else { new_state = owr_session_aggregate_ice_state(session->priv->rtp_ice_state, session->priv->rtcp_ice_state); } if (old_state == new_state) return; old_state_name = owr_ice_state_get_name(old_state); new_state_name = owr_ice_state_get_name(new_state); if (new_state == OWR_ICE_STATE_FAILED) { GST_ERROR_OBJECT(session, "Session %u, ICE failed to establish a connection!\n" "ICE state changed from %s to %s", session_id, old_state_name, new_state_name); } else if (new_state == OWR_ICE_STATE_CONNECTED || new_state == OWR_ICE_STATE_READY) { GST_INFO_OBJECT(session, "Session %u, ICE state changed from %s to %s", session_id, old_state_name, new_state_name); } else { GST_DEBUG_OBJECT(session, "Session %u, ICE state changed from %s to %s", session_id, old_state_name, new_state_name); } g_free(old_state_name); g_free(new_state_name); session->priv->ice_state = new_state; g_object_notify_by_pspec(G_OBJECT(session), obj_properties[PROP_ICE_STATE]); }
static void update_sub_sync (GstElement * sink, gpointer data) { /* Some sinks (like autovideosink) don't have the sync property so * we check it exists before setting it to avoid a warning at * runtime. */ if (g_object_class_find_property (G_OBJECT_GET_CLASS (sink), "sync")) g_object_set (sink, "sync", *((gboolean *) data), NULL); else GST_WARNING ("Internal sink doesn't have sync property"); }
void QGstreamerVideoInputDeviceControl::update() { m_names.clear(); m_descriptions.clear(); // subdevsrc and the like have a camera-device property that takes an enumeration // identifying a primary or secondary camera, so return identifiers that map to those // instead of a list of actual devices. if (m_source && g_object_class_find_property(G_OBJECT_GET_CLASS(m_source), "camera-device")) { m_names << QLatin1String("primary") << QLatin1String("secondary"); m_descriptions << tr("Main camera") << tr("Front camera"); return; } QDir devDir("/dev"); devDir.setFilter(QDir::System); QFileInfoList entries = devDir.entryInfoList(QStringList() << "video*"); foreach( const QFileInfo &entryInfo, entries ) { //qDebug() << "Try" << entryInfo.filePath(); int fd = qt_safe_open(entryInfo.filePath().toLatin1().constData(), O_RDWR ); if (fd == -1) continue; bool isCamera = false; v4l2_input input; memset(&input, 0, sizeof(input)); for (; ::ioctl(fd, VIDIOC_ENUMINPUT, &input) >= 0; ++input.index) { if(input.type == V4L2_INPUT_TYPE_CAMERA || input.type == 0) { isCamera = ::ioctl(fd, VIDIOC_S_INPUT, input.index) != 0; break; } } if (isCamera) { // find out its driver "name" QString name; struct v4l2_capability vcap; memset(&vcap, 0, sizeof(struct v4l2_capability)); if (ioctl(fd, VIDIOC_QUERYCAP, &vcap) != 0) name = entryInfo.fileName(); else name = QString((const char*)vcap.card); //qDebug() << "found camera: " << name; m_names.append(entryInfo.filePath()); m_descriptions.append(name); } qt_safe_close(fd); }
gboolean empathy_audio_src_supports_changing_mic (EmpathyGstAudioSrc *self) { EmpathyGstAudioSrcPrivate *priv = EMPATHY_GST_AUDIO_SRC_GET_PRIVATE (self); GObjectClass *object_class; object_class = G_OBJECT_GET_CLASS (priv->src); return (g_object_class_find_property (object_class, "source-output-index") != NULL); }
static void layout_notify (GObject *object, GParamSpec *pspec, gpointer user_data) { GObject *self = user_data; const char *prop_name = g_param_spec_get_name (pspec); if (g_object_class_find_property (G_OBJECT_GET_CLASS (self), prop_name)) g_object_notify (self, prop_name); }
static void set_sysfs_uint (const char *iface, GObject *obj, const char *obj_prop, const char *dir, const char *sysfs_prop, gboolean default_if_zero, gboolean user_hz_compensate) { char *path, *s; GParamSpec *pspec; GValue val = { 0 }; guint32 uval = 0; pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (obj), obj_prop); g_return_if_fail (pspec != NULL); /* Get the property's value */ g_value_init (&val, G_PARAM_SPEC_VALUE_TYPE (pspec)); g_object_get_property (obj, obj_prop, &val); if (G_VALUE_HOLDS_BOOLEAN (&val)) uval = g_value_get_boolean (&val) ? 1 : 0; else if (G_VALUE_HOLDS_UINT (&val)) { uval = g_value_get_uint (&val); /* zero means "unspecified" for some NM properties but isn't in the * allowed kernel range, so reset the property to the default value. */ if (default_if_zero && uval == 0) { g_value_unset (&val); g_value_init (&val, G_PARAM_SPEC_VALUE_TYPE (pspec)); g_param_value_set_default (pspec, &val); uval = g_value_get_uint (&val); } } else g_assert_not_reached (); g_value_unset (&val); /* Linux kernel bridge interfaces use 'centiseconds' for time-based values. * In reality it's not centiseconds, but depends on HZ and USER_HZ, which * is almost always works out to be a multiplier of 100, so we can assume * centiseconds. See clock_t_to_jiffies(). */ if (user_hz_compensate) uval *= 100; path = g_strdup_printf ("/sys/class/net/%s/%s/%s", iface, dir, sysfs_prop); s = g_strdup_printf ("%u", uval); /* FIXME: how should failure be handled? */ nm_utils_do_sysctl (path, s); g_free (path); g_free (s); }
static void playbin_source_cb (GstElement *playbin, GParamSpec *pspec, GbpPlayer *player) { GstElement *element; GObjectClass *klass; g_object_get (G_OBJECT (playbin), "source", &element, NULL); klass = G_OBJECT_GET_CLASS (element); if (g_object_class_find_property (klass, "latency")) { g_object_set (element, "latency", GST_TIME_AS_MSECONDS (player->priv->latency), NULL); } if (g_object_class_find_property (klass, "tcp-timeout")) { g_object_set (element, "tcp-timeout", GST_TIME_AS_USECONDS (player->priv->tcp_timeout), NULL); } }
static gboolean set_videosrc_zoom (GstWrapperCameraBinSrc * self, gfloat zoom) { gboolean ret = FALSE; if (g_object_class_find_property (G_OBJECT_GET_CLASS (self->src_vid_src), "zoom")) { g_object_set (G_OBJECT (self->src_vid_src), "zoom", zoom, NULL); ret = TRUE; } return ret; }
static void empathy_video_widget_element_set_sink_properties_unlocked ( EmpathyVideoWidget *self) { EmpathyVideoWidgetPriv *priv = GET_PRIV (self); if (priv->overlay == NULL) return; if (g_object_class_find_property (G_OBJECT_GET_CLASS (priv->overlay), "force-aspect-ratio")) g_object_set (G_OBJECT (priv->overlay), "force-aspect-ratio", TRUE, NULL); if (g_object_class_find_property ( G_OBJECT_GET_CLASS (priv->overlay), "sync")) g_object_set (G_OBJECT (priv->overlay), "sync", priv->sync, NULL); if (g_object_class_find_property (G_OBJECT_GET_CLASS (priv->overlay), "async")) g_object_set (G_OBJECT (priv->overlay), "async", priv->async, NULL); }
/** Reads an integer from the GTK default settings registry * (see http://library.gnome.org/devel/gtk/stable/GtkSettings.html). * @param property_name The property to read. * @param default_value The default value in case the value could not be read. * @return The value for the property if it exists, otherwise the @a default_value. */ gint ui_get_gtk_settings_integer(const gchar *property_name, gint default_value) { if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT( gtk_settings_get_default())), property_name)) { gint value; g_object_get(G_OBJECT(gtk_settings_get_default()), property_name, &value, NULL); return value; } else return default_value; }
static GParamSpec * _g_type_struct_find_property (GType the_type, gpointer type_struct, const gchar *property_name) { if (G_TYPE_IS_INTERFACE (the_type)) return g_object_interface_find_property (type_struct, property_name); else if (G_TYPE_IS_OBJECT (the_type)) return g_object_class_find_property (type_struct, property_name); else g_return_val_if_reached (NULL); }
static void gimp_operation_histogram_sink_attach (GeglOperation *self) { GeglOperation *operation = GEGL_OPERATION (self); GObjectClass *object_class = G_OBJECT_GET_CLASS (self); GEGL_OPERATION_CLASS (parent_class)->attach (self); gegl_operation_create_pad (operation, g_object_class_find_property (object_class, "aux")); }
gboolean rb_gst_encoder_set_encoding_style (GstElement *encoder, const char *style) { GstElementFactory *factory; char *group_name; char **keys; int i; factory = gst_element_get_factory (encoder); group_name = g_strdup_printf (ENCODER_STYLE_SETTINGS_PREFIX "%s-%s", gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory)), style); rb_debug ("applying settings from %s", group_name); keys = g_key_file_get_keys (get_target_keyfile (), group_name, NULL, NULL); if (keys == NULL) { rb_debug ("nothing to apply"); g_free (group_name); return FALSE; } for (i = 0; keys[i] != NULL; i++) { GParamSpec *pspec; GValue v = {0,}; char *value; pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (encoder), keys[i]); if (pspec == NULL) { rb_debug ("couldn't find property %s", keys[i]); continue; } value = g_key_file_get_string (get_target_keyfile (), group_name, keys[i], NULL); if (value == NULL) { rb_debug ("couldn't get value for property %s", keys[i]); continue; } g_value_init (&v, pspec->value_type); if (gst_value_deserialize (&v, value)) { rb_debug ("applying value \"%s\" to property %s", value, keys[i]); g_object_set_property (G_OBJECT (encoder), keys[i], &v); } else { rb_debug ("couldn't deserialize value \"%s\" for property %s", value, keys[i]); } g_value_unset (&v); } g_strfreev (keys); g_free (group_name); return TRUE; }
static void gimp_mandala_constructed (GObject *object) { GimpSymmetry *sym; GParamSpecDouble *dspec; sym = GIMP_SYMMETRY (object); /* Update property values to actual image size. */ dspec = G_PARAM_SPEC_DOUBLE (g_object_class_find_property (G_OBJECT_GET_CLASS (object), "center-x")); dspec->maximum = gimp_image_get_width (sym->image); dspec = G_PARAM_SPEC_DOUBLE (g_object_class_find_property (G_OBJECT_GET_CLASS (object), "center-y")); dspec->maximum = gimp_image_get_height (sym->image); g_signal_connect (sym->image, "size-changed-detailed", G_CALLBACK (gimp_mandala_image_size_changed_cb), sym); }
/* Build attachment's full path. * Create new relative location for attachment if it's empty. * WARNING! Keep in mind that attachment's location might be changed * between midgard_blob method calls! */ static void __get_filepath(MidgardBlob *self) { if(self->priv->filepath) return; gchar *fname = NULL; gchar *location = NULL; gchar *up_a, *up_b; MidgardObject *attachment = self->priv->attachment; GParamSpec *pspec = g_object_class_find_property( G_OBJECT_GET_CLASS(G_OBJECT(attachment)), "location"); /* FIXME, we can not depend on just location property here. * This must be defined in mgdschema file. */ if(!pspec){ midgard_set_error(self->priv->mgd, MGD_GENERIC_ERROR, MGD_ERR_USER_DATA, "Invalid Object. " "Blobs can not be attached to %s", G_OBJECT_TYPE_NAME(G_OBJECT(attachment))); return; } g_object_get(G_OBJECT(self->priv->attachment), "location", &location, NULL); if(location == NULL || *location == '\0') { fname = midgard_uuid_new(); up_a = g_strdup(" "); up_a[0] = g_ascii_toupper(fname[0]); up_b = g_strdup(" "); up_b[0] = g_ascii_toupper(fname[1]); /* g_strdup is used to avoid filling every byte, which should be done with g_new(gchar, 2) */ location = g_build_path(G_DIR_SEPARATOR_S, up_a, up_b, fname, NULL); g_free(fname); g_free(up_a); g_free(up_b); g_object_set(G_OBJECT(self->priv->attachment), "location", location , NULL); } self->priv->location = location; self->priv->filepath = g_build_path(G_DIR_SEPARATOR_S, self->priv->blobdir, self->priv->location, NULL); }
void GstEnginePipeline::SourceSetupCallback(GstURIDecodeBin* bin, GParamSpec* pspec, gpointer self) { GstEnginePipeline* instance = reinterpret_cast<GstEnginePipeline*>(self); GstElement* element; g_object_get(bin, "source", &element, nullptr); if (!element) { return; } if (g_object_class_find_property(G_OBJECT_GET_CLASS(element), "device") && !instance->source_device().isEmpty()) { // Gstreamer is not able to handle device in URL (refering to Gstreamer // documentation, this might be added in the future). Despite that, for now // we include device inside URL: we decompose it during Init and set device // here, when this callback is called. g_object_set(element, "device", instance->source_device().toLocal8Bit().constData(), nullptr); } if (g_object_class_find_property(G_OBJECT_GET_CLASS(element), "extra-headers") && instance->url().host().contains("grooveshark")) { // Grooveshark streaming servers will answer with a 400 error 'Bad request' // if we don't specify 'Range' field in HTTP header. // Maybe it could be useful in some other cases, but for now, I prefer to // keep this grooveshark specific. GstStructure* headers; headers = gst_structure_new("extra-headers", "Range", G_TYPE_STRING, "bytes=0-", nullptr); g_object_set(element, "extra-headers", headers, nullptr); gst_structure_free(headers); } if (g_object_class_find_property(G_OBJECT_GET_CLASS(element), "user-agent")) { QString user_agent = QString("%1 %2").arg(QCoreApplication::applicationName(), QCoreApplication::applicationVersion()); g_object_set(element, "user-agent", user_agent.toUtf8().constData(), nullptr); } }
static void cs_binding_B_changed (GObject *objectB, GParamSpec *arg1, Binding *binding) { GParamSpec *pspecA, *pspecB; GObjectClass *klassA, *klassB; GValue valueB = {0, }; DelayedUpdateAClosure *uac; if (binding->refs!=2) return; klassA = G_OBJECT_GET_CLASS (binding->objectA); klassB = G_OBJECT_GET_CLASS (binding->objectB); pspecA = g_object_class_find_property (klassA, binding->propertyA); pspecB = g_object_class_find_property (klassB, binding->propertyB); g_value_init (&valueB, pspecB->value_type); uac = g_new0 (DelayedUpdateAClosure, 1); uac->binding = binding; g_value_init (&uac->valueA, pspecA->value_type); g_object_get_property (objectB, binding->propertyB, &valueB); if (!g_value_transform (&valueB, &uac->valueA)) { g_warning ("failed to transform value from %s to %s", g_type_name (pspecB->value_type), g_type_name (pspecA->value_type)); g_value_unset (&uac->valueA); g_free (uac); } else { if (binding->a_changed_idle) g_source_remove (binding->a_changed_idle); binding->a_changed_idle = g_timeout_add (0, delayed_update_A, uac); } g_value_unset (&valueB); }