static void terminal_profile_gsettings_changeset_add (TerminalProfile *profile, GSettings *changeset, GParamSpec *pspec) { TerminalProfilePrivate *priv = profile->priv; char *key; const GValue *value; /* FIXME: do this? */ #if 0 if (priv->locked[pspec->param_id]) return; if (!g_settings_is_writable (priv->settings, gsettings_key, NULL)) return; #endif key = g_param_spec_get_qdata (pspec, gsettings_key_quark); if (!key) return; value = g_value_array_get_nth (priv->properties, pspec->param_id); _terminal_debug_print (TERMINAL_DEBUG_PROFILE, "Adding pspec %s with value %s to the GSettings changeset\n", pspec->name, g_strdup_value_contents (value)); if (G_IS_PARAM_SPEC_BOOLEAN (pspec)) g_settings_set_boolean (changeset, key, g_value_get_boolean (value)); else if (G_IS_PARAM_SPEC_STRING (pspec)) { const char *str; str = g_value_get_string (value); g_settings_set_string (changeset, key, str ? str : ""); } else if (G_IS_PARAM_SPEC_ENUM (pspec)) { const GEnumValue *eval; eval = g_enum_get_value (G_PARAM_SPEC_ENUM (pspec)->enum_class, g_value_get_enum (value)); g_settings_set_enum (changeset, key, eval->value); } else if (G_PARAM_SPEC_VALUE_TYPE (pspec) == GDK_TYPE_COLOR) { GdkColor *color; char str[16]; color = g_value_get_boxed (value); if (!color) goto cleanup; g_snprintf (str, sizeof (str), "#%04X%04X%04X", color->red, color->green, color->blue); g_settings_set_string (changeset, key, str); } else if (G_PARAM_SPEC_VALUE_TYPE (pspec) == PANGO_TYPE_FONT_DESCRIPTION) { PangoFontDescription *font_desc; char *font; font_desc = g_value_get_boxed (value); if (!font_desc) goto cleanup; font = pango_font_description_to_string (font_desc); g_settings_set_string (changeset, key, font); g_free (font); } else if (G_IS_PARAM_SPEC_DOUBLE (pspec)) g_settings_set_double (changeset, key, g_value_get_double (value)); else if (G_IS_PARAM_SPEC_INT (pspec)) g_settings_set_int (changeset, key, g_value_get_int (value)); else if (G_IS_PARAM_SPEC_VALUE_ARRAY (pspec) && G_PARAM_SPEC_VALUE_TYPE (G_PARAM_SPEC_VALUE_ARRAY (pspec)->element_spec) == GDK_TYPE_COLOR) { GValueArray *array; GString *string; guint n_colors, i; /* We need to do this ourselves, because the gtk_color_selection_palette_to_string * does not carry all the bytes, and xterm's palette is messed up... */ array = g_value_get_boxed (value); if (!array) goto cleanup; n_colors = array->n_values; string = g_string_sized_new (n_colors * (1 /* # */ + 3 * 4) + n_colors /* : separators and terminating \0 */); for (i = 0; i < n_colors; ++i) { GdkColor *color; if (i > 0) g_string_append_c (string, ':'); color = g_value_get_boxed (g_value_array_get_nth (array, i)); if (!color) continue; g_string_append_printf (string, "#%04X%04X%04X", color->red, color->green, color->blue); } g_settings_set_string (changeset, key, string->str); g_string_free (string, TRUE); } else g_printerr ("Unhandled value type %s of pspec %s\n", g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)), pspec->name); cleanup: return; }
JsonNode * json_serialize_pspec (const GValue *real_value, GParamSpec *pspec) { JsonNode *retval = NULL; JsonNodeType node_type; switch (G_TYPE_FUNDAMENTAL (G_VALUE_TYPE (real_value))) { /* JSON native types */ case G_TYPE_INT64: retval = json_node_init_int (json_node_alloc (), g_value_get_int64 (real_value)); break; case G_TYPE_BOOLEAN: retval = json_node_init_boolean (json_node_alloc (), g_value_get_boolean (real_value)); break; case G_TYPE_DOUBLE: retval = json_node_init_double (json_node_alloc (), g_value_get_double (real_value)); break; case G_TYPE_STRING: retval = json_node_init_string (json_node_alloc (), g_value_get_string (real_value)); break; /* auto-promoted types */ case G_TYPE_INT: retval = json_node_init_int (json_node_alloc (), g_value_get_int (real_value)); break; case G_TYPE_UINT: retval = json_node_init_int (json_node_alloc (), g_value_get_uint (real_value)); break; case G_TYPE_LONG: retval = json_node_init_int (json_node_alloc (), g_value_get_long (real_value)); break; case G_TYPE_ULONG: retval = json_node_init_int (json_node_alloc (), g_value_get_ulong (real_value)); break; case G_TYPE_FLOAT: retval = json_node_init_double (json_node_alloc (), g_value_get_float (real_value)); break; case G_TYPE_CHAR: retval = json_node_alloc (); json_node_init_int (retval, g_value_get_schar (real_value)); break; case G_TYPE_UCHAR: retval = json_node_init_int (json_node_alloc (), g_value_get_uchar (real_value)); break; case G_TYPE_ENUM: retval = json_node_init_int (json_node_alloc (), g_value_get_enum (real_value)); break; case G_TYPE_FLAGS: retval = json_node_init_int (json_node_alloc (), g_value_get_flags (real_value)); break; /* complex types */ case G_TYPE_BOXED: if (G_VALUE_HOLDS (real_value, G_TYPE_STRV)) { gchar **strv = g_value_get_boxed (real_value); gint i, strv_len; JsonArray *array; strv_len = g_strv_length (strv); array = json_array_sized_new (strv_len); for (i = 0; i < strv_len; i++) { JsonNode *str = json_node_new (JSON_NODE_VALUE); json_node_set_string (str, strv[i]); json_array_add_element (array, str); } retval = json_node_init_array (json_node_alloc (), array); json_array_unref (array); } else if (json_boxed_can_serialize (G_VALUE_TYPE (real_value), &node_type)) { gpointer boxed = g_value_get_boxed (real_value); retval = json_boxed_serialize (G_VALUE_TYPE (real_value), boxed); } else g_warning ("Boxed type '%s' is not handled by JSON-GLib", g_type_name (G_VALUE_TYPE (real_value))); break; case G_TYPE_OBJECT: { GObject *object = g_value_get_object (real_value); retval = json_node_alloc (); if (object != NULL) { json_node_init (retval, JSON_NODE_OBJECT); json_node_take_object (retval, json_gobject_dump (object)); } else json_node_init_null (retval); } break; case G_TYPE_NONE: retval = json_node_new (JSON_NODE_NULL); break; default: g_warning ("Unsupported type `%s'", g_type_name (G_VALUE_TYPE (real_value))); break; } return retval; }
static gboolean gail_focus_watcher (GSignalInvocationHint *ihint, guint n_param_values, const GValue *param_values, gpointer data) { GObject *object; GtkWidget *widget; GdkEvent *event; object = g_value_get_object (param_values + 0); g_return_val_if_fail (GTK_IS_WIDGET(object), FALSE); event = g_value_get_boxed (param_values + 1); widget = GTK_WIDGET (object); if (event->type == GDK_FOCUS_CHANGE) { if (event->focus_change.in) { if (GTK_IS_WINDOW (widget)) { GtkWidget *focus_widget; GtkWindow *window; GtkWindowType type; window = GTK_WINDOW (widget); focus_widget = gtk_window_get_focus (window); g_object_get (window, "type", &type, NULL); if (focus_widget) { /* * If we already have a potential focus widget set this * windows's focus widget to focus_before_menu so that * it will be reported when menu item is unset. */ if (next_focus_widget) { if (GTK_IS_MENU_ITEM (next_focus_widget) && !focus_before_menu) { void *vp_focus_before_menu = &focus_before_menu; focus_before_menu = focus_widget; g_object_add_weak_pointer (G_OBJECT (focus_before_menu), vp_focus_before_menu); } return TRUE; } widget = focus_widget; } else if (type == GTK_WINDOW_POPUP) { if (GTK_IS_BIN (widget)) { GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget)); if (GTK_IS_WIDGET (child) && gtk_widget_has_grab (child)) { if (GTK_IS_MENU_SHELL (child)) { if (gtk_menu_shell_get_selected_item (GTK_MENU_SHELL (child))) { /* * We have a menu which has a menu item selected * so we do not report focus on the menu. */ return TRUE; } } widget = child; } } else /* popup window has no children; this edge case occurs in some custom code (OOo for instance) */ { return TRUE; } } else /* Widget is a non-popup toplevel with no focus children; don't emit for this case either, as it's useless */ { return TRUE; } } } else { if (next_focus_widget) { GtkWidget *toplevel; toplevel = gtk_widget_get_toplevel (next_focus_widget); if (toplevel == widget) next_focus_widget = NULL; } /* focus out */ widget = NULL; } } else { if (event->type == GDK_MOTION_NOTIFY && gtk_widget_has_focus (widget)) { if (widget == _focus_widget) { return TRUE; } } else { return TRUE; } } #ifdef GDK_WINDOWING_X11 /* * If the focus widget is a GtkSocket without a plug * then ignore the focus notification as the embedded * plug will report a focus notification. */ if (GTK_IS_SOCKET (widget) && gtk_socket_get_plug_window (GTK_SOCKET (widget)) != NULL) return TRUE; #endif /* * The widget may not yet be visible on the screen so we wait until it is. */ gail_focus_notify_when_idle (widget); return TRUE; }
static void gimp_color_config_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { GimpColorConfig *color_config = GIMP_COLOR_CONFIG (object); GError *error = NULL; switch (property_id) { case PROP_MODE: color_config->mode = g_value_get_enum (value); break; case PROP_RGB_PROFILE: gimp_color_config_set_rgb_profile (color_config, g_value_get_string (value), &error); break; case PROP_GRAY_PROFILE: gimp_color_config_set_gray_profile (color_config, g_value_get_string (value), &error); break; case PROP_CMYK_PROFILE: gimp_color_config_set_cmyk_profile (color_config, g_value_get_string (value), &error); break; case PROP_DISPLAY_PROFILE: gimp_color_config_set_display_profile (color_config, g_value_get_string (value), &error); break; case PROP_DISPLAY_PROFILE_FROM_GDK: color_config->display_profile_from_gdk = g_value_get_boolean (value); break; case PROP_PRINTER_PROFILE: gimp_color_config_set_printer_profile (color_config, g_value_get_string (value), &error); break; case PROP_DISPLAY_RENDERING_INTENT: color_config->display_intent = g_value_get_enum (value); break; case PROP_DISPLAY_USE_BPC: color_config->display_use_black_point_compensation = g_value_get_boolean (value); break; case PROP_SIMULATION_RENDERING_INTENT: color_config->simulation_intent = g_value_get_enum (value); break; case PROP_SIMULATION_USE_BPC: color_config->simulation_use_black_point_compensation = g_value_get_boolean (value); break; case PROP_SIMULATION_GAMUT_CHECK: color_config->simulation_gamut_check = g_value_get_boolean (value); break; case PROP_OUT_OF_GAMUT_COLOR: color_config->out_of_gamut_color = *(GimpRGB *) g_value_get_boxed (value); break; case PROP_DISPLAY_MODULE: g_free (color_config->display_module); color_config->display_module = g_value_dup_string (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } if (error) { g_message ("%s", error->message); g_clear_error (&error); } }
static void gimp_text_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { GimpText *text = GIMP_TEXT (object); GimpRGB *color; GimpMatrix2 *matrix; switch (property_id) { case PROP_TEXT: g_free (text->text); text->text = g_value_dup_string (value); if (text->text && text->markup) { g_free (text->markup); text->markup = NULL; g_object_notify (object, "markup"); } break; case PROP_MARKUP: g_free (text->markup); text->markup = g_value_dup_string (value); if (text->markup && text->text) { g_free (text->text); text->text = NULL; g_object_notify (object, "text"); } break; case PROP_FONT: { const gchar *font = g_value_get_string (value); g_free (text->font); if (font) { gsize len = strlen (font); if (g_str_has_suffix (font, " Not-Rotated")) len -= strlen ( " Not-Rotated"); text->font = g_strndup (font, len); } else { text->font = NULL; } } break; case PROP_FONT_SIZE: text->font_size = g_value_get_double (value); break; case PROP_UNIT: text->unit = g_value_get_int (value); break; case PROP_ANTIALIAS: text->antialias = g_value_get_boolean (value); break; case PROP_HINT_STYLE: text->hint_style = g_value_get_enum (value); break; case PROP_KERNING: text->kerning = g_value_get_boolean (value); break; case PROP_LANGUAGE: g_free (text->language); text->language = g_value_dup_string (value); break; case PROP_BASE_DIR: text->base_dir = g_value_get_enum (value); break; case PROP_COLOR: color = g_value_get_boxed (value); text->color = *color; break; case PROP_OUTLINE: text->outline = g_value_get_enum (value); break; case PROP_JUSTIFICATION: text->justify = g_value_get_enum (value); break; case PROP_INDENTATION: text->indent = g_value_get_double (value); break; case PROP_LINE_SPACING: text->line_spacing = g_value_get_double (value); break; case PROP_LETTER_SPACING: text->letter_spacing = g_value_get_double (value); break; case PROP_BOX_MODE: text->box_mode = g_value_get_enum (value); break; case PROP_BOX_WIDTH: text->box_width = g_value_get_double (value); break; case PROP_BOX_HEIGHT: text->box_height = g_value_get_double (value); break; case PROP_BOX_UNIT: text->box_unit = g_value_get_int (value); break; case PROP_TRANSFORMATION: matrix = g_value_get_boxed (value); text->transformation = *matrix; break; case PROP_OFFSET_X: text->offset_x = g_value_get_double (value); break; case PROP_OFFSET_Y: text->offset_y = g_value_get_double (value); break; case PROP_BORDER: text->border = g_value_get_int (value); break; case PROP_HINTING: text->hint_style = (g_value_get_boolean (value) ? GIMP_TEXT_HINT_STYLE_MEDIUM : GIMP_TEXT_HINT_STYLE_NONE); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }
GPParam * plug_in_args_to_params (GimpValueArray *args, gboolean full_copy) { GPParam *params; gint length; gint i; g_return_val_if_fail (args != NULL, NULL); params = g_new0 (GPParam, gimp_value_array_length (args)); length = gimp_value_array_length (args); for (i = 0; i < length; i++) { GValue *value = gimp_value_array_index (args, i); params[i].type = gimp_pdb_compat_arg_type_from_gtype (G_VALUE_TYPE (value)); switch (params[i].type) { case GIMP_PDB_INT32: if (G_VALUE_HOLDS_INT (value)) params[i].data.d_int32 = g_value_get_int (value); else if (G_VALUE_HOLDS_UINT (value)) params[i].data.d_int32 = g_value_get_uint (value); else if (G_VALUE_HOLDS_ENUM (value)) params[i].data.d_int32 = g_value_get_enum (value); else if (G_VALUE_HOLDS_BOOLEAN (value)) params[i].data.d_int32 = g_value_get_boolean (value); else { g_printerr ("%s: unhandled GIMP_PDB_INT32 type: %s\n", G_STRFUNC, g_type_name (G_VALUE_TYPE (value))); g_return_val_if_reached (params); } break; case GIMP_PDB_INT16: params[i].data.d_int16 = g_value_get_int (value); break; case GIMP_PDB_INT8: params[i].data.d_int8 = g_value_get_uint (value); break; case GIMP_PDB_FLOAT: params[i].data.d_float = g_value_get_double (value); break; case GIMP_PDB_STRING: if (full_copy) params[i].data.d_string = g_value_dup_string (value); else params[i].data.d_string = (gchar *) g_value_get_string (value); break; case GIMP_PDB_INT32ARRAY: if (full_copy) params[i].data.d_int32array = gimp_value_dup_int32array (value); else params[i].data.d_int32array = (gint32 *) gimp_value_get_int32array (value); break; case GIMP_PDB_INT16ARRAY: if (full_copy) params[i].data.d_int16array = gimp_value_dup_int16array (value); else params[i].data.d_int16array = (gint16 *) gimp_value_get_int16array (value); break; case GIMP_PDB_INT8ARRAY: if (full_copy) params[i].data.d_int8array = gimp_value_dup_int8array (value); else params[i].data.d_int8array = (guint8 *) gimp_value_get_int8array (value); break; case GIMP_PDB_FLOATARRAY: if (full_copy) params[i].data.d_floatarray = gimp_value_dup_floatarray (value); else params[i].data.d_floatarray = (gdouble *) gimp_value_get_floatarray (value); break; case GIMP_PDB_STRINGARRAY: if (full_copy) params[i].data.d_stringarray = gimp_value_dup_stringarray (value); else params[i].data.d_stringarray = (gchar **) gimp_value_get_stringarray (value); break; case GIMP_PDB_COLOR: gimp_value_get_rgb (value, ¶ms[i].data.d_color); break; case GIMP_PDB_ITEM: params[i].data.d_item = g_value_get_int (value); break; case GIMP_PDB_DISPLAY: params[i].data.d_display = g_value_get_int (value); break; case GIMP_PDB_IMAGE: params[i].data.d_image = g_value_get_int (value); break; case GIMP_PDB_LAYER: params[i].data.d_layer = g_value_get_int (value); break; case GIMP_PDB_CHANNEL: params[i].data.d_channel = g_value_get_int (value); break; case GIMP_PDB_DRAWABLE: params[i].data.d_drawable = g_value_get_int (value); break; case GIMP_PDB_SELECTION: params[i].data.d_selection = g_value_get_int (value); break; case GIMP_PDB_COLORARRAY: if (full_copy) params[i].data.d_colorarray = gimp_value_dup_colorarray (value); else params[i].data.d_colorarray = (GimpRGB *) gimp_value_get_colorarray (value); break; case GIMP_PDB_VECTORS: params[i].data.d_vectors = g_value_get_int (value); break; case GIMP_PDB_PARASITE: { GimpParasite *parasite = (full_copy ? g_value_dup_boxed (value) : g_value_get_boxed (value)); if (parasite) { params[i].data.d_parasite.name = parasite->name; params[i].data.d_parasite.flags = parasite->flags; params[i].data.d_parasite.size = parasite->size; params[i].data.d_parasite.data = parasite->data; if (full_copy) { parasite->name = NULL; parasite->flags = 0; parasite->size = 0; parasite->data = NULL; gimp_parasite_free (parasite); } } else { params[i].data.d_parasite.name = NULL; params[i].data.d_parasite.flags = 0; params[i].data.d_parasite.size = 0; params[i].data.d_parasite.data = NULL; } } break; case GIMP_PDB_STATUS: params[i].data.d_status = g_value_get_enum (value); break; case GIMP_PDB_END: break; } } return params; }
static void gtk_cell_view_set_property (GObject *object, guint param_id, const GValue *value, GParamSpec *pspec) { GtkCellView *view = GTK_CELL_VIEW (object); GtkCellViewPrivate *priv = view->priv; GtkCellArea *area; GtkCellAreaContext *context; switch (param_id) { case PROP_ORIENTATION: priv->orientation = g_value_get_enum (value); if (priv->context) gtk_cell_area_context_reset (priv->context); _gtk_orientable_set_style_classes (GTK_ORIENTABLE (object)); break; case PROP_BACKGROUND: { GdkColor color; if (!g_value_get_string (value)) gtk_cell_view_set_background_color (view, NULL); else if (gdk_color_parse (g_value_get_string (value), &color)) gtk_cell_view_set_background_color (view, &color); else g_warning ("Don't know color `%s'", g_value_get_string (value)); g_object_notify (object, "background-gdk"); } break; case PROP_BACKGROUND_GDK: gtk_cell_view_set_background_color (view, g_value_get_boxed (value)); break; case PROP_BACKGROUND_RGBA: gtk_cell_view_set_background_rgba (view, g_value_get_boxed (value)); break; case PROP_BACKGROUND_SET: view->priv->background_set = g_value_get_boolean (value); break; case PROP_MODEL: gtk_cell_view_set_model (view, g_value_get_object (value)); break; case PROP_CELL_AREA: /* Construct-only, can only be assigned once */ area = g_value_get_object (value); if (area) { if (priv->area != NULL) { g_warning ("cell-area has already been set, ignoring construct property"); g_object_ref_sink (area); g_object_unref (area); } else priv->area = g_object_ref_sink (area); } break; case PROP_CELL_AREA_CONTEXT: /* Construct-only, can only be assigned once */ context = g_value_get_object (value); if (context) { if (priv->context != NULL) { g_warning ("cell-area-context has already been set, ignoring construct property"); g_object_ref_sink (context); g_object_unref (context); } else priv->context = g_object_ref (context); } break; case PROP_DRAW_SENSITIVE: gtk_cell_view_set_draw_sensitive (view, g_value_get_boolean (value)); break; case PROP_FIT_MODEL: gtk_cell_view_set_fit_model (view, g_value_get_boolean (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; } }
/* Container marshaller function. */ static int marshal_container_marshaller (lua_State *L) { GValue *value; GITypeInfo **ti; GITypeTag tag; GITransfer transfer; gpointer data; int nret = 0; gboolean get_mode = lua_isnone (L, 3); /* Get GValue to operate on. */ lgi_type_get_repotype (L, G_TYPE_VALUE, NULL); lgi_record_2c (L, 1, &value, FALSE, FALSE, FALSE, FALSE); /* Get raw pointer from the value. */ if (get_mode) { if (G_VALUE_TYPE (value) == G_TYPE_POINTER) data = g_value_get_pointer (value); else data = g_value_get_boxed (value); } /* Get info and transfer from upvalue. */ ti = lua_touserdata (L, lua_upvalueindex (1)); tag = g_type_info_get_tag (*ti); transfer = lua_tointeger (L, lua_upvalueindex (2)); switch (tag) { case GI_TYPE_TAG_ARRAY: { GIArrayType atype = g_type_info_get_array_type (*ti); gssize size = -1; if (get_mode) { if (lua_type (L, 2) == LUA_TTABLE) { lua_getfield (L, 2, "length"); size = luaL_optinteger (L, -1, -1); lua_pop (L, 1); } marshal_2lua_array (L, *ti, GI_DIRECTION_OUT, atype, transfer, data, size, 0); } else { nret = marshal_2c_array (L, *ti, atype, &data, &size, 3, FALSE, transfer); if (lua_type (L, 2) == LUA_TTABLE) { lua_pushnumber (L, size); lua_setfield (L, 2, "length"); } } break; } case GI_TYPE_TAG_GSLIST: case GI_TYPE_TAG_GLIST: if (get_mode) marshal_2lua_list (L, *ti, GI_DIRECTION_OUT, tag, transfer, data); else nret = marshal_2c_list (L, *ti, tag, &data, 3, transfer); break; case GI_TYPE_TAG_GHASH: if (get_mode) marshal_2lua_hash (L, *ti, GI_DIRECTION_OUT, transfer, data); else nret = marshal_2c_hash (L, *ti, (GHashTable **) &data, 3, FALSE, transfer); break; default: g_assert_not_reached (); } /* Store result pointer to the value. */ if (!get_mode) { if (G_VALUE_TYPE (value) == G_TYPE_POINTER) g_value_set_pointer (value, data); else g_value_set_boxed (value, data); } /* If there are any temporary objects, try to store them into attrs.keepalive table, if it is present. */ if (!lua_isnoneornil (L, 2)) { lua_getfield (L, 2, "keepalive"); if (!lua_isnil (L, -1)) for (lua_insert (L, -nret - 1); nret > 0; nret--) { lua_pushnumber (L, lua_objlen (L, -nret - 1)); lua_insert (L, -2); lua_settable (L, -nret - 3); lua_pop (L, 1); } else lua_pop (L, nret); lua_pop (L, 1); } else lua_pop (L, nret); return get_mode ? 1 : 0; }
static void gst_gnome_vfs_sink_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { GstGnomeVFSSink *sink; GstState cur_state; sink = GST_GNOME_VFS_SINK (object); gst_element_get_state (GST_ELEMENT (sink), &cur_state, NULL, 0); if (cur_state == GST_STATE_PLAYING || cur_state == GST_STATE_PAUSED) { GST_WARNING_OBJECT (sink, "cannot set property when PAUSED or PLAYING"); return; } GST_OBJECT_LOCK (sink); switch (prop_id) { case ARG_LOCATION: { const gchar *new_location; if (sink->uri) { gnome_vfs_uri_unref (sink->uri); sink->uri = NULL; } if (sink->uri_name) { g_free (sink->uri_name); sink->uri_name = NULL; } new_location = g_value_get_string (value); if (new_location) { sink->uri_name = gst_gnome_vfs_location_to_uri_string (new_location); sink->uri = gnome_vfs_uri_new (sink->uri_name); } break; } case ARG_URI: { if (sink->uri) { gnome_vfs_uri_unref (sink->uri); sink->uri = NULL; } if (sink->uri_name) { g_free (sink->uri_name); sink->uri_name = NULL; } if (g_value_get_boxed (value)) { sink->uri = (GnomeVFSURI *) g_value_dup_boxed (value); sink->uri_name = gnome_vfs_uri_to_string (sink->uri, 0); } break; } case ARG_HANDLE: { if (sink->uri) { gnome_vfs_uri_unref (sink->uri); sink->uri = NULL; } if (sink->uri_name) { g_free (sink->uri_name); sink->uri_name = NULL; } sink->handle = g_value_get_boxed (value); break; } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } GST_OBJECT_UNLOCK (sink); }
/* Callback which gets called when a new row is selected in the acr's variable treeview. We use if to set the togglebuttons and entries to correspond to the selected row. */ static void on_acr_selection_change (GtkTreeSelection *selection, gpointer data) { struct recode_dialog *rd = data; GtkTreeModel *model = NULL; GtkTreeIter iter; GValue ov_value = {0}; GValue nv_value = {0}; struct old_value *ov = NULL; struct new_value *nv = NULL; if ( ! gtk_tree_selection_get_selected (selection, &model, &iter) ) return; gtk_tree_model_get_value (GTK_TREE_MODEL (model), &iter, COL_VALUE_OLD, &ov_value); gtk_tree_model_get_value (GTK_TREE_MODEL (model), &iter, COL_VALUE_NEW, &nv_value); ov = g_value_get_boxed (&ov_value); nv = g_value_get_boxed (&nv_value); if (nv) { switch (nv->type) { case NV_NUMERIC: { gchar *str = num_to_string (nv->v.v); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rd->toggle [BUTTON_NEW_VALUE]), TRUE); gtk_entry_set_text (GTK_ENTRY (rd->new_value_entry), str); g_free (str); } break; case NV_STRING: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rd->toggle [BUTTON_NEW_VALUE]), TRUE); gtk_entry_set_text (GTK_ENTRY (rd->new_value_entry), nv->v.s); break; case NV_SYSMIS: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rd->toggle [BUTTON_NEW_SYSMIS]), TRUE); break; case NV_COPY: gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rd->toggle [BUTTON_NEW_COPY]), TRUE); break; default: g_warning ("Invalid new value type"); break; } g_value_unset (&nv_value); } psppire_val_chooser_set_status (PSPPIRE_VAL_CHOOSER (rd->old_value_chooser), ov); }
static char * generate_syntax (const struct recode_dialog *rd) { gboolean ok; GtkTreeIter iter; gchar *text; GString *str = g_string_sized_new (100); /* Declare new string variables if applicable */ if ( rd->different && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rd->string_button))) { GHashTableIter iter; struct variable *var = NULL; struct nlp *nlp = NULL; g_hash_table_iter_init (&iter, rd->varmap); while (g_hash_table_iter_next (&iter, (void**) &var, (void**) &nlp)) { g_string_append (str, "\nSTRING "); g_string_append (str, nlp->name); g_string_append_printf (str, " (A%d).", (int) gtk_spin_button_get_value (GTK_SPIN_BUTTON (rd->width_entry) ) ); } } g_string_append (str, "\nRECODE "); psppire_var_view_append_names (PSPPIRE_VAR_VIEW (rd->variable_treeview), 0, str); g_string_append (str, "\n\t"); if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rd->convert_button))) { g_string_append (str, "(CONVERT) "); } for (ok = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (rd->value_map), &iter); ok; ok = gtk_tree_model_iter_next (GTK_TREE_MODEL (rd->value_map), &iter)) { GValue ov_value = {0}; GValue nv_value = {0}; struct old_value *ov; struct new_value *nv; gtk_tree_model_get_value (GTK_TREE_MODEL (rd->value_map), &iter, COL_VALUE_OLD, &ov_value); gtk_tree_model_get_value (GTK_TREE_MODEL (rd->value_map), &iter, COL_VALUE_NEW, &nv_value); ov = g_value_get_boxed (&ov_value); nv = g_value_get_boxed (&nv_value); g_string_append (str, "("); old_value_append_syntax (str, ov); g_string_append (str, " = "); new_value_append_syntax (str, nv); g_string_append (str, ") "); g_value_unset (&ov_value); g_value_unset (&nv_value); } if ( rd->different ) { GtkTreeIter iter; g_string_append (str, "\n\tINTO "); for (ok = psppire_var_view_get_iter_first (PSPPIRE_VAR_VIEW (rd->variable_treeview), &iter); ok; ok = psppire_var_view_get_iter_next (PSPPIRE_VAR_VIEW (rd->variable_treeview), &iter)) { struct nlp *nlp = NULL; const struct variable *var = psppire_var_view_get_variable (PSPPIRE_VAR_VIEW (rd->variable_treeview), 0, &iter); nlp = g_hash_table_lookup (rd->varmap, var); g_string_append (str, nlp->name); g_string_append (str, " "); } } g_string_append (str, "."); /* If applicable, set labels for the new variables. */ if ( rd->different ) { GHashTableIter iter; struct variable *var = NULL; struct nlp *nlp = NULL; g_hash_table_iter_init (&iter, rd->varmap); while (g_hash_table_iter_next (&iter, (void**) &var, (void**) &nlp)) { if (nlp->label) { struct string sl; ds_init_empty (&sl); syntax_gen_string (&sl, ss_cstr (nlp->label)); g_string_append_printf (str, "\nVARIABLE LABELS %s %s.", nlp->name, ds_cstr (&sl)); ds_destroy (&sl); } } } g_string_append (str, "\nEXECUTE.\n"); text = str->str; g_string_free (str, FALSE); return text; }
static void hippo_canvas_text_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { HippoCanvasText *text; text = HIPPO_CANVAS_TEXT(object); switch (prop_id) { case PROP_TEXT: { const char *new_text; new_text = g_value_get_string(value); if (!(new_text == text->text || (new_text && text->text && strcmp(new_text, text->text) == 0))) { g_free(text->text); text->text = g_strdup(new_text); hippo_canvas_item_emit_request_changed(HIPPO_CANVAS_ITEM(text)); hippo_canvas_item_emit_paint_needed(HIPPO_CANVAS_ITEM(text), 0, 0, -1, -1); } } break; case PROP_ATTRIBUTES: { PangoAttrList *attrs = g_value_get_boxed(value); if (attrs) pango_attr_list_ref(attrs); if (text->attributes) pango_attr_list_unref(text->attributes); text->attributes = attrs; hippo_canvas_item_emit_request_changed(HIPPO_CANVAS_ITEM(text)); hippo_canvas_item_emit_paint_needed(HIPPO_CANVAS_ITEM(text), 0, 0, -1, -1); } break; case PROP_MARKUP: { char *text; PangoAttrList *attrs; GError *error = NULL; if (!pango_parse_markup(g_value_get_string(value), -1, 0, &attrs, &text, NULL, &error)) { g_error("Failed to set markup: %s", error->message); return; } g_object_set(object, "text", text, "attributes", attrs, NULL); pango_attr_list_unref(attrs); g_free(text); } break; case PROP_FONT_SCALE: text->font_scale = g_value_get_double(value); hippo_canvas_item_emit_request_changed(HIPPO_CANVAS_ITEM(text)); hippo_canvas_item_emit_paint_needed(HIPPO_CANVAS_ITEM(text), 0, 0, -1, -1); break; case PROP_SIZE_MODE: text->size_mode = g_value_get_enum(value); hippo_canvas_item_emit_request_changed(HIPPO_CANVAS_ITEM(text)); hippo_canvas_item_emit_paint_needed(HIPPO_CANVAS_ITEM(text), 0, 0, -1, -1); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; } }
static void glade_eprop_attrs_populate_view (GladeEditorProperty *eprop, GtkTreeView *view) { GList *attributes, *list; GtkListStore *model = (GtkListStore *) gtk_tree_view_get_model (view); GtkTreeIter *iter; GladeAttribute *gattr; GladeProperty *property; gchar *text; property = glade_editor_property_get_property (eprop); attributes = g_value_get_boxed (glade_property_inline_value (property)); append_empty_row (model, PANGO_ATTR_FONT_DESC); append_empty_row (model, PANGO_ATTR_STYLE); append_empty_row (model, PANGO_ATTR_WEIGHT); append_empty_row (model, PANGO_ATTR_VARIANT); append_empty_row (model, PANGO_ATTR_LANGUAGE); append_empty_row (model, PANGO_ATTR_STRETCH); append_empty_row (model, PANGO_ATTR_SCALE); append_empty_row (model, PANGO_ATTR_UNDERLINE); append_empty_row (model, PANGO_ATTR_STRIKETHROUGH); append_empty_row (model, PANGO_ATTR_FOREGROUND); append_empty_row (model, PANGO_ATTR_BACKGROUND); append_empty_row (model, PANGO_ATTR_UNDERLINE_COLOR); append_empty_row (model, PANGO_ATTR_STRIKETHROUGH_COLOR); append_empty_row (model, PANGO_ATTR_GRAVITY); append_empty_row (model, PANGO_ATTR_GRAVITY_HINT); append_empty_row (model, PANGO_ATTR_SIZE); append_empty_row (model, PANGO_ATTR_ABSOLUTE_SIZE); append_empty_row (model, PANGO_ATTR_SHAPE); /* XXX Populate here ... */ for (list = attributes; list; list = list->next) { gattr = list->data; if ((iter = get_row_by_type (GTK_TREE_MODEL (model), gattr->type))) { text = glade_gtk_string_from_attr (gattr); gtk_list_store_set (GTK_LIST_STORE (model), iter, COLUMN_NAME_WEIGHT, PANGO_WEIGHT_BOLD, COLUMN_TEXT, text, COLUMN_TEXT_STYLE, PANGO_STYLE_NORMAL, COLUMN_TEXT_FG, "Black", -1); if (gattr->type == PANGO_ATTR_UNDERLINE || gattr->type == PANGO_ATTR_STRIKETHROUGH) gtk_list_store_set (GTK_LIST_STORE (model), iter, COLUMN_TOGGLE_DOWN, g_value_get_boolean (&(gattr->value)), -1); g_free (text); gtk_tree_iter_free (iter); } } }
gchar * glade_gtk_string_from_attr (GladeAttribute *gattr) { gchar *ret = NULL; gint ival; gdouble fval; GdkColor *color; switch (gattr->type) { case PANGO_ATTR_LANGUAGE: case PANGO_ATTR_FAMILY: case PANGO_ATTR_FONT_DESC: ret = g_value_dup_string (&(gattr->value)); break; case PANGO_ATTR_STYLE: case PANGO_ATTR_WEIGHT: case PANGO_ATTR_VARIANT: case PANGO_ATTR_STRETCH: case PANGO_ATTR_GRAVITY: case PANGO_ATTR_GRAVITY_HINT: /* Enums ... */ ival = g_value_get_enum (&(gattr->value)); ret = glade_utils_enum_string_from_value (G_VALUE_TYPE (&(gattr->value)), ival); break; case PANGO_ATTR_UNDERLINE: case PANGO_ATTR_STRIKETHROUGH: /* Booleans */ if (g_value_get_boolean (&(gattr->value))) ret = g_strdup_printf ("True"); else ret = g_strdup_printf ("False"); break; /* PangoAttrSize */ case PANGO_ATTR_SIZE: case PANGO_ATTR_ABSOLUTE_SIZE: /* ints */ ival = g_value_get_int (&(gattr->value)); ret = g_strdup_printf ("%d", ival); break; /* PangoAttrFloat */ case PANGO_ATTR_SCALE: { /* doubles */ gchar buf[G_ASCII_DTOSTR_BUF_SIZE]; fval = g_value_get_double (&(gattr->value)); ret = g_strdup (g_ascii_dtostr (buf, sizeof (buf), fval)); break; } /* PangoAttrColor */ case PANGO_ATTR_FOREGROUND: case PANGO_ATTR_BACKGROUND: case PANGO_ATTR_UNDERLINE_COLOR: case PANGO_ATTR_STRIKETHROUGH_COLOR: /* boxed colours */ color = g_value_get_boxed (&(gattr->value)); ret = gdk_color_to_string (color); break; /* PangoAttrShape */ case PANGO_ATTR_SHAPE: /* Unsupported for now */ break; case PANGO_ATTR_INVALID: case PANGO_ATTR_LETTER_SPACING: case PANGO_ATTR_RISE: case PANGO_ATTR_FALLBACK: default: break; } return ret; }
static PyObject * pymatecomponent_corbatypecode_from_value(const GValue *value) { return pycorba_typecode_new(g_value_get_boxed(value)); }
static gboolean async_bus_cb (GstBus *bus, GstMessage *message, gpointer user_data) { switch (GST_MESSAGE_TYPE(message)) { case GST_MESSAGE_ERROR: { GError *error = NULL; gchar *debug_str = NULL; gst_message_parse_error (message, &error, &debug_str); g_error ("Got gst message: %s %s", error->message, debug_str); } break; case GST_MESSAGE_WARNING: { GError *error = NULL; gchar *debug_str = NULL; gst_message_parse_warning (message, &error, &debug_str); g_warning ("Got gst message: %s %s", error->message, debug_str); } break; case GST_MESSAGE_ELEMENT: { const GstStructure *s = gst_message_get_structure (message); if (gst_structure_has_name (s, "farsight-error")) { gint error; const gchar *error_msg = gst_structure_get_string (s, "error-msg"); const gchar *debug_msg = gst_structure_get_string (s, "debug-msg"); g_assert (gst_structure_get_enum (s, "error-no", FS_TYPE_ERROR, &error)); if (FS_ERROR_IS_FATAL (error)) g_error ("Farsight fatal error: %d %s %s", error, error_msg, debug_msg); else g_warning ("Farsight non-fatal error: %d %s %s", error, error_msg, debug_msg); } else if (gst_structure_has_name (s, "farsight-new-local-candidate")) { const GValue *val = gst_structure_get_value (s, "candidate"); FsCandidate *cand = NULL; g_assert (val); cand = g_value_get_boxed (val); g_print ("New candidate: %s %d\n", cand->ip, cand->port); } else if (gst_structure_has_name (s, "farsight-local-candidates-prepared")) { g_print ("Local candidates prepared\n"); } else if (gst_structure_has_name (s, "farsight-recv-codecs-changed")) { const GValue *val = gst_structure_get_value (s, "codecs"); GList *codecs = NULL; g_assert (val); codecs = g_value_get_boxed (val); g_print ("Recv codecs changed:\n"); for (; codecs; codecs = g_list_next (codecs)) { FsCodec *codec = codecs->data; gchar *tmp = fs_codec_to_string (codec); g_print ("%s\n", tmp); g_free (tmp); } } else if (gst_structure_has_name (s, "farsight-send-codec-changed")) { const GValue *val = gst_structure_get_value (s, "codec"); FsCodec *codec = NULL; gchar *tmp; g_assert (val); codec = g_value_get_boxed (val); tmp = fs_codec_to_string (codec); g_print ("Send codec changed: %s\n", tmp); g_free (tmp); } } break; default: break; } return TRUE; }
static PyObject * pymatecomponent_corbaobject_from_value(const GValue *value) { return pycorba_object_new((CORBA_Object)g_value_get_boxed(value)); }
gint64 gimp_g_value_get_memsize (GValue *value) { gint64 memsize = 0; if (! value) return 0; if (G_VALUE_HOLDS_STRING (value)) { memsize += gimp_string_get_memsize (g_value_get_string (value)); } else if (G_VALUE_HOLDS_BOXED (value)) { if (GIMP_VALUE_HOLDS_RGB (value)) { memsize += sizeof (GimpRGB); } else if (GIMP_VALUE_HOLDS_MATRIX2 (value)) { memsize += sizeof (GimpMatrix2); } else if (GIMP_VALUE_HOLDS_PARASITE (value)) { memsize += gimp_parasite_get_memsize (g_value_get_boxed (value), NULL); } else if (GIMP_VALUE_HOLDS_ARRAY (value) || GIMP_VALUE_HOLDS_INT8_ARRAY (value) || GIMP_VALUE_HOLDS_INT16_ARRAY (value) || GIMP_VALUE_HOLDS_INT32_ARRAY (value) || GIMP_VALUE_HOLDS_FLOAT_ARRAY (value)) { GimpArray *array = g_value_get_boxed (value); if (array) memsize += (sizeof (GimpArray) + array->static_data ? 0 : array->length); } else if (GIMP_VALUE_HOLDS_STRING_ARRAY (value)) { GimpArray *array = g_value_get_boxed (value); if (array) { memsize += sizeof (GimpArray); if (! array->static_data) { gchar **tmp = (gchar **) array->data; gint i; memsize += array->length * sizeof (gchar *); for (i = 0; i < array->length; i++) memsize += gimp_string_get_memsize (tmp[i]); } } } else { g_printerr ("%s: unhandled boxed value type: %s\n", G_STRFUNC, G_VALUE_TYPE_NAME (value)); } } else if (G_VALUE_HOLDS_OBJECT (value)) { g_printerr ("%s: unhandled object value type: %s\n", G_STRFUNC, G_VALUE_TYPE_NAME (value)); } return memsize + sizeof (GValue); }
gboolean cd_NetworkMonitor_get_active_connection_info (void) { cd_debug ("%s ()", __func__); //\_____________ on reset tout. myData.bWiredExt = myData.bWirelessExt = FALSE; g_free (myData.cDevice); myData.cDevice = NULL; g_free (myData.cInterface); myData.cInterface = NULL; g_free (myData.cAccessPoint); myData.cAccessPoint = NULL; _reset_proxy (myData.dbus_proxy_ActiveConnection); _reset_proxy (myData.dbus_proxy_ActiveConnection_prop); _reset_proxy (myData.dbus_proxy_Device); _reset_proxy (myData.dbus_proxy_Device_prop); _reset_proxy (myData.dbus_proxy_ActiveAccessPoint); _reset_proxy (myData.dbus_proxy_ActiveAccessPoint_prop); _reset_proxy (myData.dbus_proxy_WirelessDevice); _reset_proxy (myData.dbus_proxy_WiredDevice); DBusGProxy *dbus_proxy_ActiveConnection_prop = NULL; DBusGProxy *dbus_proxy_Device_prop = NULL; uint j,k; GPtrArray *paActiveConnections = NULL; gchar *cActiveConnection, *cDevice, *cAccessPointPath, *cConnection; const gchar *cServiceName; //\_____________ On recupere la liste des connexions actives (ce sont les configs tout-en-un de NM qui sont actuellement utilisees). paActiveConnections = (GPtrArray*) cairo_dock_dbus_get_property_as_boxed (myData.dbus_proxy_NM_prop, "org.freedesktop.NetworkManager", "ActiveConnections"); cd_debug ("%d connections", paActiveConnections->len); for (j=0; j < paActiveConnections->len; j++) { cActiveConnection = (gchar *)g_ptr_array_index(paActiveConnections,j); cd_debug ("Network-Monitor : Active Connection path : %s", cActiveConnection); // on recupere les proprietes de la connexion. dbus_proxy_ActiveConnection_prop = cairo_dock_create_new_system_proxy ( "org.freedesktop.NetworkManager", cActiveConnection, "org.freedesktop.DBus.Properties"); GHashTable *props = cairo_dock_dbus_get_all_properties (dbus_proxy_ActiveConnection_prop, "org.freedesktop.NetworkManager.Connection.Active"); if (props == NULL) { g_object_unref (dbus_proxy_ActiveConnection_prop); continue; } // on regarde si c'est la connexion par defaut. GValue *v = g_hash_table_lookup (props, "Default"); if (!v || !G_VALUE_HOLDS_BOOLEAN (v) || ! g_value_get_boolean (v)) { g_hash_table_unref (props); g_object_unref (dbus_proxy_ActiveConnection_prop); continue; } cd_debug (" c'est la connexion par defaut\n"); myData.cActiveConnection = g_strdup (cActiveConnection); // on recupere le SpecificObject qui contient le point d'acces courant. cAccessPointPath=NULL; v = g_hash_table_lookup (props, "SpecificObject"); if (v && G_VALUE_HOLDS_BOXED (v)) { cAccessPointPath = g_value_get_boxed (v); cd_debug (" cAccessPointPath : %s", cAccessPointPath); } // on recupere le nom du service qui fournit cette connexion. cServiceName=NULL; v = g_hash_table_lookup (props, "ServiceName"); if (v && G_VALUE_HOLDS_STRING (v)) { cServiceName = g_value_get_string (v); cd_debug (" cServiceName : %s", cServiceName); } // on recupere le chemin de la connection. cConnection=NULL; v = g_hash_table_lookup (props, "Connection"); if (v && G_VALUE_HOLDS (v, DBUS_TYPE_G_OBJECT_PATH)) { cConnection = g_value_get_boxed (v); cd_debug (" cConnectionPath : %s", cConnection); } // on parcourt la liste des devices associes. v = g_hash_table_lookup (props, "Devices"); if (v && G_VALUE_HOLDS_BOXED (v)) { GPtrArray *paDevices = g_value_get_boxed (v); cd_debug (" %d devices", paDevices->len); for (k=0; k < paDevices->len; k++) { // on recupere le device. cDevice = (gchar *)g_ptr_array_index(paDevices,k); cd_debug (" device path : %s", cDevice); dbus_proxy_Device_prop = cairo_dock_create_new_system_proxy ( "org.freedesktop.NetworkManager", cDevice, "org.freedesktop.DBus.Properties"); // on regarde son type. guint iDeviceType = cairo_dock_dbus_get_property_as_uint (dbus_proxy_Device_prop, "org.freedesktop.NetworkManager.Device", "DeviceType"); // 1 : ethernet, 2 : wifi cd_debug (" device type : %d", iDeviceType); if (iDeviceType != 1 && iDeviceType != 2) // ne nous insteresse pas. { g_object_unref (dbus_proxy_Device_prop); continue; } // on recupere son interface. gchar *cInterface = cairo_dock_dbus_get_property_as_string (dbus_proxy_Device_prop, "org.freedesktop.NetworkManager.Device", "Interface"); cd_debug (" interface :%s", cInterface); // on garde toutes les infos en memoire. myData.cInterface = cInterface; myData.cDevice = g_strdup(cDevice); myData.cServiceName = g_strdup (cServiceName); myData.cConnection = g_strdup (cConnection); myData.dbus_proxy_ActiveConnection_prop = dbus_proxy_ActiveConnection_prop; myData.dbus_proxy_ActiveConnection = cairo_dock_create_new_system_proxy ( "org.freedesktop.NetworkManager", myData.cActiveConnection, "org.freedesktop.NetworkManager.Connection.Active"); dbus_g_proxy_add_signal(myData.dbus_proxy_ActiveConnection, "PropertiesChanged", CD_DBUS_TYPE_HASH_TABLE, G_TYPE_INVALID); dbus_g_proxy_connect_signal(myData.dbus_proxy_ActiveConnection, "PropertiesChanged", G_CALLBACK(onChangeActiveConnectionProperties), NULL, NULL); myData.dbus_proxy_Device_prop = dbus_proxy_Device_prop; myData.dbus_proxy_Device = cairo_dock_create_new_system_proxy ( "org.freedesktop.NetworkManager", cDevice, "org.freedesktop.NetworkManager.Device"); if (cAccessPointPath && strncmp (cAccessPointPath, "/org/freedesktop/NetworkManager/AccessPoint/", 44) == 0) { myData.cAccessPoint = g_strdup (cAccessPointPath); myData.dbus_proxy_ActiveAccessPoint_prop = cairo_dock_create_new_system_proxy ( "org.freedesktop.NetworkManager", cAccessPointPath, "org.freedesktop.DBus.Properties"); myData.dbus_proxy_ActiveAccessPoint = cairo_dock_create_new_system_proxy ( "org.freedesktop.NetworkManager", cAccessPointPath, "org.freedesktop.NetworkManager.AccessPoint"); dbus_g_proxy_add_signal(myData.dbus_proxy_ActiveAccessPoint, "PropertiesChanged", CD_DBUS_TYPE_HASH_TABLE, G_TYPE_INVALID); dbus_g_proxy_connect_signal(myData.dbus_proxy_ActiveAccessPoint, "PropertiesChanged", G_CALLBACK(onChangeAccessPointProperties), NULL, NULL); } if (iDeviceType == 1) { cd_debug (" => Network-Monitor : Connexion filaire\n"); myData.bWiredExt = TRUE; // on se connecte au changement de la propriete Carrier. myData.dbus_proxy_WiredDevice = cairo_dock_create_new_system_proxy ( "org.freedesktop.NetworkManager", myData.cDevice, "org.freedesktop.NetworkManager.Device.Wired"); dbus_g_proxy_add_signal(myData.dbus_proxy_WiredDevice, "PropertiesChanged", CD_DBUS_TYPE_HASH_TABLE, G_TYPE_INVALID); dbus_g_proxy_connect_signal(myData.dbus_proxy_WiredDevice, "PropertiesChanged", G_CALLBACK(onChangeWiredDeviceProperties), NULL, NULL); // on recupere les proprietes de la carte reseau, et de son etat connecte ou non. cd_NetworkMonitor_get_wired_connection_infos(); } else { cd_debug (" => Network-Monitor : Connexion sans fil\n"); myData.bWirelessExt = TRUE; // on se connecte au changement de la propriete ActiveAccessPoint. myData.dbus_proxy_WirelessDevice = cairo_dock_create_new_system_proxy ( "org.freedesktop.NetworkManager", myData.cDevice, "org.freedesktop.NetworkManager.Device.Wireless"); dbus_g_proxy_add_signal(myData.dbus_proxy_WirelessDevice, "PropertiesChanged", CD_DBUS_TYPE_HASH_TABLE, G_TYPE_INVALID); dbus_g_proxy_connect_signal(myData.dbus_proxy_WirelessDevice, "PropertiesChanged", G_CALLBACK(onChangeWirelessDeviceProperties), NULL, NULL); // Recuperation de l'AP active. cd_NetworkMonitor_get_wireless_connection_infos(); // Calcul de la qualite du signal cd_NetworkMonitor_quality(); } cd_NetworkMonitor_draw_icon (); break ; } // fin de la liste des devices. } g_hash_table_unref (props); break; // on prend la premierr connexion. } g_ptr_array_free(paActiveConnections,TRUE); return (myData.bWiredExt || myData.bWirelessExt); }
static void xfce_cell_renderer_pixbuf_on_demand_set_property(GObject *object, guint param_id, const GValue *value, GParamSpec *pspec) { XfceCellRendererPixbufOnDemand *aXfceCellRendererPixbufOnDemand; XfceCellRendererPixbufOnDemandPrivate *priv; gchar const *s; GdkPixbuf *pix; aXfceCellRendererPixbufOnDemand = XFCE_CELL_RENDERER_PIXBUF_ON_DEMAND(object); priv = aXfceCellRendererPixbufOnDemand->priv; switch (param_id) { case PATH_PROP: if (priv->path) { g_free (priv->path); priv->path = NULL; } /*g_value_set_string (value, priv->); */ s = g_value_get_string (value); if (s) priv->path = g_strdup (s); break; case LOADED_PROP: priv->loaded = g_value_get_boolean (value); break; case ITER_PROP: if (priv->iter) { gtk_tree_iter_free (priv->iter); priv->iter = NULL; } priv->iter = g_memdup (g_value_get_boxed (value), sizeof(GtkTreeIter)); break; case FALLBACK_PIXBUF_PROP: if (priv->fallback_pixbuf) { g_object_unref (G_OBJECT (priv->fallback_pixbuf)); priv->fallback_pixbuf = NULL; } priv->fallback_pixbuf = GDK_PIXBUF (g_value_dup_object (value)); break; case PIXBUF_PROP: if (priv->pixbuf) { g_object_unref (G_OBJECT (priv->pixbuf)); priv->pixbuf = NULL; } /*pix = g_value_get_object (value);*/ /* FIXME use dup_object instead of _copy? */ /*if (pix) priv->pixbuf = gdk_pixbuf_copy (pix); */ priv->pixbuf = GDK_PIXBUF (g_value_dup_object (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); break; } }
extern void CommandExternal(char *sz) { #if !HAVE_SOCKETS outputl(_("This installation of GNU Backgammon was compiled without\n" "socket support, and does not implement external controllers.")); #else int h, hPeer, cb; struct sockaddr *psa; char szCommand[256]; char *szResponse = NULL; struct sockaddr_in saRemote; socklen_t saLen; scancontext scanctx; int fExit; int fRestart = TRUE; int retval; sz = NextToken(&sz); if (!sz || !*sz) { outputl(_("You must specify the name of the socket to the external controller.")); return; } memset(&scanctx, 0, sizeof(scanctx)); ExtInitParse(&scanctx.scanner); listenloop: { fExit = FALSE; scanctx.fDebug = FALSE; scanctx.fNewInterface = FALSE; if ((h = ExternalSocket(&psa, &cb, sz)) < 0) { SockErr(sz); ExtDestroyParse(scanctx.scanner); return; } if (bind(h, psa, cb) < 0) { SockErr(sz); closesocket(h); free(psa); ExtDestroyParse(scanctx.scanner); return; } free(psa); if (listen(h, 1) < 0) { SockErr("listen"); closesocket(h); ExternalUnbind(sz); ExtDestroyParse(scanctx.scanner); return; } outputf(_("Waiting for a connection from %s...\n"), sz); outputx(); ProcessEvents(); /* Must set length when using windows */ saLen = sizeof(struct sockaddr); while ((hPeer = accept(h, (struct sockaddr *) &saRemote, &saLen)) < 0) { if (errno == EINTR) { ProcessEvents(); if (fInterrupt) { closesocket(h); ExternalUnbind(sz); ExtDestroyParse(scanctx.scanner); return; } continue; } SockErr("accept"); closesocket(h); ExternalUnbind(sz); ExtDestroyParse(scanctx.scanner); return; } closesocket(h); ExternalUnbind(sz); /* print info about remove client */ outputf(_("Accepted connection from %s.\n"), inet_ntoa(saRemote.sin_addr)); outputx(); ProcessEvents(); while (!fExit && !(retval = ExternalRead(hPeer, szCommand, sizeof(szCommand)))) { if ((ExtParse(&scanctx, szCommand)) == 0) { /* parse error */ szResponse = scanctx.szError; } else { ProcessedFIBSBoard processedBoard; GValue *optionsmapgv; GValue *boarddatagv; GString *dbgStr; int anScore[2]; int fCrawford, fJacoby; char *asz[7] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL }; char szBoard[10000]; char **aszLines; char **aszLinesOrig; char *szMatchID; gchar *szOptStr; switch (scanctx.ct) { case COMMAND_HELP: szResponse = g_strdup("\tNo help information available\n"); break; case COMMAND_SET: szOptStr = g_value_get_gstring_gchar(g_list_nth_data(scanctx.pCmdData, 0)); if (g_ascii_strcasecmp(szOptStr, KEY_STR_DEBUG) == 0) { scanctx.fDebug = g_value_get_int(g_list_nth_data(scanctx.pCmdData, 1)); szResponse = g_strdup_printf("Debug output %s\n", scanctx.fDebug ? "ON" : "OFF"); } else if (g_ascii_strcasecmp(szOptStr, KEY_STR_NEWINTERFACE) == 0) { scanctx.fNewInterface = g_value_get_int(g_list_nth_data(scanctx.pCmdData, 1)); szResponse = g_strdup_printf("New interface %s\n", scanctx.fNewInterface ? "ON" : "OFF"); } else { szResponse = g_strdup_printf("Error: set option '%s' not supported\n", szOptStr); } g_list_gv_boxed_free(scanctx.pCmdData); break; case COMMAND_VERSION: szResponse = g_strdup("Interface: " EXTERNAL_INTERFACE_VERSION "\n" "RFBF: " RFBF_VERSION_SUPPORTED "\n" "Engine: " WEIGHTS_VERSION "\n" "Software: " VERSION "\n"); break; case COMMAND_NONE: szResponse = g_strdup("Error: no command given\n"); break; case COMMAND_FIBSBOARD: case COMMAND_EVALUATION: if (scanctx.fDebug) { optionsmapgv = (GValue *) g_list_nth_data(g_value_get_boxed(scanctx.pCmdData), 1); boarddatagv = (GValue *) g_list_nth_data(g_value_get_boxed(scanctx.pCmdData), 0); dbgStr = g_string_new(DEBUG_PREFIX); g_value_tostring(dbgStr, optionsmapgv, 0); g_string_append(dbgStr, "\n" DEBUG_PREFIX); g_value_tostring(dbgStr, boarddatagv, 0); g_string_append(dbgStr, "\n" DEBUG_PREFIX "\n"); ExternalWrite(hPeer, dbgStr->str, strlen(dbgStr->str)); ProcessFIBSBoardInfo(&scanctx.bi, &processedBoard); anScore[0] = processedBoard.nScoreOpp; anScore[1] = processedBoard.nScore; /* If the session isn't using Crawford rule, set crawford flag to false */ fCrawford = scanctx.fCrawfordRule ? processedBoard.fCrawford : FALSE; /* Set the Jacoby flag appropriately from the external interface settings */ fJacoby = scanctx.fJacobyRule; szMatchID = MatchID((unsigned int *) processedBoard.anDice, 1, processedBoard.nResignation, processedBoard.fDoubled, 1, processedBoard.fCubeOwner, fCrawford, processedBoard.nMatchTo, anScore, processedBoard.nCube, fJacoby, GAME_PLAYING); DrawBoard(szBoard, (ConstTanBoard) & processedBoard.anBoard, 1, asz, szMatchID, 15); aszLines = g_strsplit(&szBoard[0], "\n", 32); aszLinesOrig = aszLines; while (*aszLines) { ExternalWrite(hPeer, DEBUG_PREFIX, strlen(DEBUG_PREFIX)); ExternalWrite(hPeer, *aszLines, strlen(*aszLines)); ExternalWrite(hPeer, "\n", 1); aszLines++; } dbgStr = g_string_assign(dbgStr, ""); g_string_append_printf(dbgStr, DEBUG_PREFIX "X is %s, O is %s\n", processedBoard.szPlayer, processedBoard.szOpp); if (processedBoard.nMatchTo) { g_string_append_printf(dbgStr, DEBUG_PREFIX "Match Play %s Crawford Rule\n", scanctx.fCrawfordRule ? "with" : "without"); g_string_append_printf(dbgStr, DEBUG_PREFIX "Score: %d-%d/%d%s, ", processedBoard.nScore, processedBoard.nScoreOpp, processedBoard.nMatchTo, fCrawford ? "*" : ""); } else { g_string_append_printf(dbgStr, DEBUG_PREFIX "Money Session %s Jacoby Rule, %s Beavers\n", scanctx.fJacobyRule ? "with" : "without", scanctx.fBeavers ? "with" : "without"); g_string_append_printf(dbgStr, DEBUG_PREFIX "Score: %d-%d, ", processedBoard.nScore, processedBoard.nScoreOpp); } g_string_append_printf(dbgStr, "Roll: %d%d\n", processedBoard.anDice[0], processedBoard.anDice[1]); g_string_append_printf(dbgStr, DEBUG_PREFIX "CubeOwner: %d, Cube: %d, Turn: %c, Doubled: %d, Resignation: %d\n", processedBoard.fCubeOwner, processedBoard.nCube, 'X', processedBoard.fDoubled, processedBoard.nResignation); g_string_append(dbgStr, DEBUG_PREFIX "\n"); ExternalWrite(hPeer, dbgStr->str, strlen(dbgStr->str)); g_string_free(dbgStr, TRUE); g_strfreev(aszLinesOrig); } g_value_unsetfree(scanctx.pCmdData); if (scanctx.ct == COMMAND_EVALUATION) szResponse = ExtEvaluation(&scanctx); else szResponse = ExtFIBSBoard(&scanctx); break; case COMMAND_EXIT: closesocket(hPeer); fExit = TRUE; break; default: szResponse = g_strdup("Unsupported Command\n"); } unset_scan_context(&scanctx, FALSE); } if (szResponse) { if (ExternalWrite(hPeer, szResponse, strlen(szResponse))) break; g_free(szResponse); szResponse = NULL; } } /* Interrupted : get out of listen loop */ if (retval == -2) { ProcessEvents(); fRestart = FALSE; } closesocket(hPeer); if (szResponse) g_free(szResponse); szResponse = NULL; scanctx.szError = NULL; } if (fRestart) goto listenloop; unset_scan_context(&scanctx, TRUE); #endif }
QT_BEGIN_NAMESPACE //internal static void addTagToMap(const GstTagList *list, const gchar *tag, gpointer user_data) { QMap<QByteArray, QVariant> *map = reinterpret_cast<QMap<QByteArray, QVariant>* >(user_data); GValue val; val.g_type = 0; gst_tag_list_copy_value(&val,list,tag); switch( G_VALUE_TYPE(&val) ) { case G_TYPE_STRING: { const gchar *str_value = g_value_get_string(&val); map->insert(QByteArray(tag), QString::fromUtf8(str_value)); break; } case G_TYPE_INT: map->insert(QByteArray(tag), g_value_get_int(&val)); break; case G_TYPE_UINT: map->insert(QByteArray(tag), g_value_get_uint(&val)); break; case G_TYPE_LONG: map->insert(QByteArray(tag), qint64(g_value_get_long(&val))); break; case G_TYPE_BOOLEAN: map->insert(QByteArray(tag), g_value_get_boolean(&val)); break; case G_TYPE_CHAR: #if GLIB_CHECK_VERSION(2,32,0) map->insert(QByteArray(tag), g_value_get_schar(&val)); #else map->insert(QByteArray(tag), g_value_get_char(&val)); #endif break; case G_TYPE_DOUBLE: map->insert(QByteArray(tag), g_value_get_double(&val)); break; default: // GST_TYPE_DATE is a function, not a constant, so pull it out of the switch #if GST_CHECK_VERSION(1,0,0) if (G_VALUE_TYPE(&val) == G_TYPE_DATE) { const GDate *date = (const GDate *)g_value_get_boxed(&val); #else if (G_VALUE_TYPE(&val) == GST_TYPE_DATE) { const GDate *date = gst_value_get_date(&val); #endif if (g_date_valid(date)) { int year = g_date_get_year(date); int month = g_date_get_month(date); int day = g_date_get_day(date); map->insert(QByteArray(tag), QDate(year,month,day)); if (!map->contains("year")) map->insert("year", year); } } else if (G_VALUE_TYPE(&val) == GST_TYPE_FRACTION) { int nom = gst_value_get_fraction_numerator(&val); int denom = gst_value_get_fraction_denominator(&val); if (denom > 0) { map->insert(QByteArray(tag), double(nom)/denom); } } break; } g_value_unset(&val); } /*! Convert GstTagList structure to QMap<QByteArray, QVariant>. Mapping to int, bool, char, string, fractions and date are supported. Fraction values are converted to doubles. */ QMap<QByteArray, QVariant> QGstUtils::gstTagListToMap(const GstTagList *tags) { QMap<QByteArray, QVariant> res; gst_tag_list_foreach(tags, addTagToMap, &res); return res; }
static void list_update_property (const gchar *property, GValue *value, gpointer user_data) { CarrickList *list = user_data; CarrickListPrivate *priv = list->priv; if (g_str_equal (property, "OfflineMode")) { priv->offline_mode = g_value_get_boolean (value); } else if (g_str_equal (property, "AvailableTechnologies")) { gchar **tech = g_value_get_boxed (value); gint i; priv->have_wifi = FALSE; priv->have_ethernet = FALSE; priv->have_threeg = FALSE; priv->have_wimax = FALSE; priv->have_bluetooth = FALSE; for (i = 0; i < g_strv_length (tech); i++) { if (g_str_equal ("wifi", *(tech + i))) priv->have_wifi = TRUE; else if (g_str_equal ("wimax", *(tech + i))) priv->have_wimax = TRUE; else if (g_str_equal ("bluetooth", *(tech + i))) priv->have_bluetooth = TRUE; else if (g_str_equal ("cellular", *(tech + i))) priv->have_threeg = TRUE; else if (g_str_equal ("ethernet", *(tech + i))) priv->have_ethernet = TRUE; } } else if (g_str_equal (property, "EnabledTechnologies")) { gchar **tech = g_value_get_boxed (value); gint i; priv->wifi_enabled = FALSE; priv->ethernet_enabled = FALSE; priv->threeg_enabled = FALSE; priv->wimax_enabled = FALSE; priv->bluetooth_enabled = FALSE; for (i = 0; i < g_strv_length (tech); i++) { if (g_str_equal ("wifi", *(tech + i))) priv->wifi_enabled = TRUE; else if (g_str_equal ("wimax", *(tech + i))) priv->wimax_enabled = TRUE; else if (g_str_equal ("bluetooth", *(tech + i))) priv->bluetooth_enabled = TRUE; else if (g_str_equal ("cellular", *(tech + i))) priv->threeg_enabled = TRUE; else if (g_str_equal ("ethernet", *(tech + i))) priv->ethernet_enabled = TRUE; } } }
// ---------------------------------------------------------------------------- // Handle the "tag" message void GStreamerImportFileHandle::OnTag(GstAppSink * WXUNUSED(appsink), GstTagList *tags) { // Collect all of the associates tags for (guint i = 0, icnt = gst_tag_list_n_tags(tags); i < icnt; i++) { wxString string; // Get tag name...should always succeed...no need to release const gchar *name = gst_tag_list_nth_tag_name(tags, i); if (!name) { continue; } // For each tag, determine its type and retrieve if possible for (guint j = 0, jcnt = gst_tag_list_get_tag_size(tags, name); j < jcnt; j++) { const GValue *val; val = gst_tag_list_get_value_index(tags, name, j); if (G_VALUE_HOLDS_STRING(val)) { string = wxString::FromUTF8(g_value_get_string(val)); } else if (G_VALUE_HOLDS_UINT(val)) { string.Printf(wxT("%u"), (unsigned int) g_value_get_uint(val)); } else if (G_VALUE_HOLDS_DOUBLE(val)) { string.Printf(wxT("%g"), g_value_get_double(val)); } else if (G_VALUE_HOLDS_BOOLEAN(val)) { string = g_value_get_boolean(val) ? wxT("true") : wxT("false"); } else if (GST_VALUE_HOLDS_DATE_TIME(val)) { GstDateTime *dt = (GstDateTime *) g_value_get_boxed(val); gchar *str = gst_date_time_to_iso8601_string(dt); string = wxString::FromUTF8(str).c_str(); g_free(str); } else if (G_VALUE_HOLDS(val, G_TYPE_DATE)) { gchar *str = gst_value_serialize(val); string = wxString::FromUTF8(str).c_str(); g_free(str); } else { wxLogMessage(wxT("Tag %s has unhandled type: %s"), wxString::FromUTF8(name).c_str(), wxString::FromUTF8(G_VALUE_TYPE_NAME(val)).c_str()); continue; } // Translate known tag names wxString tag; if (strcmp(name, GST_TAG_TITLE) == 0) { tag = TAG_TITLE; } else if (strcmp(name, GST_TAG_ARTIST) == 0) { tag = TAG_ARTIST; } else if (strcmp(name, GST_TAG_ALBUM) == 0) { tag = TAG_ALBUM; } else if (strcmp(name, GST_TAG_TRACK_NUMBER) == 0) { tag = TAG_TRACK; } else if (strcmp(name, GST_TAG_DATE) == 0) { tag = TAG_YEAR; } else if (strcmp(name, GST_TAG_GENRE) == 0) { tag = TAG_GENRE; } else if (strcmp(name, GST_TAG_COMMENT) == 0) { tag = TAG_COMMENTS; } else { tag = wxString::FromUTF8(name).c_str(); } if (jcnt > 1) { tag.Printf(wxT("%s:%d"), tag.c_str(), j); } // Store the tag mTags.SetTag(tag, string); } } }
static void udisks_device_added(DBusGProxy *proxy, const char *object_path, gpointer user_data) { GHashTable *device_props; GValue *val; const char *device; int icon; gboolean mountable; gboolean busy; if ((device_props = _get_device_props(proxy, object_path)) == NULL) return; if (!_device_should_display(device_props)) goto out; if ((val = g_hash_table_lookup(device_props, "DeviceFilePresentation")) == NULL || (device = g_value_get_string(val)) == NULL) goto out; mountable = _device_should_mount(device_props); icon = WMVM_ICON_UNKNOWN; if ((val = g_hash_table_lookup(device_props, "DeviceIsOpticalDisc")) != NULL && g_value_get_boolean(val) == TRUE) { if (mountable == FALSE && (val = g_hash_table_lookup(device_props, "OpticalDiscNumAudioTracks")) != NULL && g_value_get_uint(val) > 0) { icon = WMVM_ICON_CDAUDIO; } else { const char *disk_type = NULL; if ((val = g_hash_table_lookup(device_props, "DriveMedia")) != NULL) disk_type = g_value_get_string(val); #define DISK_IS(t) disk_type != NULL && strcmp(disk_type, (t)) == 0 if (DISK_IS("optical_cd")) { icon = WMVM_ICON_CDROM; } else if (DISK_IS("optical_cd_r")) { icon = WMVM_ICON_CDR; } else if (DISK_IS("optical_cd_rw")) { icon = WMVM_ICON_CDRW; } else if (DISK_IS("optical_dvd")) { icon = WMVM_ICON_DVDROM; } else if (DISK_IS("optical_dvd_r")) { icon = WMVM_ICON_DVDR; } else if (DISK_IS("optical_dvd_rw")) { icon = WMVM_ICON_DVDRW; } else if (DISK_IS("optical_dvd_ram")) { icon = WMVM_ICON_DVDRAM; } else if (DISK_IS("optical_dvd_plus_r")) { icon = WMVM_ICON_DVDPLUSR; } else if (DISK_IS("optical_dvd_plus_rw")) { icon = WMVM_ICON_DVDPLUSRW; } else if (DISK_IS("optical_dvd_plus_r_dl")) { icon = WMVM_ICON_DVDPLUSR; } else if (DISK_IS("optical_dvd_plus_rw_dl")) { icon = WMVM_ICON_DVDPLUSRW; } else if (DISK_IS("optical_bd")) { icon = WMVM_ICON_BD; } else if (DISK_IS("optical_bd_r")) { icon = WMVM_ICON_BDR; } else if (DISK_IS("optical_bd_re")) { icon = WMVM_ICON_BDRE; } else if (DISK_IS("optical_hddvd")) { icon = WMVM_ICON_HDDVD; } else if (DISK_IS("optical_hddvd_r")) { icon = WMVM_ICON_HDDVDR; } else if (DISK_IS("optical_hddvd_rw")) { icon = WMVM_ICON_HDDVDRW; } #undef DISK_IS } } else { GHashTable *drive_props; const char *drive_path; const char *media_type; drive_path = NULL; if ((val = g_hash_table_lookup(device_props, "PartitionSlave")) != NULL) { drive_path = g_value_get_boxed(val); } if (drive_path == NULL || (drive_props = _get_device_props(proxy, drive_path)) == NULL) drive_props = device_props; media_type = NULL; if ((val = g_hash_table_lookup(drive_props, "DriveMedia")) != NULL) media_type = g_value_get_string(val); #define MEDIA_IS(t) media_type != NULL && strcmp(media_type, (t)) == 0 if (MEDIA_IS("flash")) { icon = WMVM_ICON_CARD_CF; } else if (MEDIA_IS("flash_cf")) { icon = WMVM_ICON_CARD_CF; } else if (MEDIA_IS("flash_ms")) { icon = WMVM_ICON_CARD_MS; } else if (MEDIA_IS("flash_sm")) { icon = WMVM_ICON_CARD_SM; } else if (MEDIA_IS("flash_sd")) { icon = WMVM_ICON_CARD_SDMMC; } else if (MEDIA_IS("flash_sdhc")) { icon = WMVM_ICON_CARD_SDMMC; } else if (MEDIA_IS("flash_mmc")) { icon = WMVM_ICON_CARD_SDMMC; } else { const char *drive_iface; drive_iface = NULL; if ((val = g_hash_table_lookup(drive_props, "DriveConnectionInterface")) != NULL) drive_iface = g_value_get_string(val); if ((val = g_hash_table_lookup(drive_props, "DeviceIsRemovable")) != NULL) { if (g_value_get_boolean(val) == TRUE) { icon = WMVM_ICON_REMOVABLE; if (drive_iface != NULL && strcmp(drive_iface, "usb")) icon = WMVM_ICON_REMOVABLE_USB; else if (drive_iface != NULL && strcmp(drive_iface, "firewire")) icon = WMVM_ICON_REMOVABLE_1394; } else { icon = WMVM_ICON_HARDDISK; if (drive_iface != NULL && strcmp(drive_iface, "usb")) icon = WMVM_ICON_HARDDISK_USB; else if (drive_iface != NULL && strcmp(drive_iface, "firewire")) icon = WMVM_ICON_HARDDISK_1394; } } } #undef MEDIA_IS if (drive_props != device_props) g_hash_table_unref(drive_props); } wmvm_add_volume(object_path, device, icon, mountable); udisks_device_changed(proxy, object_path, user_data); busy = FALSE; if ((val = g_hash_table_lookup(device_props, "JobInProgress")) != NULL) busy = g_value_get_boolean(val); wmvm_volume_set_busy(object_path, busy); out: g_hash_table_unref(device_props); return; }
/** * tp_properties_mixin_emit_flags: * @obj: an object with the properties mixin * @props: a set of property IDs * * Emit the PropertyFlagsChanged signal to indicate that the flags of the * given property IDs have changed; the actual flags are automatically * added using their stored values. */ void tp_properties_mixin_emit_flags (GObject *obj, const TpIntSet *props) { TpPropertiesMixin *mixin = TP_PROPERTIES_MIXIN (obj); TpPropertiesMixinClass *mixin_cls = TP_PROPERTIES_MIXIN_CLASS ( G_OBJECT_GET_CLASS (obj)); GPtrArray *prop_arr; GValue prop_list = { 0, }; TpIntSetIter iter = TP_INTSET_ITER_INIT (props); guint len = tp_intset_size (props); if (len == 0) { return; } prop_arr = g_ptr_array_sized_new (len); if (DEBUGGING) printf (TP_ANSI_BOLD_ON TP_ANSI_FG_WHITE "%s: emitting properties flags changed for propert%s:\n", G_STRFUNC, (len > 1) ? "ies" : "y"); while (tp_intset_iter_next (&iter)) { GValue prop_val = { 0, }; guint prop_id = iter.element; guint prop_flags; prop_flags = mixin->properties[prop_id].flags; g_value_init (&prop_val, TP_STRUCT_TYPE_PROPERTY_FLAGS_CHANGE); g_value_take_boxed (&prop_val, dbus_g_type_specialized_construct (TP_STRUCT_TYPE_PROPERTY_FLAGS_CHANGE)); dbus_g_type_struct_set (&prop_val, 0, prop_id, 1, prop_flags, G_MAXUINT); g_ptr_array_add (prop_arr, g_value_get_boxed (&prop_val)); if (DEBUGGING) { gchar *str_flags = property_flags_to_string (prop_flags); printf (" %s's flags now: %s\n", mixin_cls->signatures[prop_id].name, str_flags); g_free (str_flags); } } if (DEBUGGING) { printf (TP_ANSI_RESET); fflush (stdout); } tp_svc_properties_interface_emit_property_flags_changed ( (TpSvcPropertiesInterface *) obj, prop_arr); g_value_init (&prop_list, TP_ARRAY_TYPE_PROPERTY_FLAGS_CHANGE_LIST); g_value_take_boxed (&prop_list, prop_arr); g_value_unset (&prop_list); }
static void set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (object); GHashTable *new_hash; switch (prop_id) { case PROP_PORT: g_free (priv->port); priv->port = g_value_dup_string (value); break; case PROP_SPEED: priv->speed = g_value_get_uint (value); break; case PROP_DUPLEX: g_free (priv->duplex); priv->duplex = g_value_dup_string (value); break; case PROP_AUTO_NEGOTIATE: priv->auto_negotiate = g_value_get_boolean (value); break; case PROP_MAC_ADDRESS: if (priv->device_mac_address) g_byte_array_free (priv->device_mac_address, TRUE); priv->device_mac_address = g_value_dup_boxed (value); break; case PROP_CLONED_MAC_ADDRESS: if (priv->cloned_mac_address) g_byte_array_free (priv->cloned_mac_address, TRUE); priv->cloned_mac_address = g_value_dup_boxed (value); break; case PROP_MAC_ADDRESS_BLACKLIST: g_slist_free_full (priv->mac_address_blacklist, g_free); priv->mac_address_blacklist = g_value_dup_boxed (value); break; case PROP_MTU: priv->mtu = g_value_get_uint (value); break; case PROP_S390_SUBCHANNELS: if (priv->s390_subchannels) { g_ptr_array_foreach (priv->s390_subchannels, (GFunc) g_free, NULL); g_ptr_array_free (priv->s390_subchannels, TRUE); } priv->s390_subchannels = g_value_dup_boxed (value); break; case PROP_S390_NETTYPE: g_free (priv->s390_nettype); priv->s390_nettype = g_value_dup_string (value); break; case PROP_S390_OPTIONS: /* Must make a deep copy of the hash table here... */ g_hash_table_remove_all (priv->s390_options); new_hash = g_value_get_boxed (value); if (new_hash) g_hash_table_foreach (new_hash, copy_hash, priv->s390_options); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static void manager_update_property (const gchar *key, GValue *value, CmManager *manager) { CmManagerPrivate *priv = manager->priv; gchar *tmp; if (!strcmp ("Devices", key)) { if (priv->low_level) { GPtrArray *devices = g_value_get_boxed (value); gint i; const gchar *path = NULL; GList *curr, *next; /* First remove stale devices */ curr = priv->devices; while (curr != NULL) { CmDevice *dev = CM_DEVICE (curr->data); gboolean found = FALSE; next = curr->next; for (i = 0; i < devices->len && !found; i++) { path = g_ptr_array_index (devices, i); if (g_strcmp0 (path, cm_device_get_path (dev)) == 0) { found = TRUE; } } /* device not in retrieved list, delete from our list */ if (!found) { priv->devices = g_list_delete_link (priv->devices, curr); } curr = next; } /* iterate retrieved list, add any new items to our list */ for (i = 0; i < devices->len; i++) { path = g_ptr_array_index (devices, i); CmDevice *device; GError *error = NULL; device = cm_manager_find_device (manager, path); if (!device) { device = internal_device_new (priv->proxy, path, manager, &error); if (!device) { g_debug ("device_new failed in %s: %s\n", __FUNCTION__, error->message); g_error_free (error); continue; } else { priv->devices = g_list_append (priv->devices, device); } } } g_signal_emit (manager, manager_signals[SIGNAL_DEVICES_CHANGED], 0); } } else if (!strcmp ("Connections", key)) { if (priv->low_level) { GPtrArray *connections = g_value_get_boxed (value); gint i; const gchar *path = NULL; GList *curr, *next; /* First remove stale connections */ curr = priv->connections; while (curr != NULL) { CmConnection *con = CM_CONNECTION (curr->data); gboolean found = FALSE; next = curr->next; for (i = 0; i < connections->len && !found; i++) { path = g_ptr_array_index (connections, i); if (g_strcmp0 (path, cm_connection_get_path (con)) == 0) { found = TRUE; } } /* connection not in retrieved list, delete from our list */ if (!found) { priv->connections = g_list_delete_link (priv->connections, curr); } curr = next; } /* iterate retrieved list, add any new items to our list */ for (i = 0; i < connections->len; i++) { path = g_ptr_array_index (connections, i); CmConnection *connection; GError *error = NULL; connection = cm_manager_find_connection (manager, path); if (!connection) { connection = internal_connection_new (priv->proxy, path, manager, &error); if (!connection) { g_debug ("connection_new failed in %s: %s\n", __FUNCTION__, error->message); g_error_free (error); continue; } else { priv->connections = g_list_append (priv->connections, connection); } } } g_signal_emit (manager, manager_signals[SIGNAL_CONNECTIONS_CHANGED], 0); } } else if (!strcmp ("Services", key)) { GPtrArray *services = g_value_get_boxed (value); gint i; const gchar *path = NULL; GList *curr, *next; /* First remove stale services */ curr = priv->services; while (curr != NULL) { CmService *serv = CM_SERVICE (curr->data); gboolean found = FALSE; next = curr->next; for (i = 0; i < services->len && !found; i++) { path = g_ptr_array_index (services, i); if (g_strcmp0 (path, cm_service_get_path (serv)) == 0) { found = TRUE; } } /* service not in retrieved list, delete from our list */ if (!found) { priv->services = g_list_delete_link (priv->services, curr); } curr = next; } /* iterate retrieved list, add any new items to our list */ for (i = 0; i < services->len; i++) { path = g_ptr_array_index (services, i); CmService *service; GError *error = NULL; service = cm_manager_find_service (manager, path); if (!service) { service = internal_service_new (priv->proxy, path, i, manager, &error); if (!service) { g_debug ("service_new failed in %s: %s\n", __FUNCTION__, error->message); g_error_free (error); continue; } else { priv->services = g_list_append (priv->services, service); } } else { /* services are sorted so update the order */ cm_service_set_order (service, i); } } priv->services = g_list_sort (priv->services, (GCompareFunc) cm_service_compare); g_signal_emit (manager, manager_signals[SIGNAL_SERVICES_CHANGED], 0); } else if (!strcmp ("Profiles", key)) { } else if (!strcmp ("ActiveProfile", key)) { // gchar *profile = g_value_get_boxed (value); /* FIXME: Finish this property */ } else if (!strcmp ("OfflineMode", key)) { priv->offline_mode = g_value_get_boolean (value); g_signal_emit (manager, manager_signals[SIGNAL_OFFLINE_MODE_CHANGED], 0); } else if (!strcmp ("State", key)) { g_free (priv->state); priv->state = g_value_dup_string (value); g_signal_emit (manager, manager_signals[SIGNAL_STATE_CHANGED], 0); } else if (!strcmp ("AvailableTechnologies", key)) { gchar **v = g_value_get_boxed (value); gint i; GList *curr, *next; /* cleanup existing list */ curr = priv->available_technologies; while (curr) { next = curr->next; g_free (curr->data); priv->available_technologies = g_list_delete_link (priv->available_technologies, curr); curr = next; } for (i = 0; i < g_strv_length(v); i++) { priv->available_technologies = g_list_prepend (priv->available_technologies, g_strdup (*(v + i))); } g_signal_emit (manager, manager_signals[SIGNAL_AVAILABLE_TECHNOLOGIES_CHANGED], 0); } else if (!strcmp ("ConnectedTechnologies", key)) { gchar **v = g_value_get_boxed (value); gint i; GList *curr, *next; /* cleanup existing list */ curr = priv->connected_technologies; while (curr) { next = curr->next; g_free (curr->data); priv->connected_technologies = g_list_delete_link (priv->connected_technologies, curr); curr = next; } for (i = 0; i < g_strv_length(v); i++) { priv->connected_technologies = g_list_prepend (priv->connected_technologies, g_strdup (*(v + i))); } g_signal_emit (manager, manager_signals[SIGNAL_CONNECTED_TECHNOLOGIES_CHANGED], 0); } else if (!strcmp ("EnabledTechnologies", key)) { gchar **v = g_value_get_boxed (value); gint i; GList *curr, *next; /* cleanup existnig list */ curr = priv->enabled_technologies; while (curr) { next = curr->next; g_free (curr->data); priv->enabled_technologies = g_list_delete_link (priv->enabled_technologies, curr); curr = next; } for (i = 0; i < g_strv_length(v); i++) { priv->enabled_technologies = g_list_prepend (priv->enabled_technologies, g_strdup (*(v + i))); } g_signal_emit (manager, manager_signals[SIGNAL_ENABLED_TECHNOLOGIES_CHANGED], 0); } else if (!strcmp ("DefaultTechnology", key)) { /* FIXME: finish this property */ } else { tmp = g_strdup_value_contents (value); g_debug ("Unhandled Manager property on Manager: %s = %s\n", key, tmp); g_free (tmp); } }
static void gimp_device_info_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { GimpDeviceInfo *info = GIMP_DEVICE_INFO (object); GdkDevice *device = info->device; GimpCurve *src_curve = NULL; GimpCurve *dest_curve = NULL; switch (property_id) { case PROP_DEVICE: info->device = g_value_get_object (value); break; case PROP_DISPLAY: info->display = g_value_get_object (value); break; case PROP_MODE: gimp_device_info_set_mode (info, g_value_get_enum (value)); break; case PROP_AXES: { GimpValueArray *array = g_value_get_boxed (value); if (array) { gint i; gint n_device_values; if (device) { n_device_values = MIN (gimp_value_array_length (array), device->num_axes); } else { n_device_values = gimp_value_array_length (array); info->n_axes = n_device_values; info->axes = g_renew (GdkAxisUse, info->axes, info->n_axes); memset (info->axes, 0, info->n_axes * sizeof (GdkAxisUse)); } for (i = 0; i < n_device_values; i++) { GdkAxisUse axis_use; axis_use = g_value_get_enum (gimp_value_array_index (array, i)); gimp_device_info_set_axis_use (info, i, axis_use); } } } break; case PROP_KEYS: { GimpValueArray *array = g_value_get_boxed (value); if (array) { gint i; gint n_device_values; if (device) { n_device_values = MIN (gimp_value_array_length (array), device->num_keys); } else { n_device_values = gimp_value_array_length (array); info->n_keys = n_device_values; info->keys = g_renew (GdkDeviceKey, info->keys, info->n_keys); memset (info->keys, 0, info->n_keys * sizeof (GdkDeviceKey)); } for (i = 0; i < n_device_values; i++) { const gchar *accel; guint keyval; GdkModifierType modifiers; accel = g_value_get_string (gimp_value_array_index (array, i)); gtk_accelerator_parse (accel, &keyval, &modifiers); gimp_device_info_set_key (info, i, keyval, modifiers); } } } break; case PROP_PRESSURE_CURVE: src_curve = g_value_get_object (value); dest_curve = info->pressure_curve; break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } if (src_curve && dest_curve) { gimp_config_copy (GIMP_CONFIG (src_curve), GIMP_CONFIG (dest_curve), GIMP_CONFIG_PARAM_SERIALIZE); } }
static void terminal_profile_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { TerminalProfile *profile = TERMINAL_PROFILE (object); TerminalProfilePrivate *priv = profile->priv; GValue *prop_value; if (prop_id == 0 || prop_id >= LAST_PROP) { G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); return; } prop_value = g_value_array_get_nth (priv->properties, prop_id); /* Preprocessing */ switch (prop_id) { #if 0 case PROP_FONT: { PangoFontDescription *font_desc, *new_font_desc; font_desc = g_value_get_boxed (prop_value); new_font_desc = g_value_get_boxed (value); if (font_desc && new_font_desc) { /* Merge in case the new string isn't complete enough to load a font */ pango_font_description_merge (font_desc, new_font_desc, TRUE); pango_font_description_free (new_font_desc); break; } /* fall-through */ } #endif default: g_value_copy (value, prop_value); break; } /* Postprocessing */ switch (prop_id) { case PROP_NAME: { const char *name = g_value_get_string (value); g_assert (name != NULL); priv->profile_dir = g_strdup (name); if (priv->settings != NULL) { g_signal_handlers_disconnect_by_func (priv->settings, G_CALLBACK(terminal_profile_gsettings_notify_cb), profile); g_object_unref (priv->settings); priv->settings = g_settings_new_with_path (CONF_PROFILE_SCHEMA, g_strconcat (CONF_PROFILE_PREFIX, priv->profile_dir, "/", NULL)); g_signal_connect (priv->settings, g_strconcat("changed::", priv->profile_dir, "/", NULL), G_CALLBACK(terminal_profile_gsettings_notify_cb), profile); } break; } case PROP_BACKGROUND_IMAGE_FILE: /* Clear the cached image */ g_value_set_object (g_value_array_get_nth (priv->properties, PROP_BACKGROUND_IMAGE), NULL); priv->background_load_failed = FALSE; g_object_notify (object, TERMINAL_PROFILE_BACKGROUND_IMAGE); break; default: break; } }