Пример #1
0
static void
mex_view_model_set_property (GObject      *object,
                             guint         property_id,
                             const GValue *value,
                             GParamSpec   *pspec)
{
  MexViewModel *self = MEX_VIEW_MODEL (object);

  switch (property_id)
    {
    case PROP_MODEL:
      mex_view_model_set_model (self, g_value_get_object (value));
      break;

    case PROP_LIMIT:
      mex_view_model_set_limit (self, g_value_get_uint (value));
      break;

    case PROP_TITLE:
    case PROP_SORT_FUNC:
    case PROP_SORT_DATA:
    case PROP_ICON_NAME:
    case PROP_CATEGORY:
    case PROP_PRIORITY:
    case PROP_SORT_FUNCTIONS:
    case PROP_ALT_MODEL:
    case PROP_ALT_MODEL_STRING:
    case PROP_ALT_MODEL_ACTIVE:
      g_object_set_property (G_OBJECT (self->priv->model), pspec->name, value);
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
    }
}
Пример #2
0
static inline gboolean
layout_set_property_internal (ClutterLayoutManager *manager,
                              GObject              *gobject,
                              GParamSpec           *pspec,
                              const GValue         *value)
{
  if (pspec->flags & G_PARAM_CONSTRUCT_ONLY)
    {
      g_warning ("%s: Child property '%s' of the layout manager of "
                 "type '%s' is constructor-only",
                 G_STRLOC, pspec->name, G_OBJECT_TYPE_NAME (manager));
      return FALSE;
    }

  if (!(pspec->flags & G_PARAM_WRITABLE))
    {
      g_warning ("%s: Child property '%s' of the layout manager of "
                 "type '%s' is not writable",
                 G_STRLOC, pspec->name, G_OBJECT_TYPE_NAME (manager));
      return FALSE;
    }

  g_object_set_property (gobject, pspec->name, value);

  return TRUE;
}
Пример #3
0
static void
gst_gl_sink_bin_set_property (GObject * object, guint prop_id,
    const GValue * value, GParamSpec * pspec)
{
  GstGLSinkBin *self = GST_GL_SINK_BIN (object);

  switch (prop_id) {
    case PROP_SINK:
    {
      GstElement *sink = g_value_get_object (value);
      if (self->sink)
        gst_bin_remove (GST_BIN (self), self->sink);
      self->sink = sink;
      if (sink)
        _connect_sink_element (self);
      break;
    }
    case PROP_FORCE_ASPECT_RATIO:
      if (self->sink)
        g_object_set_property (G_OBJECT (self->sink), pspec->name, value);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
  }
}
/**
 * gst_child_proxy_set_property:
 * @object: the parent object
 * @name: name of the property to set
 * @value: new #GValue for the property
 *
 * Sets a single property using the GstChildProxy mechanism.
 */
void
gst_child_proxy_set_property (GstChildProxy * object, const gchar * name,
    const GValue * value)
{
  GParamSpec *pspec;
  GObject *target;

  g_return_if_fail (GST_IS_CHILD_PROXY (object));
  g_return_if_fail (name != NULL);
  g_return_if_fail (G_IS_VALUE (value));

  if (!gst_child_proxy_lookup (object, name, &target, &pspec))
    goto not_found;

  g_object_set_property (target, pspec->name, value);
  g_object_unref (target);
  return;

not_found:
  {
    g_warning ("cannot set property %s on object %s", name,
        (GST_IS_OBJECT (object) ? GST_OBJECT_NAME (object) : ""));
    return;
  }
}
Пример #5
0
static void
e_bind_properties_transfer (GObject *src_object,
                            GParamSpec *src_pspec,
                            GObject *dst_object,
                            GParamSpec *dst_pspec,
                            GlideBindingTransform  transform,
                            gpointer user_data)
{
	const gchar *src_name;
	const gchar *dst_name;
	gboolean result;
	GValue src_value = { 0, };
	GValue dst_value = { 0, };

	src_name = g_param_spec_get_name (src_pspec);
	dst_name = g_param_spec_get_name (dst_pspec);

	g_value_init (&src_value, G_PARAM_SPEC_VALUE_TYPE (src_pspec));
	g_object_get_property (src_object, src_name, &src_value);

	g_value_init (&dst_value, G_PARAM_SPEC_VALUE_TYPE (dst_pspec));
	result = (*transform) (&src_value, &dst_value, user_data);

	g_value_unset (&src_value);

	g_return_if_fail (result);

	g_param_value_validate (dst_pspec, &dst_value);
	g_object_set_property (dst_object, dst_name, &dst_value);
	g_value_unset (&dst_value);
}
Пример #6
0
/**
 * ppg_animation_update_property:
 * @animation: (in): A #PpgAnimation.
 * @target: (in): A #GObject.
 * @tween: (in): a #Tween containing the property.
 * @value: (in) The new value for the property.
 *
 * Updates the value of a property on an object using @value.
 *
 * Returns: None.
 * Side effects: The property of @target is updated.
 */
static void
ppg_animation_update_property (PpgAnimation *animation,
                               gpointer      target,
                               Tween        *tween,
                               const GValue *value)
{
	g_object_set_property(target, tween->pspec->name, value);
}
Пример #7
0
int main(int argc, char **argv) {
	GError *error = NULL;
	GdkScreen *screen;
//	GdkVisual *visual;
	GtkWidget *grid;
	GtkWidget *tmp;
	GtkStuff *stuff = calloc(1, sizeof(GtkStuff));
	GValue val = G_VALUE_INIT;

	gtk_init(&argc, &argv);

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	g_signal_connect (window, "destroy", gtk_main_quit, NULL);
	gtk_window_set_resizable (GTK_WINDOW (window), 0);

	grid = gtk_grid_new ();
	gtk_container_add (GTK_CONTAINER (window), grid);

/*	screen = gdk_screen_get_default ();
	visual = gdk_screen_get_rgba_visual (screen);
	if (visual != NULL && gdk_screen_is_composited (screen)) {
		gtk_widget_set_visual (window, visual);
	}*/

	stuff->notes = GTK_TEXT_VIEW (gtk_text_view_new ());
	gtk_text_view_set_wrap_mode (stuff->notes, GTK_WRAP_WORD);
	//g_signal_connect (stuff->notes, "draw", G_CALLBACK(on_draw_notes), NULL);
	g_signal_connect (stuff->notes, "paste-clipboard", G_CALLBACK(on_notes_paste_clipboard), stuff);
	g_signal_connect (stuff->notes, "key-release-event", G_CALLBACK(on_notes_key_release_event), stuff);

	gtk_window_set_icon_name((GtkWindow*)window, "gtk-yes");

	stuff->calendar = GTK_CALENDAR (gtk_calendar_new ());
	gtk_calendar_set_detail_func(stuff->calendar, &details, NULL, NULL);
	gtk_calendar_set_detail_width_chars(stuff->calendar, 3);
	gtk_calendar_set_detail_height_rows(stuff->calendar, 1);
	on_calendar1_day_selected(stuff->calendar, stuff);
	g_signal_connect (stuff->calendar, "day-selected", G_CALLBACK(on_calendar1_day_selected), stuff);
	gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (stuff->calendar), 0, 1, 1, 9);

	tmp = gtk_button_new_with_label ("Today");
	gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (tmp), 0, 0, 1, 1);
	g_signal_connect (tmp, "clicked", (GCallback)on_today_clicked, stuff);

	tmp = gtk_scrolled_window_new (NULL, NULL);
	g_value_init (&val, G_TYPE_INT);
	g_value_set_int (&val, 240);
	g_object_set_property (G_OBJECT (tmp), "width-request", &val);
	gtk_container_add (GTK_CONTAINER (tmp), GTK_WIDGET (stuff->notes));
	gtk_grid_attach (GTK_GRID (grid), GTK_WIDGET (tmp), 1, 0, 1, 10);

	gtk_window_set_title((GtkWindow*)window, "Planner");

	gtk_widget_show_all(window);
	gtk_main();

	return 0;
}
Пример #8
0
static void
gimp_color_button_set_property (GObject      *object,
                                guint         property_id,
                                const GValue *value,
                                GParamSpec   *pspec)
{
  GimpColorButton *button = GIMP_COLOR_BUTTON (object);
  gint             other;

  switch (property_id)
    {
    case PROP_TITLE:
      g_free (button->title);
      button->title = g_value_dup_string (value);
      break;

    case PROP_COLOR:
      g_object_set_property (G_OBJECT (button->color_area), "color", value);
      break;

    case PROP_TYPE:
      g_object_set_property (G_OBJECT (button->color_area), "type", value);
      break;

    case PROP_UPDATE:
      gimp_color_button_set_update (button, g_value_get_boolean (value));
      break;

    case PROP_AREA_WIDTH:
      gtk_widget_get_size_request (button->color_area, NULL, &other);
      gtk_widget_set_size_request (button->color_area,
                                   g_value_get_int (value), other);
      break;

    case PROP_AREA_HEIGHT:
      gtk_widget_get_size_request (button->color_area, &other, NULL);
      gtk_widget_set_size_request (button->color_area,
                                   other, g_value_get_int (value));
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
      break;
    }
}
Пример #9
0
/**
 * crée un une image avec 2 états
 *
 * \param etat  0 = Warning 1 = OK
 *
 * \return      widget initialisé
 * */
GtkWidget *utils_get_image_with_etat ( GtkMessageType msg,
                        gint initial,
                        const gchar *tooltip_0,
                        const gchar *tooltip_1 )
{
    GtkWidget *hbox;
    GtkWidget *icon_0;
    GtkWidget *icon_1;
    GValue value = {0,};

    g_value_init ( &value, G_TYPE_BOOLEAN );
    g_value_set_boolean ( &value, TRUE );

    hbox = gtk_hbox_new ( FALSE, 5 );
    g_object_set_data ( G_OBJECT ( hbox ), "initial", GINT_TO_POINTER ( initial ) );

    if ( msg == GTK_MESSAGE_WARNING )
        icon_0 = gtk_image_new_from_stock ( GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_MENU );
    else
        icon_0 = gtk_image_new_from_stock ( GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_MENU );

    g_object_set_property ( G_OBJECT ( icon_0 ), "no-show-all", &value );
    if ( tooltip_0 )
        gtk_widget_set_tooltip_text ( icon_0, tooltip_0 );
    gtk_box_pack_start ( GTK_BOX ( hbox ), icon_0, FALSE, FALSE, 0 );
    g_object_set_data ( G_OBJECT ( hbox ), "icon_0", icon_0 );

    icon_1 = gtk_image_new_from_stock ( GTK_STOCK_APPLY, GTK_ICON_SIZE_MENU );
    g_object_set_property ( G_OBJECT ( icon_1 ), "no-show-all", &value );

    if ( tooltip_1 )
        gtk_widget_set_tooltip_text ( icon_1, tooltip_1 );
    gtk_box_pack_start ( GTK_BOX ( hbox ), icon_1, FALSE, FALSE, 0 );
    g_object_set_data ( G_OBJECT ( hbox ), "icon_1", icon_1 );

    if ( initial )
        gtk_widget_show ( icon_1 );
    else
        gtk_widget_show ( icon_0 );

    gtk_widget_show ( hbox );

    /* return */
    return hbox;
}
Пример #10
0
static void
gst_gl_video_mixer_bin_set_property (GObject * object, guint prop_id,
    const GValue * value, GParamSpec * pspec)
{
  GstGLMixerBin *self = GST_GL_MIXER_BIN (object);

  if (self->mixer)
    g_object_set_property (G_OBJECT (self->mixer), pspec->name, value);
}
Пример #11
0
void gtk_scrollbox_enablecb (GtkScrollbox *self, gboolean enable)
{
        GValue val = {0,};

        g_value_init (&val, G_TYPE_BOOLEAN);
        g_value_set_boolean (&val, enable);

        g_object_set_property(G_OBJECT(self), "enablecb", &val);
}
Пример #12
0
void trace_view_data_func(GtkTreeViewColumn *column, GtkCellRenderer *renderer,
			  GtkTreeModel *model, GtkTreeIter *iter,
			  gpointer data)
{
	long col_num = (long)data;
	int str_len, label_len;
	gchar *text, *str;
	int new_w, x_pad;
	GValue val = {0};
	GtkWidget *view;

	PangoFontDescription *pfd;
	PangoLayout *playout;

	/* Put the text in the renderer. */
	gtk_tree_model_get_value(model, iter, col_num, &val);
	g_object_set_property(G_OBJECT(renderer), "text", &val);

	g_object_get(G_OBJECT(renderer),
			"text", &text,
			"font-desc", &pfd,
			NULL);

	if (!text)
		goto out;

	/* Make sure there is enough room to render the column label. */
	str = text;
	str_len = strlen(str);
	label_len = strlen(col_labels[col_num]);
	if (label_len > str_len) {
		str = col_labels[col_num];
		str_len = label_len;
	}

	/* Don't bother with pango unless we have more chars than the max. */
	if (str_len > col_chars[col_num]) {
		col_chars[col_num] = str_len;

		view = GTK_WIDGET(gtk_tree_view_column_get_tree_view(column));
		playout = gtk_widget_create_pango_layout(GTK_WIDGET(view), str);
		pango_layout_set_font_description(playout, pfd);
		pango_layout_get_pixel_size(playout, &new_w, NULL);
		gtk_cell_renderer_get_padding(renderer, &x_pad, NULL);
		/* +10 to avoid another adjustment for one char */
		new_w += 2*x_pad + 10;
		g_object_unref(playout);

		if (new_w > gtk_tree_view_column_get_width(column))
			gtk_tree_view_column_set_fixed_width(column, new_w);
	}

	g_free(text);
 out:
	pango_font_description_free(pfd);
	g_value_unset(&val);
}
Пример #13
0
static gboolean gostv_helper(gpointer user_data) {
	struct gost_helper* help = (struct gost_helper*) user_data;
	g_object_set_property(help->obj, help->name, (GValue*)help->value);
	if(help->free) {
		help->free(help->value);
	}
	free(help);
	return FALSE;
}
Пример #14
0
static void
gst_gl_video_mixer_input_set_property (GObject * object, guint prop_id,
    const GValue * value, GParamSpec * pspec)
{
  GstGLVideoMixerInput *self = (GstGLVideoMixerInput *) object;

  if (self->mixer_pad)
    g_object_set_property (G_OBJECT (self->mixer_pad), pspec->name, value);
}
Пример #15
0
static void
gst_xvidenc_init (GstXvidEnc * xvidenc)
{
  GParamSpec **pspecs;
  guint i, num_props;

  /* create the sink pad */
  xvidenc->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink");
  gst_element_add_pad (GST_ELEMENT (xvidenc), xvidenc->sinkpad);

  gst_pad_set_chain_function (xvidenc->sinkpad,
      GST_DEBUG_FUNCPTR (gst_xvidenc_chain));
  gst_pad_set_setcaps_function (xvidenc->sinkpad,
      GST_DEBUG_FUNCPTR (gst_xvidenc_setcaps));
  gst_pad_set_getcaps_function (xvidenc->sinkpad,
      GST_DEBUG_FUNCPTR (gst_xvidenc_getcaps));
  gst_pad_set_event_function (xvidenc->sinkpad,
      GST_DEBUG_FUNCPTR (gst_xvidenc_handle_sink_event));

  /* create the src pad */
  xvidenc->srcpad = gst_pad_new_from_static_template (&src_template, "src");
  gst_element_add_pad (GST_ELEMENT (xvidenc), xvidenc->srcpad);
  gst_pad_use_fixed_caps (xvidenc->srcpad);

  /* init properties. */
  xvidenc->width = xvidenc->height = xvidenc->csp = -1;
  xvidenc->par_width = xvidenc->par_height = 1;

  /* set defaults for user properties */
  pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (xvidenc),
      &num_props);

  for (i = 0; i < num_props; ++i) {
    GValue val = { 0, };
    GParamSpec *pspec = pspecs[i];

    /* only touch those that are really ours; i.e. should have some qdata */
    if (!g_param_spec_get_qdata (pspec, xvidenc_pspec_quark))
      continue;
    g_value_init (&val, G_PARAM_SPEC_VALUE_TYPE (pspec));
    g_param_value_set_default (pspec, &val);
    g_object_set_property (G_OBJECT (xvidenc), g_param_spec_get_name (pspec),
        &val);
    g_value_unset (&val);
  }

  g_free (pspecs);

  /* set xvid handle to NULL */
  xvidenc->handle = NULL;

  /* get a queue to keep time info if frames get delayed */
  xvidenc->delay = NULL;

  /* cache some xvid data so need not rebuild for each frame */
  xvidenc->xframe_cache = NULL;
}
Пример #16
0
int Notebook::openPage(NotebookPage *np,bool sel) {
	np->tab.index = pages.size();
	pages << np;
	np->page->parent = this;
debug_output("Notebook::openPage(page->create(%s))\n",np->page->getInstance().getName());
	np->page->create(window,0);
	np->page->createAll(0,false);
#ifdef USE_GTK
	GtkWidget *t;
	if((style&NOTEBOOK_CLOSE_BUTTON)) {
		GValue val = { 0 };
		int w,h;
		GtkWidget *bt,*im,*l;

		t = gtk_hbox_new(FALSE,3);
		l = gtk_label_new(np->tab.name);

		bt = gtk_button_new();
		gtk_widget_set_name(bt,"tab-close-button");
		g_value_init(&val,G_TYPE_INT);
		g_value_set_int(&val,GTK_RELIEF_NONE); 
		g_object_set_property(G_OBJECT(bt),"relief",&val);
		g_value_unset(&val);
		im = gtk_image_new_from_stock(GTK_STOCK_CLOSE,GTK_ICON_SIZE_MENU);
		gtk_icon_size_lookup(GTK_ICON_SIZE_MENU,&w,&h);
		gtk_widget_set_size_request(bt,w+2,h+2);
		gtk_container_add(GTK_CONTAINER(bt),im);
		g_signal_connect(G_OBJECT(bt),"clicked",G_CALLBACK(close_tab_callback),(gpointer)&np->tab);
		gtk_box_pack_start(GTK_BOX(t),l,TRUE,TRUE,0);
		gtk_box_pack_start(GTK_BOX(t),bt,FALSE,FALSE,0);

		np->tab.button = bt;
		np->tab.label = l;

		gtk_widget_show_all(t);
	} else {
		t = gtk_label_new(np->tab.name);
	}
	gtk_widget_show_all(t);
	np->page->show();
	gtk_notebook_append_page(GTK_NOTEBOOK(component),(GtkWidget *)np->page->getComponent(),t);
#endif
#ifdef USE_WIN32
	np->status = 1;
//	SetParent((HWND)page->getComponent(),(HWND)parent->getComponent());
debug_output("Notebook::openPage(%s)\n",np->tab.name);
	if(type==WIDGET_NOTEBOOK) {
		TCITEM ti = {TCIF_TEXT};
		ti.pszText = tstrdup(np->tab.name);
		TabCtrl_InsertItem((HWND)component,np->tab.index,&ti);
		tfree(ti.pszText);
	}
#endif
	if(sel) selectPage(np->tab.index);
	return selected;
}
Пример #17
0
/*
 * The window should not show up in the pager. This sets an EWMH property.
 */
static void
skip_pager(GtkWidget *window)
{
	GValue	t = G_VALUE_INIT;

	g_value_init(&t, G_TYPE_BOOLEAN);
	g_value_set_boolean(&t, TRUE);
	g_object_set_property(G_OBJECT(window), "skip-pager-hint", &t);
	g_value_unset(&t);
}
Пример #18
0
EXPORT_C
#endif

gboolean
gst_controller_sync_values (GstController * self, GstClockTime timestamp)
{
  GstControlledProperty *prop;
  GList *node;
  gboolean ret = TRUE, val_ret;
  GValue value = { 0, };

  g_return_val_if_fail (GST_IS_CONTROLLER (self), FALSE);
  g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE);

  GST_LOG ("sync_values");

  g_mutex_lock (self->lock);
  g_object_freeze_notify (self->object);
  /* go over the controlled properties of the controller */
  for (node = self->properties; node; node = g_list_next (node)) {
    prop = node->data;

    if (!prop->csource || prop->disabled)
      continue;

    GST_LOG ("property '%s' at ts=%" G_GUINT64_FORMAT, prop->name, timestamp);

    /* we can make this faster
     * http://bugzilla.gnome.org/show_bug.cgi?id=536939
     */
    g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (prop->pspec));
    val_ret = gst_control_source_get_value (prop->csource, timestamp, &value);
    if (G_LIKELY (val_ret)) {
      /* always set the value for first time, but then only if it changed
       * this should limit g_object_notify invocations.
       * FIXME: can we detect negative playback rates?
       */
      if ((timestamp < self->priv->last_sync) ||
          gst_value_compare (&value, &prop->last_value) != GST_VALUE_EQUAL) {
        g_object_set_property (self->object, prop->name, &value);
        g_value_copy (&value, &prop->last_value);
      }
    } else {
      GST_DEBUG ("no control value for param %s", prop->name);
    }
    g_value_unset (&value);
    ret &= val_ret;
  }
  self->priv->last_sync = timestamp;
  g_object_thaw_notify (self->object);

  g_mutex_unlock (self->lock);

  return ret;
}
Пример #19
0
static void
gstbt_sim_syn_set_property (GObject * object, guint prop_id,
    const GValue * value, GParamSpec * pspec)
{
  GstBtSimSyn *src = GSTBT_SIM_SYN (object);

  if (src->dispose_has_run)
    return;

  switch (prop_id) {
    case PROP_TUNING:
      g_object_set_property ((GObject *) (src->n2f), "tuning", value);
      break;
    case PROP_NOTE:
      if ((src->note = g_value_get_enum (value))) {
        GST_DEBUG ("new note -> '%d'", src->note);
        gdouble freq =
            gstbt_tone_conversion_translate_from_number (src->n2f, src->note);
        gstbt_envelope_d_setup (src->volenv,
            ((GstBtAudioSynth *) src)->samplerate, src->decay, src->volume);
        g_object_set (src->osc, "frequency", freq, NULL);
      }
      break;
    case PROP_WAVE:
      g_object_set_property ((GObject *) (src->osc), "wave", value);
      break;
    case PROP_VOLUME:
      src->volume = g_value_get_double (value);
      break;
    case PROP_DECAY:
      src->decay = g_value_get_double (value);
      break;
    case PROP_FILTER:
    case PROP_CUTOFF:
    case PROP_RESONANCE:
      g_object_set_property ((GObject *) (src->filter), pspec->name, value);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
  }
}
Пример #20
0
void
ags_port_real_safe_set_property(AgsPort *port, gchar *property_name, GValue *value)
{
  //  pthread_mutex_lock(&(port->mutex));

  g_object_set_property(port->port_value.ags_port_object,
			property_name,
			value);

  //  pthread_mutex_unlock(&(port->mutex));
}
Пример #21
0
int
main (int argc, char ** argv)
{
  gst_init (&argc, &argv);

  GMainLoop* loop = g_main_loop_new (NULL, FALSE);

  pipe = gst_pipeline_new ("pipeline");

  src = gst_element_factory_make ("filesrc", NULL);

  // this parses the FLAC tags to replay gain stuff.
  GstElement* decoder = gst_element_factory_make("decodebin2",NULL);
  GstElement* converter = gst_element_factory_make("audioconvert",NULL);
  GstElement* analyzer = gst_element_factory_make("rganalysis",NULL);

  GstElement* alsa = gst_element_factory_make("fakesink", NULL);

  if(!(src && decoder && converter && analyzer && alsa))
    g_error("_______ could not be created");

  GValue val = { 0, };

  g_value_init (&val, G_TYPE_INT);
  g_value_set_schar (&val, 1);

  g_object_set_property(G_OBJECT(analyzer),"num-tracks",&val);
  g_value_unset(&val);

  GstBus* bus = gst_pipeline_get_bus (GST_PIPELINE (pipe));
  gst_bus_add_watch (bus, bus_call, loop);
  g_object_unref(bus);

  gst_bin_add_many (GST_BIN (pipe), src, decoder,
                    converter, analyzer, alsa, NULL);

  // src -> decoder ...> converter -> analyzer -> sink
  gst_element_link(src,decoder);
  g_signal_connect (decoder, "pad-added", G_CALLBACK (on_new_pad), converter);
  gst_element_link_many(converter, analyzer, alsa, NULL);

  if(argc==2) {
    GString* next = g_string_new(argv[1]);
    nextSong(next);
  } else {
    watch_input(loop);
  }

  g_main_loop_run(loop);
  gst_element_set_state (pipe, GST_STATE_NULL);
  puts("boofff");
  gst_object_unref (pipe);
  return 0;
}
Пример #22
0
static void
gtk_tool_button_set_property (GObject         *object,
			      guint            prop_id,
			      const GValue    *value,
			      GParamSpec      *pspec)
{
  GtkToolButton *button = GTK_TOOL_BUTTON (object);
  
  switch (prop_id)
    {
    case PROP_LABEL:
      gtk_tool_button_set_label (button, g_value_get_string (value));
      break;
    case PROP_USE_UNDERLINE:
      gtk_tool_button_set_use_underline (button, g_value_get_boolean (value));
      break;
    case PROP_LABEL_WIDGET:
      gtk_tool_button_set_label_widget (button, g_value_get_object (value));
      break;
    case PROP_STOCK_ID:
      G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
      gtk_tool_button_set_stock_id (button, g_value_get_string (value));
      G_GNUC_END_IGNORE_DEPRECATIONS;
      break;
    case PROP_ICON_NAME:
      gtk_tool_button_set_icon_name (button, g_value_get_string (value));
      break;
    case PROP_ICON_WIDGET:
      gtk_tool_button_set_icon_widget (button, g_value_get_object (value));
      break;
    case PROP_ACTION_NAME:
      g_object_set_property (G_OBJECT (button->priv->button), "action-name", value);
      break;
    case PROP_ACTION_TARGET:
      g_object_set_property (G_OBJECT (button->priv->button), "action-target", value);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}
Пример #23
0
void lxmusic_do_notify( LXMusicNotification lxn ) 
{
#if HAVE_LIBNOTIFY
    GValue val = { 0, };
    g_value_init (&val, G_TYPE_STRING);
    g_value_set_string( &val, "lxmusic" );
    g_object_set_property( G_OBJECT(lxn->notify), "icon-name", &val );
    g_value_unset (&val);
    LXMUSIC_NOTIFY_NOTIFICATION_SHOW( lxn->notify );
    g_free(lxn);
#endif	/* HAVE_LIBNOTIFY */
}
Пример #24
0
gboolean
rb_gst_encoder_set_encoding_style (GstElement *encoder, const char *style)
{
	GstElementFactory *factory;
	char *group_name;
	char **keys;
	int i;

	factory = gst_element_get_factory (encoder);
	group_name = g_strdup_printf (ENCODER_STYLE_SETTINGS_PREFIX "%s-%s",
				      gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory)),
				      style);
	rb_debug ("applying settings from %s", group_name);

	keys = g_key_file_get_keys (get_target_keyfile (), group_name, NULL, NULL);
	if (keys == NULL) {
		rb_debug ("nothing to apply");
		g_free (group_name);
		return FALSE;
	}

	for (i = 0; keys[i] != NULL; i++) {
		GParamSpec *pspec;
		GValue v = {0,};
		char *value;

		pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (encoder), keys[i]);
		if (pspec == NULL) {
			rb_debug ("couldn't find property %s", keys[i]);
			continue;
		}

		value = g_key_file_get_string (get_target_keyfile (), group_name, keys[i], NULL);
		if (value == NULL) {
			rb_debug ("couldn't get value for property %s", keys[i]);
			continue;
		}

		g_value_init (&v, pspec->value_type);
		if (gst_value_deserialize (&v, value)) {
			rb_debug ("applying value \"%s\" to property %s", value, keys[i]);
			g_object_set_property (G_OBJECT (encoder), keys[i], &v);
		} else {
			rb_debug ("couldn't deserialize value \"%s\" for property %s", value, keys[i]);
		}

		g_value_unset (&v);
	}

	g_strfreev (keys);
	g_free (group_name);
	return TRUE;
}
Пример #25
0
gint _vala_main (void) {
	Adress* x = adress_new ();
	/* set property */
	GValue val = G_VALUE_INIT;
	g_value_init (&val, G_TYPE_STRING);
	g_value_set_string (&val, "hello");
	g_object_set_property(G_OBJECT (x), "street", &val);
	/* printf */
	g_printf("%s\n", x->street);
	_g_object_unref0 (x);//_adress_unref0 (x);
	return 0;
}
Пример #26
0
int recurseDirs(const char *path, ThreadManager *threadman) {
	
	GValue message = {0,};
	g_value_init(&message,G_TYPE_STRING);
	g_value_set_string(&message,"busy");
	g_object_set_property(G_OBJECT(threadman),"status", &message);
	g_value_unset(&message);

	if(path==NULL) {
		return 1;
	}
	sleep(1);
	GFile *dir = g_file_new_for_path(path);
	GFileEnumerator *fileEnumerator;
	GError *errorHandler=NULL;
	fileEnumerator = g_file_enumerate_children(dir,"standard::*",G_FILE_QUERY_INFO_NONE,NULL,&errorHandler);
	if(errorHandler!=NULL) {
		fprintf(stderr,"ERROR: %s\n",errorHandler->message);
		g_error_free(errorHandler);
		return 1;
	}
	if(fileEnumerator!=NULL) {
		GFileInfo *finfo = g_file_enumerator_next_file(fileEnumerator,NULL,NULL);
		while(finfo!=NULL) {
			if(!g_file_info_get_is_hidden(finfo)) {
				const gchar *name;
				char *fullPath;
				
				name = g_file_info_get_name(finfo);
				fullPath = strdup(path);
				fullPath = realloc(fullPath,strlen(path)+3+strlen(name));
				strcat(fullPath,"/");
				strcat(fullPath,name);
				
				if(g_file_info_get_file_type(finfo)==G_FILE_TYPE_DIRECTORY) {
					int res = recurseDirs(fullPath,threadman);
					if(res!=0) {
						fprintf(stderr,"Error with %s\n",fullPath);
					}
				} else {			
					const gchar *type = g_file_info_get_attribute_string(finfo,G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
					if(strcmp(type,"audio/mpeg")==0) {
						addToIndex(name,fullPath,type);
					}
				} 
				free(fullPath);
			}
			finfo = g_file_enumerator_next_file(fileEnumerator,NULL,NULL);	
		}
		g_object_unref(fileEnumerator);
	}
	return 0;
}
Пример #27
0
/**
 * gtk_cell_view_set_value:
 * @cell_view: a #GtkCellView widget
 * @renderer: one of the renderers of @cell_view
 * @property: the name of the property of @renderer to set
 * @value: the new value to set the property to
 * 
 * Sets a property of a cell renderer of @cell_view, and
 * makes sure the display of @cell_view is updated.
 *
 * Since: 2.6
 */
static void
gtk_cell_view_set_value (GtkCellView     *cell_view,
                         GtkCellRenderer *renderer,
                         gchar           *property,
                         GValue          *value)
{
  g_object_set_property (G_OBJECT (renderer), property, value);

  /* force resize and redraw */
  gtk_widget_queue_resize (GTK_WIDGET (cell_view));
  gtk_widget_queue_draw (GTK_WIDGET (cell_view));
}
Пример #28
0
static void
object_test_property (GObject           *object,
                      GParamSpec        *pspec,
                      double             dvalue)
{
  /* test setting of a normal writable property */
  if (pspec->flags & G_PARAM_WRITABLE &&
      !(pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY)))
    {
      GValue value = { 0, };
      guint i;
      const IgnoreProperty *ignore_properties;
      /* select value to set */
      g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
      pspec_select_value (pspec, &value, dvalue);
      /* ignore untestable properties */
      ignore_properties = list_ignore_properties (FALSE);
      for (i = 0; ignore_properties[i].name; i++)
        if (g_strcmp0 ("", ignore_properties[i].name) ||
            g_type_is_a (G_OBJECT_TYPE (object), g_type_from_name (ignore_properties[i].type_name)) &&
            strcmp (pspec->name, ignore_properties[i].name) == 0 &&
            (MATCH_ANY_VALUE == ignore_properties[i].value ||
             value_as_pointer (&value) == ignore_properties[i].value ||
             (G_VALUE_HOLDS_STRING (&value) &&
              strcmp (g_value_get_string (&value), ignore_properties[i].value) == 0)))
          break;
      /* ignore known property bugs if not testing thoroughly */
      if (ignore_properties[i].name == NULL && !g_test_thorough ())
        {
          ignore_properties = list_ignore_properties (TRUE);
          for (i = 0; ignore_properties[i].name; i++)
            if (g_type_is_a (G_OBJECT_TYPE (object), g_type_from_name (ignore_properties[i].type_name)) &&
                strcmp (pspec->name, ignore_properties[i].name) == 0 &&
                (MATCH_ANY_VALUE == ignore_properties[i].value ||
                 value_as_pointer (&value) == ignore_properties[i].value ||
                 (G_VALUE_HOLDS_STRING (&value) &&
                  strcmp (g_value_get_string (&value), ignore_properties[i].value) == 0)))
              break;
        }
      /* assign unignored properties */
      if (ignore_properties[i].name == NULL)
        {
          if (g_test_verbose ())
            g_print ("PropertyTest: %s::%s := (%s value (%s): %p)\n",
                     g_type_name (G_OBJECT_TYPE (object)), pspec->name,
                     SELECT_NAME (dvalue), g_type_name (G_VALUE_TYPE (&value)),
                     value_as_pointer (&value));
          g_object_set_property (object, pspec->name, &value);
        }
      /* cleanups */
      g_value_unset (&value);
    }
}
Пример #29
0
void GstPlayer::buildPipeline(){
    QLOG_TRACE() << "GstPlayer::buildPipeline";

    pipeline = gst_element_factory_make("pipeline", gstObjectName.toUtf8().data());
    decodebin = gst_element_factory_make("uridecodebin",NULL);
    audioconvert = gst_element_factory_make("audioconvert",NULL);
    volume = gst_element_factory_make("volume",NULL);
    audiobin = gst_element_factory_make("autoaudiosink",NULL);


    gst_bin_add(GST_BIN(pipeline), decodebin);
    gst_bin_add(GST_BIN(pipeline), audioconvert);
    gst_bin_add(GST_BIN(pipeline), volume);
    gst_bin_add(GST_BIN(pipeline), audiobin);

    gst_element_link_many(volume, audioconvert, audiobin, NULL);

    // as soon as decodebin has a pad (i.e. file was loaded), connect it to volume
    g_signal_connect (decodebin, "pad-added", G_CALLBACK (GstPlayer::handleAddedPad), volume);

    // volume needs an initial value
    double volumeMax=0.5;


    //g_value_init(theVol,G_TYPE_DOUBLE);
    g_value_set_double(theVol,volumeMax);
    g_object_set_property(G_OBJECT(volume),"volume",theVol);

    //fade
    long fadeIn,fadeOut, minFade = 500;
    fadeIn = this->track->getFadeInDuration();
    if(fadeIn <= 0 && this->track->getStartTime() > 0)
        fadeIn = minFade;

    fadeOut = this->track->getFadeOutDuration();
    if(fadeOut <= 0 && this->track->getEndTime() > 0)
        fadeOut = minFade;

    if(fadeIn > 10)
        this->setFade(fadeInController,
                  this->track->getStartTime(),
                  this->track->getStartTime()+fadeIn,
                  0.0,volumeMax);

    if(fadeOut > 10)
        if(this->track->getEndTime() > 0)
        this->setFade(fadeOutController,
                  this->track->getEndTime()-fadeOut,
                  this->track->getEndTime(),
                  volumeMax,0.0);


}
Пример #30
0
// just g_object_set_property(), except we allow set enum from string
static void 
set_property( VipsObject *object, const char *name, const GValue *value )
{
	VipsObjectClass *object_class = VIPS_OBJECT_GET_CLASS( object );
	GType type = G_VALUE_TYPE( value );

	GParamSpec *pspec;
	VipsArgumentClass *argument_class;
	VipsArgumentInstance *argument_instance;

	if( vips_object_get_argument( object, name, 
		&pspec, &argument_class, &argument_instance ) ) {
		g_warning( "%s", vips_error_buffer() );
		vips_error_clear();
		return;
	}

	if( G_IS_PARAM_SPEC_ENUM( pspec ) &&
		type == G_TYPE_STRING ) {
		GType pspec_type = G_PARAM_SPEC_VALUE_TYPE( pspec );

		int enum_value;
		GValue value2 = { 0 }; 

		if( (enum_value = vips_enum_from_nick( object_class->nickname, 
			pspec_type, g_value_get_string( value ) )) < 0 ) {
			g_warning( "%s", vips_error_buffer() );
			vips_error_clear();
			return;
		}

		g_value_init( &value2, pspec_type ); 
		g_value_set_enum( &value2, enum_value ); 
		g_object_set_property( G_OBJECT( object ), name, &value2 );
		g_value_unset( &value2 );
	}
	else
		g_object_set_property( G_OBJECT( object ), name, value );
}