Ejemplo n.º 1
0
static void
_metadata_set_property (GObject *object, guint property_id,
        const GValue *value, GParamSpec *pspec)
{
	MidgardMetadata *self = (MidgardMetadata *) object;
	
	switch (property_id) {
		
		case MIDGARD_METADATA_AUTHORS:
			g_free (self->priv->authors);
			self->priv->authors = g_value_dup_string (value);
			break;
			
		case MIDGARD_METADATA_OWNER:
			g_free (self->priv->owner);
			self->priv->owner = g_value_dup_string (value);
			break;

		case MIDGARD_METADATA_SCHEDULE_START:
			g_free (self->priv->schedule_start);
			self->priv->schedule_start = g_value_dup_boxed (value);
			break;
		
		case MIDGARD_METADATA_SCHEDULE_END:
			g_free (self->priv->schedule_end);
			self->priv->schedule_end = g_value_dup_boxed (value);
			break;
		
		case MIDGARD_METADATA_HIDDEN:
			if (G_VALUE_HOLDS_BOOLEAN (value))
				self->priv->hidden = g_value_get_boolean (value);
			break;
			
		case MIDGARD_METADATA_NAV_NOENTRY:
			if (G_VALUE_HOLDS_BOOLEAN (value))
				self->priv->nav_noentry = g_value_get_boolean (value);
			break;
						
		case MIDGARD_METADATA_PUBLISHED:	    
			g_free (self->priv->published);	
			self->priv->published = g_value_dup_boxed (value);
			break;

		case MIDGARD_METADATA_SCORE:
			self->priv->score = g_value_get_int (value);
			break;
			
		default:
			G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
			break;                  
	}
}
gboolean
terminal_profile_get_property_boolean (TerminalProfile *profile,
                                       const char *prop_name)
{
	const GValue *value;

	value = get_prop_value_from_prop_name (profile, prop_name);
	g_return_val_if_fail (value != NULL && G_VALUE_HOLDS_BOOLEAN (value), FALSE);
	if (!value || !G_VALUE_HOLDS_BOOLEAN (value))
		return FALSE;

	return g_value_get_boolean (value);
}
Ejemplo n.º 3
0
static void
print_one_tag (const GstTagList * list, const gchar * tag, gpointer user_data)
{
  gint i, num;

  num = gst_tag_list_get_tag_size (list, tag);
  for (i = 0; i < num; ++i) {
    const GValue *val;

    val = gst_tag_list_get_value_index (list, tag, i);
    if (G_VALUE_HOLDS_STRING (val)) {
      g_print ("    %s : %s \n", tag, g_value_get_string (val));
    } else if (G_VALUE_HOLDS_UINT (val)) {
      g_print ("    %s : %u \n", tag, g_value_get_uint (val));
    } else if (G_VALUE_HOLDS_DOUBLE (val)) {
      g_print ("    %s : %g \n", tag, g_value_get_double (val));
    } else if (G_VALUE_HOLDS_BOOLEAN (val)) {
      g_print ("    %s : %s \n", tag,
          g_value_get_boolean (val) ? "true" : "false");
    } else if (GST_VALUE_HOLDS_DATE_TIME (val)) {
      GstDateTime *dt = g_value_get_boxed (val);
      gchar *dt_str = gst_date_time_to_iso8601_string (dt);

      g_print ("    %s : %s \n", tag, dt_str);
      g_free (dt_str);
    } else {
      g_print ("    %s : tag of type '%s' \n", tag, G_VALUE_TYPE_NAME (val));
    }
  }
}
Ejemplo n.º 4
0
void
xaccAccountScrubKvp (Account *account)
{
    GValue v = G_VALUE_INIT;
    const gchar *str;
    gchar *str2;

    if (!account) return;

    qof_instance_get_kvp (QOF_INSTANCE (account), "notes", &v);
    if (G_VALUE_HOLDS_STRING (&v))
    {
        str2 = g_strstrip(g_value_dup_string(&v));
        if (strlen(str2) == 0)
            qof_instance_slot_delete (QOF_INSTANCE (account), "notes");
        g_free(str2);
    }

    qof_instance_get_kvp (QOF_INSTANCE (account), "placeholder", &v);
    if ((G_VALUE_HOLDS_STRING (&v) &&
        strcmp(g_value_get_string (&v), "false") == 0) ||
        (G_VALUE_HOLDS_BOOLEAN (&v) && ! g_value_get_boolean (&v)))
        qof_instance_slot_delete (QOF_INSTANCE (account), "placeholder");

    qof_instance_slot_delete_if_empty (QOF_INSTANCE (account), "hbci");
}
void cd_NetworkMonitor_get_wired_connection_infos (void)
{
	cd_debug ("%s ()", __func__);
	GHashTable *hProperties;
	GValue *v;
	
	//\_____________ On recupere les proprietes du device "wired"
	hProperties = cairo_dock_dbus_get_all_properties (myData.dbus_proxy_Device_prop, "org.freedesktop.NetworkManager.Device.Wired");
	g_return_if_fail (hProperties != NULL);
	
	v = (GValue *)g_hash_table_lookup (hProperties, "Speed");
	if (v != NULL && G_VALUE_HOLDS_UINT (v))
	{
		myData.iSpeed = g_value_get_uint (v);
		cd_debug("  Vitesse de connexion : %d",myData.iSpeed);
	}
	
	v = (GValue *)g_hash_table_lookup (hProperties, "HwAddress");
	if (v != NULL && G_VALUE_HOLDS_STRING (v))
	{
		myData.cAccessPointHwAdress = g_strdup(g_value_get_string (v));
		cd_debug("  Adresse physique : %s",myData.cAccessPointHwAdress);
	}
	
	myData.iQuality = WIRED_NO_CONNECTION;
	v = (GValue *)g_hash_table_lookup (hProperties, "Carrier");
	if (v != NULL && G_VALUE_HOLDS_BOOLEAN (v))
	{
		if (g_value_get_boolean (v))
			myData.iQuality = WIRED_CONNECTION;
		cd_debug("  cable branche : %d", g_value_get_boolean (v));
	}
	
	g_hash_table_unref (hProperties);
}
static void
modem_properties_changed (DBusGProxy *proxy,
                          const char *interface,
                          GHashTable *props,
                          gpointer user_data)
{
	CdmaDeviceInfo *info = user_data;
	GValue *value;

	if (!strcmp (interface, MM_OLD_DBUS_INTERFACE_MODEM)) {
		value = g_hash_table_lookup (props, "Enabled");
		if (value && G_VALUE_HOLDS_BOOLEAN (value)) {
			info->modem_enabled = g_value_get_boolean (value);
			if (!info->modem_enabled) {
				info->quality = 0;
				info->quality_valid = 0;
				info->cdma1x_state = 0;
				info->evdo_state = 0;
				info->sid = 0;
				g_free (info->provider_name);
				info->provider_name = NULL;
			}
			check_start_polling (info);
		}
	}
}
Ejemplo n.º 7
0
static inline gboolean
default_invert_boolean_transform (const GValue *value_a,
                                  GValue       *value_b)
{
  gboolean value;

  g_assert (G_VALUE_HOLDS_BOOLEAN (value_a));
  g_assert (G_VALUE_HOLDS_BOOLEAN (value_b));

  value = g_value_get_boolean (value_a);
  value = !value;

  g_value_set_boolean (value_b, value);

  return TRUE;
}
Ejemplo n.º 8
0
/**
 * g_value_get_boolean:
 * @value: a valid #GValue of type %G_TYPE_BOOLEAN
 *
 * Get the contents of a %G_TYPE_BOOLEAN #GValue.
 *
 * Returns: boolean contents of @value
 */
gboolean
g_value_get_boolean (const GValue *value)
{
  g_return_val_if_fail (G_VALUE_HOLDS_BOOLEAN (value), 0);
  
  return value->data[0].v_int;
}
Ejemplo n.º 9
0
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(), "WebKitWebAudioEnabled"))
        propertyName = "enable-webaudio";
    else if (g_str_equal(originalName.get(), "WebKitTabToLinksPreferenceKey")) {
        DumpRenderTreeSupportGtk::setLinksIncludedInFocusChain(!g_ascii_strcasecmp(valueAsString.get(), "true") || !g_ascii_strcasecmp(valueAsString.get(), "1"));
        return;
    } else if (g_str_equal(originalName.get(), "WebKitHixie76WebSocketProtocolEnabled")) {
        DumpRenderTreeSupportGtk::setHixie76WebSocketProtocolEnabled(webkit_web_frame_get_web_view(mainFrame), !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(&currentPropertyValue, pspec->value_type);

    if (G_VALUE_HOLDS_STRING(&currentPropertyValue))
        g_object_set(settings, propertyName, valueAsString.get(), NULL);
    else if (G_VALUE_HOLDS_BOOLEAN(&currentPropertyValue))
        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(&currentPropertyValue))
        g_object_set(G_OBJECT(settings), propertyName, atoi(valueAsString.get()), NULL);
    else if (G_VALUE_HOLDS_FLOAT(&currentPropertyValue)) {
        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());
}
static gboolean
cc_sharing_panel_switch_to_label_transform_func (GBinding       *binding,
                                                 const GValue   *source_value,
                                                 GValue         *target_value,
                                                 CcSharingPanel *self)
{
  gboolean active;

  if (!G_VALUE_HOLDS_BOOLEAN (source_value))
    return FALSE;

  if (!G_VALUE_HOLDS_STRING (target_value))
    return FALSE;

  active = g_value_get_boolean (source_value);

  if (active)
    g_value_set_string (target_value, C_("service is enabled", "On"));
  else
    g_value_set_string (target_value, C_("service is disabled", "Off"));

  /* ensure the master switch is active if one of the services is active */
  if (active)
    gtk_switch_set_active (GTK_SWITCH (self->priv->master_switch), TRUE);

  return TRUE;
}
Ejemplo n.º 11
0
void TagExtractor::printOneTag( const GstTagList * list, const gchar * tag, gpointer user_data ) {
	int i, num;

	num = gst_tag_list_get_tag_size( list, tag );
	for (i = 0; i < num; ++i) {
		const GValue *val;

		/* Note: when looking for specific tags, use the gst_tag_list_get_xyz() API,
		 * we only use the GValue approach here because it is more generic */
		val = gst_tag_list_get_value_index( list, tag, i );
		if( G_VALUE_HOLDS_STRING (val)) {
			g_print( "\t%20s : %s\n", tag, g_value_get_string( val ) );
		} else if( G_VALUE_HOLDS_UINT (val)) {
			g_print( "\t%20s : %u\n", tag, g_value_get_uint( val ) );
		} else if( G_VALUE_HOLDS_DOUBLE (val)) {
			g_print( "\t%20s : %g\n", tag, g_value_get_double( val ) );
		} else if( G_VALUE_HOLDS_BOOLEAN (val)) {
			g_print( "\t%20s : %s\n", tag, (g_value_get_boolean( val )) ? "true" : "false" );
		} else if( GST_VALUE_HOLDS_BUFFER (val)) {
			GstBuffer *buf = gst_value_get_buffer (val);
			guint buffer_size = gst_buffer_get_size( buf );

			g_print( "\t%20s : buffer of size %u\n", tag, buffer_size );
		} else if( GST_VALUE_HOLDS_DATE_TIME (val)) {
			GstDateTime *dt = (GstDateTime*) g_value_get_boxed( val );
			gchar *dt_str = gst_date_time_to_iso8601_string( dt );

			g_print( "\t%20s : %s\n", tag, dt_str );
			g_free( dt_str );
		} else {
			g_print( "\t%20s : tag of type '%s'\n", tag, G_VALUE_TYPE_NAME (val));
		}
	}
}
Ejemplo n.º 12
0
static gpointer
value_as_pointer (GValue *value)
{
  if (g_value_fits_pointer (value))
    return g_value_peek_pointer (value);
  if (G_VALUE_HOLDS_BOOLEAN (value))
    return (void*) g_value_get_boolean (value);
  if (G_VALUE_HOLDS_CHAR (value))
    return (void*) (gssize) g_value_get_char (value);
  if (G_VALUE_HOLDS_UCHAR (value))
    return (void*) (gsize) g_value_get_uchar (value);
  if (G_VALUE_HOLDS_INT (value))
    return (void*) g_value_get_int (value);
  if (G_VALUE_HOLDS_UINT (value))
    return (void*) g_value_get_uint (value);
  if (G_VALUE_HOLDS_LONG (value))
    return (void*) g_value_get_long (value);
  if (G_VALUE_HOLDS_ULONG (value))
    return (void*) g_value_get_ulong (value);
  if (G_VALUE_HOLDS_FLOAT (value))
    return (void*) (gssize) g_value_get_float (value);
  if (G_VALUE_HOLDS_DOUBLE (value))
    return (void*) (gssize) g_value_get_double (value);
  if (G_VALUE_HOLDS_ENUM (value))
    return (void*) (gssize) g_value_get_enum (value);
  if (G_VALUE_HOLDS_FLAGS (value))
    return (void*) (gsize) g_value_get_flags (value);
  return (void*) 0x1373babe;
}
Ejemplo n.º 13
0
static
void cb_custom_toggled(GtkCellRendererToggle *cell, char *path, gpointer data)
{
	GtkTreeIter iter;
	GtkTreeModel *model = (GtkTreeModel*) data;
	if (gtk_tree_model_get_iter_from_string(model, &iter, path)) {
                PurpleAccount *account;
                GValue value;
                memset(&value, 0, sizeof(value));
                gtk_tree_model_get_value(model, &iter, 5, &value);
                assert(G_VALUE_HOLDS_POINTER(&value));
                account = g_value_get_pointer(&value);
                g_value_unset(&value);

		gboolean flag;
		char pref[STRLEN];

		build_pref(pref, PREF_CUSTOM_DISABLED, purple_account_get_username(account), purple_account_get_protocol_name(account));

		memset(&value, 0, sizeof(value));
		gtk_tree_model_get_value(model, &iter, 3, &value);
		assert(G_VALUE_HOLDS_BOOLEAN(&value));
		flag = !g_value_get_boolean(&value);
		g_value_unset(&value);

		gtk_list_store_set(GTK_LIST_STORE(model), &iter, 3, flag, -1);
		purple_prefs_set_bool(pref, flag);
		if (flag) {
			set_status(account, "", 0);
		}
	}
}
Ejemplo n.º 14
0
/**
 * g_value_set_boolean:
 * @value: a valid #GValue of type %G_TYPE_BOOLEAN
 * @v_boolean: boolean value to be set
 *
 * Set the contents of a %G_TYPE_BOOLEAN #GValue to @v_boolean.
 */
void
g_value_set_boolean (GValue  *value,
		     gboolean v_boolean)
{
  g_return_if_fail (G_VALUE_HOLDS_BOOLEAN (value));
  
  value->data[0].v_int = v_boolean != FALSE;
}
Ejemplo n.º 15
0
static void
bluez_property_changed (DBusGProxy *proxy,
                        const char *property,
                        GValue *value,
                        gpointer user_data)
{
	NMDevice *device = NM_DEVICE (user_data);
	NMDeviceBt *self = NM_DEVICE_BT (user_data);
	NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (self);
	gboolean connected;
	NMDeviceState state;
	const char *prop_str = "(unknown)";

	if (G_VALUE_HOLDS_STRING (value))
		prop_str = g_value_get_string (value);
	else if (G_VALUE_HOLDS_BOOLEAN (value))
		prop_str = g_value_get_boolean (value) ? "true" : "false";

	nm_log_dbg (LOGD_BT, "(%s): bluez property '%s' changed to '%s'",
	            nm_device_get_iface (device),
	            property,
	            prop_str);

	if (strcmp (property, "Connected"))
		return;

	state = nm_device_get_state (device);
	connected = g_value_get_boolean (value);
	if (connected) {
		if (state == NM_DEVICE_STATE_CONFIG) {
			nm_log_dbg (LOGD_BT, "(%s): connected to the device",
			            nm_device_get_iface (device));

			priv->connected = TRUE;
			check_connect_continue (self);
		}
	} else {
		gboolean fail = FALSE;

		/* Bluez says we're disconnected from the device.  Suck. */

		if (nm_device_is_activating (device)) {
			nm_log_info (LOGD_BT,
			             "Activation (%s/bluetooth): bluetooth link disconnected.",
			             nm_device_get_iface (device));
			fail = TRUE;
		} else if (state == NM_DEVICE_STATE_ACTIVATED) {
			nm_log_info (LOGD_BT, "(%s): bluetooth link disconnected.",
			             nm_device_get_iface (device));
			fail = TRUE;
		}

		if (fail) {
			nm_device_state_changed (device, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_CARRIER);
			priv->connected = FALSE;
		}
	}
}
Ejemplo n.º 16
0
static void on_properties_changed (DBusGProxy *player_proxy, const gchar *cInterface, GHashTable *pChangedProps, const gchar **cInvalidProps, gpointer data)
{
	g_return_if_fail (cInterface != NULL);
	cd_debug ("");
	GValue *v;
	if (strcmp (cInterface, "org.mpris.MediaPlayer2.Player") == 0)
	{
		v = g_hash_table_lookup (pChangedProps, "PlaybackStatus");
		if (v != NULL && G_VALUE_HOLDS_STRING (v))  // status has changed
		{
			const gchar *cStatus = g_value_get_string (v);  // "Playing", "Paused" or "Stopped"
			myData.iPlayingStatus = _extract_status (cStatus);
			cd_debug ("PlaybackStatus: Status: %s, %d", cStatus, myData.iPlayingStatus);
			
			if (myData.iPlayingStatus == PLAYER_PLAYING)  // le handler est stoppe lorsque le lecteur ne joue rien.
				cd_musicplayer_relaunch_handler ();
			
			cd_musicplayer_update_icon ();
		}
		
		v = g_hash_table_lookup (pChangedProps, "Metadata");
		if (v != NULL && G_VALUE_HOLDS_BOXED (v))
		{
			GHashTable *pMetadata = g_value_get_boxed (v);
			gboolean bTrackHasChanged = _extract_metadata (pMetadata);
			
			if (bTrackHasChanged)  // new song (song changed or started playing)
			{
				myData.iPlayingStatus = PLAYER_PLAYING;  // pour les lecteurs bugues comme Exaile qui envoit un statut "stop" au changement de musique sans envoyer de status "play" par la suite. On considere donc que si le lecteur joue une nouvelle musique, c'est qu'il est en "play".
				cd_musicplayer_update_icon ();
			}
		}
		
		v = g_hash_table_lookup (pChangedProps, "LoopStatus");
		if (v != NULL && G_VALUE_HOLDS_STRING (v))  // loop status has changed
		{
			const gchar *cStatus = g_value_get_string (v);  // "Playlist", "None"
			s_bIsLoop = (cStatus && strcmp (cStatus, "Playlist") == 0);
			cd_debug ("LoopStatus: %s, %d", cStatus, s_bIsLoop);
			s_bGotLoopStatus = TRUE;
		}
		
		v = g_hash_table_lookup (pChangedProps, "Shuffle");
		if (v != NULL && G_VALUE_HOLDS_BOOLEAN (v))  // Shuffle status has changed
		{
			s_bIsShuffle = g_value_get_boolean (v);
			cd_debug ("Shuffle: %d", s_bIsShuffle);
			s_bGotShuffleStatus = TRUE;
		}
	}
	/*else if (strcmp (cInterface, "org.mpris.MediaPlayer2.TrackList") == 0)
	{
		
	}*/
	else
		cd_debug ("Another interface: %s", cInterface);
}
Ejemplo n.º 17
0
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
dummy_closure_marshal (GClosure     *closure,
		       GValue       *return_value,
		       guint         n_param_values,
		       const GValue *param_values,
		       gpointer      invocation_hint,
		       gpointer      marshal_data)
{
  if (G_VALUE_HOLDS_BOOLEAN (return_value))
    g_value_set_boolean (return_value, TRUE);
}
Ejemplo n.º 19
0
static gboolean tp_asv_get_sms_channel (GHashTable *properties)
{
  GValue *value = g_hash_table_lookup (properties,
      TP_IFACE_CHANNEL_INTERFACE_SMS ".SMSChannel");

  if (value == NULL)
    return TRUE;
  else if (!G_VALUE_HOLDS_BOOLEAN (value))
    return FALSE;
  else
    return g_value_get_boolean (value);
}
Ejemplo n.º 20
0
static gboolean get_boolean (GHashTable *dict, const char *key)
{
        GValue *val;

        val = g_hash_table_lookup (dict, key);
        if (val == NULL) {
                return FALSE;
        }
        if (!G_VALUE_HOLDS_BOOLEAN (val)) {
                return FALSE;
        }
        return g_value_get_boolean (val);
}
Ejemplo n.º 21
0
/*
 * Enable or disable reading from and writing to the tile cache.
 */
void
ph_config_set_tile_cache_enabled(const GValue *value)
{
    g_return_if_fail(ph_config != NULL);
    g_return_if_fail(value == NULL || G_VALUE_HOLDS_BOOLEAN(value));

    if (value != NULL)
        g_key_file_set_boolean(ph_config->key_file, "tile-cache", "enabled",
                               g_value_get_boolean(value));
    else
        g_key_file_remove_key(ph_config->key_file, "tile-cache", "enabled",
                              NULL);
}
Ejemplo n.º 22
0
/* Attempts to get the image style from the xfdesktop pre-4.11 format */
static void
xfce_workspace_migrate_backdrop_image_style(XfceWorkspace *workspace,
                                            XfceBackdrop *backdrop,
                                            guint monitor)
{
    XfconfChannel *channel = workspace->priv->channel;
    char buf[1024];
    gint pp_len;
    GValue value = { 0, };

    TRACE("entering");

    /* Use the old property format */
    g_snprintf(buf, sizeof(buf), "%smonitor%d/",
               workspace->priv->property_prefix, monitor);
    pp_len = strlen(buf);

    /* show image */
    buf[pp_len] = 0;
    g_strlcat(buf, "image-show", sizeof(buf));
    xfconf_channel_get_property(channel, buf, &value);

    if(G_VALUE_HOLDS_BOOLEAN(&value)) {
        gboolean show_image = g_value_get_boolean(&value);

        /* if we aren't showing the image, set the style and exit the function
         * so we don't set the style to something else */
        if(!show_image) {
             xfce_backdrop_set_image_style(backdrop, XFCE_BACKDROP_IMAGE_NONE);
             g_value_unset(&value);
             return;
        }

        g_value_unset(&value);
    }

    /* image style */
    buf[pp_len] = 0;
    g_strlcat(buf, "image-style", sizeof(buf));
    xfconf_channel_get_property(channel, buf, &value);

    if(G_VALUE_HOLDS_INT(&value)) {
        XfceBackdropImageStyle style;
        style = xfce_translate_image_styles(g_value_get_int(&value));
        xfce_backdrop_set_image_style(backdrop, style);
        g_value_unset(&value);
    } else {
        /* If no value was ever set default to stretched */
        xfce_backdrop_set_image_style(backdrop, XFCE_BACKDROP_IMAGE_STRETCHED);
    }
}
Ejemplo n.º 23
0
/*
 * If the given row in the model is the name we're looking for, run it.
 * Otherwise keep looking.
 */
gboolean
run_desktop_entry(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter,
    gpointer data)
{
	char		*name_v;
	struct state	*st;
	GValue	 	 value = G_VALUE_INIT;

	st = (struct state *)data;

	gtk_tree_model_get_value(model, iter, NAME_COLUMN, &value);
	if (!G_VALUE_HOLDS_STRING(&value)) {
		warnx("gtk_tree_model_get_value: name is not a string");
		return FALSE;
	}
	name_v = g_value_dup_string(&value);
	g_value_unset(&value);

	if (strlen(name_v) != strlen(st->name) ||
	    strncmp(name_v, st->name, strlen(st->name)) != 0)
		return FALSE;

	gtk_tree_model_get_value(model, iter, EXEC_COLUMN, &value);
	if (!G_VALUE_HOLDS_STRING(&value)) {
		warnx("gtk_tree_model_get_value: exec is not a string");
		return TRUE;
	}
	st->cmd = g_value_dup_string(&value);
	g_value_unset(&value);

	gtk_tree_model_get_value(model, iter, FCODE_COLUMN, &value);
	if (!G_VALUE_HOLDS_UINT(&value)) {
		warnx("gtk_tree_model_get_value: flags are not an integer");
		return TRUE;
	}
	st->flags = g_value_get_uint(&value);
	g_value_unset(&value);

	gtk_tree_model_get_value(model, iter, TERM_COLUMN, &value);
	if (!G_VALUE_HOLDS_BOOLEAN(&value)) {
		warnx("gtk_tree_model_get_value: term is not a Boolean");
		return TRUE;
	}
	st->use_term = g_value_get_boolean(&value);
	g_value_unset(&value);

	if (run_cmd(st))
		return TRUE;

	return TRUE;
}
Ejemplo n.º 24
0
static void
commit_option (NMDevice *device, NMSetting *setting, const Option *option, gboolean slave)
{
	int ifindex = nm_device_get_ifindex (device);
	GParamSpec *pspec;
	GValue val = G_VALUE_INIT;
	guint32 uval = 0;
	gs_free char *value = NULL;

	g_assert (setting);

	pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (setting), option->name);
	g_assert (pspec);

	/* Get the property's value */
	g_value_init (&val, G_PARAM_SPEC_VALUE_TYPE (pspec));
	g_object_get_property ((GObject *) setting, option->name, &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 (option->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);
		}

		/* 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 (option->user_hz_compensate)
			uval *= 100;
	} else
		g_assert_not_reached ();
	g_value_unset (&val);

	value = g_strdup_printf ("%u", uval);
	if (slave)
		nm_platform_slave_set_option (ifindex, option->sysname, value);
	else
		nm_platform_master_set_option (ifindex, option->sysname, value);
}
Ejemplo n.º 25
0
static gboolean
impl_start (NMCEService *self, GHashTable *table, GError **error)
{
	GValue *value;
	const char *type = NULL;
	const char *uuid = NULL;
	gboolean create = FALSE;
	gboolean show = FALSE;
	gboolean show_list;

	value = g_hash_table_lookup (table, ARG_TYPE);
	if (value && G_VALUE_HOLDS_STRING (value)) {
		type = g_value_get_string (value);
		g_assert (type);
	}

	value = g_hash_table_lookup (table, ARG_UUID);
	if (value && G_VALUE_HOLDS_STRING (value)) {
		uuid = g_value_get_string (value);
		g_assert (uuid);
	}

	value = g_hash_table_lookup (table, ARG_CREATE);
	if (value && G_VALUE_HOLDS_BOOLEAN (value))
		create = g_value_get_boolean (value);

	value = g_hash_table_lookup (table, ARG_SHOW);
	if (value && G_VALUE_HOLDS_BOOLEAN (value))
		show = g_value_get_boolean (value);

	show_list = handle_arguments (self->list, type, create, show, uuid, FALSE);
	if (show_list)
		nm_connection_list_present (self->list);

	return TRUE;
}
Ejemplo n.º 26
0
/*
 * Pull out the executable from the selected entry, and run it.
 */
void
app_selected(GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn
    *column, gpointer user_data)
{
	GtkTreeModel	*model;
	GtkTreeIter	 iter;
	GValue		 value = G_VALUE_INIT;
	struct state	*st;

	st = (struct state *)user_data;

	if ((model = gtk_tree_view_get_model(tree_view)) == NULL) {
		warnx("gtk_tree_view_get_model is NULL");
		return;
	}

	if (!gtk_tree_model_get_iter(model, &iter, path)) {
		warnx("gtk_tree_model_get_iter: path does not exist");
		return;
	}

	gtk_tree_model_get_value(model, &iter, EXEC_COLUMN, &value);
	if (!G_VALUE_HOLDS_STRING(&value)) {
		warnx("gtk_tree_model_get_value: exec is not a string");
		return;
	}
	st->cmd = g_value_dup_string(&value);
	g_value_unset(&value);

	gtk_tree_model_get_value(model, &iter, FCODE_COLUMN, &value);
	if (!G_VALUE_HOLDS_UINT(&value)) {
		warnx("gtk_tree_model_get_value: flags are not an integer");
		return;
	}
	st->flags = g_value_get_uint(&value);
	g_value_unset(&value);

	gtk_tree_model_get_value(model, &iter, TERM_COLUMN, &value);
	if (!G_VALUE_HOLDS_BOOLEAN(&value)) {
		warnx("gtk_tree_model_get_value: term is not a Boolean");
		return;
	}
	st->use_term = g_value_get_boolean(&value);
	g_value_unset(&value);

	if (run_cmd(st))
		gtk_main_quit();
}
Ejemplo n.º 27
0
/**
 * grl_related_keys_get_boolean:
 * @relkeys: set of related keys to inspect
 * @key: (type GrlKeyID): key to use
 *
 * Returns the value associated with @key from @relkeys. If @key has no value,
 * or value is not a gboolean, or @key is not in @relkeys, then %FALSE is
 * returned.
 *
 * Returns: float value associated with @key, or %FALSE in other case.
 *
 * Since: 0.2.3
 **/
gboolean
grl_related_keys_get_boolean (GrlRelatedKeys *relkeys,
                              GrlKeyID key)
{
  const GValue *value;

  g_return_val_if_fail (GRL_IS_RELATED_KEYS (relkeys), FALSE);

  value = grl_related_keys_get (relkeys, key);

  if (!value || !G_VALUE_HOLDS_BOOLEAN (value)) {
    return FALSE;
  } else {
    return g_value_get_boolean (value);
  }
}
Ejemplo n.º 28
0
/**
 * Get a gboolean property
 * @param filter_param A RSFilterParam
 * @param name The name of the property
 * @param value A pointer to a gboolean where the value will be stored
 * @return TRUE if the property was found, FALSE otherwise
 */
gboolean
rs_filter_param_get_boolean(const RSFilterParam *filter_param, const gchar *name, gboolean *value)
{
	GValue *val;

	g_return_val_if_fail(RS_IS_FILTER_PARAM(filter_param), FALSE);
	g_return_val_if_fail(name != NULL, FALSE);
	g_return_val_if_fail(name[0] != '\0', FALSE);
	g_return_val_if_fail(value != NULL, FALSE);

	val = rs_filter_param_get_gvalue(filter_param, name);

	if (val && G_VALUE_HOLDS_BOOLEAN(val))
		*value = g_value_get_boolean(val);

	return (val != NULL);
}
Ejemplo n.º 29
0
/* A helper function whch transforms string to boolean */
static void 
__transform_string_to_boolean (const GValue *src_val, GValue *dest_val)
{
	g_assert (src_val != NULL);
	g_assert (dest_val != NULL);

	g_assert (G_VALUE_HOLDS_BOOLEAN (dest_val));

	const gchar *_str = g_value_get_string (src_val);

	if (!_str || (_str && *_str == '\0')) {
		g_value_set_boolean (dest_val, FALSE);
		return;
	}

    	/* Stringified boolean */
	if (g_str_equal (_str, "TRUE")) {
		g_value_set_boolean (dest_val, TRUE);
		return;
	}

	if (g_str_equal (_str, "true")) {
		g_value_set_boolean (dest_val, TRUE);
		return;
	}

	if (g_str_equal (_str, "FALSE")) {
		g_value_set_boolean (dest_val, FALSE);
		return;
	}

	if (g_str_equal (_str, "false")) {
		g_value_set_boolean (dest_val, FALSE);
		return;
	}

	gint i = atoi (_str);

	if (i > 0)
		g_value_set_boolean (dest_val, TRUE);
	else
		g_value_set_boolean (dest_val, FALSE);

	return;
}
static void
enabled_reply (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
{
	CdmaDeviceInfo *info = user_data;
	GError *error = NULL;
	GValue value = { 0 };

	if (dbus_g_proxy_end_call (proxy, call, &error,
	                           G_TYPE_VALUE, &value,
	                           G_TYPE_INVALID)) {
		if (G_VALUE_HOLDS_BOOLEAN (&value))
			info->modem_enabled = g_value_get_boolean (&value);
		g_value_unset (&value);
	}

	g_clear_error (&error);
	check_start_polling (info);
}